From 8d1f11495df9ee87c23b77ff8d138d6efa481b10 Mon Sep 17 00:00:00 2001 From: "songwei.li" Date: Sat, 12 Jul 2025 16:37:39 +0800 Subject: [PATCH] FIX:The estimated flushing amount of consumables for multi-color printing is inaccurate. change: Multiply the flush_volumes_matrix in the exported gcode by the coefficient and output the final value. Also fixed the issue where the flush matrix page was limited to 900, but the Gcode output value could be greater than 900 (the product of the matrix and the multiplier was limited to 900 before storing the value) jira: STUDIO-13332 Change-Id: I893f27bec206c3b9da3273241d1cd5f1883e55a9 (cherry picked from commit 8aa91cd86c8c75b3736c616bcfbed4872db9734c) (cherry picked from commit 038fc1c18220cef8c269d272059afea503fb5d5b) --- src/libslic3r/GCode.cpp | 24 +++++++++++++++++++++++- src/slic3r/GUI/WipeTowerDialog.cpp | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 986cca50e8..6e52342a20 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5059,7 +5059,29 @@ void GCode::apply_print_config(const PrintConfig &print_config) void GCode::append_full_config(const Print &print, std::string &str) { - const DynamicPrintConfig &cfg = print.full_print_config(); + DynamicPrintConfig cfg = print.full_print_config(); + { // correct the flush_volumes_matrix with flush_multiplier values + std::vector temp_cfg_flush_multiplier = cfg.option("flush_multiplier")->values; + std::vector temp_flush_volumes_matrix = cfg.option("flush_volumes_matrix")->values; + auto temp_filament_color = cfg.option("filament_colour")->values; + size_t heads_count_tmp = temp_cfg_flush_multiplier.size(), + matrix_value_count = temp_flush_volumes_matrix.size() / temp_cfg_flush_multiplier.size(), + filament_count_tmp = temp_filament_color.size(); + if (filament_count_tmp * filament_count_tmp * heads_count_tmp == temp_flush_volumes_matrix.size()) { + for (size_t idx = 0; idx < heads_count_tmp; ++idx) { + double temp_cfg_flush_multiplier_idx = temp_cfg_flush_multiplier[idx]; + size_t temp_begin_t = idx * matrix_value_count, temp_end_t = (idx + 1) * matrix_value_count; + std::transform(temp_flush_volumes_matrix.begin() + temp_begin_t, temp_flush_volumes_matrix.begin() + temp_end_t, + temp_flush_volumes_matrix.begin() + temp_begin_t, + [temp_cfg_flush_multiplier_idx](double inputx) { return inputx * temp_cfg_flush_multiplier_idx; }); + } + cfg.option("flush_volumes_matrix")->values = temp_flush_volumes_matrix; + } else if (filament_count_tmp == 1) { + } // Not applicable to flush matrix situations + else { // flush_volumes_matrix value count error? + throw Slic3r::SlicingError(_(L("Flush volumes matrix do not match to the correct size!"))); + } + } // Sorted list of config keys, which shall not be stored into the G-code. Initializer list. static const std::set banned_keys( { "compatible_printers"sv, diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 3f91e6a3bf..e06b02215f 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -411,6 +411,21 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector> store_matrixs.emplace_back((*iter).get>()); } std::vectorstore_multipliers = j["flush_multiplier"].get>(); + {// limit all matrix value before write to gcode, the limitation is depends on the multipliers + size_t cols_temp_matrix = 0; + if (!store_matrixs.empty()) { cols_temp_matrix = store_matrixs[0].size(); } + if (store_multipliers.size() == store_matrixs.size() && cols_temp_matrix>0) // nuzzles==nuzzles + { + for (size_t idx = 0; idx < store_multipliers.size(); ++idx) { + double m_max_flush_volume_t = (double)m_max_flush_volume, m_store_multipliers=store_multipliers[idx]; + std::transform(store_matrixs[idx].begin(), store_matrixs[idx].end(), + store_matrixs[idx].begin(), + [m_max_flush_volume_t, m_store_multipliers](double inputx) { + return std::clamp(inputx, 0.0, m_max_flush_volume_t / m_store_multipliers); + }); + } + } + } this->StoreFlushData(extruder_num, store_matrixs, store_multipliers); m_submit_flag = true; this->Close();