Fixed issues in SLA gizmos related to showing/hiding of the model/support structures

This commit is contained in:
Lukas Matena 2020-01-16 12:43:42 +01:00
parent 902d3bb904
commit 822f9ff4a6
4 changed files with 23 additions and 24 deletions

View File

@ -1558,10 +1558,9 @@ int GLCanvas3D::check_volumes_outside_state() const
return (int)state;
}
bool GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx)
void GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo, int instance_idx)
{
if (m_render_sla_auxiliaries == visible)
return false;
m_render_sla_auxiliaries = visible;
for (GLVolume* vol : m_volumes.volumes) {
if ((mo == nullptr || m_model->objects[vol->composite_id.object_id] == mo)
@ -1569,9 +1568,6 @@ bool GLCanvas3D::toggle_sla_auxiliaries_visibility(bool visible, const ModelObje
&& vol->composite_id.volume_id < 0)
vol->is_active = visible;
}
m_render_sla_auxiliaries = visible;
return true;
}
void GLCanvas3D::toggle_model_objects_visibility(bool visible, const ModelObject* mo, int instance_idx)

View File

@ -500,7 +500,7 @@ public:
void reset_volumes();
int check_volumes_outside_state() const;
bool toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
void 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<size_t>& object_idxs);

View File

@ -87,7 +87,7 @@ void GLGizmoHollow::set_sla_support_data(ModelObject* model_object, const Select
if (m_state == On) {
m_parent.toggle_model_objects_visibility(false);
m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(bool(m_c->m_cavity_mesh), m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(m_show_supports, m_c->m_model_object, m_c->m_active_instance);
}
else
m_parent.toggle_model_objects_visibility(true, nullptr, -1);
@ -132,9 +132,6 @@ void GLGizmoHollow::on_render() const
m_c->m_volume_with_cavity->render(color_id, print_box_detection_id, print_box_worldmatrix_id);
m_parent.get_shader().stop_using();
}
// Show/hide the original object
m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(bool(m_c->m_cavity_mesh), m_c->m_model_object, m_c->m_active_instance);
m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z();
@ -649,6 +646,9 @@ void GLGizmoHollow::update_hollowed_mesh(std::unique_ptr<TriangleMesh> &&mesh)
m_c->m_volume_with_cavity->finalize_geometry(true);
m_c->m_volume_with_cavity->force_transparent = false;
m_parent.toggle_model_objects_visibility(false, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(true, m_c->m_model_object, m_c->m_active_instance);
// Reset raycaster so it works with the new mesh:
m_c->m_mesh_raycaster.reset(new MeshRaycaster(*m_c->mesh()));
}
@ -908,8 +908,10 @@ RENDER_AGAIN:
update_clipping_plane(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_c->m_model_object, m_c->m_active_instance);
if (m_imgui->checkbox(m_desc["show_supports"], m_show_supports)) {
m_parent.toggle_sla_auxiliaries_visibility(m_show_supports, m_c->m_model_object, m_c->m_active_instance);
force_refresh = true;
}
m_imgui->end();
@ -990,7 +992,8 @@ void GLGizmoHollow::on_set_state()
m_parent.toggle_model_objects_visibility(false);
if (m_c->m_model_object)
m_parent.toggle_model_objects_visibility(true, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(m_show_supports, m_c->m_model_object, m_c->m_active_instance);
// Set default head diameter from config.
//const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;

View File

@ -88,7 +88,7 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
if (m_state == On) {
m_parent.toggle_model_objects_visibility(false);
m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(bool(m_c->m_cavity_mesh), m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(! m_editing_mode, m_c->m_model_object, m_c->m_active_instance);
}
else
m_parent.toggle_model_objects_visibility(true, nullptr, -1);
@ -144,8 +144,8 @@ void GLGizmoSlaSupports::on_render() const
m_parent.get_shader().stop_using();
}
// Show/hide the original object
m_parent.toggle_model_objects_visibility(! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(bool(m_c->m_cavity_mesh), m_c->m_model_object, m_c->m_active_instance);
//m_parent.toggle_model_objects_visibility(! m_editing_mode && ! m_c->m_cavity_mesh, m_c->m_model_object, m_c->m_active_instance);
//m_parent.toggle_sla_auxiliaries_visibility(! m_editing_mode, m_c->m_model_object, m_c->m_active_instance);
m_z_shift = selection.get_volume(*selection.get_volume_idxs().begin())->get_sla_shift_z();
@ -967,12 +967,6 @@ RENDER_AGAIN:
m_imgui->end();
// 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_c->m_model_object, m_c->m_active_instance);
if (remove_selected || remove_all) {
force_refresh = false;
m_parent.set_as_dirty();
@ -1052,8 +1046,9 @@ void GLGizmoSlaSupports::on_set_state()
reload_cache();
m_parent.toggle_model_objects_visibility(false);
if (m_c->m_model_object)
if (m_c->m_model_object && ! m_c->m_cavity_mesh)
m_parent.toggle_model_objects_visibility(true, m_c->m_model_object, m_c->m_active_instance);
m_parent.toggle_sla_auxiliaries_visibility(! m_editing_mode, m_c->m_model_object, m_c->m_active_instance);
// Set default head diameter from config.
const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config;
@ -1305,6 +1300,9 @@ void GLGizmoSlaSupports::switch_to_editing_mode()
for (const sla::SupportPoint& sp : m_normal_cache)
m_editing_cache.emplace_back(sp);
select_point(NoPoints);
m_parent.toggle_sla_auxiliaries_visibility(false, m_c->m_model_object, m_c->m_active_instance);
m_parent.set_as_dirty();
}
@ -1313,6 +1311,8 @@ void GLGizmoSlaSupports::disable_editing_mode()
if (m_editing_mode) {
m_editing_mode = false;
wxGetApp().plater()->leave_gizmos_stack();
m_parent.toggle_sla_auxiliaries_visibility(true, m_c->m_model_object, m_c->m_active_instance);
m_parent.set_as_dirty();
}
}