WIP Undo / Redo and project state: Marking Undo / Redo snapshots

with their purpose.
This commit is contained in:
Vojtech Bubnik 2021-09-27 14:10:53 +02:00
parent 783c9cf202
commit 41dc265a45
9 changed files with 80 additions and 31 deletions

View file

@ -8,6 +8,7 @@
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
#include "libslic3r/PresetBundle.hpp"
#include "libslic3r/Model.hpp"
@ -51,17 +52,18 @@ void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
? _u8L("Entering Paint-on supports")
: _u8L("Entering Seam painting");
if (last_snapshot_name != str)
Plater::TakeSnapshot(plater, str);
Plater::TakeSnapshot(plater, str, UndoRedo::SnapshotType::EnteringGizmo);
plater->enter_gizmos_stack();
m_internal_stack_active = true;
}
if (!activate && m_internal_stack_active) {
plater->leave_gizmos_stack();
bool project_modified = plater->leave_gizmos_stack();
std::string str = get_painter_type() == PainterGizmoType::SEAM
? _u8L("Leaving Seam painting")
: _u8L("Leaving Paint-on supports");
if (last_snapshot_name != str)
Plater::TakeSnapshot(plater, str);
Plater::TakeSnapshot(plater, str,
project_modified ? UndoRedo::SnapshotType::LeavingGizmoWithAction : UndoRedo::SnapshotType::LeavingGizmoNoAction);
m_internal_stack_active = false;
}
}

View file

@ -4,6 +4,7 @@
#include "slic3r/GUI/Camera.hpp"
#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp"
#include "slic3r/GUI/MainFrame.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
#include <GL/glew.h>
@ -907,7 +908,7 @@ void GLGizmoSlaSupports::on_set_state()
// data are not yet available, the CallAfter will postpone taking the
// snapshot until they are. No, it does not feel right.
wxGetApp().CallAfter([]() {
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Entering SLA gizmo"));
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Entering SLA gizmo"), UndoRedo::SnapshotType::EnteringGizmo);
});
}
@ -925,8 +926,9 @@ void GLGizmoSlaSupports::on_set_state()
}
else {
// we are actually shutting down
disable_editing_mode(); // so it is not active next time the gizmo opens
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Leaving SLA gizmo"));
bool project_modified = disable_editing_mode(); // so it is not active next time the gizmo opens
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Leaving SLA gizmo"),
project_modified ? UndoRedo::SnapshotType::LeavingGizmoWithAction : UndoRedo::SnapshotType::LeavingGizmoNo);
m_normal_cache.clear();
m_old_mo_id = -1;
}