Project dirty state manager -> Improvements to management of gizmos dirty state
This commit is contained in:
parent
8c3d098ff6
commit
ce73671f47
@ -32,6 +32,42 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if ENABLE_PROJECT_DIRTY_STATE
|
||||||
|
// port of 948bc382655993721d93d3b9fce9b0186fcfb211
|
||||||
|
void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
|
||||||
|
{
|
||||||
|
Plater* plater = wxGetApp().plater();
|
||||||
|
|
||||||
|
// Following is needed to prevent taking an extra snapshot when the activation of
|
||||||
|
// the internal stack happens when the gizmo is already active (such as open gizmo,
|
||||||
|
// close gizmo, undo, start painting). The internal stack does not activate on the
|
||||||
|
// undo, because that would obliterate all future of the main stack (user would
|
||||||
|
// have to close the gizmo himself, he has no access to main undo/redo after the
|
||||||
|
// internal stack opens). We don't want the "entering" snapshot taken in this case,
|
||||||
|
// because there already is one.
|
||||||
|
std::string last_snapshot_name;
|
||||||
|
plater->undo_redo_topmost_string_getter(plater->can_undo(), last_snapshot_name);
|
||||||
|
|
||||||
|
if (activate && !m_internal_stack_active) {
|
||||||
|
std::string str = get_painter_type() == PainterGizmoType::FDM_SUPPORTS
|
||||||
|
? _u8L("Entering Paint-on supports")
|
||||||
|
: _u8L("Entering Seam painting");
|
||||||
|
if (last_snapshot_name != str)
|
||||||
|
Plater::TakeSnapshot(plater, str);
|
||||||
|
plater->enter_gizmos_stack();
|
||||||
|
m_internal_stack_active = true;
|
||||||
|
}
|
||||||
|
if (!activate && m_internal_stack_active) {
|
||||||
|
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);
|
||||||
|
m_internal_stack_active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
|
void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
|
||||||
{
|
{
|
||||||
if (activate && ! m_internal_stack_active) {
|
if (activate && ! m_internal_stack_active) {
|
||||||
@ -51,6 +87,7 @@ void GLGizmoPainterBase::activate_internal_undo_redo_stack(bool activate)
|
|||||||
m_internal_stack_active = false;
|
m_internal_stack_active = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ void ProjectDirtyStateManager::render_debug_window() const
|
|||||||
|
|
||||||
if (ImGui::CollapsingHeader("Last save timestamps", ImGuiTreeNodeFlags_DefaultOpen)) {
|
if (ImGui::CollapsingHeader("Last save timestamps", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||||
append_int_item("Main:", m_last_save.main);
|
append_int_item("Main:", m_last_save.main);
|
||||||
append_int_item("Gizmo:", m_last_save.gizmo);
|
append_int_item("Current gizmo:", m_last_save.gizmo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::CollapsingHeader("Main snapshots", ImGuiTreeNodeFlags_DefaultOpen)) {
|
if (ImGui::CollapsingHeader("Main snapshots", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||||
@ -279,6 +279,10 @@ void ProjectDirtyStateManager::render_debug_window() const
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
imgui.text_colored(color(active), " (S)");
|
imgui.text_colored(color(active), " (S)");
|
||||||
}
|
}
|
||||||
|
if (m_last_save.main > 0 && m_last_save.main == snapshot.timestamp) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
imgui.text_colored(color(active), " (LS)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,11 +311,11 @@ void ProjectDirtyStateManager::update_from_undo_redo_main_stack(UpdateType type,
|
|||||||
{
|
{
|
||||||
m_state.plater = false;
|
m_state.plater = false;
|
||||||
|
|
||||||
const UndoRedo::Snapshot* active_snapshot = get_active_snapshot(stack);
|
|
||||||
|
|
||||||
if (type == UpdateType::TakeSnapshot)
|
if (type == UpdateType::TakeSnapshot)
|
||||||
m_state.gizmos.remove_obsolete_used(stack);
|
m_state.gizmos.remove_obsolete_used(stack);
|
||||||
|
|
||||||
|
const UndoRedo::Snapshot* active_snapshot = get_active_snapshot(stack);
|
||||||
|
|
||||||
if (active_snapshot->name == _utf8("New Project") ||
|
if (active_snapshot->name == _utf8("New Project") ||
|
||||||
active_snapshot->name == _utf8("Reset Project") ||
|
active_snapshot->name == _utf8("Reset Project") ||
|
||||||
boost::starts_with(active_snapshot->name, _utf8("Load Project:")))
|
boost::starts_with(active_snapshot->name, _utf8("Load Project:")))
|
||||||
@ -319,6 +323,18 @@ void ProjectDirtyStateManager::update_from_undo_redo_main_stack(UpdateType type,
|
|||||||
|
|
||||||
size_t search_timestamp = 0;
|
size_t search_timestamp = 0;
|
||||||
if (boost::starts_with(active_snapshot->name, _utf8("Entering"))) {
|
if (boost::starts_with(active_snapshot->name, _utf8("Entering"))) {
|
||||||
|
if (type == UpdateType::UndoRedoTo) {
|
||||||
|
std::string topmost_redo;
|
||||||
|
wxGetApp().plater()->undo_redo_topmost_string_getter(false, topmost_redo);
|
||||||
|
if (boost::starts_with(topmost_redo, _utf8("Leaving"))) {
|
||||||
|
const std::vector<UndoRedo::Snapshot>& snapshots = stack.snapshots();
|
||||||
|
const UndoRedo::Snapshot* leaving_snapshot = &(*std::lower_bound(snapshots.begin(), snapshots.end(), UndoRedo::Snapshot(active_snapshot->timestamp + 1)));
|
||||||
|
if (m_state.gizmos.is_used_and_modified(*leaving_snapshot)) {
|
||||||
|
m_state.plater = (leaving_snapshot != nullptr && leaving_snapshot->timestamp != m_last_save.main);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
m_state.gizmos.current = false;
|
m_state.gizmos.current = false;
|
||||||
m_last_save.gizmo = 0;
|
m_last_save.gizmo = 0;
|
||||||
search_timestamp = m_last_save.main;
|
search_timestamp = m_last_save.main;
|
||||||
|
Loading…
Reference in New Issue
Block a user