Keep the printer preset when reselecting its nozzle diameter

Printers without a named nozzle variant no longer switch profiles when their
current diameter is picked in the sidebar. The filament tab reads the selected
variant through one helper.
This commit is contained in:
SoftFever
2026-10-01 02:54:18 +08:00
parent c03f4925a9
commit e1da47a72b
4 changed files with 34 additions and 25 deletions
+3 -3
View File
@@ -79,9 +79,9 @@ public:
void apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase*, ModelConfig*> const & configs); void apply_null_fff_config(DynamicPrintConfig *config, std::vector<std::string> const &keys, std::map<ObjectBase*, ModelConfig*> const & configs);
//BBS: FFF filament nozzle temperature range //BBS: FFF filament nozzle temperature range
void check_nozzle_recommended_temperature_range(DynamicPrintConfig *config, unsigned int variant_index = 0); void check_nozzle_recommended_temperature_range(DynamicPrintConfig *config, unsigned int variant_index);
void check_nozzle_temperature_range(DynamicPrintConfig* config, unsigned int variant_index = 0); void check_nozzle_temperature_range(DynamicPrintConfig* config, unsigned int variant_index);
void check_nozzle_temperature_initial_layer_range(DynamicPrintConfig* config, unsigned int variant_index = 0); void check_nozzle_temperature_initial_layer_range(DynamicPrintConfig* config, unsigned int variant_index);
void check_adaptive_pressure_advance_model(DynamicPrintConfig* config); void check_adaptive_pressure_advance_model(DynamicPrintConfig* config);
void check_filament_max_volumetric_speed(DynamicPrintConfig *config); void check_filament_max_volumetric_speed(DynamicPrintConfig *config);
void check_chamber_temperature(DynamicPrintConfig* config); void check_chamber_temperature(DynamicPrintConfig* config);
+10 -9
View File
@@ -1797,16 +1797,17 @@ bool Sidebar::priv::switch_diameter_to(const wxString &diameter)
Preset& printer_preset = wxGetApp().preset_bundle->printers.get_edited_preset(); Preset& printer_preset = wxGetApp().preset_bundle->printers.get_edited_preset();
// The combo lists printer variants, and the variant of a mixed-nozzle machine ("0.4+0.6") is no // The combo lists printer variants, and the variant of a mixed-nozzle machine ("0.4+0.6") is no
// single extruder's diameter, so the preset's own variant answers first. // single extruder's diameter, so the preset's own variant answers first.
if (printer_preset.config.opt_string("printer_variant") == diameter.ToStdString()) { const std::string &printer_variant = printer_preset.config.opt_string("printer_variant");
if (printer_variant == diameter.ToStdString()) {
return true; return true;
} }
// A named variant ("0.4 High Flow") shares its diameter with the standard profile, which selecting
// the plain diameter switches back to, so only a preset naming no variant is kept by its diameter.
auto* nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter")); auto* nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter"));
if (nozzle_diameter && nozzle_diameter->size() > 0) { if (printer_variant.empty() && nozzle_diameter && nozzle_diameter->size() > 0) {
auto current_nozzle_dia = get_diameter_string(nozzle_diameter->values[0]); auto current_nozzle_dia = get_diameter_string(nozzle_diameter->values[0]);
// A named variant can share this diameter; selecting the plain diameter // If the selected diameter is the same as current nozzle, don't switch profiles
// must still switch back to the standard profile. if (current_nozzle_dia == diameter.ToStdString()) {
if (current_nozzle_dia == diameter.ToStdString() &&
printer_preset.config.opt_string("printer_variant") == diameter.ToStdString()) {
return true; return true;
} }
} }
@@ -3944,9 +3945,9 @@ void Sidebar::update_presets(Preset::Type preset_type)
auto nozzle_dia = get_diameter_string(nozzle_diameter->values[extruder_index]); auto nozzle_dia = get_diameter_string(nozzle_diameter->values[extruder_index]);
// Named variants such as "0.4HS" and "0.4 High Flow" share a physical diameter. // Named variants such as "0.4HS" and "0.4 High Flow" share a physical diameter.
// Retain the variant selection unless the diameter was customized. // Retain the variant selection unless the diameter was customized.
const auto selected_variant = const bool keep_variant = diameter.substr(0, diameter.find_first_not_of("0123456789.")) == nozzle_dia &&
diameter.substr(0, diameter.find_first_not_of("0123456789.")) == nozzle_dia && std::find(diameters.begin(), diameters.end(), diameter) != diameters.end();
std::find(diameters.begin(), diameters.end(), diameter) != diameters.end() ? diameter : nozzle_dia; const std::string &selected_variant = keep_variant ? diameter : nozzle_dia;
// ORCA try to add nozzle diameter from config if list is empty. fixes blank nozzle combo box when preset has no alias // ORCA try to add nozzle diameter from config if list is empty. fixes blank nozzle combo box when preset has no alias
if(!diameters.empty() && diameters[0].empty() && !nozzle_dia.empty()){ if(!diameters.empty() && diameters[0].empty() && !nozzle_dia.empty()){
diameters[0] = nozzle_dia; diameters[0] = nozzle_dia;
+19 -13
View File
@@ -4404,8 +4404,9 @@ void TabFilament::build()
DynamicPrintConfig &filament_config = m_preset_bundle->filaments.get_edited_preset().config; DynamicPrintConfig &filament_config = m_preset_bundle->filaments.get_edited_preset().config;
update_dirty(); update_dirty();
if (!m_postpone_update_ui && (opt_key.substr(0, opt_key.find('#')) == "nozzle_temperature_range_low" || opt_key.substr(0, opt_key.find('#')) == "nozzle_temperature_range_high")) { const std::string opt_key_without_idx = opt_key.substr(0, opt_key.find('#'));
m_config_manipulation.check_nozzle_recommended_temperature_range(&filament_config, m_variant_combo ? std::max(0, m_variant_combo->GetSelection()) : 0); if (!m_postpone_update_ui && (opt_key_without_idx == "nozzle_temperature_range_low" || opt_key_without_idx == "nozzle_temperature_range_high")) {
m_config_manipulation.check_nozzle_recommended_temperature_range(&filament_config, selected_variant_index());
} }
on_value_change(opt_key, value); on_value_change(opt_key, value);
}; };
@@ -4520,6 +4521,7 @@ void TabFilament::build()
DynamicPrintConfig& filament_config = m_preset_bundle->filaments.get_edited_preset().config; DynamicPrintConfig& filament_config = m_preset_bundle->filaments.get_edited_preset().config;
update_dirty(); update_dirty();
const std::string opt_key_without_idx = opt_key.substr(0, opt_key.find('#'));
/*if (opt_key == "cool_plate_temp" || opt_key == "cool_plate_temp_initial_layer") { /*if (opt_key == "cool_plate_temp" || opt_key == "cool_plate_temp_initial_layer") {
m_config_manipulation.check_bed_temperature_difference(BedType::btPC, &filament_config); m_config_manipulation.check_bed_temperature_difference(BedType::btPC, &filament_config);
} }
@@ -4532,11 +4534,11 @@ void TabFilament::build()
else if (opt_key == "textured_plate_temp" || opt_key == "textured_plate_temp_initial_layer") { else if (opt_key == "textured_plate_temp" || opt_key == "textured_plate_temp_initial_layer") {
m_config_manipulation.check_bed_temperature_difference(BedType::btPTE, &filament_config); m_config_manipulation.check_bed_temperature_difference(BedType::btPTE, &filament_config);
} }
else */if (opt_key.substr(0, opt_key.find('#')) == "nozzle_temperature") { else */if (opt_key_without_idx == "nozzle_temperature") {
m_config_manipulation.check_nozzle_temperature_range(&filament_config, m_variant_combo ? std::max(0, m_variant_combo->GetSelection()) : 0); m_config_manipulation.check_nozzle_temperature_range(&filament_config, selected_variant_index());
} }
else if (opt_key.substr(0, opt_key.find('#')) == "nozzle_temperature_initial_layer") { else if (opt_key_without_idx == "nozzle_temperature_initial_layer") {
m_config_manipulation.check_nozzle_temperature_initial_layer_range(&filament_config, m_variant_combo ? std::max(0, m_variant_combo->GetSelection()) : 0); m_config_manipulation.check_nozzle_temperature_initial_layer_range(&filament_config, selected_variant_index());
} }
on_value_change(opt_key, value); on_value_change(opt_key, value);
@@ -4770,9 +4772,14 @@ void TabFilament::update_description_lines()
// this->update_volumetric_flow_preset_hints(); // this->update_volumetric_flow_preset_hints();
} }
unsigned int TabFilament::selected_variant_index() const
{
return m_variant_combo ? std::max(0, m_variant_combo->GetSelection()) : 0;
}
void TabFilament::toggle_options() void TabFilament::toggle_options()
{ {
const unsigned int variant_index = m_variant_combo ? std::max(0, m_variant_combo->GetSelection()) : 0; const unsigned int variant_index = selected_variant_index();
if (!m_active_page) if (!m_active_page)
return; return;
bool is_BBL_printer = false; bool is_BBL_printer = false;
@@ -4882,20 +4889,19 @@ void TabFilament::toggle_options()
if (m_active_page->title() == L("Multimaterial")) { if (m_active_page->title() == L("Multimaterial")) {
// Orca: hide specific settings for BBL printers // Orca: hide specific settings for BBL printers
for (auto el : {"filament_minimal_purge_on_wipe_tower", "filament_loading_speed_start", "filament_loading_speed", toggle_option("filament_minimal_purge_on_wipe_tower", !is_BBL_printer, 256 + variant_index);
for (auto el : {"filament_loading_speed_start", "filament_loading_speed",
"filament_unloading_speed_start", "filament_unloading_speed", "filament_toolchange_delay", "filament_cooling_moves", "filament_unloading_speed_start", "filament_unloading_speed", "filament_toolchange_delay", "filament_cooling_moves",
"filament_cooling_initial_speed", "filament_cooling_final_speed"}) "filament_cooling_initial_speed", "filament_cooling_final_speed"})
toggle_option(el, !is_BBL_printer, filament_options_with_variant.count(el) ? 256 + variant_index : -1); toggle_option(el, !is_BBL_printer);
bool multitool_ramming = m_config->opt_bool("filament_multitool_ramming", variant_index); bool multitool_ramming = m_config->opt_bool("filament_multitool_ramming", variant_index);
toggle_option("filament_multitool_ramming_volume", multitool_ramming, 256 + variant_index); toggle_option("filament_multitool_ramming_volume", multitool_ramming, 256 + variant_index);
toggle_option("filament_multitool_ramming_flow", multitool_ramming, 256 + variant_index); toggle_option("filament_multitool_ramming_flow", multitool_ramming, 256 + variant_index);
bool is_BBL_multi_extruder = is_BBL_printer && printer_cfg.option<ConfigOptionFloats>("nozzle_diameter")->size() > 1; bool is_BBL_multi_extruder = is_BBL_printer && printer_cfg.option<ConfigOptionFloats>("nozzle_diameter")->size() > 1;
const int selection = m_variant_combo ? m_variant_combo->GetSelection() : 0; toggle_line("long_retractions_when_ec", is_BBL_multi_extruder, 256 + variant_index);
const int extruder_idx = std::max(selection, 0); toggle_line("retraction_distances_when_ec", is_BBL_multi_extruder && m_config->opt_bool("long_retractions_when_ec", variant_index), 256 + variant_index);
toggle_line("long_retractions_when_ec", is_BBL_multi_extruder, 256 + extruder_idx);
toggle_line("retraction_distances_when_ec", is_BBL_multi_extruder && m_config->opt_bool("long_retractions_when_ec", extruder_idx), 256 + extruder_idx);
} }
} }
+2
View File
@@ -616,6 +616,8 @@ private:
void add_filament_overrides_page(); void add_filament_overrides_page();
void update_filament_overrides_page(const DynamicPrintConfig* printers_config); void update_filament_overrides_page(const DynamicPrintConfig* printers_config);
void update_volumetric_flow_preset_hints(); void update_volumetric_flow_preset_hints();
// The variant index the variant switch shows, 0 without one.
unsigned int selected_variant_index() const;
std::map<std::string, ::CheckBox*> m_overrides_options; std::map<std::string, ::CheckBox*> m_overrides_options;