From 7bc01c625dc0b8d624fa0178cc32851cb47516cc Mon Sep 17 00:00:00 2001 From: "weizhen.xie" Date: Tue, 19 Aug 2025 20:04:46 +0800 Subject: [PATCH] ENH: Add a button to control whether to enable volumetric-speed fitting Jira: None Change-Id: I8d9fd3468dbfb8904d164b289f9d5223e476145c (cherry picked from commit 3acf97f1b3cf12d34a3679eef550cc26e03eb86c) --- src/libslic3r/GCode.cpp | 8 ++++++-- src/libslic3r/Preset.cpp | 2 +- src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 12 +++++++++++- src/libslic3r/PrintConfig.hpp | 1 + src/slic3r/GUI/Tab.cpp | 5 +++++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 8b66f1e010..d8debb7260 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5981,8 +5981,12 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, } } //BBS: if not set the speed, then use the filament_max_volumetric_speed directly - double filament_max_volumetric_speed = calc_max_volumetric_speed(path.height, path.width, FILAMENT_CONFIG(volumetric_speed_coefficients)); - filament_max_volumetric_speed = std::min(filament_max_volumetric_speed, FILAMENT_CONFIG(filament_max_volumetric_speed)); + double filament_max_volumetric_speed = FILAMENT_CONFIG(filament_max_volumetric_speed); + if (FILAMENT_CONFIG(filament_adaptive_volumetric_speed)){ + double fitted_value = calc_max_volumetric_speed(path.height, path.width, FILAMENT_CONFIG(volumetric_speed_coefficients)); + filament_max_volumetric_speed = std::min(filament_max_volumetric_speed, fitted_value); + } + if (speed == 0) speed = filament_max_volumetric_speed / _mm3_per_mm; if (this->on_first_layer()) { diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 13354dec54..bbe1afb2f8 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -949,7 +949,7 @@ static std::vector s_Preset_print_options { static std::vector s_Preset_filament_options {/*"filament_colour", */ "default_filament_colour", "required_nozzle_HRC", "filament_diameter", "pellet_flow_coefficient", "volumetric_speed_coefficients", "filament_type", "filament_soluble", "filament_is_support", "filament_printable", - "filament_max_volumetric_speed", + "filament_max_volumetric_speed", "filament_adaptive_volumetric_speed", "filament_flow_ratio", "filament_density", "filament_adhesiveness_category", "filament_cost", "filament_minimal_purge_on_wipe_tower", "nozzle_temperature", "nozzle_temperature_initial_layer", // BBS diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 12c3ef7f58..ac34009b68 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -276,6 +276,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n || opt_key == "nozzle_temperature_initial_layer" || opt_key == "filament_minimal_purge_on_wipe_tower" || opt_key == "filament_max_volumetric_speed" + || opt_key == "filament_adaptive_volumetric_speed" || opt_key == "filament_loading_speed" || opt_key == "filament_loading_speed_start" || opt_key == "filament_unloading_speed" diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 20aa61bbe0..46a8c4b53e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2320,6 +2320,15 @@ void PrintConfigDef::init_fff_params() def->min = 0; def->set_default_value(new ConfigOptionFloats{ 0.4157 }); + def = this->add("filament_adaptive_volumetric_speed", coBools); + def->label = L("Adaptive volumetric speed"); + def->tooltip = L("When enabled, the extrusion flow is limited by the smaller of " + "the fitted value (calculated from line width and layer height) and the user-defined maximum flow." + " When disabled, only the user-defined maximum flow is applied."); + def->mode = comAdvanced; + def->nullable = true; + def->set_default_value(new ConfigOptionBoolsNullable {false}); + def = this->add("volumetric_speed_coefficients", coStrings); def->label = L("Max volumetric speed multinomial coefficients"); def->set_default_value(new ConfigOptionStrings{""}); @@ -7523,7 +7532,8 @@ std::set filament_options_with_variant = { "nozzle_temperature", "filament_flush_volumetric_speed", "filament_flush_temp", - "volumetric_speed_coefficients" + "volumetric_speed_coefficients", + "filament_adaptive_volumetric_speed" }; // Parameters that are the same as the number of extruders diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index a834c4f9eb..fd721650e9 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1224,6 +1224,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionBool, fan_speedup_overhangs)) ((ConfigOptionFloat, fan_speedup_time)) ((ConfigOptionFloats, filament_diameter)) + ((ConfigOptionBoolsNullable, filament_adaptive_volumetric_speed)) ((ConfigOptionStrings, volumetric_speed_coefficients)) ((ConfigOptionInts, filament_adhesiveness_category)) ((ConfigOptionFloats, filament_density)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index b11c4cda17..7564ab8c79 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3823,6 +3823,7 @@ void TabFilament::build() //BBS optgroup = page->new_optgroup(L("Volumetric speed limitation"), L"param_volumetric_speed"); + optgroup->append_single_option_line("filament_adaptive_volumetric_speed"); optgroup->append_single_option_line("filament_max_volumetric_speed"); //line = { "", "" }; @@ -4087,6 +4088,10 @@ void TabFilament::toggle_options() bool support_chamber_temp_control = this->m_preset_bundle->printers.get_edited_preset().config.opt_bool("support_chamber_temp_control"); toggle_line("chamber_temperature", support_chamber_temp_control); + + std::string volumetric_speed_cos = m_config->opt_string("volumetric_speed_coefficients", 0u); + bool enable_fit = volumetric_speed_cos != "0;0;0;0;0;0"; + toggle_option("filament_adaptive_volumetric_speed", enable_fit); } if (m_active_page->title() == L("Setting Overrides"))