Reduce amount of Undo/Redo snapshots

This commit is contained in:
Filip Sykala 2022-02-22 12:43:29 +01:00
parent 6181b166a4
commit 8f9887acdb
3 changed files with 12 additions and 7 deletions

View File

@ -13,6 +13,7 @@
#include "slic3r/GUI/Jobs/NotificationProgressIndicator.hpp"
#include "slic3r/Utils/WxFontUtils.hpp"
#include "slic3r/Utils/FontListSerializable.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
// TODO: remove include
#include "libslic3r/SVG.hpp" // debug store
@ -979,7 +980,7 @@ void GLGizmoEmboss::draw_model_type()
if (m_volume != nullptr && new_type.has_value() && !is_last_solid_part) {
GUI_App &app = wxGetApp();
Plater * plater = app.plater();
plater->take_snapshot(_L("Change Part Type"));
Plater::TakeSnapshot snapshot(plater, _L("Change Part Type"), UndoRedo::SnapshotType::GizmoAction);
m_volume->set_type(*new_type);
// inspiration in ObjectList::change_part_type()

View File

@ -72,10 +72,10 @@ protected:
void on_start_dragging() override;
void on_stop_dragging() override;
//bool wants_enter_leave_snapshots() const override { return true; }
//std::string get_gizmo_entering_text() const override { return _u8L("Enter emboss gizmo"); }
//std::string get_gizmo_leaving_text() const override { return _u8L("Leave emboss gizmo"); }
//std::string get_action_snapshot_name() override { return _u8L("Emboss action"); }
bool wants_enter_leave_snapshots() const override { return true; }
std::string get_gizmo_entering_text() const override { return _u8L("Enter emboss gizmo"); }
std::string get_gizmo_leaving_text() const override { return _u8L("Leave emboss gizmo"); }
std::string get_action_snapshot_name() override { return _u8L("Embossing actions"); }
private:
void initialize();
static FontList create_default_font_list();

View File

@ -13,6 +13,7 @@
#include "slic3r/GUI/GUI_ObjectManipulation.hpp"
#include "slic3r/GUI/Gizmos/GLGizmoEmboss.hpp"
#include "slic3r/GUI/CameraUtils.hpp"
#include "slic3r/Utils/UndoRedo.hpp"
using namespace Slic3r;
using namespace GUI;
@ -49,7 +50,10 @@ void EmbossUpdateJob::finalize(bool canceled, std::exception_ptr &)
// Check emboss gizmo is still open
if (manager.get_current_type() != GLGizmosManager::Emboss) return;
plater->take_snapshot(_L("Emboss text") + ": " + m_input->volume_name);
Plater::TakeSnapshot snapshot(plater,
GUI::format(_L("Text: %1%"),
m_input->text_configuration.text),
UndoRedo::SnapshotType::GizmoAction);
ModelVolume *volume = m_input->volume;
// find volume by object id - NOT WORK
@ -162,7 +166,7 @@ void EmbossCreateJob::finalize(bool canceled, std::exception_ptr &)
// decide if create object or volume
bool create_object = !m_input->object_idx.has_value();
if (create_object) {
plater->take_snapshot(_L("Add Emboss text object"));
Plater::TakeSnapshot snapshot(plater, _L("Add Emboss text object"));
// Create new object and change selection
bool center = false;
obj_list->load_mesh_object(std::move(m_result), m_input->volume_name, center,