Hiding the sla support structures after undo/redo
This commit is contained in:
parent
dda7b3fc52
commit
fe62362960
6 changed files with 20 additions and 11 deletions
|
@ -1134,7 +1134,7 @@ ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, b
|
||||||
if (keep_upper) {
|
if (keep_upper) {
|
||||||
upper->set_model(nullptr);
|
upper->set_model(nullptr);
|
||||||
upper->sla_support_points.clear();
|
upper->sla_support_points.clear();
|
||||||
upper->sla_points_status = sla::PointsStatus::None;
|
upper->sla_points_status = sla::PointsStatus::NoPoints;
|
||||||
upper->clear_volumes();
|
upper->clear_volumes();
|
||||||
upper->input_file = "";
|
upper->input_file = "";
|
||||||
}
|
}
|
||||||
|
@ -1142,7 +1142,7 @@ ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, b
|
||||||
if (keep_lower) {
|
if (keep_lower) {
|
||||||
lower->set_model(nullptr);
|
lower->set_model(nullptr);
|
||||||
lower->sla_support_points.clear();
|
lower->sla_support_points.clear();
|
||||||
lower->sla_points_status = sla::PointsStatus::None;
|
lower->sla_points_status = sla::PointsStatus::NoPoints;
|
||||||
lower->clear_volumes();
|
lower->clear_volumes();
|
||||||
lower->input_file = "";
|
lower->input_file = "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ public:
|
||||||
std::vector<sla::SupportPoint> sla_support_points;
|
std::vector<sla::SupportPoint> sla_support_points;
|
||||||
// To keep track of where the points came from (used for synchronization between
|
// To keep track of where the points came from (used for synchronization between
|
||||||
// the SLA gizmo and the backend).
|
// the SLA gizmo and the backend).
|
||||||
sla::PointsStatus sla_points_status = sla::PointsStatus::None;
|
sla::PointsStatus sla_points_status = sla::PointsStatus::NoPoints;
|
||||||
|
|
||||||
/* This vector accumulates the total translation applied to the object by the
|
/* This vector accumulates the total translation applied to the object by the
|
||||||
center_around_origin() method. Callers might want to apply the same translation
|
center_around_origin() method. Callers might want to apply the same translation
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace sla {
|
||||||
|
|
||||||
// An enum to keep track of where the current points on the ModelObject came from.
|
// An enum to keep track of where the current points on the ModelObject came from.
|
||||||
enum class PointsStatus {
|
enum class PointsStatus {
|
||||||
None, // No points were generated so far.
|
NoPoints, // No points were generated so far.
|
||||||
Generating, // The autogeneration algorithm triggered, but not yet finished.
|
Generating, // The autogeneration algorithm triggered, but not yet finished.
|
||||||
AutoGenerated, // Points were autogenerated (i.e. copied from the backend).
|
AutoGenerated, // Points were autogenerated (i.e. copied from the backend).
|
||||||
UserModified // User has done some edits.
|
UserModified // User has done some edits.
|
||||||
|
|
|
@ -388,9 +388,9 @@ SLAPrint::ApplyStatus SLAPrint::apply(const Model &model, const DynamicPrintConf
|
||||||
if (it_print_object_status != print_object_status.end())
|
if (it_print_object_status != print_object_status.end())
|
||||||
update_apply_status(it_print_object_status->print_object->invalidate_step(slaposSupportPoints));
|
update_apply_status(it_print_object_status->print_object->invalidate_step(slaposSupportPoints));
|
||||||
|
|
||||||
model_object.sla_points_status = model_object_new.sla_points_status;
|
|
||||||
model_object.sla_support_points = model_object_new.sla_support_points;
|
model_object.sla_support_points = model_object_new.sla_support_points;
|
||||||
}
|
}
|
||||||
|
model_object.sla_points_status = model_object_new.sla_points_status;
|
||||||
|
|
||||||
// Copy the ModelObject name, input_file and instances. The instances will compared against PrintObject instances in the next step.
|
// Copy the ModelObject name, input_file and instances. The instances will compared against PrintObject instances in the next step.
|
||||||
model_object.name = model_object_new.name;
|
model_object.name = model_object_new.name;
|
||||||
|
|
|
@ -1905,7 +1905,10 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||||
if (volume->volume_idx() < 0) {
|
if (volume->volume_idx() < 0) {
|
||||||
auto it = std::lower_bound(aux_volume_state.begin(), aux_volume_state.end(), key, model_volume_state_lower);
|
auto it = std::lower_bound(aux_volume_state.begin(), aux_volume_state.end(), key, model_volume_state_lower);
|
||||||
if (it != aux_volume_state.end() && it->geometry_id == key.geometry_id)
|
if (it != aux_volume_state.end() && it->geometry_id == key.geometry_id)
|
||||||
mvs = &(*it);
|
// This can be an SLA support structure that should not be rendered (in case someone used undo
|
||||||
|
// to revert to before it was generated). We only reuse the volume if that's not the case.
|
||||||
|
if (m_model->objects[volume->composite_id.object_id]->sla_points_status != sla::PointsStatus::NoPoints)
|
||||||
|
mvs = &(*it);
|
||||||
} else {
|
} else {
|
||||||
auto it = std::lower_bound(model_volume_state.begin(), model_volume_state.end(), key, model_volume_state_lower);
|
auto it = std::lower_bound(model_volume_state.begin(), model_volume_state.end(), key, model_volume_state_lower);
|
||||||
if (it != model_volume_state.end() && it->geometry_id == key.geometry_id)
|
if (it != model_volume_state.end() && it->geometry_id == key.geometry_id)
|
||||||
|
@ -2018,8 +2021,14 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
|
||||||
ModelVolumeState key(state.step[istep].timestamp, instance.instance_id.id);
|
ModelVolumeState key(state.step[istep].timestamp, instance.instance_id.id);
|
||||||
auto it = std::lower_bound(aux_volume_state.begin(), aux_volume_state.end(), key, model_volume_state_lower);
|
auto it = std::lower_bound(aux_volume_state.begin(), aux_volume_state.end(), key, model_volume_state_lower);
|
||||||
assert(it != aux_volume_state.end() && it->geometry_id == key.geometry_id);
|
assert(it != aux_volume_state.end() && it->geometry_id == key.geometry_id);
|
||||||
if (it->new_geometry())
|
if (it->new_geometry()) {
|
||||||
instances[istep].emplace_back(std::pair<size_t, size_t>(instance_idx, print_instance_idx));
|
// This can be an SLA support structure that should not be rendered (in case someone used undo
|
||||||
|
// to revert to before it was generated). If that's the case, we should not generate anything.
|
||||||
|
if (model_object->sla_points_status != sla::PointsStatus::NoPoints)
|
||||||
|
instances[istep].emplace_back(std::pair<size_t, size_t>(instance_idx, print_instance_idx));
|
||||||
|
else
|
||||||
|
shift_zs[object_idx] = 0.;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Recycling an old GLVolume. Update the Object/Instance indices into the current Model.
|
// Recycling an old GLVolume. Update the Object/Instance indices into the current Model.
|
||||||
m_volumes.volumes[it->volume_idx]->composite_id = GLVolume::CompositeID(object_idx, m_volumes.volumes[it->volume_idx]->volume_idx(), instance_idx);
|
m_volumes.volumes[it->volume_idx]->composite_id = GLVolume::CompositeID(object_idx, m_volumes.volumes[it->volume_idx]->volume_idx(), instance_idx);
|
||||||
|
|
|
@ -84,7 +84,7 @@ void GLGizmoSlaSupports::set_sla_support_data(ModelObject* model_object, const S
|
||||||
|
|
||||||
if (m_editing_mode_cache.empty()
|
if (m_editing_mode_cache.empty()
|
||||||
&& m_model_object->sla_points_status != sla::PointsStatus::UserModified
|
&& m_model_object->sla_points_status != sla::PointsStatus::UserModified
|
||||||
&& m_model_object->sla_points_status != sla::PointsStatus::None)
|
&& m_model_object->sla_points_status != sla::PointsStatus::NoPoints)
|
||||||
get_data_from_backend();
|
get_data_from_backend();
|
||||||
|
|
||||||
if (m_state == On) {
|
if (m_state == On) {
|
||||||
|
@ -961,7 +961,7 @@ RENDER_AGAIN:
|
||||||
m_imgui->disabled_end();
|
m_imgui->disabled_end();
|
||||||
|
|
||||||
// m_imgui->text("");
|
// m_imgui->text("");
|
||||||
// m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::None ? _(L("No points (will be autogenerated)")) :
|
// m_imgui->text(m_model_object->sla_points_status == sla::PointsStatus::NoPoints ? _(L("No points (will be autogenerated)")) :
|
||||||
// (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? _(L("Autogenerated points (no modifications)")) :
|
// (m_model_object->sla_points_status == sla::PointsStatus::AutoGenerated ? _(L("Autogenerated points (no modifications)")) :
|
||||||
// (m_model_object->sla_points_status == sla::PointsStatus::UserModified ? _(L("User-modified points")) :
|
// (m_model_object->sla_points_status == sla::PointsStatus::UserModified ? _(L("User-modified points")) :
|
||||||
// (m_model_object->sla_points_status == sla::PointsStatus::Generating ? _(L("Generation in progress...")) : "UNKNOWN STATUS"))));
|
// (m_model_object->sla_points_status == sla::PointsStatus::Generating ? _(L("Generation in progress...")) : "UNKNOWN STATUS"))));
|
||||||
|
@ -1190,8 +1190,8 @@ void GLGizmoSlaSupports::editing_mode_discard_changes()
|
||||||
else
|
else
|
||||||
editing_mode_reload_cache();*/
|
editing_mode_reload_cache();*/
|
||||||
|
|
||||||
|
select_point(NoPoints);
|
||||||
m_editing_mode_cache = m_old_cache;
|
m_editing_mode_cache = m_old_cache;
|
||||||
|
|
||||||
m_editing_mode = false;
|
m_editing_mode = false;
|
||||||
m_unsaved_changes = false;
|
m_unsaved_changes = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue