Split to objects and Split to parts
This commit is contained in:
parent
f3c9a798dd
commit
90ecbce9bb
4 changed files with 59 additions and 15 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue