diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index b5e9c6ff09..762c5cdaae 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -1710,6 +1710,8 @@ std::pair PresetBundle::load_configbundle( return std::make_pair(std::move(substitutions), presets_loaded + ph_printers_loaded); } + + void PresetBundle::update_multi_material_filament_presets() { if (printers.get_edited_preset().printer_technology() != ptFFF) @@ -1733,17 +1735,21 @@ void PresetBundle::update_multi_material_filament_presets() std::vector old_matrix = this->project_config.option("wiping_volumes_matrix")->values; size_t old_number_of_extruders = size_t(std::sqrt(old_matrix.size())+EPSILON); if (num_extruders != old_number_of_extruders) { - const double default_purge = static_cast(printers.get_edited_preset().config.option("multimaterial_purging"))->value; + + // Extract the relevant config options, even values from possibly modified presets. + const double default_purge = static_cast(this->printers.get_edited_preset().config.option("multimaterial_purging"))->value; + const std::vector filament_purging_multipliers = get_config_options_for_current_filaments("filament_purge_multiplier"); std::vector new_matrix; - for (unsigned int i=0;iproject_config.option("wiping_volumes_matrix")->values = new_matrix; } } diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 1e6aa1caa1..bb9d9ee41a 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -63,6 +63,30 @@ public: void cache_extruder_filaments_names(); void reset_extruder_filaments(); + // Another hideous function related to current ExtruderFilaments hack. Returns a vector of values + // of a given config option for all currently used filaments. Modified value is returned for modified preset. + // Must be called with the vector ConfigOption type, e.g. ConfigOptionPercents. + template + auto get_config_options_for_current_filaments(const t_config_option_key& key) + { + decltype(T::values) out; + const Preset& edited_preset = this->filaments.get_edited_preset(); + for (const ExtruderFilaments& extr_filament : this->extruders_filaments) { + const Preset& selected_preset = *extr_filament.get_selected_preset(); + const Preset& preset = edited_preset.name == selected_preset.name ? edited_preset : selected_preset; + const T* co = preset.config.opt(key); + if (co) { + assert(co->values.size() == 1); + out.push_back(co->values.back()); + } else { + // Key is missing or type mismatch. + } + } + return out; + } + + + PresetCollection& get_presets(Preset::Type preset_type); // The project configuration values are kept separated from the print/filament/printer preset, diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index bb18a4d787..21968281bd 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2149,7 +2149,7 @@ void PrintConfigDef::init_fff_params() def->tooltip = L(""); def->sidetext = L("mm³"); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionFloat(70)); + def->set_default_value(new ConfigOptionFloat(140.)); def = this->add("perimeter_acceleration", coFloat); def->label = L("Perimeters"); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3921c5c354..bb96ebe41e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -518,12 +518,16 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) : sizer->Add(m_wiping_dialog_button, 0, wxALIGN_CENTER_VERTICAL); m_wiping_dialog_button->Bind(wxEVT_BUTTON, ([parent](wxCommandEvent& e) { - auto &project_config = wxGetApp().preset_bundle->project_config; + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + DynamicPrintConfig& project_config = preset_bundle->project_config; const std::vector &init_matrix = (project_config.option("wiping_volumes_matrix"))->values; - const std::vector extruder_colours = wxGetApp().plater()->get_extruder_colors_from_plater_config(); - WipingDialog dlg(parent, cast(init_matrix), extruder_colours); + // Extract the relevant config options, even values from possibly modified presets. + const double default_purge = static_cast(preset_bundle->printers.get_edited_preset().config.option("multimaterial_purging"))->value; + std::vector filament_purging_multipliers = preset_bundle->get_config_options_for_current_filaments("filament_purge_multiplier"); + + WipingDialog dlg(parent, cast(init_matrix), extruder_colours, default_purge, filament_purging_multipliers); if (dlg.ShowModal() == wxID_OK) { std::vector matrix = dlg.get_matrix(); diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 9dab4d96e9..6ad1a5644a 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -189,8 +189,9 @@ std::string RammingPanel::get_parameters() // Parent dialog for purging volume adjustments - it fathers WipingPanel widget (that contains all controls) and a button. -WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours) -: wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) +WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours, + double printer_purging_volume, const std::vector& filament_purging_multipliers) + : wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { SetFont(wxGetApp().normal_font()); update_ui(this); @@ -202,7 +203,7 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, c m_radio_button2 = new wxRadioButton(this, wxID_ANY, _L("Custom project-specific settings")); auto stb = new wxStaticBox(this, wxID_ANY, wxEmptyString); - m_panel_wiping = new WipingPanel(this,matrix, extruder_colours, m_widget_button); + m_panel_wiping = new WipingPanel(this, matrix, extruder_colours, filament_purging_multipliers, printer_purging_volume, m_widget_button); update_ui(m_radio_button1); update_ui(m_radio_button2); @@ -247,12 +248,15 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, c EndModal(wxID_OK); },wxID_OK); - this->Bind(wxEVT_RADIOBUTTON, [this](wxCommandEvent& evt) { - wxRadioButton* rdb = dynamic_cast(FindWindowById(evt.GetId())); - m_widget_button->Enable(rdb == m_radio_button2); - m_panel_wiping->Enable(rdb == m_radio_button2); + this->Bind(wxEVT_RADIOBUTTON, [this](wxCommandEvent&) { + enable_or_disable_panel(); }); + const bool start_default = should_start_as_default(); + m_radio_button1->SetValue(start_default); + m_radio_button2->SetValue(! start_default); + enable_or_disable_panel(); + this->Show(); } @@ -267,11 +271,24 @@ void WipingPanel::format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_ } -WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours, wxButton* widget_button) +WipingPanel::WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours, + const std::vector& filament_purging_multipliers, double printer_purging_volume, wxButton* widget_button) : wxPanel(parent,wxID_ANY, wxDefaultPosition, wxDefaultSize/*,wxBORDER_RAISED*/) { + m_filament_purging_multipliers = filament_purging_multipliers; + m_printer_purging_volume = printer_purging_volume; m_widget_button = widget_button; // pointer to the button in parent dialog - m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){ }); + m_widget_button->Bind(wxEVT_BUTTON,[this](wxCommandEvent&){ + // Set the matrix to defaults. + for (size_t i = 0; i < m_number_of_extruders; ++i) { + for (size_t j = 0; j < m_number_of_extruders; ++j) { + if (i != j) { + double def_val = m_printer_purging_volume * m_filament_purging_multipliers[j] / 100.; + edit_boxes[j][i]->SetValue(wxString("") << int(def_val)); + } + } + } + }); m_number_of_extruders = (int)(sqrt(matrix.size())+0.001); @@ -375,3 +392,18 @@ std::vector WipingPanel::read_matrix_values() { } return output; } + + + +bool WipingDialog::should_start_as_default() const +{ + return true; +} + + +void WipingDialog::enable_or_disable_panel() +{ + bool enable = m_radio_button2->GetValue(); + m_widget_button->Enable(enable); + m_panel_wiping->Enable(enable); +} \ No newline at end of file diff --git a/src/slic3r/GUI/WipeTowerDialog.hpp b/src/slic3r/GUI/WipeTowerDialog.hpp index b7daf33fc2..d07ecfdf66 100644 --- a/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/src/slic3r/GUI/WipeTowerDialog.hpp @@ -51,7 +51,8 @@ private: class WipingPanel : public wxPanel { public: - WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours, wxButton* widget_button); + WipingPanel(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours, + const std::vector& filament_purging_multipliers, double printer_purging_volume, wxButton* widget_button); std::vector read_matrix_values(); void format_sizer(wxSizer* sizer, wxPanel* page, wxGridSizer* grid_sizer, const wxString& table_title, int table_lshift=0); @@ -64,6 +65,8 @@ private: wxBoxSizer* m_sizer_advanced = nullptr; wxGridSizer* m_gridsizer_advanced = nullptr; wxButton* m_widget_button = nullptr; + double m_printer_purging_volume; + std::vector m_filament_purging_multipliers; // In percents ! }; @@ -72,16 +75,20 @@ private: class WipingDialog : public wxDialog { public: - WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours); + WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours, + double printer_purging_volume, const std::vector& filament_purging_multipliers); std::vector get_matrix() const { return m_output_matrix; } private: - WipingPanel* m_panel_wiping = nullptr; + bool should_start_as_default() const; + void enable_or_disable_panel(); + + WipingPanel* m_panel_wiping = nullptr; std::vector m_output_matrix; - wxRadioButton* m_radio_button1 = nullptr; - wxRadioButton* m_radio_button2 = nullptr; - wxButton* m_widget_button = nullptr; + wxRadioButton* m_radio_button1 = nullptr; + wxRadioButton* m_radio_button2 = nullptr; + wxButton* m_widget_button = nullptr; }; #endif // _WIPE_TOWER_DIALOG_H_ \ No newline at end of file