From 3e549c153d508ba2cd5cea41ee8bd35b53b87596 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 15 Aug 2018 11:18:20 +0200 Subject: [PATCH] Improvement of extruder selection for the object/part according to the actually extruders count --- xs/src/slic3r/GUI/GUI_ObjectParts.cpp | 35 ++++++++++++++++++--------- xs/src/slic3r/GUI/GUI_ObjectParts.hpp | 3 +++ xs/src/slic3r/GUI/Tab.cpp | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 8f74158e9..616f0dc57 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -8,7 +8,6 @@ #include "../../libslic3r/Utils.hpp" #include -#include #include #include #include "Geometry.hpp" @@ -210,6 +209,18 @@ wxPoint get_mouse_position_in_control() { pt.y - win->GetScreenPosition().y); } +wxDataViewColumn* object_ctrl_create_extruder_column(int extruders_count) +{ + wxArrayString choices; + choices.Add("default"); + for (int i = 1; i <= extruders_count; ++i) + choices.Add(wxString::Format("%d", i)); + wxDataViewChoiceRenderer *c = + new wxDataViewChoiceRenderer(choices, wxDATAVIEW_CELL_EDITABLE, wxALIGN_CENTER_HORIZONTAL); + wxDataViewColumn* column = new wxDataViewColumn(_(L("Extruder")), c, 3, 60, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); + return column; +} + void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz) { m_objects_ctrl = new wxDataViewCtrl(win, wxID_ANY, wxDefaultPosition, wxDefaultSize); @@ -238,17 +249,7 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz) wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); // column 3 of the view control: - wxArrayString choices; - choices.Add("default"); - choices.Add("1"); - choices.Add("2"); - choices.Add("3"); - choices.Add("4"); - wxDataViewChoiceRenderer *c = - new wxDataViewChoiceRenderer(choices, wxDATAVIEW_CELL_EDITABLE, wxALIGN_CENTER_HORIZONTAL); - wxDataViewColumn *column3 = - new wxDataViewColumn(_(L("Extruder")), c, 3, 60, wxALIGN_CENTER_HORIZONTAL, wxDATAVIEW_COL_RESIZABLE); - m_objects_ctrl->AppendColumn(column3); + m_objects_ctrl->AppendColumn(object_ctrl_create_extruder_column(4)); // column 4 of the view control: m_objects_ctrl->AppendBitmapColumn(" ", 4, wxDATAVIEW_CELL_INERT, 25, @@ -1608,5 +1609,15 @@ void on_drop(wxDataViewEvent &event) g_prevent_list_events = false; } +void update_objects_list_extruder_column(const int extruders_count) +{ + // delete old 3rd column + m_objects_ctrl->DeleteColumn(m_objects_ctrl->GetColumnAt(3)); + // insert new created 3rd column + m_objects_ctrl->InsertColumn(3, object_ctrl_create_extruder_column(extruders_count)); + // set show/hide for this column + set_extruder_column_hidden(extruders_count <= 1); +} + } //namespace GUI } //namespace Slic3r \ No newline at end of file diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp index f9fffb58b..15be90bbf 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp @@ -118,6 +118,9 @@ void on_begin_drag(wxDataViewEvent &event); void on_drop_possible(wxDataViewEvent &event); void on_drop(wxDataViewEvent &event); +// update extruder column for objects_ctrl according to extruders count +void update_objects_list_extruder_column(const int extruders_count); + } //namespace GUI } //namespace Slic3r #endif //slic3r_GUI_ObjectParts_hpp_ \ No newline at end of file diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index 8fbedb121..c4736a2dd 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -1698,6 +1698,7 @@ void TabPrinter::extruders_count_changed(size_t extruders_count){ build_extruder_pages(); reload_config(); on_value_change("extruders_count", extruders_count); + update_objects_list_extruder_column(extruders_count); } void TabPrinter::append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key) @@ -2010,7 +2011,6 @@ void Tab::load_current_preset() const Preset* parent_preset = m_presets->get_selected_preset_parent(); static_cast(this)->m_sys_extruders_count = parent_preset == nullptr ? 0 : static_cast(parent_preset->config.option("nozzle_diameter"))->values.size(); - set_extruder_column_hidden(static_cast(this)->m_sys_extruders_count <= 1); } m_opt_status_value = (m_presets->get_selected_preset_parent() ? osSystemValue : 0) | osInitValue; init_options_list();