diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 762c5cdaae..b8b4f82b52 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -38,7 +38,8 @@ namespace Slic3r { static std::vector s_project_options { "colorprint_heights", - "wiping_volumes_matrix" + "wiping_volumes_matrix", + "wiping_volumes_use_custom_matrix" }; const char *PresetBundle::PRUSA_BUNDLE = "PrusaResearch"; diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 94fee1e1fc..146994c201 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -246,6 +246,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n || opt_key == "wipe_tower_no_sparse_layers" || opt_key == "wipe_tower_extruder" || opt_key == "wiping_volumes_matrix" + || opt_key == "wiping_volumes_use_custom_matrix" || opt_key == "parking_pos_retraction" || opt_key == "cooling_tube_retraction" || opt_key == "cooling_tube_length" diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 21968281bd..62a12bf0eb 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3310,6 +3310,11 @@ void PrintConfigDef::init_fff_params() 140., 140., 140., 0., 140., 140., 140., 140., 140., 0. }); + def = this->add("wiping_volumes_use_custom_matrix", coBool); + def->label = L(""); + def->tooltip = L(""); + def->set_default_value(new ConfigOptionBool{ false }); + def = this->add("wipe_tower_x", coFloat); def->label = L("Position X"); def->tooltip = L("X coordinate of the left front corner of a wipe tower"); @@ -4526,6 +4531,26 @@ void PrintConfigDef::handle_legacy_composite(DynamicPrintConfig &config) config.set_key_value("thumbnails", new ConfigOptionString(thumbnails_str)); } } + + if (config.has("wiping_volumes_matrix") && !config.has("wiping_volumes_use_custom_matrix")) { + // This is apparently some pre-2.7.3 config, where the wiping_volumes_matrix was always used. + // The 2.7.3 introduced an option to use defaults derived from config. In case the matrix + // contains only default values, switch it to default behaviour. The default values + // were zeros on the diagonal and 140 otherwise. + std::vector matrix = config.opt("wiping_volumes_matrix")->values; + int num_of_extruders = int(std::sqrt(matrix.size()) + 0.5); + int i = -1; + bool custom = false; + for (int j = 0; j < int(matrix.size()); ++j) { + if (j % num_of_extruders == 0) + ++i; + if (i != j % num_of_extruders && !is_approx(matrix[j], 140.)) { + custom = true; + break; + } + } + config.set_key_value("wiping_volumes_use_custom_matrix", new ConfigOptionBool(custom)); + } } const PrintConfigDef print_config_def; diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index f5f63c5720..09e6612d3b 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -883,6 +883,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionFloat, wipe_tower_bridging)) ((ConfigOptionInt, wipe_tower_extruder)) ((ConfigOptionFloats, wiping_volumes_matrix)) + ((ConfigOptionBool, wiping_volumes_use_custom_matrix)) ((ConfigOptionFloat, z_offset)) ) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index bb96ebe41e..a8d5ba2df0 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -520,6 +520,7 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) : { PresetBundle* preset_bundle = wxGetApp().preset_bundle; DynamicPrintConfig& project_config = preset_bundle->project_config; + const bool use_custom_matrix = (project_config.option("wiping_volumes_use_custom_matrix"))->value; 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(); @@ -527,11 +528,12 @@ FreqChangedParams::FreqChangedParams(wxWindow* parent) : 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); + WipingDialog dlg(parent, cast(init_matrix), extruder_colours, default_purge, filament_purging_multipliers, use_custom_matrix); if (dlg.ShowModal() == wxID_OK) { std::vector matrix = dlg.get_matrix(); (project_config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(), matrix.end()); + (project_config.option("wiping_volumes_use_custom_matrix"))->value = dlg.get_use_custom_matrix(); // Update Project dirty state, update application title bar. wxGetApp().plater()->update_project_dirty_from_presets(); wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent)); diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 6ad1a5644a..3f77e7b62f 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -190,7 +190,7 @@ 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, - double printer_purging_volume, const std::vector& filament_purging_multipliers) + double printer_purging_volume, const std::vector& filament_purging_multipliers, bool use_custom_matrix) : wxDialog(parent, wxID_ANY, _(L("Wipe tower - Purging volume adjustment")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE/* | wxRESIZE_BORDER*/) { SetFont(wxGetApp().normal_font()); @@ -252,9 +252,8 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector& matrix, c enable_or_disable_panel(); }); - const bool start_default = should_start_as_default(); - m_radio_button1->SetValue(start_default); - m_radio_button2->SetValue(! start_default); + m_radio_button1->SetValue(! use_custom_matrix); + m_radio_button2->SetValue(use_custom_matrix); enable_or_disable_panel(); this->Show(); @@ -394,13 +393,6 @@ std::vector WipingPanel::read_matrix_values() { } - -bool WipingDialog::should_start_as_default() const -{ - return true; -} - - void WipingDialog::enable_or_disable_panel() { bool enable = m_radio_button2->GetValue(); diff --git a/src/slic3r/GUI/WipeTowerDialog.hpp b/src/slic3r/GUI/WipeTowerDialog.hpp index d07ecfdf66..f5e9f855cc 100644 --- a/src/slic3r/GUI/WipeTowerDialog.hpp +++ b/src/slic3r/GUI/WipeTowerDialog.hpp @@ -76,12 +76,12 @@ private: class WipingDialog : public wxDialog { public: WipingDialog(wxWindow* parent, const std::vector& matrix, const std::vector& extruder_colours, - double printer_purging_volume, const std::vector& filament_purging_multipliers); + double printer_purging_volume, const std::vector& filament_purging_multipliers, bool use_custom_matrix); std::vector get_matrix() const { return m_output_matrix; } + bool get_use_custom_matrix() const { return m_radio_button2->GetValue(); } private: - bool should_start_as_default() const; void enable_or_disable_panel(); WipingPanel* m_panel_wiping = nullptr;