diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 81945061b0..00b9c2e290 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -1930,6 +1930,8 @@ void Control::auto_color_change() double delta_area = scale_(scale_(25)); // equal to 25 mm2 for (auto object : print.objects()) { + if (object->layer_count() == 0) + continue; double prev_area = area(object->get_layer(0)->lslices); for (size_t i = 1; i < object->layers().size(); i++) { diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 2f11d66f5f..da7d7810ad 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -1,4 +1,5 @@ #include "libslic3r/libslic3r.h" +#include "libslic3r/Layer.hpp" #include "GUI_Preview.hpp" #include "GUI_App.hpp" #include "GUI.hpp" @@ -24,6 +25,7 @@ // this include must follow the wxWidgets ones or it won't compile on Windows -> see http://trac.wxwidgets.org/ticket/2421 #include "libslic3r/Print.hpp" #include "libslic3r/SLAPrint.hpp" +#include "NotificationManager.hpp" namespace Slic3r { namespace GUI { @@ -639,6 +641,53 @@ void Preview::update_layers_slider(const std::vector& layers_z, bool kee else m_layers_slider->SetLayersTimes(m_gcode_result->time_statistics.modes.front().layers_times); + // Suggest the auto color change, if model looks like sign + if (ticks_info_from_model.gcodes.empty()) + { + NotificationManager* notif_mngr = wxGetApp().plater()->get_notification_manager(); +// notif_mngr->close_notification_of_type(NotificationType::SignDetected); + + 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()) { + 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); + int i; + for (i = 1; i < int(0.3 * object->layers().size()); i++) + if (area(object->get_layer(1)->lslices) != bottom_area) + break; + if (i < int(0.3 * object->layers().size())) + continue; + + double top_area = area(object->get_layer(int(object->layers().size()) - 1)->lslices); + if( bottom_area - top_area > delta_area) { + notif_mngr->push_notification( + NotificationType::SignDetected, NotificationManager::NotificationLevel::RegularNotification, + _u8L("NOTE:") + "\n" + _u8L("Sliced object looks like the sign") + "\n", + _u8L("Apply auto color change to print"), + [this/*, notif_mngr*/](wxEvtHandler*) { + // notif_mngr->close_notification_of_type(NotificationType::SignDetected); + m_layers_slider->auto_color_change(); + return true; + }); + + notif_mngr->set_in_preview(true); + + break; + } + } + } + m_layers_slider_sizer->Show((size_t)0); Layout(); } diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 266814e09c..eb028d3d36 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -1298,7 +1298,9 @@ void NotificationManager::set_in_preview(bool preview) m_in_preview = preview; for (std::unique_ptr ¬ification : m_pop_notifications) { if (notification->get_type() == NotificationType::PlaterWarning) - notification->hide(preview); + notification->hide(preview); + if (notification->get_type() == NotificationType::SignDetected) + notification->hide(!preview); } } diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index 4b32a716ff..222d6b1552 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -74,6 +74,8 @@ enum class NotificationType CustomSupportsAndSeamRemovedAfterRepair, // Notification that auto adding of color changes is impossible EmptyAutoColorChange, + // Notification about detected sign + SignDetected, // Notification emitted by Print::validate PrintValidateWarning, // Notification telling user to quit SLA supports manual editing