SLA support points are correctly appointed as user-modified

SLA gizmo point cache is reloaded when appropriate
This commit is contained in:
Lukas Matena 2019-03-11 11:13:37 +01:00
parent c77d15c98b
commit cbe96906eb
3 changed files with 25 additions and 22 deletions

View File

@ -587,8 +587,10 @@ namespace Slic3r {
object.second->layer_height_profile = obj_layer_heights_profile->second; object.second->layer_height_profile = obj_layer_heights_profile->second;
IdToSlaSupportPointsMap::iterator obj_sla_support_points = m_sla_support_points.find(object.first); IdToSlaSupportPointsMap::iterator obj_sla_support_points = m_sla_support_points.find(object.first);
if (obj_sla_support_points != m_sla_support_points.end() && !obj_sla_support_points->second.empty()) if (obj_sla_support_points != m_sla_support_points.end() && !obj_sla_support_points->second.empty()) {
object.second->sla_support_points = obj_sla_support_points->second; object.second->sla_support_points = obj_sla_support_points->second;
object.second->sla_points_status = sla::PointsStatus::UserModified;
}
IdToMetadataMap::iterator obj_metadata = m_objects_metadata.find(object.first); IdToMetadataMap::iterator obj_metadata = m_objects_metadata.find(object.first);
if (obj_metadata != m_objects_metadata.end()) if (obj_metadata != m_objects_metadata.end())

View File

@ -600,6 +600,7 @@ void AMFParserContext::endElement(const char * /* name */)
break; break;
p = end + 1; p = end + 1;
} }
m_object->sla_points_status = sla::PointsStatus::UserModified;
} }
else if (m_path.size() == 5 && m_path[3] == NODE_TYPE_VOLUME && m_volume) { else if (m_path.size() == 5 && m_path[3] == NODE_TYPE_VOLUME && m_volume) {
if (strcmp(opt_key, "modifier") == 0) { if (strcmp(opt_key, "modifier") == 0) {

View File

@ -1773,8 +1773,10 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const G
if (model_object && selection.is_from_single_instance()) if (model_object && selection.is_from_single_instance())
{ {
if (is_mesh_update_necessary()) if (is_mesh_update_necessary()) {
update_mesh(); update_mesh();
editing_mode_reload_cache();
}
if (m_model_object != m_old_model_object) if (m_model_object != m_old_model_object)
m_editing_mode = false; m_editing_mode = false;
@ -1953,9 +1955,6 @@ void GLGizmoSlaSupports::update_mesh()
m_AABB = igl::AABB<Eigen::MatrixXf,3>(); m_AABB = igl::AABB<Eigen::MatrixXf,3>();
m_AABB.init(m_V, m_F); m_AABB.init(m_V, m_F);
// we'll now reload support points (selection might have changed):
editing_mode_reload_cache();
} }
Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos) Vec3f GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos)
@ -2441,32 +2440,33 @@ std::string GLGizmoSlaSupports::on_get_name() const
void GLGizmoSlaSupports::on_set_state() void GLGizmoSlaSupports::on_set_state()
{ {
if (m_state == On) { if (m_state == On && m_old_state != On) { // the gizmo was just turned on
if (is_mesh_update_necessary()) if (is_mesh_update_necessary())
update_mesh(); update_mesh();
// we'll now reload support points:
if (m_model_object)
editing_mode_reload_cache();
m_parent.toggle_model_objects_visibility(false); m_parent.toggle_model_objects_visibility(false);
if (m_model_object) if (m_model_object)
m_parent.toggle_model_objects_visibility(true, m_model_object, m_active_instance); m_parent.toggle_model_objects_visibility(true, m_model_object, m_active_instance);
} }
if (m_state == Off) { if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
if (m_old_state != Off) { // the gizmo was just turned Off if (m_model_object) {
if (m_unsaved_changes) {
if (m_model_object) { wxMessageDialog dlg(GUI::wxGetApp().plater(), _(L("Do you want to save your manually edited support points ?\n")),
if (m_unsaved_changes) { _(L("Save changes?")), wxICON_QUESTION | wxYES | wxNO);
wxMessageDialog dlg(GUI::wxGetApp().plater(), _(L("Do you want to save your manually edited support points ?\n")), if (dlg.ShowModal() == wxID_YES)
_(L("Save changes?")), wxICON_QUESTION | wxYES | wxNO); editing_mode_apply_changes();
if (dlg.ShowModal() == wxID_YES) else
editing_mode_apply_changes(); editing_mode_discard_changes();
else
editing_mode_discard_changes();
}
} }
m_parent.toggle_model_objects_visibility(true);
m_editing_mode = false; // so it is not active next time the gizmo opens
m_editing_mode_cache.clear();
} }
m_parent.toggle_model_objects_visibility(true);
m_editing_mode = false; // so it is not active next time the gizmo opens
m_editing_mode_cache.clear();
} }
m_old_state = m_state; m_old_state = m_state;
} }