From 553102c4eefe89cd08cf2aff6fef68c946e21aca Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Thu, 16 Dec 2021 15:57:32 +0100 Subject: [PATCH] Fix reselect in flattening --- src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp | 35 +++++++++++++++--------- src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp | 2 +- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp index 53eb1bb8b..08c2e2912 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.cpp @@ -23,23 +23,32 @@ bool GLGizmoFlatten::on_mouse(const wxMouseEvent &mouse_event) if (mouse_event.Moving()) { // only for sure m_mouse_left_down = false; - - if (m_hover_id != -1) m_parent.set_as_dirty(); return false; } - if (mouse_event.LeftDown() && m_hover_id != -1) { - Selection &selection = m_parent.get_selection(); - if (selection.is_single_full_instance()) { - // Rotate the object so the normal points downward: - selection.flattening_rotate(m_planes[m_hover_id].normal); - m_parent.do_rotate(L("Gizmo-Place on Face")); + if (mouse_event.LeftDown()) { + if (m_hover_id != -1) { + m_mouse_left_down = true; + Selection &selection = m_parent.get_selection(); + if (selection.is_single_full_instance()) { + // Rotate the object so the normal points downward: + selection.flattening_rotate(m_planes[m_hover_id].normal); + m_parent.do_rotate(L("Gizmo-Place on Face")); + } + return true; } - m_mouse_left_down = true; - return true; - } else if (m_mouse_left_down && mouse_event.LeftUp()) { - // responsible for mouse left up + + // fix: prevent restart gizmo when reselect object + // take responsibility for left up + if (m_parent.get_first_hover_volume_idx() >= 0) m_mouse_left_down = true; + + } else if (mouse_event.LeftUp()) { + if (m_mouse_left_down) { + // responsible for mouse left up after selecting plane + m_mouse_left_down = false; + return true; + } + } else if (mouse_event.Leaving()) { m_mouse_left_down = false; - return true; } return false; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp index bddf829c4..dcb9e48ba 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp @@ -33,7 +33,7 @@ private: Vec3d m_first_instance_mirror; std::vector m_planes; - bool m_mouse_left_down = false; + bool m_mouse_left_down = false; // for detection left_up of this gizmo bool m_planes_valid = false; const ModelObject* m_old_model_object = nullptr; std::vector instances_matrices;