From 3c23917e9e4fbc6a088b1f73d530c568019cd079 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 6 Feb 2020 14:46:02 +0100 Subject: [PATCH] SLA gizmos: make sure that the clipping plane is properly reset to zero when the shown meshes are exchanged --- src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp index 6264304b7..c0e518e4d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp @@ -43,6 +43,7 @@ public: void update_hollowed_mesh(std::unique_ptr &&mesh); bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } + void update_clipping_plane(bool keep_normal = false) const; private: bool on_init() override; @@ -96,7 +97,6 @@ private: void select_point(int i); void unselect_point(int i); void reload_cache(); - void update_clipping_plane(bool keep_normal = false) const; protected: void on_set_state() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index 7ded6aadb..a2da5e506 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -80,6 +80,7 @@ public: bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); } bool has_backend_supports() const; void reslice_SLA_supports(bool postpone_error_messages = false) const; + void update_clipping_plane(bool keep_normal = false) const; private: bool on_init() override; @@ -139,7 +140,6 @@ private: void switch_to_editing_mode(); void disable_editing_mode(); void reset_clipping_plane_normal() const; - void update_clipping_plane(bool keep_normal = false) const; protected: void on_set_state() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index be0f48007..613e15192 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -348,11 +348,22 @@ void GLGizmosManager::set_sla_support_data(ModelObject* model_object) if (!m_enabled || m_gizmos.empty()) return; - // Update common data for hollowing and sla support gizmos. - m_common_gizmos_data->update_from_backend(m_parent, model_object); + auto* gizmo_supports = dynamic_cast(m_gizmos[SlaSupports].get()); + auto* gizmo_hollow = dynamic_cast(m_gizmos[Hollow].get()); - dynamic_cast(m_gizmos[SlaSupports].get())->set_sla_support_data(model_object, m_parent.get_selection()); - dynamic_cast(m_gizmos[Hollow].get())->set_sla_support_data(model_object, m_parent.get_selection()); + + // Update common data for hollowing and sla support gizmos. + if (m_common_gizmos_data->update_from_backend(m_parent, model_object)) { + // FIXME: this is a hack to make that the clipping plane is + // updated when the update set its position to zero. The clipping + // plane itself should be common, including the update_function. + // Then update_from_backend could do it itself. + gizmo_supports->update_clipping_plane(); + gizmo_hollow->update_clipping_plane(); + } + + gizmo_supports->set_sla_support_data(model_object, m_parent.get_selection()); + gizmo_hollow->set_sla_support_data(model_object, m_parent.get_selection()); } // Returns true if the gizmo used the event to do something, false otherwise.