Next auto color change improvements

This commit is contained in:
YuSanka 2021-03-19 11:11:46 +01:00
parent 995512f280
commit 4602f40813
3 changed files with 17 additions and 8 deletions

View file

@ -645,23 +645,24 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
// Suggest the auto color change, if model looks like sign
if (m_layers_slider->IsNewPrint())
{
NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager();
const Print& print = wxGetApp().plater()->fff_print();
double delta_area = scale_(scale_(25)); // equal to 25 mm2
//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;
// 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());
if (height / longer_side > 0.3)
continue;
const ExPolygons& bottom = object->get_layer(0)->lslices;
//if (bottom.size() > 1 || !bottom[0].holes.empty())
// continue;
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)
@ -671,6 +672,7 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
double top_area = area(object->get_layer(int(object->layers().size()) - 1)->lslices);
if( bottom_area - top_area > delta_area) {
NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager();
notif_mngr->push_notification(
NotificationType::SignDetected, NotificationManager::NotificationLevel::RegularNotification,
_u8L("NOTE:") + "\n" + _u8L("Sliced object looks like the sign") + "\n",