ENH: add default params for long retraction

1. Only auto calculate flush when enabled
2. Add default params for long retraction
3. Disable filament override for unsupport machines

jira:NEW

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Ib5d51505b58101839527e944f9a237483951f9fe
This commit is contained in:
xun.zhang 2024-04-02 19:48:34 +08:00 committed by Lane.Wei
parent 081ac40f38
commit 7116c5a7c5
19 changed files with 90 additions and 34 deletions

View File

@ -8,6 +8,12 @@
"filament_max_volumetric_speed": [
"1"
],
"filament_long_retractions_when_cut": [
"1"
],
"filament_retraction_distances_when_cut": [
"18"
],
"compatible_printers": [
"Bambu Lab X1 Carbon 0.2 nozzle",
"Bambu Lab X1 0.2 nozzle",

View File

@ -11,6 +11,12 @@
"fan_min_speed": [
"20"
],
"filament_long_retractions_when_cut": [
"1"
],
"filament_retraction_distances_when_cut": [
"18"
],
"filament_max_volumetric_speed": [
"16"
],

View File

@ -8,6 +8,12 @@
"filament_max_volumetric_speed": [
"13"
],
"filament_long_retractions_when_cut": [
"1"
],
"filament_retraction_distances_when_cut": [
"18"
],
"compatible_printers": [
"Bambu Lab X1 Carbon 0.4 nozzle",
"Bambu Lab X1 0.4 nozzle",

View File

@ -8,6 +8,12 @@
"filament_max_volumetric_speed": [
"21"
],
"filament_long_retractions_when_cut": [
"1"
],
"filament_retraction_distances_when_cut": [
"18"
],
"slow_down_layer_time": [
"8"
],

View File

@ -5,6 +5,12 @@
"from": "system",
"setting_id": "GFSA00_00",
"instantiation": "true",
"filament_long_retractions_when_cut": [
"1"
],
"filament_retraction_distances_when_cut": [
"18"
],
"filament_max_volumetric_speed": [
"2"
],

View File

@ -8,6 +8,12 @@
"filament_max_volumetric_speed": [
"21"
],
"filament_long_retractions_when_cut": [
"1"
],
"filament_retraction_distances_when_cut": [
"18"
],
"compatible_printers": [
"Bambu Lab X1 Carbon 0.8 nozzle",
"Bambu Lab P1S 0.8 nozzle",

View File

@ -8,6 +8,12 @@
"filament_max_volumetric_speed": [
"21"
],
"filament_long_retractions_when_cut": [
"1"
],
"filament_retraction_distances_when_cut": [
"18"
],
"compatible_printers": [
"Bambu Lab X1 Carbon 0.4 nozzle",
"Bambu Lab X1 Carbon 0.6 nozzle",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -247,6 +247,10 @@ void AppConfig::set_defaults()
set_bool("auto_calculate", true);
}
if (get("auto_calculate_when_filament_change").empty()){
set_bool("auto_calculate_when_filament_change", true);
}
if (get("show_home_page").empty()) {
set_bool("show_home_page", true);
}

View File

@ -179,7 +179,12 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"activate_air_filtration",
"during_print_exhaust_fan_speed",
"complete_print_exhaust_fan_speed",
"use_firmware_retraction"
"use_firmware_retraction",
"enable_long_retraction_when_cut",
"long_retractions_when_cut",
"retraction_distances_when_cut",
"filament_long_retractions_when_cut",
"filament_retraction_distances_when_cut"
};
static std::unordered_set<std::string> steps_ignore;

View File

@ -230,20 +230,22 @@ static t_config_option_keys print_config_diffs(
if (opt_new == nullptr)
//FIXME This may happen when executing some test cases.
continue;
if ((opt_key == "long_retractions_when_cut" || opt_key == "retraction_distances_when_cut")
&& current_config.enable_long_retraction_when_cut.getInt() != 2)
continue; //BBS: hard code here, remove it later if the machine firwmare support
const ConfigOption *opt_new_filament = std::binary_search(extruder_retract_keys.begin(), extruder_retract_keys.end(), opt_key) ? new_full_config.option(filament_prefix + opt_key) : nullptr;
if (opt_new_filament != nullptr && ! opt_new_filament->is_nil()) {
// An extruder retract override is available at some of the filament presets.
bool overriden = opt_new->overriden_by(opt_new_filament);
if (overriden || *opt_old != *opt_new) {
auto opt_copy = opt_new->clone();
opt_copy->apply_override(opt_new_filament);
if (!((opt_key == "long_retractions_when_cut" || opt_key == "retraction_distances_when_cut")
&& new_full_config.option<ConfigOptionInt>("enable_long_retraction_when_cut")->value != LongRectrationLevel::EnableFilament)) // ugly code, remove it later if firmware supports
opt_copy->apply_override(opt_new_filament);
bool changed = *opt_old != *opt_copy;
if (changed)
print_diff.emplace_back(opt_key);
if (changed || overriden) {
if ((opt_key == "long_retractions_when_cut" || opt_key == "retraction_distances_when_cut")
&& new_full_config.option<ConfigOptionInt>("enable_long_retraction_when_cut")->value != LongRectrationLevel::EnableFilament)
continue;
// filament_overrides will be applied to the placeholder parser, which layers these parameters over full_print_config.
filament_overrides.set_key_value(opt_key, opt_copy);
} else

View File

@ -112,6 +112,13 @@ enum SupportMaterialStyle {
smsDefault, smsGrid, smsSnug, smsTreeSlim, smsTreeStrong, smsTreeHybrid, smsTreeOrganic
};
enum LongRectrationLevel
{
Disabled=0,
EnableMachine,
EnableFilament
};
enum SupportMaterialInterfacePattern {
smipAuto, smipRectilinear, smipConcentric, smipRectilinearInterlaced, smipGrid
};

View File

@ -312,16 +312,18 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
}
}
else if(m_opt_id == "filament_retraction_distances_when_cut" || opt_key_without_idx == "retraction_distances_when_cut"){
wxString msg_text = format_wxstr(_L("Value %s is out of range. The valid range is from %d to %d."), str, m_opt.min, m_opt.max);
WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES);
if (dialog.ShowModal()) {
if (m_value.empty()) {
if (m_opt.min > val) val = m_opt.min;
if (val > m_opt.max) val = m_opt.max;
if (m_value.empty() || boost::any_cast<double>(m_value) != val) {
wxString msg_text = format_wxstr(_L("Value %s is out of range. The valid range is from %d to %d."), str, m_opt.min, m_opt.max);
WarningDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxYES);
if (dialog.ShowModal()) {
if (m_value.empty()) {
if (m_opt.min > val) val = m_opt.min;
if (val > m_opt.max) val = m_opt.max;
}
else
val = boost::any_cast<double>(m_value);
set_value(double_to_string(val), true);
}
else
val = boost::any_cast<double>(m_value);
set_value(double_to_string(val), true);
}
}
else {

View File

@ -6352,10 +6352,12 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
view3D->deselect_all();
}
#if 0 // do not toggle auto calc when change printer
// update flush matrix
size_t filament_size = wxGetApp().plater()->get_extruder_colors_from_plater_config().size();
for (size_t idx = 0; idx < filament_size; ++idx)
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(idx);
#endif
}
#ifdef __WXMSW__
@ -6364,6 +6366,10 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
// So, set the focus to the combobox explicitly
combo->SetFocus();
#endif
if (preset_type == Preset::TYPE_FILAMENT && wxGetApp().app_config->get("auto_calculate_when_filament_change") == "true") {
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(idx);
}
// BBS: log modify of filament selection
Slic3r::put_other_changes();

View File

@ -54,12 +54,6 @@ class Ams;
using ModelInstancePtrs = std::vector<ModelInstance*>;
enum LongRectrationLevel
{
Disabled=0,
EnableMachine,
EnableFilament
};
namespace UndoRedo {
class Stack;

View File

@ -877,6 +877,8 @@ PreferencesDialog::PreferencesDialog(wxWindow *parent, wxWindowID id, const wxSt
std::string value;
value = wxGetApp().app_config->get("auto_calculate");
j["auto_flushing"] = value;
value = wxGetApp().app_config->get("auto_calculate_when_filament_change");
j["auto_calculate_when_filament_change"] = value;
agent->track_event("preferences_changed", j.dump());
}
} catch(...) {}
@ -1035,6 +1037,7 @@ wxWindow* PreferencesDialog::create_general_page()
"user_bed_type");
//auto item_hints = create_item_checkbox(_L("Show \"Tip of the day\" notification after start"), page, _L("If enabled, useful hints are displayed at startup."), 50, "show_hints");
auto item_calc_mode = create_item_checkbox(_L("Flushing volumes: Auto-calculate every time when the color is changed."), page, _L("If enabled, auto-calculate every time when the color is changed."), 50, "auto_calculate");
auto item_calc_in_long_retract = create_item_checkbox(_L("Flushing volumes: Auto-calculate every time when the filament is changed."), page, _L("If enabled, auto-calculate every time when filament is changed"), 50, "auto_calculate_when_filament_change");
auto title_presets = create_item_title(_L("Presets"), page, _L("Presets"));
auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset");
auto item_system_sync = create_item_checkbox(_L("Update built-in Presets automatically."), page, _L("System Sync"), 50, "sync_system_preset");
@ -1101,6 +1104,7 @@ wxWindow* PreferencesDialog::create_general_page()
sizer_page->Add(item_bed_type_follow_preset, 0, wxTOP, FromDIP(3));
//sizer_page->Add(item_hints, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_calc_mode, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_calc_in_long_retract, 0, wxTOP, FromDIP(3));
sizer_page->Add(title_presets, 0, wxTOP | wxEXPAND, FromDIP(20));
sizer_page->Add(item_user_sync, 0, wxTOP, FromDIP(3));
sizer_page->Add(item_system_sync, 0, wxTOP, FromDIP(3));

View File

@ -1560,14 +1560,8 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
"Although it can notably reduce flush, it may also elevate the risk of nozzle clogs or other printing complications."), "", wxICON_WARNING | wxOK);
dialog.ShowModal();
}
update_flush_volume();
}
if (opt_key_without_idx == "retraction_distances_when_cut")
update_flush_volume();
if (opt_key == "filament_long_retractions_when_cut"){
unsigned char activate = boost::any_cast<unsigned char>(value);
if (activate == 1) {
@ -1576,12 +1570,8 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
"Although it can notably reduce flush, it may also elevate the risk of nozzle clogs or other printing complications.Please use with the latest printer firmware."), "", wxICON_WARNING | wxOK);
dialog.ShowModal();
}
update_flush_volume();
}
if (opt_key == "filament_retraction_distances_when_cut")
update_flush_volume();
// BBS
#if 0

View File

@ -376,7 +376,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
auto message_sizer = new wxBoxSizer(wxVERTICAL);
tip_message_panel->SetSizer(message_sizer);
{
wxString message = _L("Studio would re-calculate your flushing volumes everytime the filaments color changed. You could disable the auto-calculate in Bambu Studio > Preferences");
wxString message = _L("Studio would re-calculate your flushing volumes everytime the filaments color changed or filaments changed. You could disable the auto-calculate in Bambu Studio > Preferences");
m_tip_message_label = new Label(tip_message_panel, wxEmptyString);
wxClientDC dc(tip_message_panel);
wxString multiline_message;
@ -386,7 +386,7 @@ WipingPanel::WipingPanel(wxWindow* parent, const std::vector<float>& matrix, con
message_sizer->Add(m_tip_message_label, 0, wxEXPAND | wxALL, TIP_MESSAGES_PADDING);
}
m_sizer_advanced->Add(tip_message_panel, 0, wxEXPAND | wxRIGHT | wxLEFT, TABLE_BORDER);
bool is_show = wxGetApp().app_config->get("auto_calculate") == "true";
bool is_show = wxGetApp().app_config->get("auto_calculate") == "true" || wxGetApp().app_config->get("auto_calculate_when_filament_change") == "true";
tip_message_panel->Show(is_show);
m_sizer_advanced->AddSpacer(FromDIP(10));
auto calc_btn_sizer = create_calc_btn_sizer(m_page_advanced);