Auto color change: next improvements
This commit is contained in:
parent
ab3890dab5
commit
46e4f54fd0
2 changed files with 29 additions and 14 deletions
|
@ -719,7 +719,9 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
|
|||
// m_values contains data for all layer's parts,
|
||||
// but m_layers_values contains just unique Z values.
|
||||
// Use this function for correct conversion slider position to number of printed layer
|
||||
auto get_layer_number = [this](int value) {
|
||||
auto get_layer_number = [this](int value, LabelType label_type) {
|
||||
if (label_type == ltEstimatedTime && m_layers_times.empty())
|
||||
return size_t(-1);
|
||||
double layer_print_z = m_values[is_wipe_tower_layer(value) ? std::max<int>(value - 1, 0) : value];
|
||||
auto it = std::lower_bound(m_layers_values.begin(), m_layers_values.end(), layer_print_z - epsilon());
|
||||
if (it == m_layers_values.end()) {
|
||||
|
@ -744,7 +746,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
|
|||
else {
|
||||
if (label_type == ltEstimatedTime) {
|
||||
if (m_is_wipe_tower) {
|
||||
size_t layer_number = get_layer_number(value);
|
||||
size_t layer_number = get_layer_number(value, label_type);
|
||||
return layer_number == size_t(-1) ? "" : short_and_splitted_time(get_time_dhms(m_layers_times[layer_number]));
|
||||
}
|
||||
return value < m_layers_times.size() ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : "";
|
||||
|
@ -755,7 +757,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
|
|||
if (label_type == ltHeight)
|
||||
return str;
|
||||
if (label_type == ltHeightWithLayer) {
|
||||
size_t layer_number = m_is_wipe_tower ? get_layer_number(value) : (m_values.empty() ? value : value + 1);
|
||||
size_t layer_number = m_is_wipe_tower ? get_layer_number(value, label_type) : (m_values.empty() ? value : value + 1);
|
||||
return format_wxstr("%1%\n(%2%)", str, layer_number);
|
||||
}
|
||||
}
|
||||
|
@ -2036,7 +2038,7 @@ void Control::auto_color_change()
|
|||
Layer* layer = object->get_layer(i);
|
||||
double cur_area = area(layer->lslices);
|
||||
|
||||
if (cur_area > prev_area)
|
||||
if (cur_area > prev_area && prev_area - cur_area > scale_(scale_(1)))
|
||||
break;
|
||||
|
||||
if (prev_area - cur_area > delta_area) {
|
||||
|
|
|
@ -652,24 +652,37 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
|
|||
|
||||
//bool is_possible_auto_color_change = false;
|
||||
for (auto object : print.objects()) {
|
||||
// bottom layer have to be a biggest, so control relation between bottom lazer and object size
|
||||
const ExPolygons& bottom = object->get_layer(0)->lslices;
|
||||
double bottom_area = area(bottom);
|
||||
if (bottom_area < double(object->size().x()) * double(object->size().y()))
|
||||
continue;
|
||||
double object_x = double(object->size().x());
|
||||
double object_y = double(object->size().y());
|
||||
|
||||
// if it's sign, than object have not to be a too height
|
||||
double height = object->height();
|
||||
coord_t longer_side = std::max(object->size().x(), object->size().y());
|
||||
coord_t longer_side = std::max(object_x, object_y);
|
||||
if (height / longer_side > 0.3)
|
||||
continue;
|
||||
|
||||
const ExPolygons& bottom = object->get_layer(0)->lslices;
|
||||
double bottom_area = area(bottom);
|
||||
|
||||
// at least 30% of object's height have to be a solid
|
||||
int i;
|
||||
for (i = 1; i < int(0.3 * object->layers().size()); i++)
|
||||
if (area(object->get_layer(1)->lslices) != bottom_area)
|
||||
size_t i;
|
||||
for (i = 1; i < size_t(0.3 * object->layers().size()); i++) {
|
||||
double cur_area = area(object->get_layer(i)->lslices);
|
||||
if (cur_area != bottom_area && fabs(cur_area - bottom_area) > scale_(scale_(1)))
|
||||
break;
|
||||
if (i < int(0.3 * object->layers().size()))
|
||||
}
|
||||
if (i < size_t(0.3 * object->layers().size()))
|
||||
continue;
|
||||
|
||||
// bottom layer have to be a biggest, so control relation between bottom layer and object size
|
||||
double prev_area = area(object->get_layer(i)->lslices);
|
||||
for ( i++; i < object->layers().size(); i++) {
|
||||
double cur_area = area(object->get_layer(i)->lslices);
|
||||
if (cur_area > prev_area && prev_area - cur_area > scale_(scale_(1)))
|
||||
break;
|
||||
prev_area = cur_area;
|
||||
}
|
||||
if (i < object->layers().size())
|
||||
continue;
|
||||
|
||||
double top_area = area(object->get_layer(int(object->layers().size()) - 1)->lslices);
|
||||
|
|
Loading…
Reference in a new issue