Implemented menu for Text Volume

This commit is contained in:
YuSanka 2021-10-21 10:27:19 +02:00
parent 6482775f0d
commit 1627e30aaf
5 changed files with 79 additions and 22 deletions

View File

@ -991,28 +991,52 @@ void MenuFactory::create_sla_object_menu()
m_sla_object_menu.AppendSeparator();
}
void MenuFactory::append_immutable_part_menu_items(wxMenu* menu)
{
append_menu_items_mirror(menu);
append_menu_item(menu, wxID_ANY, _L("Split"), _L("Split the selected object into individual parts"),
[](wxCommandEvent&) { plater()->split_volume(); }, "split_parts_SMALL", nullptr,
[]() { return plater()->can_split(false); }, m_parent);
menu->AppendSeparator();
append_menu_item_change_type(menu);
}
void MenuFactory::append_mutable_part_menu_items(wxMenu* menu)
{
append_menu_item_settings(menu);
append_menu_item_change_extruder(menu);
}
void MenuFactory::create_part_menu()
{
wxMenu* menu = &m_part_menu;
#ifdef __WXOSX__
append_menu_items_osx(menu);
#endif // __WXOSX__
append_menu_item_edit_text(menu);
append_menu_item_delete(menu);
append_menu_item_reload_from_disk(menu);
append_menu_item_replace_with_stl(menu);
append_menu_item_export_stl(menu);
append_menu_item_fix_through_netfabb(menu);
append_menu_item_simplify(menu);
append_menu_items_mirror(menu);
append_menu_item(menu, wxID_ANY, _L("Split"), _L("Split the selected object into individual parts"),
[](wxCommandEvent&) { plater()->split_volume(); }, "split_parts_SMALL", nullptr,
[]() { return plater()->can_split(false); }, m_parent);
append_immutable_part_menu_items(menu);
}
void MenuFactory::create_text_part_menu()
{
wxMenu* menu = &m_text_part_menu;
#ifdef __WXOSX__
append_menu_items_osx(menu);
#endif // __WXOSX__
append_menu_item_edit_text(menu);
menu->AppendSeparator();
append_menu_item_delete(menu);
menu->AppendSeparator();
append_menu_item_change_type(menu);
append_immutable_part_menu_items(menu);
}
void MenuFactory::create_instance_menu()
@ -1031,6 +1055,7 @@ void MenuFactory::init(wxWindow* parent)
create_object_menu();
create_sla_object_menu();
create_part_menu();
create_text_part_menu();
create_instance_menu();
}
@ -1067,12 +1092,19 @@ wxMenu* MenuFactory::sla_object_menu()
wxMenu* MenuFactory::part_menu()
{
append_menu_items_convert_unit(&m_part_menu, 2);
append_menu_item_settings(&m_part_menu);
append_menu_item_change_extruder(&m_part_menu);
append_mutable_part_menu_items(&m_part_menu);
return &m_part_menu;
}
wxMenu* MenuFactory::text_part_menu()
{
append_mutable_part_menu_items(&m_text_part_menu);
return &m_text_part_menu;
}
wxMenu* MenuFactory::instance_menu()
{
return &m_instance_menu;

View File

@ -52,6 +52,7 @@ public:
wxMenu* object_menu();
wxMenu* sla_object_menu();
wxMenu* part_menu();
wxMenu* text_part_menu();
wxMenu* instance_menu();
wxMenu* layer_menu();
wxMenu* multi_selection_menu();
@ -67,6 +68,7 @@ private:
MenuWithSeparators m_object_menu;
MenuWithSeparators m_part_menu;
MenuWithSeparators m_text_part_menu;
MenuWithSeparators m_sla_object_menu;
MenuWithSeparators m_default_menu;
MenuWithSeparators m_instance_menu;
@ -80,7 +82,10 @@ private:
void create_common_object_menu(wxMenu *menu);
void create_object_menu();
void create_sla_object_menu();
void append_immutable_part_menu_items(wxMenu* menu);
void append_mutable_part_menu_items(wxMenu* menu);
void create_part_menu();
void create_text_part_menu();
void create_instance_menu();
wxMenu* append_submenu_add_generic(wxMenu* menu, ModelVolumeType type);

View File

@ -955,11 +955,17 @@ void ObjectList::show_context_menu(const bool evt_context_menu)
const ItemType type = m_objects_model->GetItemType(item);
if (!(type & (itObject | itVolume | itLayer | itInstance)))
return;
menu = type & itInstance ? plater->instance_menu() :
type & itLayer ? plater->layer_menu() :
m_objects_model->GetParent(item) != wxDataViewItem(nullptr) ? plater->part_menu() :
printer_technology() == ptFFF ? plater->object_menu() : plater->sla_object_menu();
if (type & itVolume) {
int obj_idx, vol_idx;
get_selected_item_indexes(obj_idx, vol_idx, item);
if (obj_idx < 0 || vol_idx < 0)
return;
menu = object(obj_idx)->volumes[vol_idx]->text_configuration.has_value() ? plater->text_part_menu() : plater->part_menu();
}
else
menu = type & itInstance ? plater->instance_menu() :
type & itLayer ? plater->layer_menu() :
printer_technology() == ptFFF ? plater->object_menu() : plater->sla_object_menu();
}
else if (evt_context_menu)
menu = plater->default_menu();
@ -3782,8 +3788,13 @@ void ObjectList::change_part_type()
}
}
const wxString names[] = { _L("Part"), _L("Negative Volume"), _L("Modifier"), _L("Support Blocker"), _L("Support Enforcer") };
auto new_type = ModelVolumeType(wxGetSingleChoiceIndex(_L("Type:"), _L("Select type of part"), wxArrayString(5, names), int(type)));
wxArrayString names;
for (const wxString& name : { _L("Part"), _L("Negative Volume"), _L("Modifier") })
names.Add(name);
if (!volume->text_configuration.has_value())
for (const wxString& name : { _L("Support Blocker"), _L("Support Enforcer") })
names.Add(name);
auto new_type = ModelVolumeType(wxGetSingleChoiceIndex(_L("Type:"), _L("Select type of part"), names, int(type)));
if (new_type == type || new_type == ModelVolumeType::INVALID)
return;

View File

@ -4196,13 +4196,20 @@ void Plater::priv::on_right_click(RBtnEvent& evt)
menu = menus.sla_object_menu();
else {
const Selection& selection = get_selection();
// show "Object menu" for each one or several FullInstance instead of FullObject
const bool is_some_full_instances = selection.is_single_full_instance() ||
selection.is_single_full_object() ||
selection.is_multiple_full_instance();
const bool is_part = selection.is_single_volume() || selection.is_single_modifier();
menu = is_some_full_instances ? menus.object_menu() :
is_part ? menus.part_menu() : menus.multi_selection_menu();
// check if selected item is object's part
if (selection.is_single_volume() || selection.is_single_modifier()) {
int vol_idx = get_selected_volume_idx();
if (vol_idx < 0)
return;
menu = model.objects[obj_idx]->volumes[vol_idx]->text_configuration.has_value() ? menus.text_part_menu() : menus.part_menu();
}
else {
// show "Object menu" for each one or several FullInstance instead of FullObject
const bool is_some_full_instances = selection.is_single_full_instance() ||
selection.is_single_full_object() ||
selection.is_multiple_full_instance();
menu = is_some_full_instances ? menus.object_menu() : menus.multi_selection_menu();
}
}
}
@ -6841,6 +6848,7 @@ void Plater::bring_instance_forward()
wxMenu* Plater::object_menu() { return p->menus.object_menu(); }
wxMenu* Plater::part_menu() { return p->menus.part_menu(); }
wxMenu* Plater::text_part_menu() { return p->menus.text_part_menu(); }
wxMenu* Plater::sla_object_menu() { return p->menus.sla_object_menu(); }
wxMenu* Plater::default_menu() { return p->menus.default_menu(); }
wxMenu* Plater::instance_menu() { return p->menus.instance_menu(); }

View File

@ -420,6 +420,7 @@ public:
// get same Plater/ObjectList menus
wxMenu* object_menu();
wxMenu* part_menu();
wxMenu* text_part_menu();
wxMenu* sla_object_menu();
wxMenu* default_menu();
wxMenu* instance_menu();