mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-12 14:38:10 +08:00
Context menu from the object on the 3Dscene
This commit is contained in:
parent
0eba32bb0c
commit
c80267bb29
@ -539,6 +539,8 @@ void GUI_App::update_mode()
|
|||||||
mode == ConfigMenuModeExpert ? comExpert : comAdvanced;
|
mode == ConfigMenuModeExpert ? comExpert : comAdvanced;
|
||||||
for (auto tab : tabs_list)
|
for (auto tab : tabs_list)
|
||||||
tab->update_visibility(opt_mode);
|
tab->update_visibility(opt_mode);
|
||||||
|
|
||||||
|
plater()->update_object_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI_App::add_config_menu(wxMenuBar *menu)
|
void GUI_App::add_config_menu(wxMenuBar *menu)
|
||||||
|
@ -327,6 +327,8 @@ void ObjectList::show_context_menu()
|
|||||||
wxMenu* menu = m_objects_model->GetParent(item) != wxDataViewItem(0) ? &m_menu_part :
|
wxMenu* menu = m_objects_model->GetParent(item) != wxDataViewItem(0) ? &m_menu_part :
|
||||||
wxGetApp().plater()->printer_technology() == ptFFF ? &m_menu_object : &m_menu_sla_object;
|
wxGetApp().plater()->printer_technology() == ptFFF ? &m_menu_object : &m_menu_sla_object;
|
||||||
|
|
||||||
|
append_menu_item_settings(menu);
|
||||||
|
|
||||||
wxGetApp().plater()->PopupMenu(menu);
|
wxGetApp().plater()->PopupMenu(menu);
|
||||||
|
|
||||||
wxGetApp().plater()->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) {
|
wxGetApp().plater()->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) {
|
||||||
@ -334,10 +336,6 @@ void ObjectList::show_context_menu()
|
|||||||
|
|
||||||
wxGetApp().plater()->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) {
|
wxGetApp().plater()->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) {
|
||||||
evt.Enable(is_splittable()); }, m_menu_item_split_part->GetId());
|
evt.Enable(is_splittable()); }, m_menu_item_split_part->GetId());
|
||||||
|
|
||||||
wxGetApp().plater()->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) {
|
|
||||||
evt.Enable(get_selected_model_volume()->type() <= ModelVolume::PARAMETER_MODIFIER);
|
|
||||||
}, m_menu_item_settings->GetId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,12 +515,13 @@ void get_options_menu(settings_menu_hierarchy& settings_menu, const bool is_part
|
|||||||
get_options_menu(settings_menu, is_part, wxGetApp().plater()->printer_technology() == ptSLA);
|
get_options_menu(settings_menu, is_part, wxGetApp().plater()->printer_technology() == ptSLA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::get_settings_choice(const wxString& category_name, const bool is_part)
|
void ObjectList::get_settings_choice(const wxString& category_name)
|
||||||
{
|
{
|
||||||
wxArrayString names;
|
wxArrayString names;
|
||||||
wxArrayInt selections;
|
wxArrayInt selections;
|
||||||
|
|
||||||
settings_menu_hierarchy settings_menu;
|
settings_menu_hierarchy settings_menu;
|
||||||
|
const bool is_part = m_objects_model->GetParent(GetSelection()) != wxDataViewItem(0);
|
||||||
get_options_menu(settings_menu, is_part);
|
get_options_menu(settings_menu, is_part);
|
||||||
std::vector< std::pair<std::string, std::string> > *settings_list = nullptr;
|
std::vector< std::pair<std::string, std::string> > *settings_list = nullptr;
|
||||||
|
|
||||||
@ -584,7 +583,7 @@ void ObjectList::get_settings_choice(const wxString& category_name, const bool i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::menu_item_add_generic(wxMenuItem* &menu, const int type) {
|
void ObjectList::append_menu_item_add_generic(wxMenuItem* menu, const int type) {
|
||||||
auto sub_menu = new wxMenu;
|
auto sub_menu = new wxMenu;
|
||||||
|
|
||||||
append_menu_item(sub_menu, wxID_ANY, _(L("Load")) + " " + dots, "",
|
append_menu_item(sub_menu, wxID_ANY, _(L("Load")) + " " + dots, "",
|
||||||
@ -600,21 +599,7 @@ void ObjectList::menu_item_add_generic(wxMenuItem* &menu, const int type) {
|
|||||||
menu->SetSubMenu(sub_menu);
|
menu->SetSubMenu(sub_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuItem* ObjectList::menu_item_split(wxMenu* menu) {
|
void ObjectList::append_menu_items_add_volume(wxMenu* menu)
|
||||||
return append_menu_item(menu, wxID_ANY, _(L("Split to parts")), "",
|
|
||||||
[this](wxCommandEvent&) { split(); }, m_bmp_split, menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxMenuItem* ObjectList::menu_item_settings(wxMenu* menu, const bool is_part, const bool is_sla_menu) {
|
|
||||||
auto menu_item = new wxMenuItem(menu, wxID_ANY, _(L("Add settings")));
|
|
||||||
menu_item->SetBitmap(m_bmp_cog);
|
|
||||||
|
|
||||||
menu_item->SetSubMenu(create_settings_popupmenu(menu, is_part, is_sla_menu));
|
|
||||||
|
|
||||||
return menu_item;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectList::create_object_popupmenu(wxMenu *menu)
|
|
||||||
{
|
{
|
||||||
// Note: id accords to type of the sub-object, so sequence of the menu items is important
|
// Note: id accords to type of the sub-object, so sequence of the menu items is important
|
||||||
std::vector<std::string> menu_object_types_items = {L("Add part"), // ~ModelVolume::MODEL_PART
|
std::vector<std::string> menu_object_types_items = {L("Add part"), // ~ModelVolume::MODEL_PART
|
||||||
@ -622,56 +607,113 @@ void ObjectList::create_object_popupmenu(wxMenu *menu)
|
|||||||
L("Add support enforcer"), // ~ModelVolume::SUPPORT_ENFORCER
|
L("Add support enforcer"), // ~ModelVolume::SUPPORT_ENFORCER
|
||||||
L("Add support blocker") }; // ~ModelVolume::SUPPORT_BLOCKER
|
L("Add support blocker") }; // ~ModelVolume::SUPPORT_BLOCKER
|
||||||
|
|
||||||
// Add first 4 menu items
|
// Update "add" items(delete old & create new) settings popupmenu
|
||||||
for (int type = 0; type < menu_object_types_items.size(); type++) {
|
for (auto& item : menu_object_types_items){
|
||||||
|
const auto settings_id = menu->FindItem(_(item));
|
||||||
|
if (settings_id != wxNOT_FOUND)
|
||||||
|
menu->Destroy(settings_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wxGetApp().get_view_mode() == ConfigMenuModeSimple)
|
||||||
|
{
|
||||||
|
append_menu_item(menu, wxID_ANY, _(L("Add part")), "",
|
||||||
|
[this](wxCommandEvent&) { load_subobject(ModelVolume::MODEL_PART); }, *m_bmp_vector[ModelVolume::MODEL_PART]);
|
||||||
|
append_menu_item(menu, wxID_ANY, _(L("Add support enforcer")), "",
|
||||||
|
[this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToStdString(), ModelVolume::SUPPORT_ENFORCER); },
|
||||||
|
*m_bmp_vector[ModelVolume::SUPPORT_ENFORCER]);
|
||||||
|
append_menu_item(menu, wxID_ANY, _(L("Add support blocker")), "",
|
||||||
|
[this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToStdString(), ModelVolume::SUPPORT_BLOCKER); },
|
||||||
|
*m_bmp_vector[ModelVolume::SUPPORT_BLOCKER]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int type = 0; type < menu_object_types_items.size(); type++)
|
||||||
|
{
|
||||||
auto& item = menu_object_types_items[type];
|
auto& item = menu_object_types_items[type];
|
||||||
|
|
||||||
auto menu_item = new wxMenuItem(menu, wxID_ANY, _(item));
|
auto menu_item = new wxMenuItem(menu, wxID_ANY, _(item));
|
||||||
menu_item->SetBitmap(*m_bmp_vector[type]);
|
menu_item->SetBitmap(*m_bmp_vector[type]);
|
||||||
menu_item_add_generic(menu_item, type);
|
append_menu_item_add_generic(menu_item, type);
|
||||||
|
|
||||||
menu->Append(menu_item);
|
menu->Append(menu_item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMenuItem* ObjectList::append_menu_item_split(wxMenu* menu)
|
||||||
|
{
|
||||||
|
return append_menu_item(menu, wxID_ANY, _(L("Split to parts")), "",
|
||||||
|
[this](wxCommandEvent&) { split(); }, m_bmp_split, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu)
|
||||||
|
{
|
||||||
|
// Update (delete old & create new) settings popupmenu
|
||||||
|
const auto settings_id = menu->FindItem(_("Add settings"));
|
||||||
|
if (settings_id != wxNOT_FOUND)
|
||||||
|
menu->Destroy(settings_id);
|
||||||
|
|
||||||
|
if (wxGetApp().get_view_mode() == ConfigMenuModeSimple)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto menu_item = new wxMenuItem(menu, wxID_ANY, _(L("Add settings")));
|
||||||
|
menu_item->SetBitmap(m_bmp_cog);
|
||||||
|
|
||||||
|
const auto sel_vol = get_selected_model_volume();
|
||||||
|
if (sel_vol && sel_vol->type() >= ModelVolume::SUPPORT_ENFORCER)
|
||||||
|
menu_item->Enable(false);
|
||||||
|
else
|
||||||
|
menu_item->SetSubMenu(create_settings_popupmenu(menu));
|
||||||
|
|
||||||
|
return menu->Append(menu_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMenuItem* ObjectList::append_menu_item_change_type(wxMenu* menu)
|
||||||
|
{
|
||||||
|
return append_menu_item(menu, wxID_ANY, _(L("Change type")), "",
|
||||||
|
[this](wxCommandEvent&) { change_part_type(); }, "", menu);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ObjectList::create_object_popupmenu(wxMenu *menu)
|
||||||
|
{
|
||||||
|
append_menu_items_add_volume(menu);
|
||||||
|
|
||||||
// Split object to parts
|
// Split object to parts
|
||||||
menu->AppendSeparator();
|
menu->AppendSeparator();
|
||||||
m_menu_item_split = menu_item_split(menu);
|
m_menu_item_split = append_menu_item_split(menu);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
menu->AppendSeparator();
|
menu->AppendSeparator();
|
||||||
// Append settings popupmenu
|
|
||||||
menu->Append(menu_item_settings(menu, false, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::create_sla_object_popupmenu(wxMenu *menu)
|
void ObjectList::create_sla_object_popupmenu(wxMenu *menu)
|
||||||
{
|
{
|
||||||
// Append settings popupmenu
|
|
||||||
menu->Append(menu_item_settings(menu, false, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectList::create_part_popupmenu(wxMenu *menu)
|
void ObjectList::create_part_popupmenu(wxMenu *menu)
|
||||||
{
|
{
|
||||||
m_menu_item_split_part = menu_item_split(menu);
|
m_menu_item_split_part = append_menu_item_split(menu);
|
||||||
|
|
||||||
// Append change part type
|
// Append change part type
|
||||||
menu->AppendSeparator();
|
menu->AppendSeparator();
|
||||||
append_menu_item(menu, wxID_ANY, _(L("Change type")), "",
|
append_menu_item_change_type(menu);
|
||||||
[this](wxCommandEvent&) { change_part_type(); }, "", menu);
|
|
||||||
|
|
||||||
// Append settings popupmenu
|
// Append settings popupmenu
|
||||||
menu->AppendSeparator();
|
menu->AppendSeparator();
|
||||||
m_menu_item_settings = menu_item_settings(menu, true, false);
|
|
||||||
menu->Append(m_menu_item_settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu* ObjectList::create_settings_popupmenu(wxMenu *parent_menu, bool is_part, const bool is_sla_menu)
|
wxMenu* ObjectList::create_settings_popupmenu(wxMenu *parent_menu)
|
||||||
{
|
{
|
||||||
wxMenu *menu = new wxMenu;
|
wxMenu *menu = new wxMenu;
|
||||||
|
|
||||||
settings_menu_hierarchy settings_menu;
|
settings_menu_hierarchy settings_menu;
|
||||||
get_options_menu(settings_menu, is_part, is_sla_menu);
|
const bool is_part = m_objects_model->GetParent(GetSelection()) != wxDataViewItem(0);
|
||||||
|
get_options_menu(settings_menu, is_part);
|
||||||
|
|
||||||
for (auto cat : settings_menu) {
|
for (auto cat : settings_menu) {
|
||||||
append_menu_item(menu, wxID_ANY, _(cat.first), "",
|
append_menu_item(menu, wxID_ANY, _(cat.first), "",
|
||||||
[menu, this, is_part](wxCommandEvent& event) { get_settings_choice(menu->GetLabel(event.GetId()), is_part); },
|
[menu, this](wxCommandEvent& event) { get_settings_choice(menu->GetLabel(event.GetId())); },
|
||||||
CATEGORY_ICON.find(cat.first) == CATEGORY_ICON.end() ? wxNullBitmap : CATEGORY_ICON.at(cat.first), parent_menu);
|
CATEGORY_ICON.find(cat.first) == CATEGORY_ICON.end() ? wxNullBitmap : CATEGORY_ICON.at(cat.first), parent_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,14 +121,16 @@ public:
|
|||||||
void on_drop_possible(wxDataViewEvent &event);
|
void on_drop_possible(wxDataViewEvent &event);
|
||||||
void on_drop(wxDataViewEvent &event);
|
void on_drop(wxDataViewEvent &event);
|
||||||
|
|
||||||
void get_settings_choice(const wxString& cat_name, const bool is_part);
|
void get_settings_choice(const wxString& category_name);
|
||||||
void menu_item_add_generic(wxMenuItem* &menu, const int type);
|
void append_menu_item_add_generic(wxMenuItem* menu, const int type);
|
||||||
wxMenuItem* menu_item_split(wxMenu* menu);
|
void append_menu_items_add_volume(wxMenu* menu);
|
||||||
wxMenuItem* menu_item_settings(wxMenu* menu, const bool is_part, const bool is_sla_menu);
|
wxMenuItem* append_menu_item_split(wxMenu* menu);
|
||||||
|
wxMenuItem* append_menu_item_settings(wxMenu* menu);
|
||||||
|
wxMenuItem* append_menu_item_change_type(wxMenu* menu);
|
||||||
void create_object_popupmenu(wxMenu *menu);
|
void create_object_popupmenu(wxMenu *menu);
|
||||||
void create_sla_object_popupmenu(wxMenu*menu);
|
void create_sla_object_popupmenu(wxMenu*menu);
|
||||||
void create_part_popupmenu(wxMenu*menu);
|
void create_part_popupmenu(wxMenu*menu);
|
||||||
wxMenu* create_settings_popupmenu(wxMenu *parent_menu, bool is_part, const bool is_sla_menu);
|
wxMenu* create_settings_popupmenu(wxMenu *parent_menu);
|
||||||
|
|
||||||
void update_opt_keys(t_config_option_keys& t_optopt_keys);
|
void update_opt_keys(t_config_option_keys& t_optopt_keys);
|
||||||
|
|
||||||
|
@ -908,7 +908,10 @@ struct Plater::priv
|
|||||||
|
|
||||||
// Object popup menu
|
// Object popup menu
|
||||||
wxMenu object_menu;
|
wxMenu object_menu;
|
||||||
wxMenuItem* item_sla_autorot = nullptr;
|
// Part popup menu
|
||||||
|
wxMenu part_menu;
|
||||||
|
// SLA-Object popup menu
|
||||||
|
wxMenu sla_object_menu;
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
Slic3r::DynamicPrintConfig *config;
|
Slic3r::DynamicPrintConfig *config;
|
||||||
@ -1033,8 +1036,14 @@ struct Plater::priv
|
|||||||
void on_update_geometry(Vec3dsEvent<2>&);
|
void on_update_geometry(Vec3dsEvent<2>&);
|
||||||
void on_3dcanvas_mouse_dragging_finished(SimpleEvent&);
|
void on_3dcanvas_mouse_dragging_finished(SimpleEvent&);
|
||||||
|
|
||||||
|
void update_object_menu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init_object_menu();
|
bool init_object_menu();
|
||||||
|
bool init_common_menu(wxMenu* menu, const bool is_part = false);
|
||||||
|
bool complit_init_object_menu();
|
||||||
|
bool complit_init_sla_object_menu();
|
||||||
|
bool complit_init_part_menu();
|
||||||
#if ENABLE_REMOVE_TABS_FROM_PLATER
|
#if ENABLE_REMOVE_TABS_FROM_PLATER
|
||||||
void init_view_toolbar();
|
void init_view_toolbar();
|
||||||
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
||||||
@ -2413,8 +2422,13 @@ void Plater::priv::on_right_click(Vec2dEvent& evt)
|
|||||||
if (obj_idx == -1)
|
if (obj_idx == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
wxMenu* menu = printer_technology == ptSLA ? &sla_object_menu :
|
||||||
|
get_selection().is_single_full_object() ? &object_menu : &part_menu;
|
||||||
|
|
||||||
|
sidebar->obj_list()->append_menu_item_settings(menu);
|
||||||
|
|
||||||
if (q != nullptr)
|
if (q != nullptr)
|
||||||
q->PopupMenu(&object_menu, (int)evt.data.x(), (int)evt.data.y());
|
q->PopupMenu(menu, (int)evt.data.x(), (int)evt.data.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
|
void Plater::priv::on_wipetower_moved(Vec3dEvent &evt)
|
||||||
@ -2442,30 +2456,63 @@ void Plater::priv::on_3dcanvas_mouse_dragging_finished(SimpleEvent&)
|
|||||||
|
|
||||||
bool Plater::priv::init_object_menu()
|
bool Plater::priv::init_object_menu()
|
||||||
{
|
{
|
||||||
wxMenuItem* item_delete = append_menu_item(&object_menu, wxID_ANY, _(L("Delete\tDel")), _(L("Remove the selected object")),
|
init_common_menu(&object_menu);
|
||||||
[this](wxCommandEvent&) { q->remove_selected(); }, "brick_delete.png");
|
complit_init_object_menu();
|
||||||
wxMenuItem* item_increase = append_menu_item(&object_menu, wxID_ANY, _(L("Increase copies\t+")), _(L("Place one more copy of the selected object")),
|
|
||||||
[this](wxCommandEvent&) { q->increase_instances(); }, "add.png");
|
|
||||||
wxMenuItem* item_decrease = append_menu_item(&object_menu, wxID_ANY, _(L("Decrease copies\t-")), _(L("Remove one copy of the selected object")),
|
|
||||||
[this](wxCommandEvent&) { q->decrease_instances(); }, "delete.png");
|
|
||||||
wxMenuItem* item_set_number_of_copies = append_menu_item(&object_menu, wxID_ANY, _(L("Set number of copies…")), _(L("Change the number of copies of the selected object")),
|
|
||||||
[this](wxCommandEvent&) { q->set_number_of_copies(); }, "textfield.png");
|
|
||||||
|
|
||||||
object_menu.AppendSeparator();
|
init_common_menu(&sla_object_menu);
|
||||||
|
complit_init_sla_object_menu();
|
||||||
|
|
||||||
|
init_common_menu(&part_menu, true);
|
||||||
|
complit_init_part_menu();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Plater::priv::init_common_menu(wxMenu* menu, const bool is_part/* = false*/)
|
||||||
|
{
|
||||||
|
wxMenuItem* item_delete = append_menu_item(menu, wxID_ANY, _(L("Delete\tDel")), _(L("Remove the selected object")),
|
||||||
|
[this](wxCommandEvent&) { q->remove_selected(); }, "brick_delete.png");
|
||||||
|
if (!is_part){
|
||||||
|
wxMenuItem* item_increase = append_menu_item(menu, wxID_ANY, _(L("Increase copies\t+")), _(L("Place one more copy of the selected object")),
|
||||||
|
[this](wxCommandEvent&) { q->increase_instances(); }, "add.png");
|
||||||
|
wxMenuItem* item_decrease = append_menu_item(menu, wxID_ANY, _(L("Decrease copies\t-")), _(L("Remove one copy of the selected object")),
|
||||||
|
[this](wxCommandEvent&) { q->decrease_instances(); }, "delete.png");
|
||||||
|
wxMenuItem* item_set_number_of_copies = append_menu_item(menu, wxID_ANY, _(L("Set number of copies…")), _(L("Change the number of copies of the selected object")),
|
||||||
|
[this](wxCommandEvent&) { q->set_number_of_copies(); }, "textfield.png");
|
||||||
|
if (q != nullptr)
|
||||||
|
{
|
||||||
|
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_increase_instances()); }, item_set_number_of_copies->GetId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menu->AppendSeparator();
|
||||||
|
|
||||||
wxMenu* mirror_menu = new wxMenu();
|
wxMenu* mirror_menu = new wxMenu();
|
||||||
if (mirror_menu == nullptr)
|
if (mirror_menu == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
append_menu_item(mirror_menu, wxID_ANY, _(L("Along X axis")), _(L("Mirror the selected object along the X axis")),
|
append_menu_item(mirror_menu, wxID_ANY, _(L("Along X axis")), _(L("Mirror the selected object along the X axis")),
|
||||||
[this](wxCommandEvent&) { mirror(X); }, "bullet_red.png", &object_menu);
|
[this](wxCommandEvent&) { mirror(X); }, "bullet_red.png", menu);
|
||||||
append_menu_item(mirror_menu, wxID_ANY, _(L("Along Y axis")), _(L("Mirror the selected object along the Y axis")),
|
append_menu_item(mirror_menu, wxID_ANY, _(L("Along Y axis")), _(L("Mirror the selected object along the Y axis")),
|
||||||
[this](wxCommandEvent&) { mirror(Y); }, "bullet_green.png", &object_menu);
|
[this](wxCommandEvent&) { mirror(Y); }, "bullet_green.png", menu);
|
||||||
append_menu_item(mirror_menu, wxID_ANY, _(L("Along Z axis")), _(L("Mirror the selected object along the Z axis")),
|
append_menu_item(mirror_menu, wxID_ANY, _(L("Along Z axis")), _(L("Mirror the selected object along the Z axis")),
|
||||||
[this](wxCommandEvent&) { mirror(Z); }, "bullet_blue.png", &object_menu);
|
[this](wxCommandEvent&) { mirror(Z); }, "bullet_blue.png", menu);
|
||||||
|
|
||||||
wxMenuItem* item_mirror = append_submenu(&object_menu, mirror_menu, wxID_ANY, _(L("Mirror")), _(L("Mirror the selected object")));
|
wxMenuItem* item_mirror = append_submenu(menu, mirror_menu, wxID_ANY, _(L("Mirror")), _(L("Mirror the selected object")));
|
||||||
|
|
||||||
|
// ui updates needs to be binded to the parent panel
|
||||||
|
if (q != nullptr)
|
||||||
|
{
|
||||||
|
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_mirror()); }, item_mirror->GetId());
|
||||||
|
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete_object()); }, item_delete->GetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Plater::priv::complit_init_object_menu()
|
||||||
|
{
|
||||||
wxMenu* split_menu = new wxMenu();
|
wxMenu* split_menu = new wxMenu();
|
||||||
if (split_menu == nullptr)
|
if (split_menu == nullptr)
|
||||||
return false;
|
return false;
|
||||||
@ -2477,25 +2524,57 @@ bool Plater::priv::init_object_menu()
|
|||||||
|
|
||||||
wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object")), "shape_ungroup.png");
|
wxMenuItem* item_split = append_submenu(&object_menu, split_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object")), "shape_ungroup.png");
|
||||||
|
|
||||||
// Add the automatic rotation sub-menu
|
// Append "Add..." popupmenu
|
||||||
item_sla_autorot = append_menu_item(&object_menu, wxID_ANY, _(L("Optimize orientation")), _(L("Optimize the rotation of the object for better print results.")),
|
object_menu.AppendSeparator();
|
||||||
[this](wxCommandEvent&) { sla_optimize_rotation(); });
|
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
|
||||||
|
|
||||||
if (printer_technology == ptFFF)
|
// object_menu.AppendSeparator();
|
||||||
item_sla_autorot = object_menu.Remove(item_sla_autorot);
|
|
||||||
|
|
||||||
// ui updates needs to be binded to the parent panel
|
// ui updates needs to be binded to the parent panel
|
||||||
if (q != nullptr)
|
if (q != nullptr)
|
||||||
{
|
{
|
||||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_mirror()); }, item_mirror->GetId());
|
|
||||||
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_increase_instances()); }, item_set_number_of_copies->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() || 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_objects()); }, item_split_objects->GetId());
|
||||||
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_volumes()); }, item_split_volumes->GetId());
|
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_volumes()); }, item_split_volumes->GetId());
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Plater::priv::complit_init_sla_object_menu()
|
||||||
|
{
|
||||||
|
wxMenuItem* item_split = append_menu_item(&sla_object_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object into individual objects")),
|
||||||
|
[this](wxCommandEvent&) { split_object(); }, "shape_ungroup_o.png");
|
||||||
|
|
||||||
|
// Add the automatic rotation sub-menu
|
||||||
|
append_menu_item(&sla_object_menu, wxID_ANY, _(L("Optimize orientation")), _(L("Optimize the rotation of the object for better print results.")),
|
||||||
|
[this](wxCommandEvent&) { sla_optimize_rotation(); });
|
||||||
|
|
||||||
|
// sla_object_menu.AppendSeparator();
|
||||||
|
|
||||||
|
// ui updates needs to be binded to the parent panel
|
||||||
|
if (q != nullptr)
|
||||||
|
{
|
||||||
|
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_objects()); }, item_split->GetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Plater::priv::complit_init_part_menu()
|
||||||
|
{
|
||||||
|
wxMenuItem* item_split = append_menu_item(&part_menu, wxID_ANY, _(L("Split")), _(L("Split the selected object into individual sub-parts")),
|
||||||
|
[this](wxCommandEvent&) { split_volume(); }, "shape_ungroup_p.png");
|
||||||
|
|
||||||
|
auto obj_list = sidebar->obj_list();
|
||||||
|
obj_list->append_menu_item_change_type(&part_menu);
|
||||||
|
|
||||||
|
// part_menu.AppendSeparator();
|
||||||
|
|
||||||
|
// ui updates needs to be binded to the parent panel
|
||||||
|
if (q != nullptr)
|
||||||
|
{
|
||||||
|
q->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_split_to_volumes()); }, item_split->GetId());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2555,8 +2634,11 @@ bool Plater::priv::can_split_to_objects() const
|
|||||||
|
|
||||||
bool Plater::priv::can_split_to_volumes() const
|
bool Plater::priv::can_split_to_volumes() const
|
||||||
{
|
{
|
||||||
int obj_idx = get_selected_object_idx();
|
if (printer_technology == ptSLA)
|
||||||
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts();
|
return false;
|
||||||
|
// int obj_idx = get_selected_object_idx();
|
||||||
|
// return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) && !model.objects[obj_idx]->is_multiparts();
|
||||||
|
return sidebar->obj_list()->is_splittable();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Plater::priv::layers_height_allowed() const
|
bool Plater::priv::layers_height_allowed() const
|
||||||
@ -2584,6 +2666,11 @@ bool Plater::priv::can_mirror() const
|
|||||||
return get_selection().is_from_single_instance();
|
return get_selection().is_from_single_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Plater::priv::update_object_menu()
|
||||||
|
{
|
||||||
|
sidebar->obj_list()->append_menu_items_add_volume(&object_menu);
|
||||||
|
}
|
||||||
|
|
||||||
// Plater / Public
|
// Plater / Public
|
||||||
|
|
||||||
Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
||||||
@ -3029,22 +3116,6 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool attached = false;
|
|
||||||
for(const wxMenuItem * m : p->object_menu.GetMenuItems())
|
|
||||||
if(m == p->item_sla_autorot) { attached = true; break; }
|
|
||||||
|
|
||||||
switch(printer_technology()) {
|
|
||||||
case ptFFF: {
|
|
||||||
// hide sla auto rotation menuitem
|
|
||||||
if(attached) p->item_sla_autorot = p->object_menu.Remove(p->item_sla_autorot);
|
|
||||||
std::cout << "sla autorot menu should be removed" << std::endl;
|
|
||||||
}
|
|
||||||
case ptSLA: {
|
|
||||||
// show sla auto rotation menuitem
|
|
||||||
if(!attached) p->object_menu.Append(p->item_sla_autorot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (update_scheduled)
|
if (update_scheduled)
|
||||||
update();
|
update();
|
||||||
|
|
||||||
@ -3135,4 +3206,6 @@ void Plater::changed_object(int obj_idx)
|
|||||||
|
|
||||||
void Plater::fix_through_netfabb(const int obj_idx) { p->fix_through_netfabb(obj_idx); }
|
void Plater::fix_through_netfabb(const int obj_idx) { p->fix_through_netfabb(obj_idx); }
|
||||||
|
|
||||||
|
void Plater::update_object_menu() { p->update_object_menu(); }
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
|
@ -157,6 +157,8 @@ public:
|
|||||||
void on_extruders_change(int extruders_count);
|
void on_extruders_change(int extruders_count);
|
||||||
void on_config_change(const DynamicPrintConfig &config);
|
void on_config_change(const DynamicPrintConfig &config);
|
||||||
|
|
||||||
|
void update_object_menu();
|
||||||
|
|
||||||
const wxString& get_project_filename() const;
|
const wxString& get_project_filename() const;
|
||||||
bool is_export_gcode_scheduled() const;
|
bool is_export_gcode_scheduled() const;
|
||||||
|
|
||||||
|
@ -24,13 +24,11 @@ wxMenuItem* append_menu_item(wxMenu* menu, int id, const wxString& string, const
|
|||||||
wxMenuItem* item = menu->Append(id, string, description);
|
wxMenuItem* item = menu->Append(id, string, description);
|
||||||
item->SetBitmap(icon);
|
item->SetBitmap(icon);
|
||||||
|
|
||||||
if (event_handler != nullptr && event_handler != menu)
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
if (event_handler != nullptr && event_handler != menu)
|
||||||
event_handler->Bind(wxEVT_MENU, cb, id);
|
event_handler->Bind(wxEVT_MENU, cb, id);
|
||||||
#else
|
|
||||||
menu->Bind(wxEVT_MENU, cb, id);
|
|
||||||
#endif
|
|
||||||
else
|
else
|
||||||
|
#endif // __WXMSW__
|
||||||
menu->Bind(wxEVT_MENU, cb, id);
|
menu->Bind(wxEVT_MENU, cb, id);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user