From b52ce29d12b4f8de95d5aa7255e47eac97e1e960 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 9 Feb 2023 15:22:01 +0100 Subject: [PATCH] Fix to #9629 - Cut tool will not cut unless there is an object Allow to perform a cut even if CutPlane doesn't cross the solid parts of object. But show the warning line --- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 9 ++++++++- src/slic3r/GUI/Gizmos/GLGizmoCut.hpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 87c0dbc86..f1758991d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -656,7 +656,7 @@ void GLGizmoCut3D::render_cut_plane() shader->set_uniform("view_model_matrix", view_model_matrix); shader->set_uniform("projection_matrix", camera.get_projection_matrix()); - if (can_perform_cut()) + if (can_perform_cut() && has_valid_contour()) // m_plane.set_color({ 0.8f, 0.8f, 0.8f, 0.5f }); m_plane.set_color({ 0.9f, 0.9f, 0.9f, 0.5f }); else @@ -1834,6 +1834,8 @@ void GLGizmoCut3D::render_input_window_warning() const } if (!m_keep_upper && !m_keep_lower) m_imgui->text(wxString(ImGui::WarningMarkerSmall) + _L("Invalid state. \nNo one part is selected for keep after cut")); + if (!has_valid_contour()) + m_imgui->text(wxString(ImGui::WarningMarkerSmall) + _L("Warning state. \nCut plane is placed out of object")); } void GLGizmoCut3D::on_render_input_window(float x, float y, float bottom_limit) @@ -2038,6 +2040,11 @@ bool GLGizmoCut3D::can_perform_cut() const if (m_has_invalid_connector || (!m_keep_upper && !m_keep_lower) || m_connectors_editing) return false; + return true;// has_valid_contour(); +} + +bool GLGizmoCut3D::has_valid_contour() const +{ const auto clipper = m_c->object_clipper(); return clipper && clipper->has_valid_contour(); } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp index 63f85e099..3483ae201 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.hpp @@ -250,6 +250,7 @@ private: void render_connectors(); bool can_perform_cut() const; + bool has_valid_contour() const; void apply_connectors_in_model(ModelObject* mo, bool &create_dowels_as_separate_object); bool cut_line_processing() const; void discard_cut_line_processing();