diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 76fae46645..1aca383714 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2774,7 +2774,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) m_dirty = true; }, [this](const Vec3d& direction, bool slow, bool camera_space) { - m_selection.start_dragging(); + m_selection.setup_cache(); double multiplier = slow ? 1.0 : 10.0; Vec3d displacement; @@ -2787,7 +2787,6 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) displacement = multiplier * direction; m_selection.translate(displacement); - m_selection.stop_dragging(); m_dirty = true; } ); @@ -2884,9 +2883,8 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) m_dirty = true; else if (m_gizmos.is_enabled() && !m_selection.is_empty()) { auto do_rotate = [this](double angle_z_rad) { - m_selection.start_dragging(); + m_selection.setup_cache(); m_selection.rotate(Vec3d(0.0, 0.0, angle_z_rad), TransformationType(TransformationType::World_Relative_Joint)); - m_selection.stop_dragging(); m_dirty = true; // wxGetApp().obj_manipul()->set_dirty(); }; @@ -3352,7 +3350,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_volumes.volumes[volume_idx]->hover = GLVolume::HS_None; // The dragging operation is initiated. m_mouse.drag.move_volume_idx = volume_idx; - m_selection.start_dragging(); + m_selection.setup_cache(); m_mouse.drag.start_position_3D = m_mouse.scene_position; m_sequential_print_clearance_first_displacement = true; m_moving = true; @@ -3464,9 +3462,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } else if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) { - if (evt.LeftUp()) - m_selection.stop_dragging(); - if (m_layers_editing.state != LayersEditing::Unknown) { m_layers_editing.state = LayersEditing::Unknown; _stop_timer(); diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index a76ad1758f..8a0d52bbbc 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -839,9 +839,9 @@ void ObjectManipulation::update_if_dirty() else m_og->disable(); - if (!selection.is_dragging()) { + if (!wxGetApp().plater()->canvas3D()->is_dragging()) { update_reset_buttons_visibility(); - update_mirror_buttons_visibility(); + update_mirror_buttons_visibility(); } m_dirty = false; @@ -1028,13 +1028,12 @@ void ObjectManipulation::change_position_value(int axis, double value) auto canvas = wxGetApp().plater()->canvas3D(); Selection& selection = canvas->get_selection(); - selection.start_dragging(); + selection.setup_cache(); #if ENABLE_WORLD_COORDINATE selection.translate(position - m_cache.position, get_coordinates_type()); #else selection.translate(position - m_cache.position, selection.requires_local_axes()); #endif // ENABLE_WORLD_COORDINATE - selection.stop_dragging(); canvas->do_move(L("Set Position")); m_cache.position = position; @@ -1075,11 +1074,10 @@ void ObjectManipulation::change_rotation_value(int axis, double value) } #endif // ENABLE_WORLD_COORDINATE - selection.start_dragging(); + selection.setup_cache(); selection.rotate( (M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation), transformation_type); - selection.stop_dragging(); canvas->do_rotate(L("Set Orientation")); m_cache.rotation = rotation; @@ -1199,9 +1197,8 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const scaling_factor = scale(axis) * Vec3d::Ones(); #endif // ENABLE_WORLD_COORDINATE - selection.start_dragging(); + selection.setup_cache(); selection.scale(scaling_factor, transformation_type); - selection.stop_dragging(); wxGetApp().plater()->canvas3D()->do_scale(L("Set Scale")); } @@ -1229,9 +1226,8 @@ void ObjectManipulation::do_size(int axis, const Vec3d& scale) const } } - selection.start_dragging(); + selection.setup_cache(); selection.scale(scaling_factor, transformation_type); - selection.stop_dragging(); wxGetApp().plater()->canvas3D()->do_scale(L("Set Size")); } #endif // ENABLE_WORLD_COORDINATE_SCALE_REVISITED diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index d88b90feba..074afe49f4 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -162,8 +162,7 @@ bool GLGizmoBase::use_grabbers(const wxMouseEvent &mouse_event) { Selection &selection = m_parent.get_selection(); if (!selection.is_empty() && m_hover_id != -1 && (m_grabbers.empty() || m_hover_id < static_cast(m_grabbers.size()))) { - // TODO: investigate if it is neccessary -> there was no stop dragging - selection.start_dragging(); + selection.setup_cache(); m_dragging = true; for (auto &grabber : m_grabbers) grabber.dragging = false; @@ -207,8 +206,6 @@ bool GLGizmoBase::use_grabbers(const wxMouseEvent &mouse_event) { on_stop_dragging(); - m_parent.get_selection().stop_dragging(); - // There is prediction that after draggign, data are changed // Data are updated twice also by canvas3D::reload_scene. // Should be fixed. @@ -241,8 +238,6 @@ void GLGizmoBase::do_stop_dragging(bool perform_mouse_cleanup) on_stop_dragging(); - m_parent.get_selection().stop_dragging(); - // There is prediction that after draggign, data are changed // Data are updated twice also by canvas3D::reload_scene. // Should be fixed. diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index e3e12a6108..045e3bf9c1 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -120,7 +120,6 @@ Selection::Selection() , m_type(Empty) , m_valid(false) , m_scale_factor(1.0f) - , m_dragging(false) { this->set_bounding_boxes_dirty(); #if ENABLE_WORLD_COORDINATE_SHOW_AXES @@ -751,12 +750,11 @@ const BoundingBoxf3& Selection::get_scaled_instance_bounding_box() const return *m_scaled_instance_bounding_box; } -void Selection::start_dragging() +void Selection::setup_cache() { if (!m_valid) return; - m_dragging = true; set_caches(); } @@ -1113,12 +1111,12 @@ void Selection::scale_to_fit_print_volume(const BuildVolume& volume) type.set_joint(); // apply scale - start_dragging(); + setup_cache(); scale(s * Vec3d::Ones(), type); wxGetApp().plater()->canvas3D()->do_scale(""); // avoid storing another snapshot // center selection on print bed - start_dragging(); + setup_cache(); offset.z() = -get_bounding_box().min.z(); translate(offset); wxGetApp().plater()->canvas3D()->do_move(""); // avoid storing another snapshot diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index a31de0bfad..858ce4afd8 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -243,7 +243,6 @@ private: #endif // ENABLE_GLBEGIN_GLEND_REMOVAL float m_scale_factor; - bool m_dragging; public: Selection(); @@ -351,9 +350,7 @@ public: const BoundingBoxf3& get_unscaled_instance_bounding_box() const; const BoundingBoxf3& get_scaled_instance_bounding_box() const; - void start_dragging(); - void stop_dragging() { m_dragging = false; } - bool is_dragging() const { return m_dragging; } + void setup_cache(); #if ENABLE_WORLD_COORDINATE void translate(const Vec3d& displacement, ECoordinatesType type = ECoordinatesType::World);