From f9c1abbd50635dadb0b423bbc07418a85ea471d7 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 24 Apr 2023 13:58:01 +0200 Subject: [PATCH] SPE-1677 - Disable SLA supports and Hollow gizmos when the selected object is non-printable. Do not allow to set to non-printable an object while the SLA supports and Hollow gizmos are active. --- src/slic3r/GUI/GUI_Factories.cpp | 8 ++++++++ src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 6 ++++++ src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 14 ++++++++++++-- src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp | 7 ++++--- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 4c12fbe23..045bd146a 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -743,6 +743,14 @@ wxMenuItem* MenuFactory::append_menu_item_printable(wxMenu* menu) } evt.Check(check); + + // disable the menu item if SLA supports or Hollow gizmos are active + if (printer_technology() == ptSLA) { + const auto gizmo_type = plater()->canvas3D()->get_gizmos_manager().get_current_type(); + const bool enable = gizmo_type != GLGizmosManager::SlaSupports && gizmo_type != GLGizmosManager::Hollow; + evt.Enable(enable); + } + plater()->set_current_canvas_as_dirty(); }, menu_item_printable->GetId()); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 91b2bd879..0a4217387 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -820,6 +820,12 @@ bool GLGizmoHollow::on_is_activable() const if (selection.get_volume(idx)->is_outside && selection.get_volume(idx)->composite_id.volume_id >= 0) return false; + // Check that none of the selected volumes is marked as non-pritable. + for (const auto& idx : list) { + if (!selection.get_volume(idx)->printable) + return false; + } + return true; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index c78a46a5b..b9ec5cf19 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -65,9 +65,13 @@ void GLGizmoSlaSupports::data_changed(bool is_serializing) // If we triggered autogeneration before, check backend and fetch results if they are there if (mo) { m_c->instances_hider()->set_hide_full_scene(true); - const SLAPrintObject* po = m_c->selection_info()->print_object(); + + int last_comp_step = slaposCount; const int required_step = get_min_sla_print_object_step(); - auto last_comp_step = static_cast(po->last_completed_step()); + const SLAPrintObject* po = m_c->selection_info()->print_object(); + if (po != nullptr) + last_comp_step = static_cast(po->last_completed_step()); + if (last_comp_step == slaposCount) last_comp_step = -1; @@ -793,6 +797,12 @@ bool GLGizmoSlaSupports::on_is_activable() const if (selection.get_volume(idx)->is_outside && selection.get_volume(idx)->composite_id.volume_id >= 0) return false; + // Check that none of the selected volumes is marked as non-pritable. + for (const auto& idx : list) { + if (!selection.get_volume(idx)->printable) + return false; + } + return true; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp b/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp index debb22535..4edb01c2b 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosCommon.cpp @@ -261,11 +261,12 @@ void Raycaster::on_update() // For sla printers we use the mesh generated by the backend std::shared_ptr preview_mesh_ptr; const SLAPrintObject* po = get_pool()->selection_info()->print_object(); - if (po) + if (po != nullptr) preview_mesh_ptr = po->get_mesh_to_print(); + else + preview_mesh_ptr.reset(); - if (preview_mesh_ptr) - m_sla_mesh_cache = TriangleMesh{*preview_mesh_ptr}; + m_sla_mesh_cache = (preview_mesh_ptr != nullptr) ? TriangleMesh{ *preview_mesh_ptr } : TriangleMesh(); if (!m_sla_mesh_cache.empty()) { m_sla_mesh_cache.transform(po->trafo().inverse());