FIX: cancel the use of perform_by_contour API

Jira: STUDIO-6255 STUDIO-6254
Change-Id: Ie766f3f1c175af23e5faed30ad8351b49b261bdd
This commit is contained in:
zhou.xu 2024-03-04 15:33:37 +08:00 committed by Lane.Wei
parent df6c72beff
commit 210cd5a4fe
2 changed files with 9 additions and 21 deletions

View File

@ -509,8 +509,7 @@ void GLGizmoAdvancedCut::on_set_state()
// be deleted prematurely. // be deleted prematurely.
if (m_part_selection && m_part_selection->valid()) { if (m_part_selection && m_part_selection->valid()) {
wxGetApp().CallAfter([this]() { wxGetApp().CallAfter([this]() {
delete_part_selection(); m_part_selection.reset(new PartSelection());
m_part_selection = new PartSelection();
}); });
} }
} }
@ -520,7 +519,7 @@ bool GLGizmoAdvancedCut::on_is_activable() const
{ {
const Selection &selection = m_parent.get_selection(); const Selection &selection = m_parent.get_selection();
const int object_idx = selection.get_object_idx(); 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; return false;
if (const ModelObject *mo = wxGetApp().plater()->model().objects[object_idx]; mo->is_cut() && mo->volumes.size() == 1) { 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. // This shall delete the part selection class and deallocate the memory.
ScopeGuard part_selection_killer([this]() { ScopeGuard part_selection_killer([this]() {
delete_part_selection(); m_part_selection.reset(new PartSelection());
m_part_selection = new PartSelection();
}); });
const bool cut_with_groove = m_cut_mode == CutMode::cutTongueAndGroove; 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; ModelObject *cut_mo = cut_by_contour ? m_part_selection->model_object() : nullptr;
if (cut_mo) if (cut_mo)
@ -1597,8 +1595,8 @@ void GLGizmoAdvancedCut::reset_cut_by_contours()
{ {
update_buffer_data(); update_buffer_data();
update_plane_normal(); 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_cut_mode == CutMode::cutTongueAndGroove) {
if (m_dragging || m_groove_editing || !has_valid_groove()) 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)); 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); const ModelObjectPtrs &new_objects = cut.perform_with_groove(m_groove, m_rotate_matrix, true);
if (!new_objects.empty()) { if (!new_objects.empty()) {
delete_part_selection(); m_part_selection.reset(new PartSelection(new_objects.front(), instance_idx));
m_part_selection = new PartSelection(new_objects.front(), instance_idx);
} }
} }
} else { } else {
if (m_c->object_clipper()) { if (m_c->object_clipper()) {
delete_part_selection(); 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()));
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());
} }
} }
@ -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( 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) 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 {//deal pos and height,out :pos and height

View File

@ -153,7 +153,7 @@ private:
bool m_was_cut_plane_dragged{false}; bool m_was_cut_plane_dragged{false};
bool m_was_contour_selected{false}; bool m_was_contour_selected{false};
bool m_is_dragging{false}; bool m_is_dragging{false};
PartSelection * m_part_selection{nullptr}; std::shared_ptr<PartSelection> m_part_selection{nullptr};
// dragging angel in hovered axes // dragging angel in hovered axes
double m_rotate_angle{0.0}; double m_rotate_angle{0.0};
bool m_imperial_units{false}; bool m_imperial_units{false};
@ -312,7 +312,6 @@ private:
void reset_cut_by_contours(); void reset_cut_by_contours();
void process_contours(); void process_contours();
void toggle_model_objects_visibility(bool show_in_3d = false); 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 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 update_bb();
void check_and_update_connectors_state(); void check_and_update_connectors_state();