Feature: Retract amount after wipe (#11015)

Co-authored-by: Ian Bassi <ian.bassi@outlook.com>
This commit is contained in:
Valerii Bokhan
2026-07-14 14:42:16 -03:00
committed by GitHub
co-authored by Ian Bassi
parent 3c0338f462
commit 50768e0716
10 changed files with 293 additions and 45 deletions
+8 -1
View File
@@ -177,7 +177,14 @@ double Extruder::filament_flow_ratio() const
// Return a "retract_before_wipe" percentage as a factor clamped to <0, 1> // Return a "retract_before_wipe" percentage as a factor clamped to <0, 1>
double Extruder::retract_before_wipe() const 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 double Extruder::retraction_length() const
+2
View File
@@ -74,6 +74,8 @@ public:
double filament_cost() const; double filament_cost() const;
double filament_flow_ratio() const; double filament_flow_ratio() const;
double retract_before_wipe() const; double retract_before_wipe() const;
// Orca:
double retract_after_wipe() const;
double retraction_length() const; double retraction_length() const;
double retract_lift() const; double retract_lift() const;
int retract_speed() const; int retract_speed() const;
+39 -20
View File
@@ -441,22 +441,30 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
// Declare & initialize retraction lengths // Declare & initialize retraction lengths
double retraction_length_remaining = 0, double retraction_length_remaining = 0,
retractionBeforeWipe = 0, retraction_length_before_wipe = 0,
retractionDuringWipe = 0; retraction_length_during_wipe = 0,
retraction_length_after_wipe = 0;
// initialise the remaining retraction amount with the full retraction amount. // Initialise the remaining retraction amount with the full retraction amount.
retraction_length_remaining = toolchange ? extruder->retract_length_toolchange() : extruder->retraction_length(); retraction_length_remaining = toolchange ?
extruder->retract_length_toolchange() : extruder->retraction_length();
// nothing to retract - return early // Nothing to retract - return early
if(retraction_length_remaining <=EPSILON) return {0.f,0.f}; 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 // Calculate retraction before and after wipe distances from the user setting.
// to be performed before the wipe. // Keep adding to the for retraction before wipe variable any excess retraction
retractionBeforeWipe = retraction_length_remaining * extruder->retract_before_wipe(); // needed to be performed before the wipe.
retraction_length_remaining -= retractionBeforeWipe; // subtract it from the remaining retraction length retraction_length_before_wipe = retraction_length_remaining * extruder->retract_before_wipe();
retraction_length_after_wipe = retraction_length_remaining * extruder->retract_after_wipe();
// all of the retraction is to be done before the wipe // Subtract it from the remaining retraction length
if(retraction_length_remaining <=EPSILON) return {retractionBeforeWipe,0.f}; 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 // Calculate wipe speed
// Orca: resolve the travel_speed slot via the Print-side per-layer resolver; the writer's // Orca: resolve the travel_speed slot via the Print-side per-layer resolver; the writer's
@@ -471,18 +479,25 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
double wipe_path_length = std::min(wipe_path.length(), wipe_dist); double wipe_path_length = std::min(wipe_path.length(), wipe_dist);
// Calculate the maximum retraction amount during wipe // Calculate the maximum retraction amount during wipe
retractionDuringWipe = config.retraction_speed.get_at(extruder_id) * unscale_(wipe_path_length) / wipe_speed; retraction_length_during_wipe = config.retraction_speed.get_at(extruder_id) *
// If the maximum retraction amount during wipe is too small, return 0 and retract everything prior to the wipe. unscale_(wipe_path_length) / wipe_speed;
if(retractionDuringWipe <= EPSILON) return {retractionBeforeWipe,0.f};
// 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 // 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 // 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 // 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 // and return the maximum allowed wipe amount to be retracted during the wipe move
retractionBeforeWipe += retraction_length_remaining - retractionDuringWipe; retraction_length_before_wipe += retraction_length_remaining - retraction_length_during_wipe;
return {retractionBeforeWipe, retractionDuringWipe};
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) 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) // 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) { if (FILAMENT_CONFIG(wipe) && m_wipe.has_path() && scale_(FILAMENT_CONFIG(wipe_distance)) > SCALED_EPSILON) {
Wipe::RetractionValues wipeRetractions = m_wipe.calculateWipeRetractionLengths(*this, toolchange); 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 += toolchange ? m_writer.retract_for_toolchange(true, wipeRetractions.retraction_length_before_wipe) :
gcode += m_wipe.wipe(*this,wipeRetractions.retractLengthDuringWipe, toolchange, is_last_retraction); 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 /* The parent class will decide whether we need to perform an actual retraction
+7 -2
View File
@@ -60,15 +60,20 @@ class Wipe {
public: public:
bool enable; bool enable;
Polyline path; Polyline path;
// Orca:
struct RetractionValues{ struct RetractionValues{
double retractLengthBeforeWipe; double retraction_length_before_wipe = 0.;
double retractLengthDuringWipe; double retraction_length_during_wipe = 0.;
double retraction_length_after_wipe = 0.;
}; };
Wipe() : enable(false) {} Wipe() : enable(false) {}
bool has_path() const { return !this->path.points.empty(); } bool has_path() const { return !this->path.points.empty(); }
void reset_path() { this->path = Polyline(); } void reset_path() { this->path = Polyline(); }
std::string wipe(GCode &gcodegen, double length, bool toolchange = false, bool is_last = false); std::string wipe(GCode &gcodegen, double length, bool toolchange = false, bool is_last = false);
// Orca:
RetractionValues calculateWipeRetractionLengths(GCode& gcodegen, bool toolchange); RetractionValues calculateWipeRetractionLengths(GCode& gcodegen, bool toolchange);
}; };
+14 -2
View File
@@ -1333,8 +1333,20 @@ static std::vector<std::string> s_Preset_filament_options {/*"filament_colour",
//exhaust fan control //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", "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 // 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_deretraction_speed",
"filament_retract_when_changing_layer", "filament_wipe", "filament_retract_before_wipe", "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 // Profile compatibility
"filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits", "filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits",
//BBS //BBS
+2
View File
@@ -177,6 +177,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"filename_format", "filename_format",
"retraction_minimum_travel", "retraction_minimum_travel",
"retract_before_wipe", "retract_before_wipe",
// Orca:
"retract_after_wipe",
"retract_when_changing_layer", "retract_when_changing_layer",
"retraction_length", "retraction_length",
"retract_length_toolchange", "retract_length_toolchange",
+78 -11
View File
@@ -79,6 +79,9 @@ const std::vector<std::string> filament_extruder_override_keys = {
"filament_wipe", "filament_wipe",
// percents // percents
"filament_retract_before_wipe", "filament_retract_before_wipe",
// Orca
"filament_retract_after_wipe",
// BBS
"filament_long_retractions_when_cut", "filament_long_retractions_when_cut",
"filament_retraction_distances_when_cut" "filament_retraction_distances_when_cut"
}; };
@@ -5546,6 +5549,15 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPercents { 100 }); 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 = this->add("retract_when_changing_layer", coBools);
def->label = L("Retract on layer change"); def->label = L("Retract on layer change");
def->tooltip = L("This forces a retraction on layer changes."); def->tooltip = L("This forces a retraction on layer changes.");
@@ -7963,17 +7975,44 @@ void PrintConfigDef::init_extruder_option_keys()
{ {
// ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings // ConfigOptionFloats, ConfigOptionPercents, ConfigOptionBools, ConfigOptionStrings
m_extruder_option_keys = { m_extruder_option_keys = {
"extruder_type", "nozzle_diameter", "default_nozzle_volume_type", "min_layer_height", "max_layer_height", "extruder_offset", "default_filament_profile",
"extruder_printable_height", "nozzle_volume", "nozzle_type", "nozzle_flush_dataset", "default_nozzle_volume_type",
"retraction_length", "z_hop", "z_hop_types", "travel_slope", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", "deretraction_speed",
"retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", "extruder_colour",
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", "extruder_offset",
"default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut" "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 = { m_extruder_retract_keys = {
"deretraction_speed", "deretraction_speed",
"long_retractions_when_cut", "long_retractions_when_cut",
"retract_after_wipe",
"retract_before_wipe", "retract_before_wipe",
"retract_lift_above", "retract_lift_above",
"retract_lift_below", "retract_lift_below",
@@ -7996,17 +8035,40 @@ void PrintConfigDef::init_extruder_option_keys()
void PrintConfigDef::init_filament_option_keys() void PrintConfigDef::init_filament_option_keys()
{ {
m_filament_option_keys = { m_filament_option_keys = {
"filament_diameter", "min_layer_height", "max_layer_height","volumetric_speed_coefficients", "default_filament_profile",
"retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", "deretraction_speed",
"retract_before_wipe", "filament_retract_length_nc", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", "filament_colour",
"retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", "filament_diameter",
"default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"/*,"filament_seam_gap"*/ "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 = { m_filament_retract_keys = {
"deretraction_speed", "deretraction_speed",
"filament_retract_length_nc", "filament_retract_length_nc",
"long_retractions_when_cut", "long_retractions_when_cut",
"retract_after_wipe",
"retract_before_wipe", "retract_before_wipe",
"retract_lift_above", "retract_lift_above",
"retract_lift_below", "retract_lift_below",
@@ -9050,6 +9112,9 @@ std::set<std::string> filament_options_with_variant = {
//BBS //BBS
"filament_wipe_distance", "filament_wipe_distance",
"filament_retract_before_wipe", "filament_retract_before_wipe",
// Orca
"filament_retract_after_wipe",
//BBS
"filament_long_retractions_when_cut", "filament_long_retractions_when_cut",
"filament_retraction_distances_when_cut", "filament_retraction_distances_when_cut",
"long_retractions_when_ec", "long_retractions_when_ec",
@@ -9100,6 +9165,8 @@ std::set<std::string> printer_options_with_variant_1 = {
"wipe", "wipe",
"wipe_distance", "wipe_distance",
"retract_before_wipe", "retract_before_wipe",
// Orca:
"retract_after_wipe",
"retract_length_toolchange", "retract_length_toolchange",
"retract_restart_extra", "retract_restart_extra",
"retract_restart_extra_toolchange", "retract_restart_extra_toolchange",
+3
View File
@@ -1542,6 +1542,9 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionPercents, retract_before_wipe)) ((ConfigOptionPercents, retract_before_wipe))
// Orca
((ConfigOptionPercents, retract_after_wipe))
((ConfigOptionFloats, retraction_length)) ((ConfigOptionFloats, retraction_length))
((ConfigOptionFloats, retract_length_toolchange)) ((ConfigOptionFloats, retract_length_toolchange))
((ConfigOptionInt, enable_long_retraction_when_cut)) ((ConfigOptionInt, enable_long_retraction_when_cut))
+136 -7
View File
@@ -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) 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) { if (wxGetApp().plater() == nullptr) {
return; return;
} }
@@ -3986,9 +3990,12 @@ void TabFilament::add_filament_overrides_page()
"filament_retraction_minimum_travel", "filament_retraction_minimum_travel",
"filament_retract_when_changing_layer", "filament_retract_when_changing_layer",
"filament_wipe", "filament_wipe",
//BBS // BBS
"filament_wipe_distance", "filament_wipe_distance",
"filament_retract_before_wipe", "filament_retract_before_wipe",
// Orca
"filament_retract_after_wipe",
// BBS
"filament_long_retractions_when_cut", "filament_long_retractions_when_cut",
"filament_retraction_distances_when_cut" "filament_retraction_distances_when_cut"
//SoftFever //SoftFever
@@ -4112,9 +4119,12 @@ void TabFilament::update_filament_overrides_page(const DynamicPrintConfig* print
"filament_retraction_minimum_travel", "filament_retraction_minimum_travel",
"filament_retract_when_changing_layer", "filament_retract_when_changing_layer",
"filament_wipe", "filament_wipe",
//BBS // BBS
"filament_wipe_distance", "filament_wipe_distance",
"filament_retract_before_wipe", "filament_retract_before_wipe",
// Orca
"filament_retract_after_wipe",
// BBS
"filament_long_retractions_when_cut", "filament_long_retractions_when_cut",
"filament_retraction_distances_when_cut" "filament_retraction_distances_when_cut"
//SoftFever //SoftFever
@@ -4766,6 +4776,69 @@ void TabFilament::clear_pages()
m_overrides_options.clear(); 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<size_t>(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<double>(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<ConfigOptionPercents>(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<ConfigOptionPercents>(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<ConfigOptionPercents>(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*/) wxSizer* Tab::description_line_widget(wxWindow* parent, ogStaticText* *StaticText, wxString text /*= wxEmptyString*/)
{ {
*StaticText = new ogStaticText(parent, text); *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", "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("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); 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 = 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); 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 // some options only apply when not using firmware retraction
vec.resize(0); vec.resize(0);
vec = {"retraction_speed", "deretraction_speed", "retract_before_wipe", vec = {"retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_after_wipe",
"retract_length", "retract_restart_extra", "retract_length", "retract_restart_extra", "wipe_distance"};
"wipe_distance"};
for (auto el : vec) for (auto el : vec)
//BBS //BBS
toggle_option(el, retraction && !use_firmware_retraction, i); toggle_option(el, retraction && !use_firmware_retraction, i);
bool wipe = retraction && m_config->opt_bool("wipe", variant_index); bool wipe = retraction && m_config->opt_bool("wipe", variant_index);
toggle_option("retract_before_wipe", wipe, i);
float retract_before_wipe = static_cast<ConfigOptionPercents*>(m_config->option("retract_before_wipe"))->values[variant_index]; // Orca:
double retract_before_wipe = m_config->option<ConfigOptionPercents>("retract_before_wipe")->get_at(variant_index);
double retract_after_wipe = m_config->option<ConfigOptionPercents>("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) { if (use_firmware_retraction && wipe && retract_before_wipe < 100.0) {
//wxMessageDialog dialog(parent(), //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<size_t>(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<double>(value);
double retract_before_wipe = percent_value_clamp(opt_key_pure == "retract_before_wipe"
? dvalue : m_config->option<ConfigOptionPercents>("retract_before_wipe")->get_at(opt_idx));
double retract_after_wipe = percent_value_clamp(opt_key_pure == "retract_after_wipe"
? dvalue : m_config->option<ConfigOptionPercents>("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() void TabPrinter::update()
{ {
m_update_cnt++; m_update_cnt++;
+3 -1
View File
@@ -608,6 +608,8 @@ public:
void clear_pages() override; void clear_pages() override;
bool supports_printer_technology(const PrinterTechnology tech) const override { return tech == ptFFF; } 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; 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; 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; } bool supports_printer_technology(const PrinterTechnology /* tech */) const override { return true; }
void set_extruder_volume_type(int extruder_id, NozzleVolumeType type); 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); wxSizer* create_bed_shape_widget(wxWindow* parent);
void cache_extruder_cnt(const DynamicPrintConfig* config = nullptr); void cache_extruder_cnt(const DynamicPrintConfig* config = nullptr);
bool apply_extruder_cnt_from_cache(); bool apply_extruder_cnt_from_cache();
}; };
class TabSLAMaterial : public Tab class TabSLAMaterial : public Tab