From 12932832ae793b142f66e2a9c6d9a5fd819e4125 Mon Sep 17 00:00:00 2001 From: "liz.li" Date: Sat, 12 Oct 2024 14:32:06 +0800 Subject: [PATCH] ENH: filament preset edit menu should not change to self jira: new Change-Id: Ia8eb3db05f83932d2eb0b8ef2ba8014e99c8e057 --- src/slic3r/GUI/GUI_Factories.cpp | 11 +++++++---- src/slic3r/GUI/GUI_Factories.hpp | 4 ++-- src/slic3r/GUI/Plater.cpp | 4 ++-- src/slic3r/GUI/Plater.hpp | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index dd75c573d..8d399b7d6 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -1361,7 +1361,7 @@ void MenuFactory::create_cut_cutter_menu() append_menu_item_change_type(menu); } -void MenuFactory::create_filament_action_menu(bool init) +void MenuFactory::create_filament_action_menu(bool init, int active_filament_menu_id) { wxMenu *menu = &m_filament_action_menu; @@ -1380,6 +1380,9 @@ void MenuFactory::create_filament_action_menu(bool init) std::vector icons = get_extruder_color_icons(true); int filaments_cnt = icons.size(); for (int i = 0; i < filaments_cnt; i++) { + if (i == active_filament_menu_id) + continue; + auto preset = wxGetApp().preset_bundle->filaments.find_preset(wxGetApp().preset_bundle->filament_presets[i]); wxString item_name = preset ? from_u8(preset->label(false)) : wxString::Format(_L("Filament %d"), i + 1); @@ -1501,7 +1504,7 @@ void MenuFactory::init(wxWindow* parent) //BBS: add part plate related logic create_plate_menu(); - create_filament_action_menu(true); + create_filament_action_menu(true, -1); // create "Instance to Object" menu item append_menu_item_instance_to_object(&m_instance_menu); @@ -1680,8 +1683,8 @@ wxMenu* MenuFactory::assemble_multi_selection_menu() return menu; } -wxMenu *MenuFactory::filament_action_menu() { - create_filament_action_menu(false); +wxMenu *MenuFactory::filament_action_menu(int active_filament_menu_id) { + create_filament_action_menu(false, active_filament_menu_id); return &m_filament_action_menu; } diff --git a/src/slic3r/GUI/GUI_Factories.hpp b/src/slic3r/GUI/GUI_Factories.hpp index cac903ffe..f2b1510fe 100644 --- a/src/slic3r/GUI/GUI_Factories.hpp +++ b/src/slic3r/GUI/GUI_Factories.hpp @@ -79,7 +79,7 @@ public: wxMenu* assemble_part_menu(); wxMenu* assemble_multi_selection_menu(); - wxMenu *filament_action_menu(); + wxMenu *filament_action_menu(int active_filament_menu_id); private: enum MenuType { @@ -134,7 +134,7 @@ private: void create_bbl_assemble_part_menu(); void create_cut_cutter_menu(); - void create_filament_action_menu(bool init); + void create_filament_action_menu(bool init, int active_filament_menu_id); wxMenu* append_submenu_add_generic(wxMenu* menu, ModelVolumeType type); void append_menu_item_add_svg(wxMenu *menu, ModelVolumeType type, bool is_submenu_item = true); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 1ca7a4646..626faa675 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1337,7 +1337,7 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame PlaterPresetComboBox* combobox = (*combo); edit_btn->Bind(wxEVT_BUTTON, [this, edit_btn, filament_idx](wxCommandEvent) { - auto menu = p->plater->filament_action_menu(); + auto menu = p->plater->filament_action_menu(filament_idx); wxPoint pt { 0, edit_btn->GetSize().GetHeight() + 10 }; pt = edit_btn->ClientToScreen(pt); pt = wxGetApp().mainframe->ScreenToClient(pt); @@ -15223,7 +15223,7 @@ wxMenu* Plater::instance_menu() { return p->menus.instance_menu(); wxMenu* Plater::layer_menu() { return p->menus.layer_menu(); } wxMenu* Plater::multi_selection_menu() { return p->menus.multi_selection_menu(); } wxMenu *Plater::assemble_multi_selection_menu() { return p->menus.assemble_multi_selection_menu(); } -wxMenu *Plater::filament_action_menu() { return p->menus.filament_action_menu(); } +wxMenu *Plater::filament_action_menu(int active_filament_menu_id) { return p->menus.filament_action_menu(active_filament_menu_id); } int Plater::GetPlateIndexByRightMenuInLeftUI() { return p->m_is_RightClickInLeftUI; } void Plater::SetPlateIndexByRightMenuInLeftUI(int index) { p->m_is_RightClickInLeftUI = index; } SuppressBackgroundProcessingUpdate::SuppressBackgroundProcessingUpdate() : diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 69544d077..927871136 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -745,7 +745,7 @@ public: wxMenu* layer_menu(); wxMenu* multi_selection_menu(); wxMenu* assemble_multi_selection_menu(); - wxMenu* filament_action_menu(); + wxMenu* filament_action_menu(int active_filament_menu_id); int GetPlateIndexByRightMenuInLeftUI(); void SetPlateIndexByRightMenuInLeftUI(int); static bool has_illegal_filename_characters(const wxString& name);