diff options
author | Enrico Turri <enricoturri@seznam.cz> | 2018-10-24 13:55:38 +0300 |
---|---|---|
committer | Enrico Turri <enricoturri@seznam.cz> | 2018-10-24 13:55:38 +0300 |
commit | 90ecbce9bbbd4502f0d89bb9bc824e0c3dec07b5 (patch) | |
tree | 37460701216e66e27e3c4483afdc7ab7b291701c /src/slic3r/GUI | |
parent | f3c9a798dd26e18f766e5f9a2115173535131098 (diff) |
Split to objects and Split to parts
Diffstat (limited to 'src/slic3r/GUI')
-rw-r--r-- | src/slic3r/GUI/GLCanvas3D.cpp | 14 | ||||
-rw-r--r-- | src/slic3r/GUI/GLToolbar.cpp | 3 | ||||
-rw-r--r-- | src/slic3r/GUI/GLToolbar.hpp | 3 | ||||
-rw-r--r-- | src/slic3r/GUI/Plater.cpp | 54 |
4 files changed, 59 insertions, 15 deletions
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9928e4334..f8f7cb0bc 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4588,11 +4588,19 @@ bool GLCanvas3D::_init_toolbar() if (!m_toolbar.add_separator()) return false; - item.name = "split"; - item.tooltip = GUI::L_str("Split"); + item.name = "splitobjects"; + item.tooltip = GUI::L_str("Split to objects"); item.sprite_id = 6; item.is_toggable = false; - item.action_event = EVT_GLTOOLBAR_SPLIT; + item.action_event = EVT_GLTOOLBAR_SPLIT_OBJECTS; + if (!m_toolbar.add_item(item)) + return false; + + item.name = "splitvolumes"; + item.tooltip = GUI::L_str("Split to parts"); + item.sprite_id = 6; + item.is_toggable = false; + item.action_event = EVT_GLTOOLBAR_SPLIT_VOLUMES; if (!m_toolbar.add_item(item)) return false; diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index e094e1105..71ff3cf48 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -22,7 +22,8 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_MORE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_FEWER, SimpleEvent); -wxDEFINE_EVENT(EVT_GLTOOLBAR_SPLIT, SimpleEvent); +wxDEFINE_EVENT(EVT_GLTOOLBAR_SPLIT_OBJECTS, SimpleEvent); +wxDEFINE_EVENT(EVT_GLTOOLBAR_SPLIT_VOLUMES, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); #if !ENABLE_EXTENDED_SELECTION wxDEFINE_EVENT(EVT_GLTOOLBAR_SETTINGS, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 216171753..9f3853530 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -22,7 +22,8 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_MORE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_FEWER, SimpleEvent); -wxDECLARE_EVENT(EVT_GLTOOLBAR_SPLIT, SimpleEvent); +wxDECLARE_EVENT(EVT_GLTOOLBAR_SPLIT_OBJECTS, SimpleEvent); +wxDECLARE_EVENT(EVT_GLTOOLBAR_SPLIT_VOLUMES, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); #if !ENABLE_EXTENDED_SELECTION wxDECLARE_EVENT(EVT_GLTOOLBAR_SETTINGS, SimpleEvent); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 8fdb5fd3b..5c5522909 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -795,6 +795,7 @@ struct Plater::priv #endif // !ENABLE_EXTENDED_SELECTION void arrange(); void split_object(); + void split_volume(); void schedule_background_process(); void async_apply_config(); void start_background_process(); @@ -812,7 +813,8 @@ struct Plater::priv void on_layer_editing_toggled(bool enable); void on_action_add(SimpleEvent&); - void on_action_split(SimpleEvent&); + void on_action_split_objects(SimpleEvent&); + void on_action_split_volumes(SimpleEvent&); void on_action_cut(SimpleEvent&); #if !ENABLE_EXTENDED_SELECTION void on_action_settings(SimpleEvent&); @@ -844,7 +846,8 @@ private: bool can_delete_object() const; bool can_increase_instances() const; bool can_decrease_instances() const; - bool can_split_object() const; + bool can_split_to_objects() const; + bool can_split_to_volumes() const; bool can_cut_object() const; bool layers_height_allowed() const; bool can_delete_all() const; @@ -958,7 +961,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) : canvas3D->Bind(EVT_GLTOOLBAR_ARRANGE, [this](SimpleEvent&) { arrange(); }); canvas3D->Bind(EVT_GLTOOLBAR_MORE, [q](SimpleEvent&) { q->increase_instances(); }); canvas3D->Bind(EVT_GLTOOLBAR_FEWER, [q](SimpleEvent&) { q->decrease_instances(); }); - canvas3D->Bind(EVT_GLTOOLBAR_SPLIT, &priv::on_action_split, this); + canvas3D->Bind(EVT_GLTOOLBAR_SPLIT_OBJECTS, &priv::on_action_split_objects, this); + canvas3D->Bind(EVT_GLTOOLBAR_SPLIT_VOLUMES, &priv::on_action_split_volumes, this); canvas3D->Bind(EVT_GLTOOLBAR_CUT, &priv::on_action_cut, this); #if !ENABLE_EXTENDED_SELECTION canvas3D->Bind(EVT_GLTOOLBAR_SETTINGS, &priv::on_action_settings, this); @@ -1356,12 +1360,14 @@ void Plater::priv::selection_changed() _3DScene::enable_toolbar_item(canvas3D, "delete", can_delete_object()); _3DScene::enable_toolbar_item(canvas3D, "more", can_increase_instances()); _3DScene::enable_toolbar_item(canvas3D, "fewer", can_decrease_instances()); - _3DScene::enable_toolbar_item(canvas3D, "split", can_split_object()); + _3DScene::enable_toolbar_item(canvas3D, "splitobjects", can_split_to_objects()); + _3DScene::enable_toolbar_item(canvas3D, "splitvolumes", can_split_to_volumes()); _3DScene::enable_toolbar_item(canvas3D, "cut", can_cut_object()); _3DScene::enable_toolbar_item(canvas3D, "layersediting", layers_height_allowed()); #else _3DScene::enable_toolbar_item(canvas3D, "fewer", have_sel); - _3DScene::enable_toolbar_item(canvas3D, "split", have_sel); + _3DScene::enable_toolbar_item(canvas3D, "splitobjects", have_sel); + _3DScene::enable_toolbar_item(canvas3D, "splitvolumes", have_sel); _3DScene::enable_toolbar_item(canvas3D, "cut", have_sel); _3DScene::enable_toolbar_item(canvas3D, "settings", have_sel); _3DScene::enable_toolbar_item(canvas3D, "layersediting", have_sel && config->opt_bool("variable_layer_height") && _3DScene::is_layers_editing_allowed(canvas3D)); @@ -1617,8 +1623,10 @@ void Plater::priv::split_object() } else { + unsigned int counter = 1; for (ModelObject* m : new_objects) { + m->name = current_model_object->name + "_" + std::to_string(counter++); m->center_around_origin(); } @@ -1631,6 +1639,11 @@ void Plater::priv::split_object() #endif // ENABLE_EXTENDED_SELECTION } +void Plater::priv::split_volume() +{ + wxGetApp().obj_list()->split(false); +} + void Plater::priv::schedule_background_process() { // Trigger the timer event after 0.5s @@ -1868,11 +1881,16 @@ void Plater::priv::on_action_add(SimpleEvent&) q->add(); } -void Plater::priv::on_action_split(SimpleEvent&) +void Plater::priv::on_action_split_objects(SimpleEvent&) { split_object(); } +void Plater::priv::on_action_split_volumes(SimpleEvent&) +{ + split_volume(); +} + void Plater::priv::on_action_cut(SimpleEvent&) { // TODO @@ -2031,8 +2049,16 @@ bool Plater::priv::init_object_menu() wxMenuItem* item_mirror = append_submenu(&object_menu, mirror_menu, wxID_ANY, _(L("Mirror")), _(L("Mirror the selected object"))); #endif // ENABLE_MIRROR - wxMenuItem* item_split = append_menu_item(&object_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object into individual parts")), - [this](wxCommandEvent&){ split_object(); }, "shape_ungroup.png"); + wxMenu* split_menu = new wxMenu(); + if (split_menu == nullptr) + return false; + + wxMenuItem* item_split_objects = append_menu_item(split_menu, wxID_ANY, _(L("To objects")), _(L("Split the selected object into individual objects")), + [this](wxCommandEvent&){ split_object(); }, "shape_ungroup.png", &object_menu); + wxMenuItem* item_split_volumes = append_menu_item(split_menu, wxID_ANY, _(L("To parts")), _(L("Split the selected object into individual sub-parts")), + [this](wxCommandEvent&){ split_volume(); }, "shape_ungroup.png", &object_menu); + + wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object")), "shape_ungroup.png"); #if ENABLE_EXTENDED_SELECTION // ui updates needs to be binded to the parent panel @@ -2044,7 +2070,9 @@ bool Plater::priv::init_object_menu() q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete_object()); }, item_delete->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_increase_instances()); }, item_increase->GetId()); q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_decrease_instances()); }, item_decrease->GetId()); - q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_object()); }, item_split->GetId()); + q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_objects() || can_split_to_volumes()); }, item_split->GetId()); + q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_objects()); }, item_split_objects->GetId()); + q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_volumes()); }, item_split_volumes->GetId()); } #endif // ENABLE_EXTENDED_SELECTION @@ -2070,7 +2098,13 @@ bool Plater::priv::can_decrease_instances() const return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && (model.objects[obj_idx]->instances.size() > 1); } -bool Plater::priv::can_split_object() const +bool Plater::priv::can_split_to_objects() const +{ + int obj_idx = get_selected_object_idx(); + return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts(); +} + +bool Plater::priv::can_split_to_volumes() const { int obj_idx = get_selected_object_idx(); return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts(); |