Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2019-07-11 19:42:02 +0300
committerYuSanka <yusanka@gmail.com>2019-07-12 14:56:56 +0300
commitaed6acc073111d8d6134705e36894aedffba536c (patch)
tree9fce19c7552d7f26756fc47b7856908f059d35df /src
parent2f57f756e54151721e9be4b5f0bbe2788830ad20 (diff)
Add take_snapshot for layers range editing actions
Diffstat (limited to 'src')
-rw-r--r--src/slic3r/GUI/GUI_ObjectList.cpp37
-rw-r--r--src/slic3r/GUI/GUI_ObjectList.hpp2
-rw-r--r--src/slic3r/GUI/Plater.cpp14
3 files changed, 39 insertions, 14 deletions
diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp
index 360318413..dc4bb8795 100644
--- a/src/slic3r/GUI/GUI_ObjectList.cpp
+++ b/src/slic3r/GUI/GUI_ObjectList.cpp
@@ -1756,6 +1756,8 @@ void ObjectList::del_settings_from_config(const wxDataViewItem& parent_item)
is_layer_settings && opt_cnt == 2 && m_config->has("extruder") && m_config->has("layer_height"))
return;
+ take_snapshot(_(L("Delete Settings")));
+
int extruder = -1;
if (m_config->has("extruder"))
extruder = m_config->option<ConfigOptionInt>("extruder")->value;
@@ -1793,6 +1795,8 @@ void ObjectList::del_layer_from_object(const int obj_idx, const t_layer_height_r
const auto del_range = object(obj_idx)->layer_config_ranges.find(layer_range);
if (del_range == object(obj_idx)->layer_config_ranges.end())
return;
+
+ take_snapshot(_(L("Delete Layers Range")));
object(obj_idx)->layer_config_ranges.erase(del_range);
@@ -1923,8 +1927,10 @@ void ObjectList::layers_editing()
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
// set some default value
- if (ranges.empty())
+ if (ranges.empty()) {
+ take_snapshot(_(L("Add Layers")));
ranges[{ 0.0f, 2.0f }] = get_default_layer_config(obj_idx);
+ }
// create layer root item
layers_item = add_layer_root_item(obj_item);
@@ -1956,6 +1962,7 @@ wxDataViewItem ObjectList::add_layer_root_item(const wxDataViewItem obj_item)
for (const auto range : object(obj_idx)->layer_config_ranges)
add_layer_item(range.first, layers_item);
+ Expand(layers_item);
return layers_item;
}
@@ -2406,6 +2413,8 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range& curre
if (current_range == last_range)
{
+ take_snapshot(_(L("Add New Layers Range")));
+
const t_layer_height_range& new_range = { last_range.second, last_range.second + 2.0f };
ranges[new_range] = get_default_layer_config(obj_idx);
add_layer_item(new_range, layers_item);
@@ -2433,22 +2442,28 @@ void ObjectList::add_layer_range_after_current(const t_layer_height_range& curre
t_layer_height_range new_range = { midl_layer, next_range.second };
+ take_snapshot(_(L("Add New Layers Range")));
+ suppress_snapshots();
+
+ // create new 2 layers instead of deleted one
+
// delete old layer
wxDataViewItem layer_item = m_objects_model->GetItemByLayerRange(obj_idx, next_range);
del_subobject_item(layer_item);
- // create new 2 layers instead of deleted one
-
ranges[new_range] = old_config;
add_layer_item(new_range, layers_item, layer_idx);
new_range = { current_range.second, midl_layer };
ranges[new_range] = get_default_layer_config(obj_idx);
add_layer_item(new_range, layers_item, layer_idx);
+ allow_snapshots();
}
else
{
+ take_snapshot(_(L("Add New Layers Range")));
+
const t_layer_height_range new_range = { current_range.second, next_range.first };
ranges[new_range] = get_default_layer_config(obj_idx);
add_layer_item(new_range, layers_item, layer_idx);
@@ -2477,8 +2492,10 @@ void ObjectList::add_layer_item(const t_layer_height_range& range,
config.opt_int("extruder"),
layer_idx);
- if (config.keys().size() > 2)
- select_item(m_objects_model->AddSettingsChild(layer_item));
+ if (config.keys().size() > 2) {
+ m_objects_model->AddSettingsChild(layer_item);
+ Expand(layer_item);
+ }
}
bool ObjectList::edit_layer_range(const t_layer_height_range& range, coordf_t layer_height)
@@ -2508,6 +2525,8 @@ bool ObjectList::edit_layer_range(const t_layer_height_range& range, const t_lay
const int obj_idx = get_selected_obj_idx();
if (obj_idx < 0) return false;
+ take_snapshot(_(L("Edit Layers Range")));
+
const ItemType sel_type = m_objects_model->GetItemType(GetSelection());
t_layer_config_ranges& ranges = object(obj_idx)->layer_config_ranges;
@@ -3417,11 +3436,13 @@ void ObjectList::set_extruder_for_selected_items(const int extruder) const
wxGetApp().plater()->update();
}
-void ObjectList::recreate_object_list()
+void ObjectList::update_after_undo_redo()
{
m_prevent_list_events = true;
m_prevent_canvas_selection_update = true;
+ suppress_snapshots();
+
// Unselect all objects before deleting them, so that no change of selection is emitted during deletion.
this->UnselectAll();
m_objects_model->DeleteAll();
@@ -3432,10 +3453,14 @@ void ObjectList::recreate_object_list()
++obj_idx;
}
+ allow_snapshots();
+
#ifndef __WXOSX__
selection_changed();
#endif /* __WXOSX__ */
+ update_selections();
+
m_prevent_canvas_selection_update = false;
m_prevent_list_events = false;
}
diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp
index a5a9c2138..34efa9025 100644
--- a/src/slic3r/GUI/GUI_ObjectList.hpp
+++ b/src/slic3r/GUI/GUI_ObjectList.hpp
@@ -335,7 +335,7 @@ public:
void msw_rescale();
- void recreate_object_list();
+ void update_after_undo_redo();
private:
#ifdef __WXOSX__
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index e826d748e..9551524d4 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -1280,7 +1280,7 @@ struct Plater::priv
PrinterTechnology printer_technology = ptFFF;
Slic3r::GCodePreviewData gcode_preview_data;
Slic3r::UndoRedo::Stack undo_redo_stack;
- bool m_prevent_snapshots = false; /* Used for avoid of excess "snapshoting".
+ int m_prevent_snapshots = 0; /* Used for avoid of excess "snapshoting".
* Like for "delete selected" or "set numbers of copies"
* we should call tack_snapshot just ones
* instead of calls for each action separately
@@ -1587,8 +1587,9 @@ struct Plater::priv
void take_snapshot(const std::string& snapshot_name)
{
- if (this->m_prevent_snapshots)
+ if (this->m_prevent_snapshots > 0)
return;
+ assert(this->m_prevent_snapshots >= 0);
this->undo_redo_stack.take_snapshot(snapshot_name, model, view3D->get_canvas3d()->get_selection());
}
void take_snapshot(const wxString& snapshot_name) { this->take_snapshot(std::string(snapshot_name.ToUTF8().data())); }
@@ -1597,8 +1598,8 @@ struct Plater::priv
void redo();
void undo_to(size_t time_to_load);
void redo_to(size_t time_to_load);
- void suppress_snapshots() { this->m_prevent_snapshots = true; }
- void allow_snapshots() { this->m_prevent_snapshots = false; }
+ void suppress_snapshots() { this->m_prevent_snapshots++; }
+ void allow_snapshots() { this->m_prevent_snapshots--; }
bool background_processing_enabled() const { return this->get_config("background_processing") == "1"; }
void update_print_volume_state();
@@ -3611,9 +3612,8 @@ void Plater::priv::update_after_undo_redo()
//YS_FIXME update obj_list from the deserialized model (maybe store ObjectIDs into the tree?) (no selections at this point of time)
this->view3D->get_canvas3d()->get_selection().set_deserialized(GUI::Selection::EMode(this->undo_redo_stack.selection_deserialized().mode), this->undo_redo_stack.selection_deserialized().volumes_and_instances);
- wxGetApp().obj_list()->recreate_object_list();
- wxGetApp().obj_list()->update_selections();
-// selection_changed();
+ wxGetApp().obj_list()->update_after_undo_redo();
+
//FIXME what about the state of the manipulators?
//FIXME what about the focus? Cursor in the side panel?
}