mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-27 12:52:07 +00:00
Feature: Retract amount after wipe (#11015)
Co-authored-by: Ian Bassi <ian.bassi@outlook.com>
This commit is contained in:
@@ -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<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*/)
|
||||
{
|
||||
*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<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) {
|
||||
//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()
|
||||
{
|
||||
m_update_cnt++;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user