diff options
author | Lukas Matena <lukasmatena@seznam.cz> | 2021-09-30 11:21:19 +0300 |
---|---|---|
committer | Lukas Matena <lukasmatena@seznam.cz> | 2021-09-30 12:34:04 +0300 |
commit | f33c17ead5126a85bf3283eb992bdde4b0449af1 (patch) | |
tree | 5a3d87e3a859cb7dfe035b70b6e223ef6b532696 | |
parent | 9591f3ea6f5a4665f8dfff9fe23df77fe53b8db4 (diff) |
After gizmo snapshots are compacted, rename the last one to something genericvb_project_state
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoBase.hpp | 1 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp | 4 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp | 2 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 4 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp | 1 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp | 4 | ||||
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp | 1 | ||||
-rw-r--r-- | src/slic3r/GUI/Plater.cpp | 10 | ||||
-rw-r--r-- | src/slic3r/Utils/UndoRedo.cpp | 9 | ||||
-rw-r--r-- | src/slic3r/Utils/UndoRedo.hpp | 4 |
10 files changed, 29 insertions, 11 deletions
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp index 05f6adb5e..6c2c6afaf 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp @@ -136,6 +136,7 @@ public: bool is_selectable() const { return on_is_selectable(); } CommonGizmosDataID get_requirements() const { return on_get_requirements(); } virtual bool wants_enter_leave_snapshots() const { return false; } + virtual std::string get_action_snapshot_name() { return _u8L("Gizmo action"); } void set_common_data_pool(CommonGizmosDataPool* ptr) { m_c = ptr; } unsigned int get_sprite_id() const { return m_sprite_id; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp index ea164ed2f..437106fed 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.cpp @@ -8,6 +8,7 @@ #include "slic3r/GUI/ImGuiWrapper.hpp" #include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/GUI_ObjectList.hpp" +#include "slic3r/Utils/UndoRedo.hpp" #include <GL/glew.h> @@ -165,7 +166,8 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l ImGui::Separator(); if (m_imgui->button(m_desc.at("remove_all"))) { - Plater::TakeSnapshot snapshot(wxGetApp().plater(), wxString(_L("Reset selection"))); + Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Reset selection"), + UndoRedo::SnapshotType::GizmoAction); ModelObject* mo = m_c->selection_info()->model_object(); int idx = -1; for (ModelVolume* mv : mo->volumes) { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp index f2c19ba5c..0fb03140a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp @@ -21,6 +21,8 @@ protected: std::string get_gizmo_entering_text() const override { return _u8L("Entering Paint-on supports"); } std::string get_gizmo_leaving_text() const override { return _u8L("Leaving Paint-on supports"); } + std::string get_action_snapshot_name() override { return _u8L("Paint-on supports editing"); } + private: bool on_init() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 30f7ff7cf..f0a627f90 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -11,6 +11,7 @@ #include "slic3r/GUI/NotificationManager.hpp" #include "libslic3r/PresetBundle.hpp" #include "libslic3r/Model.hpp" +#include "slic3r/Utils/UndoRedo.hpp" #include <GL/glew.h> @@ -503,7 +504,8 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott ImGui::Separator(); if (m_imgui->button(m_desc.at("remove_all"))) { - Plater::TakeSnapshot snapshot(wxGetApp().plater(), wxString(_L("Reset selection"))); + Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Reset selection"), + UndoRedo::SnapshotType::GizmoAction); ModelObject * mo = m_c->selection_info()->model_object(); int idx = -1; for (ModelVolume *mv : mo->volumes) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp index ab58ba186..851a5ac4f 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp @@ -130,6 +130,7 @@ protected: std::string get_gizmo_entering_text() const override { return _u8L("Entering Multimaterial painting"); } std::string get_gizmo_leaving_text() const override { return _u8L("Leaving Multimaterial painting"); } + std::string get_action_snapshot_name() override { return _u8L("Multimaterial painting editing"); } size_t m_first_selected_extruder_idx = 0; size_t m_second_selected_extruder_idx = 1; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp index a2ee56d9a..b23528772 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp @@ -8,6 +8,7 @@ #include "slic3r/GUI/ImGuiWrapper.hpp" #include "slic3r/GUI/Plater.hpp" #include "slic3r/GUI/GUI_ObjectList.hpp" +#include "slic3r/Utils/UndoRedo.hpp" #include <GL/glew.h> @@ -121,7 +122,8 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit) m_imgui->text(""); if (m_imgui->button(m_desc.at("remove_all"))) { - Plater::TakeSnapshot snapshot(wxGetApp().plater(), wxString(_L("Reset selection"))); + Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Reset selection"), + UndoRedo::SnapshotType::GizmoAction); ModelObject* mo = m_c->selection_info()->model_object(); int idx = -1; for (ModelVolume* mv : mo->volumes) { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp index 7a00a9d8e..408c2ec4c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp @@ -22,6 +22,7 @@ protected: std::string get_gizmo_entering_text() const override { return _u8L("Entering Seam painting"); } std::string get_gizmo_leaving_text() const override { return _u8L("Leaving Seam painting"); } + std::string get_action_snapshot_name() override { return _u8L("Paint-on seam editing"); } private: bool on_init() override; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 06481772a..a1ae9c804 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4692,12 +4692,18 @@ void Plater::priv::take_snapshot(const std::string& snapshot_name, const UndoRed model.wipe_tower.position = Vec2d(config.opt_float("wipe_tower_x"), config.opt_float("wipe_tower_y")); model.wipe_tower.rotation = config.opt_float("wipe_tower_rotation_angle"); } + const GLGizmosManager& gizmos = view3D->get_canvas3d()->get_gizmos_manager(); + if (snapshot_type == UndoRedo::SnapshotType::ProjectSeparator && wxGetApp().app_config->get("clear_undo_redo_stack_on_new_project") == "1") this->undo_redo_stack().clear(); - this->undo_redo_stack().take_snapshot(snapshot_name, model, view3D->get_canvas3d()->get_selection(), view3D->get_canvas3d()->get_gizmos_manager(), snapshot_data); + this->undo_redo_stack().take_snapshot(snapshot_name, model, view3D->get_canvas3d()->get_selection(), gizmos, snapshot_data); if (snapshot_type == UndoRedo::SnapshotType::LeavingGizmoWithAction) { // Filter all but the last UndoRedo::SnapshotType::GizmoAction in a row between the last UndoRedo::SnapshotType::EnteringGizmo and UndoRedo::SnapshotType::LeavingGizmoWithAction. - this->undo_redo_stack().reduce_noisy_snapshots(); + // The remaining snapshot will be renamed to a more generic name, + // depending on what gizmo is being left. + assert(gizmos.get_current() != nullptr); + std::string new_name = gizmos.get_current()->get_action_snapshot_name(); + this->undo_redo_stack().reduce_noisy_snapshots(new_name); } else if (snapshot_type == UndoRedo::SnapshotType::ProjectSeparator) { // Reset the "dirty project" flag. m_undo_redo_stack_main.mark_current_as_saved(); diff --git a/src/slic3r/Utils/UndoRedo.cpp b/src/slic3r/Utils/UndoRedo.cpp index a43639ec6..049de5400 100644 --- a/src/slic3r/Utils/UndoRedo.cpp +++ b/src/slic3r/Utils/UndoRedo.cpp @@ -576,7 +576,7 @@ public: // Store the current application state onto the Undo / Redo stack, remove all snapshots after m_active_snapshot_time. void take_snapshot(const std::string& snapshot_name, const Slic3r::Model& model, const Slic3r::GUI::Selection& selection, const Slic3r::GUI::GLGizmosManager& gizmos, const SnapshotData &snapshot_data); - void reduce_noisy_snapshots(); + void reduce_noisy_snapshots(const std::string& new_name); void load_snapshot(size_t timestamp, Slic3r::Model& model, Slic3r::GUI::GLGizmosManager& gizmos); bool has_undo_snapshot() const; @@ -934,7 +934,7 @@ void StackImpl::take_snapshot(const std::string& snapshot_name, const Slic3r::Mo #endif /* SLIC3R_UNDOREDO_DEBUG */ } -void StackImpl::reduce_noisy_snapshots() +void StackImpl::reduce_noisy_snapshots(const std::string& new_name) { // Preceding snapshot must be a "leave gizmo" snapshot. assert(! m_snapshots.empty() && m_snapshots.back().is_topmost() && m_snapshots.back().timestamp == m_active_snapshot_time); @@ -944,7 +944,8 @@ void StackImpl::reduce_noisy_snapshots() if (it_last->snapshot_data.snapshot_type == SnapshotType::LeavingGizmoWithAction) { for (-- it_last; it_last->snapshot_data.snapshot_type != SnapshotType::EnteringGizmo; -- it_last) { if (it_last->snapshot_data.snapshot_type == SnapshotType::GizmoAction) { - auto it = it_last; + it_last->name = new_name; + auto it = it_last; for (-- it; it->snapshot_data.snapshot_type == SnapshotType::GizmoAction; -- it) ; if (++ it < it_last) { // Drop (it, it_last> @@ -1248,7 +1249,7 @@ size_t Stack::memsize() const { return pimpl->memsize(); } void Stack::release_least_recently_used() { pimpl->release_least_recently_used(); } void Stack::take_snapshot(const std::string& snapshot_name, const Slic3r::Model& model, const Slic3r::GUI::Selection& selection, const Slic3r::GUI::GLGizmosManager& gizmos, const SnapshotData &snapshot_data) { pimpl->take_snapshot(snapshot_name, model, selection, gizmos, snapshot_data); } -void Stack::reduce_noisy_snapshots() { pimpl->reduce_noisy_snapshots(); } +void Stack::reduce_noisy_snapshots(const std::string& new_name) { pimpl->reduce_noisy_snapshots(new_name); } bool Stack::has_undo_snapshot() const { return pimpl->has_undo_snapshot(); } bool Stack::has_undo_snapshot(size_t time_to_load) const { return pimpl->has_undo_snapshot(time_to_load); } bool Stack::has_redo_snapshot() const { return pimpl->has_redo_snapshot(); } diff --git a/src/slic3r/Utils/UndoRedo.hpp b/src/slic3r/Utils/UndoRedo.hpp index e58f0b3a8..7165c00e5 100644 --- a/src/slic3r/Utils/UndoRedo.hpp +++ b/src/slic3r/Utils/UndoRedo.hpp @@ -8,6 +8,7 @@ #include <cassert> #include <libslic3r/ObjectID.hpp> +#include <libslic3r/Config.hpp> typedef double coordf_t; typedef std::pair<coordf_t, coordf_t> t_layer_height_range; @@ -15,7 +16,6 @@ typedef std::pair<coordf_t, coordf_t> t_layer_height_range; namespace Slic3r { class Model; -enum PrinterTechnology : unsigned char; namespace GUI { class Selection; @@ -124,7 +124,7 @@ public: void take_snapshot(const std::string& snapshot_name, const Slic3r::Model& model, const Slic3r::GUI::Selection& selection, const Slic3r::GUI::GLGizmosManager& gizmos, const SnapshotData &snapshot_data); // To be called just after take_snapshot() when leaving a gizmo, inside which small edits like support point add / remove events or paiting actions were allowed. // Remove all but the last edit between the gizmo enter / leave snapshots. - void reduce_noisy_snapshots(); + void reduce_noisy_snapshots(const std::string& new_name); // To be queried to enable / disable the Undo / Redo buttons at the UI. bool has_undo_snapshot() const; |