From 50768e0716035201ac7a91983f27e43bc328bb37 Mon Sep 17 00:00:00 2001 From: Valerii Bokhan <80919135+valerii-bokhan@users.noreply.github.com> Date: Tue, 14 Jul 2026 19:42:16 +0200 Subject: [PATCH] Feature: Retract amount after wipe (#11015) Co-authored-by: Ian Bassi --- src/libslic3r/Extruder.cpp | 9 ++- src/libslic3r/Extruder.hpp | 2 + src/libslic3r/GCode.cpp | 61 ++++++++++----- src/libslic3r/GCode.hpp | 9 ++- src/libslic3r/Preset.cpp | 16 +++- src/libslic3r/Print.cpp | 2 + src/libslic3r/PrintConfig.cpp | 89 ++++++++++++++++++--- src/libslic3r/PrintConfig.hpp | 3 + src/slic3r/GUI/Tab.cpp | 143 ++++++++++++++++++++++++++++++++-- src/slic3r/GUI/Tab.hpp | 4 +- 10 files changed, 293 insertions(+), 45 deletions(-) diff --git a/src/libslic3r/Extruder.cpp b/src/libslic3r/Extruder.cpp index bb3a10ff48..1e250b707e 100644 --- a/src/libslic3r/Extruder.cpp +++ b/src/libslic3r/Extruder.cpp @@ -177,7 +177,14 @@ double Extruder::filament_flow_ratio() const // Return a "retract_before_wipe" percentage as a factor clamped to <0, 1> double Extruder::retract_before_wipe() const { - return std::min(1., std::max(0., m_config->retract_before_wipe.get_at(m_config_index) * 0.01)); + return std::clamp(m_config->retract_before_wipe.get_at(m_config_index) * 0.01, 0., 1.); +} + +// Orca: +// Return a "retract_after_wipe" percentage as a factor clamped to <0, 1> +double Extruder::retract_after_wipe() const +{ + return std::min(std::clamp(m_config->retract_after_wipe.get_at(m_config_index) * 0.01, 0., 1.), 1. - retract_before_wipe()); } double Extruder::retraction_length() const diff --git a/src/libslic3r/Extruder.hpp b/src/libslic3r/Extruder.hpp index 95bbae49ad..aa023ea040 100644 --- a/src/libslic3r/Extruder.hpp +++ b/src/libslic3r/Extruder.hpp @@ -74,6 +74,8 @@ public: double filament_cost() const; double filament_flow_ratio() const; double retract_before_wipe() const; + // Orca: + double retract_after_wipe() const; double retraction_length() const; double retract_lift() const; int retract_speed() const; diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 66c5ae72f4..24cbec3567 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -441,22 +441,30 @@ static std::vector get_path_of_change_filament(const Print& print) // Declare & initialize retraction lengths double retraction_length_remaining = 0, - retractionBeforeWipe = 0, - retractionDuringWipe = 0; + retraction_length_before_wipe = 0, + retraction_length_during_wipe = 0, + retraction_length_after_wipe = 0; - // initialise the remaining retraction amount with the full retraction amount. - retraction_length_remaining = toolchange ? extruder->retract_length_toolchange() : extruder->retraction_length(); + // Initialise the remaining retraction amount with the full retraction amount. + retraction_length_remaining = toolchange ? + extruder->retract_length_toolchange() : extruder->retraction_length(); - // nothing to retract - return early - if(retraction_length_remaining <=EPSILON) return {0.f,0.f}; + // Nothing to retract - return early + if (retraction_length_remaining <= EPSILON) + return { 0.f, 0.f, 0.f }; - // calculate retraction before wipe distance from the user setting. Keep adding to this variable any excess retraction needed - // to be performed before the wipe. - retractionBeforeWipe = retraction_length_remaining * extruder->retract_before_wipe(); - retraction_length_remaining -= retractionBeforeWipe; // subtract it from the remaining retraction length - - // all of the retraction is to be done before the wipe - if(retraction_length_remaining <=EPSILON) return {retractionBeforeWipe,0.f}; + // Calculate retraction before and after wipe distances from the user setting. + // Keep adding to the for retraction before wipe variable any excess retraction + // needed to be performed before the wipe. + retraction_length_before_wipe = retraction_length_remaining * extruder->retract_before_wipe(); + retraction_length_after_wipe = retraction_length_remaining * extruder->retract_after_wipe(); + + // Subtract it from the remaining retraction length + retraction_length_remaining -= retraction_length_before_wipe + retraction_length_after_wipe; + + // All of the retraction is to be done before the wipe + if (retraction_length_remaining <= EPSILON) + return { retraction_length_before_wipe, 0., retraction_length_after_wipe }; // Calculate wipe speed // Orca: resolve the travel_speed slot via the Print-side per-layer resolver; the writer's @@ -471,18 +479,25 @@ static std::vector get_path_of_change_filament(const Print& print) double wipe_path_length = std::min(wipe_path.length(), wipe_dist); // Calculate the maximum retraction amount during wipe - retractionDuringWipe = config.retraction_speed.get_at(extruder_id) * unscale_(wipe_path_length) / wipe_speed; - // If the maximum retraction amount during wipe is too small, return 0 and retract everything prior to the wipe. - if(retractionDuringWipe <= EPSILON) return {retractionBeforeWipe,0.f}; + retraction_length_during_wipe = config.retraction_speed.get_at(extruder_id) * + unscale_(wipe_path_length) / wipe_speed; + + // If the maximum retraction amount during wipe is too small, + // disable wipe-time retraction and leave any remaining retract amount + // to the subsequent standard retract flow. + if (retraction_length_during_wipe <= EPSILON) + return { retraction_length_before_wipe, 0., retraction_length_after_wipe }; // If the maximum retraction amount during wipe is greater than any remaining retraction length // return the remaining retraction length to be retracted during the wipe - if (retractionDuringWipe - retraction_length_remaining > EPSILON) return {retractionBeforeWipe,retraction_length_remaining}; + if (retraction_length_during_wipe - retraction_length_remaining > EPSILON) + return { retraction_length_before_wipe, retraction_length_remaining, retraction_length_after_wipe }; // We will always proceed with incrementing the retraction amount before wiping with the difference // and return the maximum allowed wipe amount to be retracted during the wipe move - retractionBeforeWipe += retraction_length_remaining - retractionDuringWipe; - return {retractionBeforeWipe, retractionDuringWipe}; + retraction_length_before_wipe += retraction_length_remaining - retraction_length_during_wipe; + + return { retraction_length_before_wipe, retraction_length_during_wipe, retraction_length_after_wipe }; } std::string transform_gcode(const std::string &gcode, Vec2f pos, const Vec2f &translation, float angle) @@ -8507,8 +8522,12 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li // wipe (if it's enabled for this extruder and we have a stored wipe path and no-zero wipe distance) if (FILAMENT_CONFIG(wipe) && m_wipe.has_path() && scale_(FILAMENT_CONFIG(wipe_distance)) > SCALED_EPSILON) { Wipe::RetractionValues wipeRetractions = m_wipe.calculateWipeRetractionLengths(*this, toolchange); - gcode += toolchange ? m_writer.retract_for_toolchange(true,wipeRetractions.retractLengthBeforeWipe) : m_writer.retract(true, wipeRetractions.retractLengthBeforeWipe); - gcode += m_wipe.wipe(*this,wipeRetractions.retractLengthDuringWipe, toolchange, is_last_retraction); + gcode += toolchange ? m_writer.retract_for_toolchange(true, wipeRetractions.retraction_length_before_wipe) : + m_writer.retract(true, wipeRetractions.retraction_length_before_wipe); + gcode += m_wipe.wipe(*this, wipeRetractions.retraction_length_during_wipe, toolchange, is_last_retraction); + + // Orca: wipeRetractions.retraction_length_after_wipe is not being used explicitly, + // the remaining retraction after wipe is handled by the subsequent m_writer.retract() call } /* The parent class will decide whether we need to perform an actual retraction diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 7b862f2cde..e6cf9c914e 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -60,15 +60,20 @@ class Wipe { public: bool enable; Polyline path; + + // Orca: struct RetractionValues{ - double retractLengthBeforeWipe; - double retractLengthDuringWipe; + double retraction_length_before_wipe = 0.; + double retraction_length_during_wipe = 0.; + double retraction_length_after_wipe = 0.; }; Wipe() : enable(false) {} bool has_path() const { return !this->path.points.empty(); } void reset_path() { this->path = Polyline(); } std::string wipe(GCode &gcodegen, double length, bool toolchange = false, bool is_last = false); + + // Orca: RetractionValues calculateWipeRetractionLengths(GCode& gcodegen, bool toolchange); }; diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index ac731e004b..f48e3d9145 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -1333,8 +1333,20 @@ static std::vector s_Preset_filament_options {/*"filament_colour", //exhaust fan control "activate_air_filtration","activate_air_filtration_during_print","activate_air_filtration_on_completion","during_print_exhaust_fan_speed","complete_print_exhaust_fan_speed", // Retract overrides - "filament_retraction_length", "filament_z_hop", "filament_z_hop_types", "filament_retract_lift_above", "filament_retract_lift_below", "filament_retract_lift_enforce", "filament_retraction_speed", "filament_deretraction_speed", "filament_retract_restart_extra", "filament_retraction_minimum_travel", - "filament_retract_when_changing_layer", "filament_wipe", "filament_retract_before_wipe", + "filament_deretraction_speed", + "filament_retract_after_wipe", // Orca + "filament_retract_before_wipe", + "filament_retract_lift_above", + "filament_retract_lift_below", + "filament_retract_lift_enforce", + "filament_retract_restart_extra", + "filament_retract_when_changing_layer", + "filament_retraction_length", + "filament_retraction_minimum_travel", + "filament_retraction_speed", + "filament_wipe", + "filament_z_hop", + "filament_z_hop_types", // Profile compatibility "filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits", //BBS diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index a35bd2c45c..8379e0d086 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -177,6 +177,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "filename_format", "retraction_minimum_travel", "retract_before_wipe", + // Orca: + "retract_after_wipe", "retract_when_changing_layer", "retraction_length", "retract_length_toolchange", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 01e499d488..724397d3a3 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -79,6 +79,9 @@ const std::vector filament_extruder_override_keys = { "filament_wipe", // percents "filament_retract_before_wipe", + // Orca + "filament_retract_after_wipe", + // BBS "filament_long_retractions_when_cut", "filament_retraction_distances_when_cut" }; @@ -5546,6 +5549,15 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionPercents { 100 }); + // Orca: + def = this->add("retract_after_wipe", coPercents); + def->label = L("Retract amount after wipe"); + def->tooltip = L("The length of fast retraction after wipe, relative to retraction length.\n" + "The value will be clamped by 100% minus the retract amount before the wipe value."); + def->sidetext = "%"; + def->mode = comExpert; + def->set_default_value(new ConfigOptionPercents { 0 }); + def = this->add("retract_when_changing_layer", coBools); def->label = L("Retract on layer change"); def->tooltip = L("This forces a retraction on layer changes."); @@ -7963,17 +7975,44 @@ void PrintConfigDef::init_extruder_option_keys() { // ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings m_extruder_option_keys = { - "extruder_type", "nozzle_diameter", "default_nozzle_volume_type", "min_layer_height", "max_layer_height", "extruder_offset", - "extruder_printable_height", "nozzle_volume", "nozzle_type", "nozzle_flush_dataset", - "retraction_length", "z_hop", "z_hop_types", "travel_slope", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", - "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", - "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", - "default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut" + "default_filament_profile", + "default_nozzle_volume_type", + "deretraction_speed", + "extruder_colour", + "extruder_offset", + "extruder_printable_height", + "extruder_type", + "long_retractions_when_cut", + "max_layer_height", + "min_layer_height", + "nozzle_diameter", + "nozzle_flush_dataset", + "nozzle_type", + "nozzle_volume", + "retract_after_wipe", + "retract_before_wipe", + "retract_length_toolchange", + "retract_lift_above", + "retract_lift_below", + "retract_lift_enforce", + "retract_restart_extra", + "retract_restart_extra_toolchange", + "retract_when_changing_layer", + "retraction_distances_when_cut", + "retraction_length", + "retraction_minimum_travel", + "retraction_speed", + "travel_slope", + "wipe", + "wipe_distance", + "z_hop", + "z_hop_types" }; m_extruder_retract_keys = { "deretraction_speed", "long_retractions_when_cut", + "retract_after_wipe", "retract_before_wipe", "retract_lift_above", "retract_lift_below", @@ -7996,17 +8035,40 @@ void PrintConfigDef::init_extruder_option_keys() void PrintConfigDef::init_filament_option_keys() { m_filament_option_keys = { - "filament_diameter", "min_layer_height", "max_layer_height","volumetric_speed_coefficients", - "retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", - "retract_before_wipe", "filament_retract_length_nc", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", - "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", - "default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"/*,"filament_seam_gap"*/ + "default_filament_profile", + "deretraction_speed", + "filament_colour", + "filament_diameter", + "filament_retract_length_nc", + // "filament_seam_gap", + "long_retractions_when_cut", + "max_layer_height", + "min_layer_height", + "retract_after_wipe", + "retract_before_wipe", + "retract_length_toolchange", + "retract_lift_above", + "retract_lift_below", + "retract_lift_enforce", + "retract_restart_extra", + "retract_restart_extra_toolchange", + "retract_when_changing_layer", + "retraction_distances_when_cut", + "retraction_length", + "retraction_minimum_travel", + "retraction_speed", + "volumetric_speed_coefficients", + "wipe", + "wipe_distance", + "z_hop", + "z_hop_types", }; m_filament_retract_keys = { "deretraction_speed", "filament_retract_length_nc", "long_retractions_when_cut", + "retract_after_wipe", "retract_before_wipe", "retract_lift_above", "retract_lift_below", @@ -9050,6 +9112,9 @@ std::set filament_options_with_variant = { //BBS "filament_wipe_distance", "filament_retract_before_wipe", + // Orca + "filament_retract_after_wipe", + //BBS "filament_long_retractions_when_cut", "filament_retraction_distances_when_cut", "long_retractions_when_ec", @@ -9100,6 +9165,8 @@ std::set printer_options_with_variant_1 = { "wipe", "wipe_distance", "retract_before_wipe", + // Orca: + "retract_after_wipe", "retract_length_toolchange", "retract_restart_extra", "retract_restart_extra_toolchange", diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 0ace3f5e9e..1a2540a82b 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1542,6 +1542,9 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionPercents, retract_before_wipe)) + // Orca + ((ConfigOptionPercents, retract_after_wipe)) + ((ConfigOptionFloats, retraction_length)) ((ConfigOptionFloats, retract_length_toolchange)) ((ConfigOptionInt, enable_long_retraction_when_cut)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 114fd9711f..06045912a1 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1772,6 +1772,10 @@ static wxString pad_combo_value_for_config(const DynamicPrintConfig &config) void Tab::on_value_change(const std::string& opt_key, const boost::any& value) { + // Orca: + // TODO: Move filament-specific checks to TabFilament::on_value_change() + // TODO: Move printer-specific checks to TabPrinter::on_value_change() + if (wxGetApp().plater() == nullptr) { return; } @@ -3986,9 +3990,12 @@ void TabFilament::add_filament_overrides_page() "filament_retraction_minimum_travel", "filament_retract_when_changing_layer", "filament_wipe", - //BBS + // BBS "filament_wipe_distance", "filament_retract_before_wipe", + // Orca + "filament_retract_after_wipe", + // BBS "filament_long_retractions_when_cut", "filament_retraction_distances_when_cut" //SoftFever @@ -4112,9 +4119,12 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print "filament_retraction_minimum_travel", "filament_retract_when_changing_layer", "filament_wipe", - //BBS + // BBS "filament_wipe_distance", "filament_retract_before_wipe", + // Orca + "filament_retract_after_wipe", + // BBS "filament_long_retractions_when_cut", "filament_retraction_distances_when_cut" //SoftFever @@ -4766,6 +4776,69 @@ void TabFilament::clear_pages() m_overrides_options.clear(); } +// Orca: +void TabFilament::on_value_change(const std::string& opt_key, const boost::any& value) +{ + if (wxGetApp().plater() == nullptr || m_config_manipulation.is_applying()) + return; + + const int pos = opt_key.find("#"); + + if (pos > 0) { + std::string temp_str = opt_key; + boost::erase_head(temp_str, pos + 1); + int orig_opt_idx = static_cast(atoi(temp_str.c_str())); + int opt_idx = orig_opt_idx >= 0 ? orig_opt_idx : 0; + + std::string opt_key_pure = opt_key; + boost::erase_tail(opt_key_pure, opt_key_pure.size() - pos); + + if (opt_key_pure == "filament_retract_after_wipe" || opt_key_pure == "filament_retract_before_wipe") { + double dvalue = boost::any_cast(value); + auto percent_value_clamp = [](double percent_value) { return std::clamp(percent_value, 0., 100.); }; + auto get_value_by_opt_key = [&](const std::string& opt_key) { + if (opt_key_pure == opt_key && !std::isnan(dvalue)) { + // Return the incoming value (if it is valid) if the opt_key equals the key of the changed option. + return percent_value_clamp(dvalue); + } else if (!m_config->option(opt_key)->is_nil(opt_idx)) { + // Return the overridden value if the option value for the opt_key was overridden for the given filament. + return percent_value_clamp(m_config->option(opt_key)->get_at(opt_idx)); + } else { + // Return the value of the option value for opt_key from the printer setting if it was not overridden for the filament. + const auto& printer_config = m_preset_bundle->printers.get_edited_preset().config; + const std::string printer_opt_key = opt_key.substr(strlen("filament_")); + return percent_value_clamp(printer_config.option(printer_opt_key)->get_at(opt_idx)); + } + + return 0.; + }; + + double retract_before_wipe = get_value_by_opt_key("filament_retract_before_wipe"); + double retract_after_wipe = get_value_by_opt_key("filament_retract_after_wipe"); + + bool need_to_reload_config = false; + + if (percent_value_clamp(dvalue) != dvalue) { + change_opt_value(*m_config, opt_key_pure, percent_value_clamp(dvalue), opt_idx); + need_to_reload_config = true; + } + + if (retract_after_wipe > 100. - retract_before_wipe) { + change_opt_value(*m_config, "filament_retract_after_wipe", 100. - retract_before_wipe, opt_idx); + need_to_reload_config = true; + } + + if (need_to_reload_config && !m_postpone_update_ui) { + update_dirty(); + reload_config(); + update_tab_ui(); + } + } + } + + Tab::on_value_change(opt_key, value); +} + wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticText, wxString text /*= wxEmptyString*/) { *StaticText = new ogStaticText(parent, text); @@ -5530,6 +5603,8 @@ if (is_marlin_flavor) optgroup->append_single_option_line("wipe", "printer_extruder_retraction#wipe-while-retracting", extruder_idx); optgroup->append_single_option_line("wipe_distance", "printer_extruder_retraction#wipe-distance", extruder_idx); optgroup->append_single_option_line("retract_before_wipe", "printer_extruder_retraction#retract-amount-before-wipe", extruder_idx); + // Orca + optgroup->append_single_option_line("retract_after_wipe", "printer_extruder_retraction#retract-amount-after-wipe", extruder_idx); optgroup = page->new_optgroup(L("Z-Hop"), L"param_extruder_lift_enforcement"); optgroup->append_single_option_line("retract_lift_enforce", "printer_extruder_z_hop#on-surfaces", extruder_idx); @@ -5989,16 +6064,20 @@ void TabPrinter::toggle_options() // some options only apply when not using firmware retraction vec.resize(0); - vec = {"retraction_speed", "deretraction_speed", "retract_before_wipe", - "retract_length", "retract_restart_extra", - "wipe_distance"}; + vec = {"retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_after_wipe", + "retract_length", "retract_restart_extra", "wipe_distance"}; for (auto el : vec) //BBS toggle_option(el, retraction && !use_firmware_retraction, i); bool wipe = retraction && m_config->opt_bool("wipe", variant_index); - toggle_option("retract_before_wipe", wipe, i); - float retract_before_wipe = static_cast(m_config->option("retract_before_wipe"))->values[variant_index]; + + // Orca: + double retract_before_wipe = m_config->option("retract_before_wipe")->get_at(variant_index); + double retract_after_wipe = m_config->option("retract_after_wipe")->get_at(variant_index); + + toggle_option("retract_before_wipe", wipe && !is_approx(retract_after_wipe, 100.), i); + toggle_option("retract_after_wipe", wipe && !is_approx(retract_before_wipe, 100.), i); if (use_firmware_retraction && wipe && retract_before_wipe < 100.0) { //wxMessageDialog dialog(parent(), @@ -6101,6 +6180,56 @@ void TabPrinter::toggle_options() } } +// Orca: +void TabPrinter::on_value_change(const std::string& opt_key, const boost::any& value) +{ + if (wxGetApp().plater() == nullptr || m_config_manipulation.is_applying()) + return; + + const int pos = opt_key.find("#"); + + if (pos > 0) { + std::string temp_str = opt_key; + boost::erase_head(temp_str, pos + 1); + int orig_opt_idx = static_cast(atoi(temp_str.c_str())); + int opt_idx = orig_opt_idx >= 0 ? orig_opt_idx : 0; + + std::string opt_key_pure = opt_key; + boost::erase_tail(opt_key_pure, opt_key_pure.size() - pos); + + if (opt_key_pure == "retract_after_wipe" || opt_key_pure == "retract_before_wipe") { + auto percent_value_clamp = [](double percent_value) { return std::clamp(percent_value, 0., 100.); }; + double dvalue = boost::any_cast(value); + + double retract_before_wipe = percent_value_clamp(opt_key_pure == "retract_before_wipe" + ? dvalue : m_config->option("retract_before_wipe")->get_at(opt_idx)); + + double retract_after_wipe = percent_value_clamp(opt_key_pure == "retract_after_wipe" + ? dvalue : m_config->option("retract_after_wipe")->get_at(opt_idx)); + + bool need_to_reload_config = false; + + if (percent_value_clamp(dvalue) != dvalue) { + change_opt_value(*m_config, opt_key_pure, percent_value_clamp(dvalue), opt_idx); + need_to_reload_config = true; + } + + if (retract_after_wipe > 100. - retract_before_wipe) { + change_opt_value(*m_config, "retract_after_wipe", 100. - retract_before_wipe, opt_idx); + need_to_reload_config = true; + } + + if (need_to_reload_config && !m_postpone_update_ui) { + update_dirty(); + reload_config(); + update_tab_ui(); + } + } + } + + Tab::on_value_change(opt_key, value); +} + void TabPrinter::update() { m_update_cnt++; diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index f80e67f06b..c5344131ab 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -608,6 +608,8 @@ public: void clear_pages() override; bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptFFF; } + void on_value_change(const std::string& opt_key, const boost::any& value) override; + const std::string& get_custom_gcode(const t_config_option_key& opt_key) override; void set_custom_gcode(const t_config_option_key& opt_key, const std::string& value) override; }; @@ -666,11 +668,11 @@ public: bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; } void set_extruder_volume_type(int extruder_id, NozzleVolumeType type); + void on_value_change(const std::string& opt_key, const boost::any& value) override; wxSizer* create_bed_shape_widget(wxWindow* parent); void cache_extruder_cnt(const DynamicPrintConfig* config = nullptr); bool apply_extruder_cnt_from_cache(); - }; class TabSLAMaterial : public Tab