mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 03:07:55 -06:00
Recalculate SLA supports after undo/redo in case SLA gizmo was active and had supports when the snapshot was taken
This commit is contained in:
parent
b55a140ad4
commit
52933d1bab
6 changed files with 72 additions and 18 deletions
|
@ -528,7 +528,7 @@ bool GLGizmoSlaSupports::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
|
|||
if (m_selection_empty) {
|
||||
std::pair<Vec3f, Vec3f> pos_and_normal;
|
||||
if (unproject_on_mesh(mouse_position, pos_and_normal)) { // we got an intersection
|
||||
wxGetApp().plater()->take_snapshot(_(L("Add support point")));
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Add support point")));
|
||||
m_editing_cache.emplace_back(sla::SupportPoint(pos_and_normal.first, m_new_point_head_diameter/2.f, false), false, pos_and_normal.second);
|
||||
m_parent.set_as_dirty();
|
||||
m_wait_for_up_event = true;
|
||||
|
@ -716,14 +716,12 @@ void GLGizmoSlaSupports::delete_selected_points(bool force)
|
|||
std::abort();
|
||||
}
|
||||
|
||||
wxGetApp().plater()->take_snapshot(_(L("Delete support point")));
|
||||
Plater::TakeSnapshot(wxGetApp().plater(), _(L("Delete support point")));
|
||||
|
||||
for (unsigned int idx=0; idx<m_editing_cache.size(); ++idx) {
|
||||
if (m_editing_cache[idx].selected && (!m_editing_cache[idx].support_point.is_new_island || !m_lock_unique_islands || force)) {
|
||||
m_editing_cache.erase(m_editing_cache.begin() + (idx--));
|
||||
}
|
||||
// This should trigger the support generation
|
||||
// wxGetApp().plater()->reslice_SLA_supports(*m_model_object);
|
||||
}
|
||||
|
||||
select_point(NoPoints);
|
||||
|
@ -919,7 +917,7 @@ RENDER_AGAIN:
|
|||
cache_entry.support_point.head_front_radius = m_old_point_head_diameter / 2.f;
|
||||
float backup = m_new_point_head_diameter;
|
||||
m_new_point_head_diameter = m_old_point_head_diameter;
|
||||
wxGetApp().plater()->take_snapshot(_(L("Change point head diameter")));
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Change point head diameter")));
|
||||
m_new_point_head_diameter = backup;
|
||||
for (auto& cache_entry : m_editing_cache)
|
||||
if (cache_entry.selected)
|
||||
|
@ -985,7 +983,7 @@ RENDER_AGAIN:
|
|||
if (slider_released) {
|
||||
m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = m_minimal_point_distance_stash;
|
||||
m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)m_density_stash;
|
||||
wxGetApp().plater()->take_snapshot(_(L("Support parameter change")));
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Support parameter change")));
|
||||
m_model_object->config.opt<ConfigOptionFloat>("support_points_minimal_distance", true)->value = minimal_point_distance;
|
||||
m_model_object->config.opt<ConfigOptionInt>("support_points_density_relative", true)->value = (int)density;
|
||||
wxGetApp().obj_list()->update_and_show_object_settings_item();
|
||||
|
@ -1186,7 +1184,7 @@ void GLGizmoSlaSupports::on_stop_dragging()
|
|||
&& backup.support_point.pos != m_point_before_drag.support_point.pos) // and it was moved, not just selected
|
||||
{
|
||||
m_editing_cache[m_hover_id] = m_point_before_drag;
|
||||
wxGetApp().plater()->take_snapshot(_(L("Move support point")));
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("Move support point")));
|
||||
m_editing_cache[m_hover_id] = backup;
|
||||
}
|
||||
}
|
||||
|
@ -1285,7 +1283,7 @@ void GLGizmoSlaSupports::editing_mode_apply_changes()
|
|||
disable_editing_mode(); // this leaves the editing mode undo/redo stack and must be done before the snapshot is taken
|
||||
|
||||
if (unsaved_changes()) {
|
||||
wxGetApp().plater()->take_snapshot(_(L("Support points edit")));
|
||||
take_snapshot_internal(_(L("Support points edit")));
|
||||
|
||||
m_normal_cache.clear();
|
||||
for (const CacheEntry& ce : m_editing_cache)
|
||||
|
@ -1295,7 +1293,7 @@ void GLGizmoSlaSupports::editing_mode_apply_changes()
|
|||
m_model_object->sla_support_points.clear();
|
||||
m_model_object->sla_support_points = m_normal_cache;
|
||||
|
||||
wxGetApp().CallAfter([this]() { wxGetApp().plater()->reslice_SLA_supports(*m_model_object); });
|
||||
reslice_SLA_supports();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1312,11 +1310,29 @@ void GLGizmoSlaSupports::reload_cache()
|
|||
}
|
||||
|
||||
|
||||
bool GLGizmoSlaSupports::has_backend_supports() const
|
||||
{
|
||||
// find SlaPrintObject with this ID
|
||||
for (const SLAPrintObject* po : m_parent.sla_print()->objects()) {
|
||||
if (po->model_object()->id() == m_model_object->id() && po->is_step_done(slaposSupportPoints))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::reslice_SLA_supports() const
|
||||
{
|
||||
wxGetApp().CallAfter([this]() { wxGetApp().plater()->reslice_SLA_supports(*m_model_object); });
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::get_data_from_backend()
|
||||
{
|
||||
if (! has_backend_supports())
|
||||
return;
|
||||
|
||||
// find the respective SLAPrintObject, we need a pointer to it
|
||||
for (const SLAPrintObject* po : m_parent.sla_print()->objects()) {
|
||||
if (po->model_object()->id() == m_model_object->id() && po->is_step_done(slaposSupportPoints)) {
|
||||
if (po->model_object()->id() == m_model_object->id()) {
|
||||
m_normal_cache.clear();
|
||||
const std::vector<sla::SupportPoint>& points = po->get_support_points();
|
||||
auto mat = po->trafo().inverse().cast<float>();
|
||||
|
@ -1331,6 +1347,13 @@ void GLGizmoSlaSupports::get_data_from_backend()
|
|||
// We don't copy the data into ModelObject, as this would stop the background processing.
|
||||
}
|
||||
|
||||
void GLGizmoSlaSupports::take_snapshot_internal(const wxString& desc)
|
||||
{
|
||||
m_internal_snapshot = true;
|
||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), desc);
|
||||
m_internal_snapshot = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GLGizmoSlaSupports::auto_generate()
|
||||
|
@ -1341,8 +1364,8 @@ void GLGizmoSlaSupports::auto_generate()
|
|||
)), _(L("Warning")), wxICON_WARNING | wxYES | wxNO);
|
||||
|
||||
if (m_model_object->sla_points_status != sla::PointsStatus::UserModified || m_normal_cache.empty() || dlg.ShowModal() == wxID_YES) {
|
||||
wxGetApp().plater()->take_snapshot(_(L("Autogenerate support points")));
|
||||
wxGetApp().CallAfter([this]() { wxGetApp().plater()->reslice_SLA_supports(*m_model_object); });
|
||||
take_snapshot_internal(_(L("Autogenerate support points")));
|
||||
wxGetApp().CallAfter([this]() { reslice_SLA_supports(); });
|
||||
m_model_object->sla_points_status = sla::PointsStatus::Generating;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue