From 210cd5a4fe76f664f188ac56dc5d5fc7bb302c34 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Mon, 4 Mar 2024 15:33:37 +0800 Subject: [PATCH] FIX: cancel the use of perform_by_contour API Jira: STUDIO-6255 STUDIO-6254 Change-Id: Ie766f3f1c175af23e5faed30ad8351b49b261bdd --- src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp | 27 ++++++-------------- src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp | 3 +-- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp index 1c3cf707d..00406f597 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.cpp @@ -509,8 +509,7 @@ void GLGizmoAdvancedCut::on_set_state() // be deleted prematurely. if (m_part_selection && m_part_selection->valid()) { wxGetApp().CallAfter([this]() { - delete_part_selection(); - m_part_selection = new PartSelection(); + m_part_selection.reset(new PartSelection()); }); } } @@ -520,7 +519,7 @@ bool GLGizmoAdvancedCut::on_is_activable() const { const Selection &selection = m_parent.get_selection(); const int object_idx = selection.get_object_idx(); - if (object_idx < 0 || selection.is_wipe_tower()) + if (object_idx < 0 || selection.is_wipe_tower()) return false; if (const ModelObject *mo = wxGetApp().plater()->model().objects[object_idx]; mo->is_cut() && mo->volumes.size() == 1) { @@ -864,12 +863,11 @@ void GLGizmoAdvancedCut::perform_cut(const Selection& selection) // This shall delete the part selection class and deallocate the memory. ScopeGuard part_selection_killer([this]() { - delete_part_selection(); - m_part_selection = new PartSelection(); + m_part_selection.reset(new PartSelection()); }); const bool cut_with_groove = m_cut_mode == CutMode::cutTongueAndGroove; - bool cut_by_contour = !cut_with_groove && !m_cut_to_parts && m_part_selection->valid(); + bool cut_by_contour = false;//!cut_with_groove && !m_cut_to_parts && m_part_selection->valid(); ModelObject *cut_mo = cut_by_contour ? m_part_selection->model_object() : nullptr; if (cut_mo) @@ -1597,8 +1595,8 @@ void GLGizmoAdvancedCut::reset_cut_by_contours() { update_buffer_data(); update_plane_normal(); - delete_part_selection(); - m_part_selection = new PartSelection(); + + m_part_selection.reset(new PartSelection()); if (m_cut_mode == CutMode::cutTongueAndGroove) { if (m_dragging || m_groove_editing || !has_valid_groove()) @@ -1626,14 +1624,12 @@ void GLGizmoAdvancedCut::process_contours() Cut cut(model_objects[object_idx], instance_idx, get_cut_matrix(selection)); const ModelObjectPtrs &new_objects = cut.perform_with_groove(m_groove, m_rotate_matrix, true); if (!new_objects.empty()) { - delete_part_selection(); - m_part_selection = new PartSelection(new_objects.front(), instance_idx); + m_part_selection.reset(new PartSelection(new_objects.front(), instance_idx)); } } } else { if (m_c->object_clipper()) { - delete_part_selection(); - m_part_selection = new PartSelection(model_objects[object_idx], get_cut_matrix(selection), instance_idx, m_plane_center, m_plane_normal, *m_c->object_clipper()); + m_part_selection.reset(new PartSelection(model_objects[object_idx], get_cut_matrix(selection), instance_idx, m_plane_center, m_plane_normal, *m_c->object_clipper())); } } @@ -1652,13 +1648,6 @@ void GLGizmoAdvancedCut::toggle_model_objects_visibility(bool show_in_3d) } } -void GLGizmoAdvancedCut::delete_part_selection() -{ - if (m_part_selection) { - delete m_part_selection; - } -} - void GLGizmoAdvancedCut::deal_connector_pos_by_type( Vec3d &pos, float &height, CutConnectorType connector_type, CutConnectorStyle connector_style, bool looking_forward, bool is_edit, const Vec3d &clp_normal) {//deal pos and height,out :pos and height diff --git a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp index a6401ff3a..4d76e6284 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp @@ -153,7 +153,7 @@ private: bool m_was_cut_plane_dragged{false}; bool m_was_contour_selected{false}; bool m_is_dragging{false}; - PartSelection * m_part_selection{nullptr}; + std::shared_ptr m_part_selection{nullptr}; // dragging angel in hovered axes double m_rotate_angle{0.0}; bool m_imperial_units{false}; @@ -312,7 +312,6 @@ private: void reset_cut_by_contours(); void process_contours(); void toggle_model_objects_visibility(bool show_in_3d = false); - void delete_part_selection(); void deal_connector_pos_by_type(Vec3d &pos, float &height, CutConnectorType, CutConnectorStyle, bool looking_forward, bool is_edit, const Vec3d &clp_normal); void update_bb(); void check_and_update_connectors_state();