Painting gizmos no longer use a separate undo/redo stack

This commit is contained in:
Lukas Matena 2021-08-31 13:58:20 +02:00 committed by Vojtech Bubnik
parent f7a479a90e
commit 5fe90599fc
3 changed files with 1 additions and 39 deletions

View File

@ -298,8 +298,6 @@ void GLGizmoFdmSupports::select_facets_by_angle(float threshold_deg, bool block)
}
}
activate_internal_undo_redo_stack(true);
Plater::TakeSnapshot snapshot(wxGetApp().plater(), block ? _L("Block supports by angle")
: _L("Add supports by angle"));
update_model_object();

View File

@ -26,35 +26,6 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic
m_vbo_sphere.finalize_geometry(true);
}
// 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) {
if (std::string str = this->get_gizmo_entering_text(); last_snapshot_name != 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();
if (std::string str = this->get_gizmo_leaving_text(); last_snapshot_name != str)
Plater::TakeSnapshot(plater, str, UndoRedo::SnapshotType::LeavingGizmoWithAction);
m_internal_stack_active = false;
}
}
void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection)
{
if (m_state != On)
@ -450,7 +421,6 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
&& m_button_down != Button::None) {
// Take snapshot and update ModelVolume data.
wxString action_name = this->handle_snapshot_action_name(shift_down, m_button_down);
activate_internal_undo_redo_stack(true);
Plater::TakeSnapshot snapshot(wxGetApp().plater(), action_name);
update_model_object();
@ -548,16 +518,10 @@ void GLGizmoPainterBase::on_set_state()
if (m_state == On && m_old_state != On) { // the gizmo was just turned on
on_opening();
if (! m_parent.get_gizmos_manager().is_serializing()) {
wxGetApp().CallAfter([this]() {
activate_internal_undo_redo_stack(true);
});
}
}
if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off
// we are actually shutting down
on_shutdown();
activate_internal_undo_redo_stack(false);
m_old_mo_id = -1;
//m_iva.release_geometry();
m_triangle_selectors.clear();

View File

@ -88,7 +88,6 @@ protected:
void render_cursor_sphere(const Transform3d& trafo) const;
virtual void update_model_object() const = 0;
virtual void update_from_model_object() = 0;
void activate_internal_undo_redo_stack(bool activate);
virtual std::array<float, 4> get_cursor_sphere_left_button_color() const { return {0.f, 0.f, 1.f, 0.25f}; }
virtual std::array<float, 4> get_cursor_sphere_right_button_color() const { return {1.f, 0.f, 0.f, 0.25f}; }
@ -170,6 +169,7 @@ protected:
void on_load(cereal::BinaryInputArchive& ar) override;
void on_save(cereal::BinaryOutputArchive& ar) const override {}
CommonGizmosDataID on_get_requirements() const override;
bool wants_enter_leave_snapshots() const override { return true; }
virtual wxString handle_snapshot_action_name(bool shift_down, Button button_down) const = 0;