From db60d23c1889e32767fba7587b27993826ba7b4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Tue, 21 Feb 2023 13:48:16 +0100 Subject: [PATCH] Fix of #9809: Crash after splitting an object into parts. Now after splitting an object into parts, custom supports, seams, and multimaterial painting are removed, and the user is notified about it. Also, this commit fixed the text of the notification about removing custom supports, seams, and multimaterial painting by Simplify gizmo. And it also fixed that info about custom supports, seams, and multimaterial painting was still shown in the right panel after the model simplification event when custom supports, seams, and multimaterial were removed. --- src/slic3r/GUI/GUI_ObjectList.cpp | 11 ++++++++++- src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp | 6 +++++- src/slic3r/GUI/Plater.cpp | 9 ++++++--- src/slic3r/GUI/Plater.hpp | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 1906d2c307..79ae5b8963 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -2175,6 +2175,10 @@ void ObjectList::split() take_snapshot(_(L("Split to Parts"))); + // Before splitting volume we have to remove all custom supports, seams, and multimaterial painting. + wxGetApp().plater()->clear_before_change_mesh(obj_idx, _u8L("Custom supports, seams and multimaterial painting were " + "removed after splitting the object.")); + volume->split(nozzle_dmrs_cnt); (*m_objects)[obj_idx]->input_file.clear(); @@ -2186,6 +2190,10 @@ void ObjectList::split() changed_object(obj_idx); // update printable state for new volumes on canvas3D wxGetApp().plater()->canvas3D()->update_instance_printable_state_for_object(obj_idx); + + // After removing custom supports, seams, and multimaterial painting, we have to update info about the object to remove information about + // custom supports, seams, and multimaterial painting in the right panel. + wxGetApp().obj_list()->update_info_items(obj_idx); } void ObjectList::merge(bool to_multipart_object) @@ -4682,7 +4690,8 @@ void ObjectList::fix_through_netfabb() msg += "\n"; } - plater->clear_before_change_mesh(obj_idx); + plater->clear_before_change_mesh(obj_idx, _u8L("Custom supports, seams and multimaterial painting were " + "removed after repairing the mesh.")); std::string res; if (!fix_model_by_win10_sdk_gui(*(object(obj_idx)), vol_idx, progress_dlg, msg, res)) return false; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index 177d9d5a7b..90552c0a5d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -540,7 +540,11 @@ void GLGizmoSimplify::apply_simplify() { const Selection& selection = m_parent.get_selection(); auto plater = wxGetApp().plater(); plater->take_snapshot(_u8L("Simplify ") + create_volumes_name(m_volume_ids, selection)); - plater->clear_before_change_mesh(selection.get_object_idx()); + plater->clear_before_change_mesh(selection.get_object_idx(), _u8L("Custom supports, seams and multimaterial painting were " + "removed after simplifying the mesh.")); + // After removing custom supports, seams, and multimaterial painting, we have to update info about the object to remove information about + // custom supports, seams, and multimaterial painting in the right panel. + wxGetApp().obj_list()->update_info_items(selection.get_object_idx()); for (const auto &item: m_state.result) { const ObjectID &id = item.first; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d4e0b8fbd0..15c5400822 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3127,6 +3127,10 @@ void Plater::priv::split_object() Model new_model = model; ModelObject* current_model_object = new_model.objects[obj_idx]; + // Before splitting object we have to remove all custom supports, seams, and multimaterial painting. + wxGetApp().plater()->clear_before_change_mesh(obj_idx, _u8L("Custom supports, seams and multimaterial painting were " + "removed after splitting the object.")); + wxBusyCursor wait; ModelObjectPtrs new_objects; current_model_object->split(&new_objects); @@ -7338,7 +7342,7 @@ bool Plater::set_printer_technology(PrinterTechnology printer_technology) return ret; } -void Plater::clear_before_change_mesh(int obj_idx) +void Plater::clear_before_change_mesh(int obj_idx, const std::string ¬ification_msg) { ModelObject* mo = model().objects[obj_idx]; @@ -7356,8 +7360,7 @@ void Plater::clear_before_change_mesh(int obj_idx) get_notification_manager()->push_notification( NotificationType::CustomSupportsAndSeamRemovedAfterRepair, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, - _u8L("Custom supports, seams and multimaterial painting were " - "removed after repairing the mesh.")); + notification_msg); // _u8L("Undo the repair"), // [this, snapshot_time](wxEvtHandler*){ // // Make sure the snapshot is still available and that diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 1ecbeb1906..3dcca746da 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -273,7 +273,7 @@ public: void reslice_FFF_until_step(PrintObjectStep step, const ModelObject &object, bool postpone_error_messages = false); void reslice_SLA_until_step(SLAPrintObjectStep step, const ModelObject &object, bool postpone_error_messages = false); - void clear_before_change_mesh(int obj_idx); + void clear_before_change_mesh(int obj_idx, const std::string ¬ification_msg); void changed_mesh(int obj_idx); void changed_object(int obj_idx);