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)
This commit is contained in:
songwei.li 2025-07-12 16:37:39 +08:00 committed by Noisyfox
parent 73220b4df6
commit 8d1f11495d
2 changed files with 38 additions and 1 deletions

View file

@ -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<double> temp_cfg_flush_multiplier = cfg.option<ConfigOptionFloats>("flush_multiplier")->values;
std::vector<double> temp_flush_volumes_matrix = cfg.option<ConfigOptionFloats>("flush_volumes_matrix")->values;
auto temp_filament_color = cfg.option<ConfigOptionStrings>("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<ConfigOptionFloats>("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<std::string_view> banned_keys( {
"compatible_printers"sv,

View file

@ -411,6 +411,21 @@ WipingDialog::WipingDialog(wxWindow* parent, const std::vector<std::vector<int>>
store_matrixs.emplace_back((*iter).get<std::vector<double>>());
}
std::vector<double>store_multipliers = j["flush_multiplier"].get<std::vector<double>>();
{// 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();