mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 02:37:51 -06:00
Implemented suggestion of the auto color change, if model looks like sign
This commit is contained in:
parent
c18ad5f9d6
commit
5f6253390f
4 changed files with 56 additions and 1 deletions
|
@ -1930,6 +1930,8 @@ void Control::auto_color_change()
|
||||||
double delta_area = scale_(scale_(25)); // equal to 25 mm2
|
double delta_area = scale_(scale_(25)); // equal to 25 mm2
|
||||||
|
|
||||||
for (auto object : print.objects()) {
|
for (auto object : print.objects()) {
|
||||||
|
if (object->layer_count() == 0)
|
||||||
|
continue;
|
||||||
double prev_area = area(object->get_layer(0)->lslices);
|
double prev_area = area(object->get_layer(0)->lslices);
|
||||||
|
|
||||||
for (size_t i = 1; i < object->layers().size(); i++) {
|
for (size_t i = 1; i < object->layers().size(); i++) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "libslic3r/libslic3r.h"
|
#include "libslic3r/libslic3r.h"
|
||||||
|
#include "libslic3r/Layer.hpp"
|
||||||
#include "GUI_Preview.hpp"
|
#include "GUI_Preview.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "GUI.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
|
// 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/Print.hpp"
|
||||||
#include "libslic3r/SLAPrint.hpp"
|
#include "libslic3r/SLAPrint.hpp"
|
||||||
|
#include "NotificationManager.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -639,6 +641,53 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
|
||||||
else
|
else
|
||||||
m_layers_slider->SetLayersTimes(m_gcode_result->time_statistics.modes.front().layers_times);
|
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);
|
m_layers_slider_sizer->Show((size_t)0);
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1299,6 +1299,8 @@ void NotificationManager::set_in_preview(bool preview)
|
||||||
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications) {
|
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications) {
|
||||||
if (notification->get_type() == NotificationType::PlaterWarning)
|
if (notification->get_type() == NotificationType::PlaterWarning)
|
||||||
notification->hide(preview);
|
notification->hide(preview);
|
||||||
|
if (notification->get_type() == NotificationType::SignDetected)
|
||||||
|
notification->hide(!preview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,8 @@ enum class NotificationType
|
||||||
CustomSupportsAndSeamRemovedAfterRepair,
|
CustomSupportsAndSeamRemovedAfterRepair,
|
||||||
// Notification that auto adding of color changes is impossible
|
// Notification that auto adding of color changes is impossible
|
||||||
EmptyAutoColorChange,
|
EmptyAutoColorChange,
|
||||||
|
// Notification about detected sign
|
||||||
|
SignDetected,
|
||||||
// Notification emitted by Print::validate
|
// Notification emitted by Print::validate
|
||||||
PrintValidateWarning,
|
PrintValidateWarning,
|
||||||
// Notification telling user to quit SLA supports manual editing
|
// Notification telling user to quit SLA supports manual editing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue