Gizmo measure - Hide SLA supports and pad when opening the gizmo

This commit is contained in:
enricoturri1966 2022-11-23 12:03:36 +01:00
parent 946bbd285a
commit 2b155d5932
3 changed files with 25 additions and 2 deletions

View File

@ -1346,11 +1346,26 @@ void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObje
m_render_sla_auxiliaries = visible; m_render_sla_auxiliaries = visible;
#if ENABLE_RAYCAST_PICKING
std::vector<std::shared_ptr<SceneRaycasterItem>>* raycasters = get_raycasters_for_picking(SceneRaycaster::EType::Volume);
#endif // ENABLE_RAYCAST_PICKING
for (GLVolume* vol : m_volumes.volumes) { for (GLVolume* vol : m_volumes.volumes) {
#if ENABLE_RAYCAST_PICKING
if ((mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo) if ((mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo)
&& (instance_idx == -1 || vol->composite_id.instance_id == instance_idx) && (instance_idx == -1 || vol->composite_id.instance_id == instance_idx)
&& vol->composite_id.volume_id < 0) && vol->composite_id.volume_id < 0) {
vol->is_active = visible; vol->is_active = visible;
auto it = std::find_if(raycasters->begin(), raycasters->end(), [vol](std::shared_ptr<SceneRaycasterItem> 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
} }
} }

View File

@ -900,6 +900,11 @@ RENDER_AGAIN:
bool show_sups = m_c->instances_hider()->are_supports_shown(); bool show_sups = m_c->instances_hider()->are_supports_shown();
if (m_imgui->checkbox(m_desc["show_supports"], show_sups)) { if (m_imgui->checkbox(m_desc["show_supports"], show_sups)) {
m_c->instances_hider()->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; force_refresh = true;
} }

View File

@ -411,6 +411,8 @@ bool GLGizmoMeasure::on_mouse(const wxMouseEvent &mouse_event)
void GLGizmoMeasure::data_changed() void GLGizmoMeasure::data_changed()
{ {
m_parent.toggle_sla_auxiliaries_visibility(false, nullptr, -1);
update_if_needed(); update_if_needed();
m_last_inv_zoom = 0.0f; m_last_inv_zoom = 0.0f;
@ -500,6 +502,7 @@ bool GLGizmoMeasure::on_init()
void GLGizmoMeasure::on_set_state() void GLGizmoMeasure::on_set_state()
{ {
if (m_state == Off) { if (m_state == Off) {
m_parent.toggle_sla_auxiliaries_visibility(true, nullptr, -1);
m_ctrl_kar_filter.reset_count(); m_ctrl_kar_filter.reset_count();
m_shift_kar_filter.reset_count(); m_shift_kar_filter.reset_count();
m_curr_feature.reset(); m_curr_feature.reset();