Discard changes by restore volume insted of changing history(undo/redo) stack
This commit is contained in:
parent
0e3b7cae12
commit
e7fa4fc006
4 changed files with 97 additions and 40 deletions
src/slic3r/GUI/Gizmos
|
@ -981,6 +981,9 @@ void GLGizmoEmboss::close()
|
|||
}
|
||||
}
|
||||
|
||||
// prepare for new opening
|
||||
m_unmodified_volume.reset();
|
||||
|
||||
// close gizmo == open it again
|
||||
auto& mng = m_parent.get_gizmos_manager();
|
||||
if (mng.get_current_type() == GLGizmosManager::Emboss)
|
||||
|
@ -988,9 +991,22 @@ void GLGizmoEmboss::close()
|
|||
}
|
||||
|
||||
void GLGizmoEmboss::discard_and_close() {
|
||||
close();
|
||||
auto plater = wxGetApp().plater();
|
||||
plater->undo_to(2); // undo before open emboss gizmo
|
||||
if (!m_unmodified_volume.has_value()) return;
|
||||
m_volume->set_transformation(m_unmodified_volume->tr);
|
||||
EmbossUpdateJob::update_volume(m_volume, std::move(m_unmodified_volume->tm), m_unmodified_volume->tc, m_unmodified_volume->name);
|
||||
close();
|
||||
|
||||
//auto plater = wxGetApp().plater();
|
||||
// 2 .. on set state off, history is squashed into 'emboss_begin' and 'emboss_end'
|
||||
//plater->undo_to(2); // undo before open emboss gizmo
|
||||
// TODO: need fix after move to find correct undo timestamp or different approach
|
||||
// It is weird ford user that after discard changes it is moving with history
|
||||
|
||||
// NOTE: Option to remember state before edit:
|
||||
// * Need triangle mesh(memory consuming), volume name, transformation + TextConfiguration
|
||||
// * Can't revert volume id.
|
||||
// * Need to refresh a lot of stored data. More info in implementation EmbossJob.cpp -> update_volume()
|
||||
// * Volume containing 3mf fix transformation - needs work around
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_window()
|
||||
|
@ -2831,6 +2847,11 @@ bool GLGizmoEmboss::load_configuration(ModelVolume *volume)
|
|||
|
||||
m_text = tc.text;
|
||||
m_volume = volume;
|
||||
|
||||
// store volume state before edit
|
||||
m_unmodified_volume = {*volume->get_mesh_shared_ptr(), // copy
|
||||
tc, volume->get_matrix(), volume->name};
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue