From 2b155d593292c78f51e69118fa6fc79cc119cdbc Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 23 Nov 2022 12:03:36 +0100 Subject: [PATCH] Gizmo measure - Hide SLA supports and pad when opening the gizmo --- src/slic3r/GUI/GLCanvas3D.cpp | 19 +++++++++++++++++-- src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp | 5 +++++ src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp | 3 +++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 991bbead2..345beb443 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1346,11 +1346,26 @@ void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObje m_render_sla_auxiliaries = visible; +#if ENABLE_RAYCAST_PICKING + std::vector>* raycasters = get_raycasters_for_picking(SceneRaycaster::EType::Volume); +#endif // ENABLE_RAYCAST_PICKING + for (GLVolume* vol : m_volumes.volumes) { +#if ENABLE_RAYCAST_PICKING if ((mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo) - && (instance_idx == -1 || vol->composite_id.instance_id == instance_idx) - && vol->composite_id.volume_id < 0) + && (instance_idx == -1 || vol->composite_id.instance_id == instance_idx) + && vol->composite_id.volume_id < 0) { vol->is_active = visible; + auto it = std::find_if(raycasters->begin(), raycasters->end(), [vol](std::shared_ptr item) { return item->get_raycaster() == vol->mesh_raycaster.get(); }); + if (it != raycasters->end()) + (*it)->set_active(vol->is_active); + } +#else + if ((mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo) + && (instance_idx == -1 || vol->composite_id.instance_id == instance_idx) + && vol->composite_id.volume_id < 0) + vol->is_active = visible; +#endif // ENABLE_RAYCAST_PICKING } } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp index 1ce118d71..51ea56c82 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.cpp @@ -900,6 +900,11 @@ RENDER_AGAIN: bool show_sups = m_c->instances_hider()->are_supports_shown(); if (m_imgui->checkbox(m_desc["show_supports"], show_sups)) { m_c->instances_hider()->show_supports(show_sups); +#if ENABLE_RAYCAST_PICKING + if (show_sups) + // ensure supports and pad are disabled from picking even when they are visible + set_sla_auxiliary_volumes_picking_state(false); +#endif // ENABLE_RAYCAST_PICKING force_refresh = true; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 89e6b63ef..2de29087b 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -411,6 +411,8 @@ bool GLGizmoMeasure::on_mouse(const wxMouseEvent &mouse_event) void GLGizmoMeasure::data_changed() { + m_parent.toggle_sla_auxiliaries_visibility(false, nullptr, -1); + update_if_needed(); m_last_inv_zoom = 0.0f; @@ -500,6 +502,7 @@ bool GLGizmoMeasure::on_init() void GLGizmoMeasure::on_set_state() { if (m_state == Off) { + m_parent.toggle_sla_auxiliaries_visibility(true, nullptr, -1); m_ctrl_kar_filter.reset_count(); m_shift_kar_filter.reset_count(); m_curr_feature.reset();