From acd225cee288f00a7c5f31ab545a49316bec5b66 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 11 Jan 2022 09:09:09 +0100 Subject: [PATCH 1/5] Techs ENABLE_NEW_CAMERA_MOVEMENTS_XXXX - 1st installment - Modified camera manipulation and selection by mouse --- src/libslic3r/Technologies.hpp | 4 + src/slic3r/GUI/GLCanvas3D.cpp | 127 +++++++++++++++---- src/slic3r/GUI/GLSelectionRectangle.cpp | 12 +- src/slic3r/GUI/GLSelectionRectangle.hpp | 22 ++-- src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 4 +- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 4 +- 6 files changed, 126 insertions(+), 47 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 8f372e7c5..957a060ed 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -65,6 +65,10 @@ // Enable detection of layers for spiral vase prints #define ENABLE_SPIRAL_VASE_LAYERS (1 && ENABLE_2_4_1_RC) +// Enable modified camera control and selection using mouse +#define ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE (1 && ENABLE_2_4_1_RC) +#define ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE (1 && ENABLE_2_4_1_RC) +#define ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION (1 && ENABLE_2_4_1_RC) #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 6d5bc3eb4..7a8c13e5d 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1460,7 +1460,11 @@ void GLCanvas3D::render() wxGetApp().imgui()->new_frame(); if (m_picking_enabled) { +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + if (m_rectangle_selection.is_dragging() && !m_rectangle_selection.is_empty()) +#else if (m_rectangle_selection.is_dragging()) +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION // picking pass using rectangle selection _rectangular_selection_picking_pass(); else if (!m_volumes.empty()) @@ -2635,8 +2639,13 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) _update_selection_from_hover(); m_rectangle_selection.stop_dragging(); m_mouse.ignore_left_up = true; +#if !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION m_dirty = true; +#endif // !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION } +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + m_dirty = true; +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION // set_cursor(Standard); } else if (keyCode == WXK_ALT) { @@ -2680,15 +2689,16 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) if (keyCode == WXK_SHIFT) { translationProcessor.process(evt); - if (m_picking_enabled && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)) - { + if (m_picking_enabled && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)) { m_mouse.ignore_left_up = false; // set_cursor(Cross); } +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + m_dirty = true; +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION } else if (keyCode == WXK_ALT) { - if (m_picking_enabled && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)) - { + if (m_picking_enabled && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)) { m_mouse.ignore_left_up = false; // set_cursor(Cross); } @@ -3085,6 +3095,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_layers_editing.state = LayersEditing::Editing; _perform_layer_editing_action(&evt); } +#if !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION else if (evt.LeftDown() && (evt.ShiftDown() || evt.AltDown()) && m_picking_enabled) { if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports && m_gizmos.get_current_type() != GLGizmosManager::FdmSupports @@ -3094,23 +3105,52 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_dirty = true; } } +#endif // !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION else { +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + if (evt.LeftDown() && (evt.ShiftDown() || evt.AltDown()) && m_picking_enabled) { + if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports + && m_gizmos.get_current_type() != GLGizmosManager::FdmSupports + && m_gizmos.get_current_type() != GLGizmosManager::Seam + && m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation) { + m_rectangle_selection.start_dragging(m_mouse.position, evt.ShiftDown() ? GLSelectionRectangle::EState::Select : GLSelectionRectangle::EState::Deselect); + m_dirty = true; + } + } +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + // Select volume in this 3D canvas. // Don't deselect a volume if layer editing is enabled or any gizmo is active. We want the object to stay selected // during the scene manipulation. +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + if (m_picking_enabled && (!any_gizmo_active || !evt.ShiftDown()) && (!m_hover_volume_idxs.empty() || !is_layers_editing_enabled())) { +#else if (m_picking_enabled && (!any_gizmo_active || !evt.CmdDown()) && (!m_hover_volume_idxs.empty() || !is_layers_editing_enabled())) { +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION if (evt.LeftDown() && !m_hover_volume_idxs.empty()) { int volume_idx = get_first_hover_volume_idx(); bool already_selected = m_selection.contains_volume(volume_idx); +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + bool shift_down = evt.ShiftDown(); +#else bool ctrl_down = evt.CmdDown(); +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION Selection::IndicesList curr_idxs = m_selection.get_volume_idxs(); +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + if (already_selected && shift_down) +#else if (already_selected && ctrl_down) +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION m_selection.remove(volume_idx); else { +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + m_selection.add(volume_idx, !shift_down, true); +#else m_selection.add(volume_idx, !ctrl_down, true); +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION m_mouse.drag.move_requires_threshold = !already_selected; if (already_selected) m_mouse.set_move_start_threshold_position_2D_as_invalid(); @@ -3135,7 +3175,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (!m_hover_volume_idxs.empty()) { if (evt.LeftDown() && m_moving_enabled && m_mouse.drag.move_volume_idx == -1) { // Only accept the initial position, if it is inside the volume bounding box. - int volume_idx = get_first_hover_volume_idx(); + const int volume_idx = get_first_hover_volume_idx(); BoundingBoxf3 volume_bbox = m_volumes.volumes[volume_idx]->transformed_bounding_box(); volume_bbox.offset(1.0); if ((!any_gizmo_active || !evt.CmdDown()) && volume_bbox.contains(m_mouse.scene_position)) { @@ -3143,6 +3183,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // The dragging operation is initiated. m_mouse.drag.move_volume_idx = volume_idx; m_selection.start_dragging(); +#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE + if (!evt.CmdDown()) +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE m_mouse.drag.start_position_3D = m_mouse.scene_position; m_sequential_print_clearance_first_displacement = true; m_moving = true; @@ -3151,31 +3194,35 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } } +#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE + else if (evt.Dragging() && evt.LeftIsDown() && !evt.CmdDown() && m_layers_editing.state == LayersEditing::Unknown && m_mouse.drag.move_volume_idx != -1) { +#else else if (evt.Dragging() && evt.LeftIsDown() && m_layers_editing.state == LayersEditing::Unknown && m_mouse.drag.move_volume_idx != -1) { - if (!m_mouse.drag.move_requires_threshold) { +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE + if (!m_mouse.drag.move_requires_threshold) { m_mouse.dragging = true; Vec3d cur_pos = m_mouse.drag.start_position_3D; // we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag if (m_selection.contains_volume(get_first_hover_volume_idx())) { const Camera& camera = wxGetApp().plater()->get_camera(); - if (std::abs(camera.get_dir_forward()(2)) < EPSILON) { + if (std::abs(camera.get_dir_forward().z()) < EPSILON) { // side view -> move selected volumes orthogonally to camera view direction - Linef3 ray = mouse_ray(pos); - Vec3d dir = ray.unit_vector(); + const Linef3 ray = mouse_ray(pos); + const Vec3d dir = ray.unit_vector(); // finds the intersection of the mouse ray with the plane parallel to the camera viewport and passing throught the starting position // use ray-plane intersection see i.e. https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection algebric form // in our case plane normal and ray direction are the same (orthogonal view) // when moving to perspective camera the negative z unit axis of the camera needs to be transformed in world space and used as plane normal - Vec3d inters = ray.a + (m_mouse.drag.start_position_3D - ray.a).dot(dir) / dir.squaredNorm() * dir; + const Vec3d inters = ray.a + (m_mouse.drag.start_position_3D - ray.a).dot(dir) / dir.squaredNorm() * dir; // vector from the starting position to the found intersection - Vec3d inters_vec = inters - m_mouse.drag.start_position_3D; + const Vec3d inters_vec = inters - m_mouse.drag.start_position_3D; - Vec3d camera_right = camera.get_dir_right(); - Vec3d camera_up = camera.get_dir_up(); + const Vec3d camera_right = camera.get_dir_right(); + const Vec3d camera_up = camera.get_dir_up(); // finds projection of the vector along the camera axes - double projection_x = inters_vec.dot(camera_right); - double projection_z = inters_vec.dot(camera_up); + const double projection_x = inters_vec.dot(camera_right); + const double projection_z = inters_vec.dot(camera_up); // apply offset cur_pos = m_mouse.drag.start_position_3D + projection_x * camera_right + projection_z * camera_up; @@ -3185,7 +3232,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // Get new position at the same Z of the initial click point. float z0 = 0.0f; float z1 = 1.0f; - cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2)); + cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D.z()); } } @@ -3210,13 +3257,21 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } // do not process the dragging if the left mouse was set down in another canvas +#if ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE + else if (evt.LeftIsDown() || evt.MiddleIsDown()) { +#else else if (evt.LeftIsDown()) { +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE // if dragging over blank area with left button, rotate +#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE + if ((any_gizmo_active || evt.CmdDown() || evt.MiddleIsDown() || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) { +#else if ((any_gizmo_active || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) { - const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.); +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE + const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.0) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.0); if (wxGetApp().app_config->get("use_free_camera") == "1") // Virtual track ball (similar to the 3DConnexion mouse). - wxGetApp().plater()->get_camera().rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.)); + wxGetApp().plater()->get_camera().rotate_local_around_target(Vec3d(rot.y(), rot.x(), 0.0)); else { // Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation. // It is cheaper to call this function right away instead of testing wxGetApp().plater()->get_mouse3d_controller().connected(), @@ -3229,15 +3284,20 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_dirty = true; } - m_mouse.drag.start_position_3D = Vec3d((double)pos(0), (double)pos(1), 0.0); + m_mouse.drag.start_position_3D = Vec3d((double)pos.x(), (double)pos.y(), 0.0); } +#if ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE + else if (evt.RightIsDown()) { + // If dragging with right button, pan. +#else else if (evt.MiddleIsDown() || evt.RightIsDown()) { // If dragging over blank area with right button, pan. +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE if (m_mouse.is_start_position_2D_defined()) { // get point in model space at Z = 0 float z = 0.0f; const Vec3d& cur_pos = _mouse_to_3d(pos, &z); - Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z); + const Vec3d orig = _mouse_to_3d(m_mouse.drag.start_position_2D, &z); Camera& camera = wxGetApp().plater()->get_camera(); if (wxGetApp().app_config->get("use_free_camera") != "1") // Forces camera right vector to be parallel to XY plane in case it has been misaligned using the 3D mouse free rotation. @@ -3254,7 +3314,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } else if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) { - if (evt.LeftUp()) + if (evt.LeftUp() && m_selection.is_dragging()) m_selection.stop_dragging(); if (m_layers_editing.state != LayersEditing::Unknown) { @@ -3313,7 +3373,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) if (!m_mouse.dragging) { // do not post the event if the user is panning the scene // or if right click was done over the wipe tower - bool post_right_click_event = m_hover_volume_idxs.empty() || !m_volumes.volumes[get_first_hover_volume_idx()]->is_wipe_tower; + const bool post_right_click_event = m_hover_volume_idxs.empty() || !m_volumes.volumes[get_first_hover_volume_idx()]->is_wipe_tower; if (post_right_click_event) post_event(RBtnEvent(EVT_GLCANVAS_RIGHT_CLICK, { logical_pos, m_hover_volume_idxs.empty() })); } @@ -5675,9 +5735,14 @@ void GLCanvas3D::_update_volumes_hover_state() if (volume.hover != GLVolume::HS_None) continue; +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + bool deselect = volume.selected && ((shift_pressed && m_rectangle_selection.is_empty()) || (alt_pressed && !m_rectangle_selection.is_empty())); + bool select = !volume.selected && (m_rectangle_selection.is_empty() || (shift_pressed && !m_rectangle_selection.is_empty())); +#else bool deselect = volume.selected && ((ctrl_pressed && !shift_pressed) || alt_pressed); // (volume->is_modifier && !selection_modifiers_only && !is_ctrl_pressed) -> allows hovering on selected modifiers belonging to selection of type Instance bool select = (!volume.selected || (volume.is_modifier && !selection_modifiers_only && !ctrl_pressed)) && !alt_pressed; +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION if (select || deselect) { bool as_volume = @@ -6436,7 +6501,7 @@ void GLCanvas3D::_update_selection_from_hover() bool ctrl_pressed = wxGetKeyState(WXK_CONTROL); if (m_hover_volume_idxs.empty()) { - if (!ctrl_pressed && (m_rectangle_selection.get_state() == GLSelectionRectangle::Select)) + if (!ctrl_pressed && m_rectangle_selection.get_state() == GLSelectionRectangle::EState::Select) m_selection.remove_all(); return; @@ -6453,7 +6518,10 @@ void GLCanvas3D::_update_selection_from_hover() } bool selection_changed = false; - if (state == GLSelectionRectangle::Select) { +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + if (!m_rectangle_selection.is_empty()) { +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + if (state == GLSelectionRectangle::EState::Select) { bool contains_all = true; for (int i : m_hover_volume_idxs) { if (!m_selection.contains_volume((unsigned int)i)) { @@ -6464,7 +6532,7 @@ void GLCanvas3D::_update_selection_from_hover() // the selection is going to be modified (Add) if (!contains_all) { - wxGetApp().plater()->take_snapshot(_(L("Selection-Add from rectangle")), UndoRedo::SnapshotType::Selection); + wxGetApp().plater()->take_snapshot(_L("Selection-Add from rectangle"), UndoRedo::SnapshotType::Selection); selection_changed = true; } } @@ -6479,21 +6547,24 @@ void GLCanvas3D::_update_selection_from_hover() // the selection is going to be modified (Remove) if (contains_any) { - wxGetApp().plater()->take_snapshot(_(L("Selection-Remove from rectangle")), UndoRedo::SnapshotType::Selection); + wxGetApp().plater()->take_snapshot(_L("Selection-Remove from rectangle"), UndoRedo::SnapshotType::Selection); selection_changed = true; } } +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + } +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION if (!selection_changed) return; Plater::SuppressSnapshots suppress(wxGetApp().plater()); - if ((state == GLSelectionRectangle::Select) && !ctrl_pressed) + if (state == GLSelectionRectangle::EState::Select && !ctrl_pressed) m_selection.clear(); for (int i : m_hover_volume_idxs) { - if (state == GLSelectionRectangle::Select) { + if (state == GLSelectionRectangle::EState::Select) { if (hover_modifiers_only) { const GLVolume& v = *m_volumes.volumes[i]; m_selection.add_volume(v.object_idx(), v.volume_idx(), v.instance_idx(), false); diff --git a/src/slic3r/GUI/GLSelectionRectangle.cpp b/src/slic3r/GUI/GLSelectionRectangle.cpp index 13467499a..f3d032fc3 100644 --- a/src/slic3r/GUI/GLSelectionRectangle.cpp +++ b/src/slic3r/GUI/GLSelectionRectangle.cpp @@ -13,12 +13,12 @@ namespace GUI { void GLSelectionRectangle::start_dragging(const Vec2d& mouse_position, EState state) { - if (is_dragging() || (state == Off)) + if (is_dragging() || state == EState::Off) return; m_state = state; m_start_corner = mouse_position; - m_end_corner = mouse_position; + m_end_corner = mouse_position; } void GLSelectionRectangle::dragging(const Vec2d& mouse_position) @@ -36,7 +36,7 @@ namespace GUI { if (!is_dragging()) return out; - m_state = Off; + m_state = EState::Off; const Camera& camera = wxGetApp().plater()->get_camera(); Matrix4d modelview = camera.get_view_matrix().matrix(); @@ -66,7 +66,7 @@ namespace GUI { void GLSelectionRectangle::stop_dragging() { if (is_dragging()) - m_state = Off; + m_state = EState::Off; } void GLSelectionRectangle::render(const GLCanvas3D& canvas) const @@ -93,8 +93,8 @@ namespace GUI { glsafe(::glLineWidth(1.5f)); float color[3]; - color[0] = (m_state == Select) ? 0.3f : 1.0f; - color[1] = (m_state == Select) ? 1.0f : 0.3f; + color[0] = (m_state == EState::Select) ? 0.3f : 1.0f; + color[1] = (m_state == EState::Select) ? 1.0f : 0.3f; color[2] = 0.3f; glsafe(::glColor3fv(color)); diff --git a/src/slic3r/GUI/GLSelectionRectangle.hpp b/src/slic3r/GUI/GLSelectionRectangle.hpp index d9869771e..dbbb056a9 100644 --- a/src/slic3r/GUI/GLSelectionRectangle.hpp +++ b/src/slic3r/GUI/GLSelectionRectangle.hpp @@ -11,7 +11,7 @@ class GLCanvas3D; class GLSelectionRectangle { public: - enum EState { + enum class EState { Off, Select, Deselect @@ -32,18 +32,22 @@ public: void render(const GLCanvas3D& canvas) const; - bool is_dragging() const { return m_state != Off; } + bool is_dragging() const { return m_state != EState::Off; } +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + bool is_empty() const { return m_state == EState::Off || m_start_corner.isApprox(m_end_corner); } +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + EState get_state() const { return m_state; } - float get_width() const { return std::abs(m_start_corner(0) - m_end_corner(0)); } - float get_height() const { return std::abs(m_start_corner(1) - m_end_corner(1)); } - float get_left() const { return std::min(m_start_corner(0), m_end_corner(0)); } - float get_right() const { return std::max(m_start_corner(0), m_end_corner(0)); } - float get_top() const { return std::max(m_start_corner(1), m_end_corner(1)); } - float get_bottom() const { return std::min(m_start_corner(1), m_end_corner(1)); } + float get_width() const { return std::abs(m_start_corner.x() - m_end_corner.x()); } + float get_height() const { return std::abs(m_start_corner.y() - m_end_corner.y()); } + float get_left() const { return std::min(m_start_corner.x(), m_end_corner.x()); } + float get_right() const { return std::max(m_start_corner.x(), m_end_corner.x()); } + float get_top() const { return std::max(m_start_corner.y(), m_end_corner.y()); } + float get_bottom() const { return std::min(m_start_corner.y(), m_end_corner.y()); } private: - EState m_state = Off; + EState m_state{ EState::Off }; Vec2d m_start_corner; Vec2d m_end_corner; }; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 691a86706..e5dee5248 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -258,7 +258,7 @@ bool GLGizmoHollow::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_pos if (action == SLAGizmoEventType::LeftDown && (shift_down || alt_down || control_down)) { if (m_hover_id == -1) { if (shift_down || alt_down) { - m_selection_rectangle.start_dragging(mouse_position, shift_down ? GLSelectionRectangle::Select : GLSelectionRectangle::Deselect); + m_selection_rectangle.start_dragging(mouse_position, shift_down ? GLSelectionRectangle::EState::Select : GLSelectionRectangle::EState::Deselect); } } else { @@ -324,7 +324,7 @@ bool GLGizmoHollow::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_pos trafo, wxGetApp().plater()->get_camera(), points_inside, m_c->object_clipper()->get_clipping_plane())) { - if (rectangle_status == GLSelectionRectangle::Deselect) + if (rectangle_status == GLSelectionRectangle::EState::Deselect) unselect_point(points_idxs[idx]); else select_point(points_idxs[idx]); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 29e1fd2f3..8395adadf 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -344,7 +344,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous if (action == SLAGizmoEventType::LeftDown && (shift_down || alt_down || control_down)) { if (m_hover_id == -1) { if (shift_down || alt_down) { - m_selection_rectangle.start_dragging(mouse_position, shift_down ? GLSelectionRectangle::Select : GLSelectionRectangle::Deselect); + m_selection_rectangle.start_dragging(mouse_position, shift_down ? GLSelectionRectangle::EState::Select : GLSelectionRectangle::EState::Deselect); } } else { @@ -415,7 +415,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous { if (idx >= orig_pts_num) // this is a cone-base, get index of point it belongs to idx -= orig_pts_num; - if (rectangle_status == GLSelectionRectangle::Deselect) + if (rectangle_status == GLSelectionRectangle::EState::Deselect) unselect_point(points_idxs[idx]); else select_point(points_idxs[idx]); From 7274d2bb6e7009a0bfbd0f5a281a8b6037ca7ad5 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Tue, 11 Jan 2022 09:43:43 +0100 Subject: [PATCH 2/5] Fixed warning --- src/slic3r/GUI/GLCanvas3D.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 7a8c13e5d..955287f0f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5706,7 +5706,9 @@ void GLCanvas3D::_update_volumes_hover_state() return; } +#if !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION bool selection_modifiers_only = m_selection.is_empty() || m_selection.is_any_modifier(); +#endif // !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION bool hover_modifiers_only = true; for (int i : m_hover_volume_idxs) { From f09c3e111803bc30d4cb007b898770869d93f730 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 14 Jan 2022 11:28:20 +0100 Subject: [PATCH 3/5] Techs ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE, ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE and ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION moved to 2.5.1.alpha1 --- src/libslic3r/Technologies.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index f267d4f55..1641e5804 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -43,10 +43,6 @@ // Enable detection of layers for spiral vase prints #define ENABLE_SPIRAL_VASE_LAYERS (1 && ENABLE_2_4_1_RC) -// Enable modified camera control and selection using mouse -#define ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE (1 && ENABLE_2_4_1_RC) -#define ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE (1 && ENABLE_2_4_1_RC) -#define ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION (1 && ENABLE_2_4_1_RC) //==================== @@ -62,6 +58,10 @@ #define ENABLE_PREVIEW_LAYER_TIME (1 && ENABLE_2_5_0_ALPHA1) // Enable showing time estimate for travel moves in legend #define ENABLE_TRAVEL_TIME (1 && ENABLE_2_5_0_ALPHA1) +// Enable modified camera control and selection using mouse +#define ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE (1 && ENABLE_2_5_0_ALPHA1) +#define ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE (1 && ENABLE_2_5_0_ALPHA1) +#define ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION (1 && ENABLE_2_5_0_ALPHA1) #endif // _prusaslicer_technologies_h_ From 2342002151a2ce4f25cb3b0b9cae10ce797ddc8e Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 11 Mar 2022 11:28:08 +0100 Subject: [PATCH 4/5] Tech ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE - Fixed volumes moving after releasing CTRL key Tech ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION - Selection rectangle not started while hovering on a volume --- src/slic3r/GUI/GLCanvas3D.cpp | 39 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 76bcde947..6e1c1c536 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2928,8 +2928,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) if (imgui->update_key_data(evt)) { render(); } - else - { + else { if (!m_gizmos.on_key(evt)) { if (evt.GetEventType() == wxEVT_KEY_UP) { if (evt.ShiftDown() && evt.ControlDown() && keyCode == WXK_SPACE) { @@ -2970,8 +2969,17 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) } // set_cursor(Standard); } - else if (keyCode == WXK_CONTROL) + else if (keyCode == WXK_CONTROL) { +#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE + if (m_mouse.dragging) { + // if the user releases CTRL while rotating the 3D scene + // prevent from moving the selected volume + m_mouse.drag.move_volume_idx = -1; + m_mouse.set_start_position_3D_as_invalid(); + } +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE m_dirty = true; + } else if (m_gizmos.is_enabled() && !m_selection.is_empty()) { translationProcessor.process(evt); @@ -3444,10 +3452,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) else { #if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION if (evt.LeftDown() && (evt.ShiftDown() || evt.AltDown()) && m_picking_enabled) { - if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports - && m_gizmos.get_current_type() != GLGizmosManager::FdmSupports - && m_gizmos.get_current_type() != GLGizmosManager::Seam - && m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation) { + if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports && + m_gizmos.get_current_type() != GLGizmosManager::FdmSupports && + m_gizmos.get_current_type() != GLGizmosManager::Seam && + m_gizmos.get_current_type() != GLGizmosManager::MmuSegmentation) { m_rectangle_selection.start_dragging(m_mouse.position, evt.ShiftDown() ? GLSelectionRectangle::EState::Select : GLSelectionRectangle::EState::Deselect); m_dirty = true; } @@ -3459,7 +3467,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // during the scene manipulation. #if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION - if (m_picking_enabled && (!any_gizmo_active || !evt.ShiftDown()) && (!m_hover_volume_idxs.empty() || !is_layers_editing_enabled())) { + if (m_picking_enabled && (!any_gizmo_active || !evt.ShiftDown()) && (!m_hover_volume_idxs.empty() || !is_layers_editing_enabled()) && + !m_rectangle_selection.is_dragging()) { #else if (m_picking_enabled && (!any_gizmo_active || !evt.CmdDown()) && (!m_hover_volume_idxs.empty() || !is_layers_editing_enabled())) { #endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION @@ -3507,7 +3516,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + if (!m_hover_volume_idxs.empty() && !m_rectangle_selection.is_dragging()) { +#else if (!m_hover_volume_idxs.empty()) { +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION if (evt.LeftDown() && m_moving_enabled && m_mouse.drag.move_volume_idx == -1) { // Only accept the initial position, if it is inside the volume bounding box. const int volume_idx = get_first_hover_volume_idx(); @@ -3518,6 +3531,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // The dragging operation is initiated. m_mouse.drag.move_volume_idx = volume_idx; #if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE + m_selection.setup_cache(); if (!evt.CmdDown()) #endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE m_mouse.drag.start_position_3D = m_mouse.scene_position; @@ -3529,7 +3543,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } #if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE - else if (evt.Dragging() && evt.LeftIsDown() && !evt.CmdDown() && m_layers_editing.state == LayersEditing::Unknown && m_mouse.drag.move_volume_idx != -1) { + else if (evt.Dragging() && evt.LeftIsDown() && !evt.CmdDown() && m_layers_editing.state == LayersEditing::Unknown && + m_mouse.drag.move_volume_idx != -1 && m_mouse.is_start_position_3D_defined()) { #else else if (evt.Dragging() && evt.LeftIsDown() && m_layers_editing.state == LayersEditing::Unknown && m_mouse.drag.move_volume_idx != -1) { #endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE @@ -3578,7 +3593,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } else if (evt.Dragging() && evt.LeftIsDown() && m_picking_enabled && m_rectangle_selection.is_dragging()) { +#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION + // keeps the mouse position updated while dragging the selection rectangle + m_mouse.position = pos.cast(); + m_rectangle_selection.dragging(m_mouse.position); +#else m_rectangle_selection.dragging(pos.cast()); +#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION m_dirty = true; } else if (evt.Dragging()) { From ac0ec5fa4391423e6a23dd8d4463431fb6c43d02 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 11 Mar 2022 12:36:09 +0100 Subject: [PATCH 5/5] Tech ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE renamed as ENABLE_NEW_CAMERA_MOVEMENTS Tech ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE merged into ENABLE_NEW_CAMERA_MOVEMENTS Tech ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION renamed as ENABLE_NEW_RECTANGLE_SELECTION --- src/libslic3r/Technologies.hpp | 8 +- src/slic3r/GUI/GLCanvas3D.cpp | 97 ++++++++++++------------- src/slic3r/GUI/GLSelectionRectangle.hpp | 4 +- 3 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index c306cccc4..b46b8731f 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -80,10 +80,10 @@ #define ENABLE_SHOW_TOOLPATHS_COG (1 && ENABLE_2_5_0_ALPHA1) // Enable recalculating toolpaths when switching to/from volumetric rate visualization #define ENABLE_VOLUMETRIC_RATE_TOOLPATHS_RECALC (1 && ENABLE_2_5_0_ALPHA1) -// Enable modified camera control and selection using mouse -#define ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE (1 && ENABLE_2_5_0_ALPHA1) -#define ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE (1 && ENABLE_2_5_0_ALPHA1) -#define ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION (1 && ENABLE_2_5_0_ALPHA1) +// Enable modified camera control using mouse +#define ENABLE_NEW_CAMERA_MOVEMENTS (1 && ENABLE_2_5_0_ALPHA1) +// Enable modified rectangle selection +#define ENABLE_NEW_RECTANGLE_SELECTION (1 && ENABLE_2_5_0_ALPHA1) #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 6e1c1c536..ea08f9871 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1696,11 +1696,11 @@ void GLCanvas3D::render() wxGetApp().imgui()->new_frame(); if (m_picking_enabled) { -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION if (m_rectangle_selection.is_dragging() && !m_rectangle_selection.is_empty()) #else if (m_rectangle_selection.is_dragging()) -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION // picking pass using rectangle selection _rectangular_selection_picking_pass(); else if (!m_volumes.empty()) @@ -2951,13 +2951,13 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) _update_selection_from_hover(); m_rectangle_selection.stop_dragging(); m_mouse.ignore_left_up = true; -#if !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if !ENABLE_NEW_RECTANGLE_SELECTION m_dirty = true; -#endif // !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // !ENABLE_NEW_RECTANGLE_SELECTION } -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION m_dirty = true; -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION // set_cursor(Standard); } else if (keyCode == WXK_ALT) { @@ -2970,14 +2970,14 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) // set_cursor(Standard); } else if (keyCode == WXK_CONTROL) { -#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE +#if ENABLE_NEW_CAMERA_MOVEMENTS if (m_mouse.dragging) { // if the user releases CTRL while rotating the 3D scene // prevent from moving the selected volume m_mouse.drag.move_volume_idx = -1; m_mouse.set_start_position_3D_as_invalid(); } -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE +#endif // ENABLE_NEW_CAMERA_MOVEMENTS m_dirty = true; } else if (m_gizmos.is_enabled() && !m_selection.is_empty()) { @@ -3014,9 +3014,9 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) m_mouse.ignore_left_up = false; // set_cursor(Cross); } -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION m_dirty = true; -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION } else if (keyCode == WXK_ALT) { if (m_picking_enabled && (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports)) { @@ -3438,7 +3438,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_layers_editing.state = LayersEditing::Editing; _perform_layer_editing_action(&evt); } -#if !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if !ENABLE_NEW_RECTANGLE_SELECTION else if (evt.LeftDown() && (evt.ShiftDown() || evt.AltDown()) && m_picking_enabled) { if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports && m_gizmos.get_current_type() != GLGizmosManager::FdmSupports @@ -3448,9 +3448,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_dirty = true; } } -#endif // !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // !ENABLE_NEW_RECTANGLE_SELECTION else { -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION if (evt.LeftDown() && (evt.ShiftDown() || evt.AltDown()) && m_picking_enabled) { if (m_gizmos.get_current_type() != GLGizmosManager::SlaSupports && m_gizmos.get_current_type() != GLGizmosManager::FdmSupports && @@ -3460,41 +3460,40 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) m_dirty = true; } } -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION // Select volume in this 3D canvas. // Don't deselect a volume if layer editing is enabled or any gizmo is active. We want the object to stay selected // during the scene manipulation. -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION if (m_picking_enabled && (!any_gizmo_active || !evt.ShiftDown()) && (!m_hover_volume_idxs.empty() || !is_layers_editing_enabled()) && !m_rectangle_selection.is_dragging()) { #else if (m_picking_enabled && (!any_gizmo_active || !evt.CmdDown()) && (!m_hover_volume_idxs.empty() || !is_layers_editing_enabled())) { -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION if (evt.LeftDown() && !m_hover_volume_idxs.empty()) { int volume_idx = get_first_hover_volume_idx(); bool already_selected = m_selection.contains_volume(volume_idx); -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION bool shift_down = evt.ShiftDown(); #else bool ctrl_down = evt.CmdDown(); -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION Selection::IndicesList curr_idxs = m_selection.get_volume_idxs(); -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION if (already_selected && shift_down) -#else - if (already_selected && ctrl_down) -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION m_selection.remove(volume_idx); else { -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION m_selection.add(volume_idx, !shift_down, true); #else + if (already_selected && ctrl_down) + m_selection.remove(volume_idx); + else { m_selection.add(volume_idx, !ctrl_down, true); -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION m_mouse.drag.move_requires_threshold = !already_selected; if (already_selected) m_mouse.set_move_start_threshold_position_2D_as_invalid(); @@ -3516,11 +3515,11 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION if (!m_hover_volume_idxs.empty() && !m_rectangle_selection.is_dragging()) { #else if (!m_hover_volume_idxs.empty()) { -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION if (evt.LeftDown() && m_moving_enabled && m_mouse.drag.move_volume_idx == -1) { // Only accept the initial position, if it is inside the volume bounding box. const int volume_idx = get_first_hover_volume_idx(); @@ -3530,11 +3529,11 @@ 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; -#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE +#if ENABLE_NEW_CAMERA_MOVEMENTS m_selection.setup_cache(); if (!evt.CmdDown()) -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE - m_mouse.drag.start_position_3D = m_mouse.scene_position; +#endif // ENABLE_NEW_CAMERA_MOVEMENTS + m_mouse.drag.start_position_3D = m_mouse.scene_position; m_sequential_print_clearance_first_displacement = true; m_moving = true; } @@ -3542,12 +3541,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } } -#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE +#if ENABLE_NEW_CAMERA_MOVEMENTS else if (evt.Dragging() && evt.LeftIsDown() && !evt.CmdDown() && m_layers_editing.state == LayersEditing::Unknown && m_mouse.drag.move_volume_idx != -1 && m_mouse.is_start_position_3D_defined()) { #else else if (evt.Dragging() && evt.LeftIsDown() && m_layers_editing.state == LayersEditing::Unknown && m_mouse.drag.move_volume_idx != -1) { -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE +#endif // ENABLE_NEW_CAMERA_MOVEMENTS if (!m_mouse.drag.move_requires_threshold) { m_mouse.dragging = true; Vec3d cur_pos = m_mouse.drag.start_position_3D; @@ -3593,13 +3592,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } else if (evt.Dragging() && evt.LeftIsDown() && m_picking_enabled && m_rectangle_selection.is_dragging()) { -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION // keeps the mouse position updated while dragging the selection rectangle m_mouse.position = pos.cast(); m_rectangle_selection.dragging(m_mouse.position); #else m_rectangle_selection.dragging(pos.cast()); -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION m_dirty = true; } else if (evt.Dragging()) { @@ -3612,17 +3611,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } } // do not process the dragging if the left mouse was set down in another canvas -#if ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE +#if ENABLE_NEW_CAMERA_MOVEMENTS else if (evt.LeftIsDown() || evt.MiddleIsDown()) { -#else - else if (evt.LeftIsDown()) { -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE // if dragging over blank area with left button, rotate -#if ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE if ((any_gizmo_active || evt.CmdDown() || evt.MiddleIsDown() || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) { #else + // if dragging over blank area with left button, rotate + else if (evt.LeftIsDown()) { if ((any_gizmo_active || m_hover_volume_idxs.empty()) && m_mouse.is_start_position_3D_defined()) { -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_CTRL_ROTATE +#endif // ENABLE_NEW_CAMERA_MOVEMENTS const Vec3d rot = (Vec3d(pos.x(), pos.y(), 0.0) - m_mouse.drag.start_position_3D) * (PI * TRACKBALLSIZE / 180.0); if (wxGetApp().app_config->get("use_free_camera") == "1") // Virtual track ball (similar to the 3DConnexion mouse). @@ -3641,13 +3638,13 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) } m_mouse.drag.start_position_3D = Vec3d((double)pos.x(), (double)pos.y(), 0.0); } -#if ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE +#if ENABLE_NEW_CAMERA_MOVEMENTS else if (evt.RightIsDown()) { // If dragging with right button, pan. #else else if (evt.MiddleIsDown() || evt.RightIsDown()) { // If dragging over blank area with right button, pan. -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_MIDMOUSE_ROTATE +#endif // ENABLE_NEW_CAMERA_MOVEMENTS if (m_mouse.is_start_position_2D_defined()) { // get point in model space at Z = 0 float z = 0.0f; @@ -6418,9 +6415,9 @@ void GLCanvas3D::_update_volumes_hover_state() return; } -#if !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if !ENABLE_NEW_RECTANGLE_SELECTION bool selection_modifiers_only = m_selection.is_empty() || m_selection.is_any_modifier(); -#endif // !ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // !ENABLE_NEW_RECTANGLE_SELECTION bool hover_modifiers_only = true; for (int i : m_hover_volume_idxs) { @@ -6449,14 +6446,14 @@ void GLCanvas3D::_update_volumes_hover_state() if (volume.hover != GLVolume::HS_None) continue; -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION bool deselect = volume.selected && ((shift_pressed && m_rectangle_selection.is_empty()) || (alt_pressed && !m_rectangle_selection.is_empty())); - bool select = !volume.selected && (m_rectangle_selection.is_empty() || (shift_pressed && !m_rectangle_selection.is_empty())); + bool select = !volume.selected && (m_rectangle_selection.is_empty() || (shift_pressed && !m_rectangle_selection.is_empty())); #else bool deselect = volume.selected && ((ctrl_pressed && !shift_pressed) || alt_pressed); // (volume->is_modifier && !selection_modifiers_only && !is_ctrl_pressed) -> allows hovering on selected modifiers belonging to selection of type Instance bool select = (!volume.selected || (volume.is_modifier && !selection_modifiers_only && !ctrl_pressed)) && !alt_pressed; -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION if (select || deselect) { bool as_volume = @@ -7391,9 +7388,9 @@ void GLCanvas3D::_update_selection_from_hover() } bool selection_changed = false; -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION if (!m_rectangle_selection.is_empty()) { -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION if (state == GLSelectionRectangle::EState::Select) { bool contains_all = true; for (int i : m_hover_volume_idxs) { @@ -7424,9 +7421,9 @@ void GLCanvas3D::_update_selection_from_hover() selection_changed = true; } } -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION } -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION if (!selection_changed) return; diff --git a/src/slic3r/GUI/GLSelectionRectangle.hpp b/src/slic3r/GUI/GLSelectionRectangle.hpp index f18dc4a6a..49b3447ba 100644 --- a/src/slic3r/GUI/GLSelectionRectangle.hpp +++ b/src/slic3r/GUI/GLSelectionRectangle.hpp @@ -36,9 +36,9 @@ public: void render(const GLCanvas3D& canvas); bool is_dragging() const { return m_state != EState::Off; } -#if ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#if ENABLE_NEW_RECTANGLE_SELECTION bool is_empty() const { return m_state == EState::Off || m_start_corner.isApprox(m_end_corner); } -#endif // ENABLE_NEW_CAMERA_MOVEMENTS_SHIFT_SELECTION +#endif // ENABLE_NEW_RECTANGLE_SELECTION EState get_state() const { return m_state; }