diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 64c698a9b..4c42994ee 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -475,23 +475,26 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent, const int label_width) : option.opt.sidetext = " "; line.append_option(option); - auto wiping_dialog_btn = [config, this](wxWindow* parent) { + auto wiping_dialog_btn = [this](wxWindow* parent) { m_wiping_dialog_button = new wxButton(parent, wxID_ANY, _(L("Purging volumes")) + dots, wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(m_wiping_dialog_button); m_wiping_dialog_button->Bind(wxEVT_BUTTON, ([parent](wxCommandEvent& e) { - auto &config = wxGetApp().preset_bundle->project_config; - const std::vector &init_matrix = (config.option("wiping_volumes_matrix"))->values; - const std::vector &init_extruders = (config.option("wiping_volumes_extruders"))->values; + auto &project_config = wxGetApp().preset_bundle->project_config; + const std::vector &init_matrix = (project_config.option("wiping_volumes_matrix"))->values; + const std::vector &init_extruders = (project_config.option("wiping_volumes_extruders"))->values; - WipingDialog dlg(parent, cast(init_matrix), cast(init_extruders)); + const DynamicPrintConfig* config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; + const std::vector &extruder_colours = (config->option("extruder_colour"))->values; + + WipingDialog dlg(parent, cast(init_matrix), cast(init_extruders), extruder_colours); if (dlg.ShowModal() == wxID_OK) { std::vector matrix = dlg.get_matrix(); std::vector extruders = dlg.get_extruders(); - (config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(), matrix.end()); - (config.option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(), extruders.end()); + (project_config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(), matrix.end()); + (project_config.option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(), extruders.end()); wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent)); } })); diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 4c2b2480e..d93852da2 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -1,6 +1,7 @@ #include #include #include "WipeTowerDialog.hpp" +#include "PresetBundle.hpp" #include "GUI.hpp" #include "I18N.hpp" #include "GUI_App.hpp" @@ -137,11 +138,11 @@ std::string RammingPanel::get_parameters() // Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button to toggle simple/advanced mode: -WipingDialog::WipingDialog(wxWindow* parent,const std::vector& matrix, const std::vector& extruders) +WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, const std::vector& extruder_colours) : wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { auto widget_button = new wxButton(this,wxID_ANY,"-",wxPoint(0,0),wxDefaultSize); - m_panel_wiping = new WipingPanel(this,matrix,extruders, widget_button); + m_panel_wiping = new WipingPanel(this,matrix,extruders, extruder_colours, widget_button); auto main_sizer = new wxBoxSizer(wxVERTICAL); @@ -180,7 +181,7 @@ void WipingPanel::format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_ } // This panel contains all control widgets for both simple and advanced mode (these reside in separate sizers) -WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, wxButton* widget_button) +WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, const std::vector& extruder_colours, wxButton* widget_button) : wxPanel(parent,wxID_ANY, wxDefaultPosition, wxDefaultSize/*,wxBORDER_RAISED*/) { m_widget_button = widget_button; // pointer to the button in parent dialog @@ -188,6 +189,12 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con m_number_of_extruders = (int)(sqrt(matrix.size())+0.001); + for (const std::string& color : extruder_colours) { + unsigned char rgb[3]; + Slic3r::PresetBundle::parse_color(color, rgb); + m_colours.push_back(wxColor(rgb[0], rgb[1], rgb[2])); + } + // Create two switched panels with their own sizers m_sizer_simple = new wxBoxSizer(wxVERTICAL); m_sizer_advanced = new wxBoxSizer(wxVERTICAL); @@ -212,13 +219,31 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con } } m_gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString(""))); - for (unsigned int i = 0; i < m_number_of_extruders; ++i) - m_gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); for (unsigned int i = 0; i < m_number_of_extruders; ++i) { - m_gridsizer_advanced->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); - for (unsigned int j = 0; j < m_number_of_extruders; ++j) - m_gridsizer_advanced->Add(edit_boxes[j][i], 0); - } + auto hsizer = new wxBoxSizer(wxHORIZONTAL); + hsizer->AddSpacer(20); + hsizer->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER); + wxWindow* w = new wxWindow(m_page_advanced, wxID_ANY, wxDefaultPosition, wxSize(25, 25), wxBORDER_SIMPLE); + w->SetCanFocus(false); + w->SetBackgroundColour(m_colours[i]); + hsizer->AddSpacer(10); + hsizer->Add(w); + m_gridsizer_advanced->Add(hsizer); + } + for (unsigned int i = 0; i < m_number_of_extruders; ++i) { + auto hsizer = new wxBoxSizer(wxHORIZONTAL); + wxWindow* w = new wxWindow(m_page_advanced, wxID_ANY, wxDefaultPosition, wxSize(25, 25), wxBORDER_SIMPLE); + w->SetCanFocus(false); + w->SetBackgroundColour(m_colours[i]); + hsizer->AddSpacer(20); + hsizer->Add(new wxStaticText(m_page_advanced, wxID_ANY, wxString("") << i + 1), 0, wxALIGN_CENTER | wxALIGN_CENTER_VERTICAL); + hsizer->AddSpacer(10); + hsizer->Add(w); + m_gridsizer_advanced->Add(hsizer); + + for (unsigned int j = 0; j < m_number_of_extruders; ++j) + m_gridsizer_advanced->Add(edit_boxes[j][i], 0); + } // collect and format sizer format_sizer(m_sizer_advanced, m_page_advanced, m_gridsizer_advanced, @@ -237,7 +262,16 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, con for (unsigned int i=0;iAdd(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("Tool #"))) << i + 1 << ": "), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + auto hsizer = new wxBoxSizer(wxHORIZONTAL); + wxWindow* w = new wxWindow(m_page_simple, wxID_ANY, wxDefaultPosition, wxSize(25, 25), wxBORDER_SIMPLE); + w->SetCanFocus(false); + w->SetBackgroundColour(m_colours[i]); + hsizer->Add(w, wxALIGN_CENTER_VERTICAL); + hsizer->AddSpacer(10); + hsizer->Add(new wxStaticText(m_page_simple, wxID_ANY, wxString(_(L("Tool #"))) << i + 1 << ": "), 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); + + gridsizer_simple->Add(hsizer, wxALIGN_CENTER_VERTICAL); gridsizer_simple->Add(m_old.back(),0); gridsizer_simple->Add(m_new.back(),0); } diff --git a/src/slic3r/GUI/WipeTowerDialog.hpp b/src/slic3r/GUI/WipeTowerDialog.hpp index d858062da..84b9921de 100644 --- a/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/src/slic3r/GUI/WipeTowerDialog.hpp @@ -46,7 +46,7 @@ private: class WipingPanel : public wxPanel { public: - WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, wxButton* widget_button); + WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, const std::vector& extruder_colours, wxButton* widget_button); std::vector read_matrix_values(); std::vector read_extruders_values(); void toggle_advanced(bool user_action = false); @@ -59,6 +59,7 @@ private: std::vector m_old; std::vector m_new; std::vector> edit_boxes; + std::vector m_colours; unsigned int m_number_of_extruders = 0; bool m_advanced = false; wxPanel* m_page_simple = nullptr; @@ -76,7 +77,7 @@ private: class WipingDialog : public wxDialog { public: - WipingDialog(wxWindow* parent,const std::vector& matrix, const std::vector& extruders); + WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruders, const std::vector& extruder_colours); std::vector get_matrix() const { return m_output_matrix; } std::vector get_extruders() const { return m_output_extruders; }