From 735f82c01988d65efb8befa2c828747c76db5b34 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 29 Nov 2019 13:49:38 +0100 Subject: [PATCH] Hollowing gizmo has now its own shortcut [H], fixed a situation with supports showed in editing mode --- src/slic3r/GUI/GLCanvas3D.cpp | 6 +++++- src/slic3r/GUI/GLCanvas3D.hpp | 2 +- src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 10 ++++------ src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 16 +++++----------- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp | 1 - 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index c49c7c66d..c5ade144e 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1301,8 +1301,11 @@ int GLCanvas3D::check_volumes_outside_state() const return (int)state; } -void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx) +bool GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx) { + if (m_render_sla_auxiliaries == visible) + return false; + for (GLVolume* vol : m_volumes.volumes) { if ((mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo) && (instance_idx == -1 || vol->composite_id.instance_id == instance_idx) @@ -1311,6 +1314,7 @@ void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObje } m_render_sla_auxiliaries = visible; + return true; } void GLCanvas3D::toggle_model_objects_visibility(bool visible, const ModelObject* mo, int instance_idx) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 3430c3692..32974a8df 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -462,7 +462,7 @@ public: void reset_volumes(); int check_volumes_outside_state() const; - void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1); + bool toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1); void toggle_model_objects_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1); void update_instance_printable_state_for_object(size_t obj_idx); void update_instance_printable_state_for_objects(std::vector& object_idxs); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 9c0e2c4d9..50bfb767a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -37,7 +37,7 @@ GLGizmoHollow::~GLGizmoHollow() bool GLGizmoHollow::on_init() { - m_shortcut_key = WXK_CONTROL_L; + m_shortcut_key = WXK_CONTROL_H; m_desc["head_diameter"] = _(L("Head diameter")) + ": "; m_desc["lock_supports"] = _(L("Lock supports under new islands")); @@ -595,7 +595,6 @@ void GLGizmoHollow::update_hollowed_mesh(std::unique_ptr &&mesh) m_volume_with_cavity->set_volume_transformation(volume_trafo); m_volume_with_cavity->set_instance_transformation(m_model_object->instances[size_t(m_active_instance)]->get_transformation()); } - m_parent.toggle_model_objects_visibility(! m_cavity_mesh, m_model_object, m_active_instance); } @@ -751,10 +750,9 @@ RENDER_AGAIN: if (ImGui::SliderFloat(" ", &m_clipping_plane_distance, 0.f, 1.f, "%.2f")) update_clipping_plane(true); - if (m_imgui->checkbox(m_desc["show_supports"], m_show_supports)) { - m_parent.toggle_sla_auxiliaries_visibility(m_show_supports, m_model_object, m_active_instance); - force_refresh = true; - } + // make sure supports are shown/hidden as appropriate + m_imgui->checkbox(m_desc["show_supports"], m_show_supports); + force_refresh = m_parent.toggle_sla_auxiliaries_visibility(m_show_supports, m_model_object, m_active_instance); m_imgui->end(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index 29eb72fc5..9d8b7687c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -738,11 +738,6 @@ void GLGizmoSlaSupports::on_render_input_window(float x, float y, float bottom_l bool first_run = true; // This is a hack to redraw the button when all points are removed, // so it is not delayed until the background process finishes. RENDER_AGAIN: - //m_imgui->set_next_window_pos(x, y, ImGuiCond_Always); - //const ImVec2 window_size(m_imgui->scaled(18.f, 16.f)); - //ImGui::SetNextWindowPos(ImVec2(x, y - std::max(0.f, y+window_size.y-bottom_limit) )); - //ImGui::SetNextWindowSize(ImVec2(window_size)); - const float approx_height = m_imgui->scaled(18.0f); y = std::min(y, bottom_limit - approx_height); m_imgui->set_next_window_pos(x, y, ImGuiCond_Always); @@ -761,7 +756,6 @@ RENDER_AGAIN: float window_width = minimal_slider_width + std::max(std::max(settings_sliders_left, clipping_slider_left), diameter_slider_left); window_width = std::max(std::max(window_width, buttons_width_approx), lock_supports_width_approx); - bool force_refresh = false; bool remove_selected = false; bool remove_all = false; @@ -917,11 +911,11 @@ RENDER_AGAIN: m_imgui->end(); - if (m_editing_mode != m_old_editing_state) { // user toggled between editing/non-editing mode - m_parent.toggle_sla_auxiliaries_visibility(!m_editing_mode, m_model_object, m_active_instance); - force_refresh = true; - } - m_old_editing_state = m_editing_mode; + // Make sure that the supports are (not) visible as they should be. This + // is done on each refresh because the user can switch the editing mode + // before background process finishes. + force_refresh = m_parent.toggle_sla_auxiliaries_visibility( + ! m_editing_mode, m_model_object, m_active_instance); if (remove_selected || remove_all) { force_refresh = false; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index e536aab40..1de241a53 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -99,7 +99,6 @@ private: bool m_lock_unique_islands = false; bool m_editing_mode = false; // Is editing mode active? - bool m_old_editing_state = false; // To keep track of whether the user toggled between the modes (needed for imgui refreshes). float m_new_point_head_diameter; // Size of a new point. CacheEntry m_point_before_drag; // undo/redo - so we know what state was edited float m_old_point_head_diameter = 0.; // the same