From 4d8e6538e8b9fe8ac91a705456ebe7696a1c43f3 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 8 Apr 2020 14:59:53 +0200 Subject: [PATCH] FDM supports gizmo - use right mouse to place support blockers --- src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 26 ++++++++++++++------ src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp | 8 +++++- src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp | 1 + src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 18 +++++++++++--- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index 3db236a8e..f423c0934 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -41,7 +41,7 @@ bool GLGizmoFdmSupports::on_init() m_desc["cursor_size"] = _L("Cursor size") + ": "; m_desc["enforce_caption"] = _L("Left mouse button") + ": "; m_desc["enforce"] = _L("Enforce supports"); - m_desc["block_caption"] = _L("Alt + Left mouse button") + " "; + m_desc["block_caption"] = _L("Right mouse button") + " "; m_desc["block"] = _L("Block supports"); m_desc["remove_caption"] = _L("Shift + Left mouse button") + ": "; m_desc["remove"] = _L("Remove selection"); @@ -240,8 +240,18 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous return true; } - if (action == SLAGizmoEventType::LeftDown || (action == SLAGizmoEventType::Dragging && m_wait_for_up_event)) { - int8_t new_state = shift_down ? 0 : (alt_down ? -1 : 1); + if (action == SLAGizmoEventType::LeftDown + || action == SLAGizmoEventType::RightDown + || (action == SLAGizmoEventType::Dragging && m_button_down != Button::None)) { + + int8_t new_state = 0; + if (! shift_down) { + if (action == SLAGizmoEventType::Dragging) + new_state = m_button_down == Button::Left ? 1 : -1; + else + new_state = action == SLAGizmoEventType::LeftDown ? 1 : -1; + } + const Camera& camera = wxGetApp().plater()->get_camera(); const Selection& selection = m_parent.get_selection(); const ModelObject* mo = m_c->selection_info()->model_object(); @@ -368,16 +378,18 @@ bool GLGizmoFdmSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous if (some_mesh_was_hit) { - m_wait_for_up_event = true; + if (m_button_down == Button::None) + m_button_down = ((action == SLAGizmoEventType::LeftDown) ? Button::Left : Button::Right); m_parent.set_as_dirty(); return true; } - if (action == SLAGizmoEventType::Dragging && m_wait_for_up_event) + if (action == SLAGizmoEventType::Dragging && m_button_down != Button::None) return true; } - if (action == SLAGizmoEventType::LeftUp && m_wait_for_up_event) { - m_wait_for_up_event = false; + if ((action == SLAGizmoEventType::LeftUp || action == SLAGizmoEventType::RightUp) + && m_button_down != Button::None) { + m_button_down = Button::None; return true; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp index 890e0bb2e..e9e181c2c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp @@ -47,7 +47,13 @@ private: // etc. When language changes, GUI is recreated and this class constructed again, so the change takes effect. std::map m_desc; - bool m_wait_for_up_event = false; + enum class Button { + None, + Left, + Right + }; + + Button m_button_down = Button::None; EState m_old_state = Off; // to be able to see that the gizmo has just been closed (see on_set_state) std::vector> m_neighbors; // pairs of vertex_index - facet_index for each mesh diff --git a/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp b/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp index f2d35bc4e..31c473bac 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosCommon.hpp @@ -21,6 +21,7 @@ enum class SLAGizmoEventType : unsigned char { LeftDown = 1, LeftUp, RightDown, + RightUp, Dragging, Delete, SelectAll, diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index d49537960..ac7fe72e5 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -558,8 +558,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) processed = true; m_mouse_capture.right = false; } - else - return false; +// else +// return false; } #if ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX else if (evt.Dragging() && !is_dragging()) @@ -666,13 +666,20 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) processed = true; } } - else if (evt.RightDown() && (selected_object_idx != -1) && (m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::RightDown)) + else if (evt.RightDown() && (selected_object_idx != -1) && (m_current == SlaSupports || m_current == Hollow) + && gizmo_event(SLAGizmoEventType::RightDown, mouse_pos)) { // we need to set the following right up as processed to avoid showing the context menu if the user release the mouse over the object pending_right_up = true; // event was taken care of by the SlaSupports gizmo processed = true; } + else if (evt.RightDown() && (selected_object_idx != -1) && m_current == FdmSupports + && gizmo_event(SLAGizmoEventType::RightDown, mouse_pos)) + { + // event was taken care of by the FdmSupports gizmo + processed = true; + } else if (evt.Dragging() && (m_parent.get_move_volume_id() != -1) && (m_current == SlaSupports || m_current == Hollow)) // don't allow dragging objects with the Sla gizmo on processed = true; @@ -766,6 +773,11 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt) // to avoid to loose the selection when user clicks an the white faces of a different object while the Flatten gizmo is active processed = true; } + else if (evt.RightUp() && m_current == FdmSupports && !m_parent.is_mouse_dragging()) + { + gizmo_event(SLAGizmoEventType::RightUp, mouse_pos, evt.ShiftDown(), evt.AltDown(), evt.ControlDown()); + processed = true; + } } else {