Extruder selection for multiple selected objects/parts.

A Menu with colored icons is used now instead of wxGetSingleChoice.
All menus for extruder selection use colored icon
This commit is contained in:
YuSanka 2020-02-17 11:26:40 +01:00
parent 860571d51d
commit 3631e938b2
3 changed files with 33 additions and 25 deletions

View file

@ -1122,6 +1122,8 @@ void Control::append_change_extruder_menu_item(wxMenu* menu, bool switch_current
{
std::array<int, 2> active_extruders = get_active_extruders_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value);
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
wxMenu* change_extruder_menu = new wxMenu();
for (int i = 1; i <= extruders_cnt; i++)
@ -1132,7 +1134,7 @@ void Control::append_change_extruder_menu_item(wxMenu* menu, bool switch_current
if (m_mode == t_mode::MultiAsSingle)
append_menu_item(change_extruder_menu, wxID_ANY, item_name, "",
[this, i](wxCommandEvent&) { add_code_as_tick(ToolChangeCode, i); }, "", menu,
[this, i](wxCommandEvent&) { add_code_as_tick(ToolChangeCode, i); }, *icons[i-1], menu,
[is_active_extruder]() { return !is_active_extruder; }, GUI::wxGetApp().plater());
}

View file

@ -1676,29 +1676,37 @@ void ObjectList::append_menu_item_change_extruder(wxMenu* menu)
if (extruders_cnt <= 1)
return;
if (!GetSelection().IsOk())
append_menu_item(menu, wxID_ANY, names[1],
_(L("Select extruder number for selected objects and/or parts")),
[this](wxCommandEvent&) { extruder_selection(); }, "", menu);
else
{
DynamicPrintConfig& config = get_item_config(GetSelection());
wxDataViewItemArray sels;
GetSelections(sels);
if (sels.IsEmpty())
return;
const int initial_extruder = !config.has("extruder") ? 0 :
config.option<ConfigOptionInt>("extruder")->value;
std::vector<wxBitmap*> icons = get_extruder_color_icons(true);
wxMenu* extruder_selection_menu = new wxMenu();
const wxString& name = sels.Count()==1 ? names[0] : names[1];
wxMenu* extruder_selection_menu = new wxMenu();
for (int i = 0; i <= extruders_cnt; i++)
{
const wxString& item_name = i == 0 ? _(L("Default")) : wxString::Format("%d", i);
append_menu_radio_item(extruder_selection_menu, wxID_ANY, item_name, "",
[this, i](wxCommandEvent&) { set_extruder_for_selected_items(i); }, menu)->Check(i == initial_extruder);
}
menu->AppendSubMenu(extruder_selection_menu, names[0], _(L("Select new extruder for the object/part")));
int initial_extruder = -1; // negative value for multiple object/part selection
if (sels.Count()==1) {
DynamicPrintConfig& config = get_item_config(sels[0]);
initial_extruder = !config.has("extruder") ? 0 :
config.option<ConfigOptionInt>("extruder")->value;
}
for (int i = 0; i <= extruders_cnt; i++)
{
bool is_active_extruder = i == initial_extruder;
int icon_idx = i == 0 ? 0 : i - 1;
const wxString& item_name = (i == 0 ? _(L("Default")) : wxString::Format(_(L("Extruder %d")), i)) +
(is_active_extruder ? " (" + _(L("active")) + ")" : "");
append_menu_item(extruder_selection_menu, wxID_ANY, item_name, "",
[this, i](wxCommandEvent&) { set_extruder_for_selected_items(i); }, *icons[icon_idx], menu,
[is_active_extruder]() { return !is_active_extruder; }, GUI::wxGetApp().plater());
}
menu->AppendSubMenu(extruder_selection_menu, name);
}
void ObjectList::append_menu_item_delete(wxMenu* menu)
@ -3937,9 +3945,7 @@ void ObjectList::show_multi_selection_menu()
wxMenu* menu = new wxMenu();
if (extruders_count() > 1)
append_menu_item(menu, wxID_ANY, _(L("Set extruder for selected items")),
_(L("Select extruder number for selected objects and/or parts")),
[this](wxCommandEvent&) { extruder_selection(); }, "", menu);
append_menu_item_change_extruder(menu);
append_menu_item(menu, wxID_ANY, _(L("Reload from disk")), _(L("Reload the selected volumes from disk")),
[this](wxCommandEvent&) { wxGetApp().plater()->reload_from_disk(); }, "", menu, []() {

View file

@ -543,7 +543,7 @@ std::vector<wxBitmap*> get_extruder_color_icons(bool thin_icon/* = false*/)
* and scale them in respect to em_unit value
*/
const double em = Slic3r::GUI::wxGetApp().em_unit();
const int icon_width = lround((thin_icon ? 1 : 3.2) * em);
const int icon_width = lround((thin_icon ? 1.6 : 3.2) * em);
const int icon_height = lround(1.6 * em);
for (const std::string& color : colors)