Auto color change: check overhangs lust from Preview when detecting auto color changes

+ fixed typo in equivalent_areas()
 + Added missed include
This commit is contained in:
YuSanka 2021-10-12 15:23:50 +02:00
parent 5990f05418
commit a4ad4ff4a9
3 changed files with 7 additions and 6 deletions

View File

@ -43,7 +43,7 @@ constexpr double miscalculation = scale_(scale_(1)); // equal to 1 mm2
bool equivalent_areas(const double& bottom_area, const double& top_area) bool equivalent_areas(const double& bottom_area, const double& top_area)
{ {
return fabs(bottom_area - top_area <= miscalculation); return fabs(bottom_area - top_area) <= miscalculation;
} }
wxDEFINE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent); wxDEFINE_EVENT(wxCUSTOMEVT_TICKSCHANGED, wxEvent);
@ -2042,7 +2042,7 @@ void Control::show_cog_icon_context_menu()
GUI::wxGetApp().plater()->PopupMenu(&menu); GUI::wxGetApp().plater()->PopupMenu(&menu);
} }
bool check_color_change(PrintObject* object, size_t frst_layer_id, size_t layers_cnt, std::function<bool(Layer*)> break_condition) bool check_color_change(PrintObject* object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs, std::function<bool(Layer*)> break_condition)
{ {
double prev_area = area(object->get_layer(frst_layer_id)->lslices); double prev_area = area(object->get_layer(frst_layer_id)->lslices);
@ -2052,7 +2052,7 @@ bool check_color_change(PrintObject* object, size_t frst_layer_id, size_t layers
double cur_area = area(layer->lslices); double cur_area = area(layer->lslices);
// check for overhangs // check for overhangs
if (cur_area > prev_area && !equivalent_areas(prev_area, cur_area)) if (check_overhangs && cur_area > prev_area && !equivalent_areas(prev_area, cur_area))
break; break;
// Check percent of the area decrease. // Check percent of the area decrease.
@ -2087,7 +2087,7 @@ void Control::auto_color_change()
if (object->layer_count() == 0) if (object->layer_count() == 0)
continue; continue;
check_color_change(object, 1, object->layers().size(), [this, extruders_cnt](Layer* layer) check_color_change(object, 1, object->layers().size(), false, [this, extruders_cnt](Layer* layer)
{ {
int tick = get_tick_from_value(layer->print_z); int tick = get_tick_from_value(layer->print_z);
if (tick >= 0 && !m_ticks.has_tick(tick)) { if (tick >= 0 && !m_ticks.has_tick(tick)) {

View File

@ -31,7 +31,7 @@ constexpr double epsilon() { return 0.0011; }
bool equivalent_areas(const double& bottom_area, const double& top_area); bool equivalent_areas(const double& bottom_area, const double& top_area);
// return true if color change was detected // return true if color change was detected
bool check_color_change(PrintObject* object, size_t frst_layer_id, size_t layers_cnt, bool check_color_change(PrintObject* object, size_t frst_layer_id, size_t layers_cnt, bool check_overhangs,
// what to do with detected color change // what to do with detected color change
// and return true when detection have to be desturbed // and return true when detection have to be desturbed
std::function<bool(Layer*)> break_condition); std::function<bool(Layer*)> break_condition);

View File

@ -13,6 +13,7 @@
#include "DoubleSlider.hpp" #include "DoubleSlider.hpp"
#include "Plater.hpp" #include "Plater.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "format.hpp"
#include <wx/listbook.h> #include <wx/listbook.h>
#include <wx/notebook.h> #include <wx/notebook.h>
@ -720,7 +721,7 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
if (i < min_solid_height) if (i < min_solid_height)
continue; continue;
if (DoubleSlider::check_color_change(object, i, num_layers, [this, object](Layer*) { if (DoubleSlider::check_color_change(object, i, num_layers, true, [this, object](Layer*) {
NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager(); NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager();
notif_mngr->push_notification( notif_mngr->push_notification(
NotificationType::SignDetected, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, NotificationType::SignDetected, NotificationManager::NotificationLevel::PrintInfoNotificationLevel,