ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE -> Added undo/redo

This commit is contained in:
Enrico Turri 2019-11-27 11:08:10 +01:00
parent 55a163e216
commit 5fcf41a3aa
3 changed files with 7 additions and 2 deletions

View file

@ -22,6 +22,7 @@
#include "slic3r/GUI/PresetBundle.hpp" #include "slic3r/GUI/PresetBundle.hpp"
#include "slic3r/GUI/Tab.hpp" #include "slic3r/GUI/Tab.hpp"
#include "slic3r/GUI/GUI_Preview.hpp" #include "slic3r/GUI/GUI_Preview.hpp"
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "GUI_ObjectList.hpp" #include "GUI_ObjectList.hpp"
#include "GUI_ObjectManipulation.hpp" #include "GUI_ObjectManipulation.hpp"
@ -688,7 +689,7 @@ void GLCanvas3D::LayersEditing::accept_changes(GLCanvas3D& canvas)
{ {
if (last_object_id >= 0) { if (last_object_id >= 0) {
if (m_layer_height_profile_modified) { if (m_layer_height_profile_modified) {
wxGetApp().plater()->take_snapshot(_(L("Layers heights"))); wxGetApp().plater()->take_snapshot(_(L("Layer height profile-Manual edit")));
const_cast<ModelObject*>(m_model_object)->layer_height_profile = m_layer_height_profile; const_cast<ModelObject*>(m_model_object)->layer_height_profile = m_layer_height_profile;
canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS)); canvas.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
} }
@ -1588,6 +1589,7 @@ bool GLCanvas3D::is_layers_editing_allowed() const
#if ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE #if ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE
void GLCanvas3D::reset_layer_height_profile() void GLCanvas3D::reset_layer_height_profile()
{ {
wxGetApp().plater()->take_snapshot(_(L("Layer height profile-Reset")));
m_layers_editing.reset_layer_height_profile(*this); m_layers_editing.reset_layer_height_profile(*this);
m_layers_editing.state = LayersEditing::Completed; m_layers_editing.state = LayersEditing::Completed;
m_dirty = true; m_dirty = true;
@ -1595,6 +1597,7 @@ void GLCanvas3D::reset_layer_height_profile()
void GLCanvas3D::adaptive_layer_height_profile(float cusp) void GLCanvas3D::adaptive_layer_height_profile(float cusp)
{ {
wxGetApp().plater()->take_snapshot(_(L("Layer height profile-Adaptive")));
m_layers_editing.adaptive_layer_height_profile(*this, cusp); m_layers_editing.adaptive_layer_height_profile(*this, cusp);
m_layers_editing.state = LayersEditing::Completed; m_layers_editing.state = LayersEditing::Completed;
m_dirty = true; m_dirty = true;
@ -1602,6 +1605,7 @@ void GLCanvas3D::adaptive_layer_height_profile(float cusp)
void GLCanvas3D::smooth_layer_height_profile(const HeightProfileSmoothingParams& smoothing_params) void GLCanvas3D::smooth_layer_height_profile(const HeightProfileSmoothingParams& smoothing_params)
{ {
wxGetApp().plater()->take_snapshot(_(L("Layer height profile-Smooth all")));
m_layers_editing.smooth_layer_height_profile(*this, smoothing_params); m_layers_editing.smooth_layer_height_profile(*this, smoothing_params);
m_layers_editing.state = LayersEditing::Completed; m_layers_editing.state = LayersEditing::Completed;
m_dirty = true; m_dirty = true;

View file

@ -179,7 +179,7 @@ private:
float m_object_max_z; float m_object_max_z;
// Owned by LayersEditing. // Owned by LayersEditing.
SlicingParameters *m_slicing_parameters; SlicingParameters *m_slicing_parameters;
std::vector<coordf_t> m_layer_height_profile; std::vector<double> m_layer_height_profile;
bool m_layer_height_profile_modified; bool m_layer_height_profile_modified;
#if ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE #if ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE

View file

@ -4177,6 +4177,7 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator
// Disable layer editing before the Undo / Redo jump. // Disable layer editing before the Undo / Redo jump.
if (!new_variable_layer_editing_active && view3D->is_layers_editing_enabled()) if (!new_variable_layer_editing_active && view3D->is_layers_editing_enabled())
view3D->get_canvas3d()->force_main_toolbar_left_action(view3D->get_canvas3d()->get_main_toolbar_item_id("layersediting")); view3D->get_canvas3d()->force_main_toolbar_left_action(view3D->get_canvas3d()->get_main_toolbar_item_id("layersediting"));
// Make a copy of the snapshot, undo/redo could invalidate the iterator // Make a copy of the snapshot, undo/redo could invalidate the iterator
const UndoRedo::Snapshot snapshot_copy = *it_snapshot; const UndoRedo::Snapshot snapshot_copy = *it_snapshot;
// Do the jump in time. // Do the jump in time.