Support firmware retration and retract_restart_extra

This commit is contained in:
SoftFever 2023-01-07 11:17:55 +08:00
parent 13cd930bb4
commit 0f04df2699
9 changed files with 101 additions and 24 deletions

View file

@ -2455,7 +2455,7 @@ void TabFilament::add_filament_overrides_page()
"filament_z_hop",
"filament_retraction_speed",
"filament_deretraction_speed",
//"filament_retract_restart_extra",
"filament_retract_restart_extra",
"filament_retraction_minimum_travel",
"filament_retract_when_changing_layer",
"filament_wipe",
@ -2486,7 +2486,7 @@ void TabFilament::update_filament_overrides_page()
"filament_z_hop",
"filament_retraction_speed",
"filament_deretraction_speed",
//"filament_retract_restart_extra",
"filament_retract_restart_extra",
"filament_retraction_minimum_travel",
"filament_retract_when_changing_layer",
"filament_wipe",
@ -3367,16 +3367,17 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
//BBS: don't show retract related config menu in machine page
optgroup = page->new_optgroup(L("Retraction"), L"param_retraction");
optgroup->append_single_option_line("retraction_length", "", extruder_idx);
optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);
optgroup->append_single_option_line("z_hop", "", extruder_idx);
optgroup->append_single_option_line("z_lift_type", "", extruder_idx);
optgroup->append_single_option_line("retraction_speed", "", extruder_idx);
optgroup->append_single_option_line("deretraction_speed", "", extruder_idx);
//optgroup->append_single_option_line("retract_restart_extra", "", extruder_idx);
optgroup->append_single_option_line("retraction_minimum_travel", "", extruder_idx);
optgroup->append_single_option_line("retract_when_changing_layer", "", extruder_idx);
optgroup->append_single_option_line("wipe", "", extruder_idx);
optgroup->append_single_option_line("wipe_distance", "", extruder_idx);
optgroup->append_single_option_line("retract_before_wipe", "", extruder_idx);
optgroup->append_single_option_line("use_firmware_retraction");
optgroup = page->new_optgroup(L("Retraction when switching material"), L"param_retraction", -1, true);
optgroup->append_single_option_line("retract_length_toolchange", "", extruder_idx);
@ -3559,13 +3560,17 @@ void TabPrinter::toggle_options()
size_t i = size_t(val - 1);
bool have_retract_length = m_config->opt_float("retraction_length", i) > 0;
// when using firmware retraction, firmware decides retraction length
bool use_firmware_retraction = m_config->opt_bool("use_firmware_retraction");
toggle_option("retract_length", !use_firmware_retraction, i);
// user can customize travel length if we have retraction length or we"re using
// firmware retraction
toggle_option("retraction_minimum_travel", have_retract_length, i);
toggle_option("retraction_minimum_travel", have_retract_length || use_firmware_retraction, i);
// user can customize other retraction options if retraction is enabled
//BBS
bool retraction = have_retract_length;
bool retraction = have_retract_length || use_firmware_retraction;
std::vector<std::string> vec = { "z_hop", "retract_when_changing_layer" };
for (auto el : vec)
toggle_option(el, retraction, i);
@ -3578,10 +3583,29 @@ void TabPrinter::toggle_options()
vec = { "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "wipe", "wipe_distance" };
for (auto el : vec)
//BBS
toggle_option(el, retraction, i);
toggle_option(el, retraction && !use_firmware_retraction, i);
bool wipe = retraction && m_config->opt_bool("wipe", i);
toggle_option("retract_before_wipe", wipe, i);
if (use_firmware_retraction && wipe) {
//wxMessageDialog dialog(parent(),
MessageDialog dialog(parent(),
_(L("The Wipe option is not available when using the Firmware Retraction mode.\n"
"\nShall I disable it in order to enable Firmware Retraction?")),
_(L("Firmware Retraction")), wxICON_WARNING | wxYES | wxNO);
DynamicPrintConfig new_conf = *m_config;
if (dialog.ShowModal() == wxID_YES) {
auto wipe = static_cast<ConfigOptionBools*>(m_config->option("wipe")->clone());
for (size_t w = 0; w < wipe->values.size(); w++)
wipe->values[w] = false;
new_conf.set_key_value("wipe", wipe);
}
else {
new_conf.set_key_value("use_firmware_retraction", new ConfigOptionBool(false));
}
load_config(new_conf);
}
// BBS
toggle_option("wipe_distance", wipe, i);