Publish each extruder's own retraction and Z-hop values

This commit is contained in:
SoftFever
2026-10-07 01:45:24 +08:00
parent d068468bbb
commit c740ddf0a6
3 changed files with 18 additions and 13 deletions
+3 -1
View File
@@ -882,6 +882,8 @@ void PublishSettingsDialog::build_option_model()
const size_t extruders_count = printer_tab->m_extruders_count;
for (size_t extruder_idx = 0; extruder_idx < extruders_count; ++extruder_idx) {
const wxString page_title = Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type);
// Retraction and Z-Hop values are stored per variant column, not per extruder.
const int variant_index = printer_tab->extruder_variant_index(int(extruder_idx));
for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) {
// Allowlist on the untranslated optgroup title; the "Retraction when
// switching material" group is intentionally skipped.
@@ -893,7 +895,7 @@ void PublishSettingsDialog::build_option_model()
// Rows are keyed by the full per-extruder "#N" opt_id so each extruder
// tab publishes its own value; GetPublishedKeys() emits the checked rows
// as-is.
const std::string opt_id = pure_key + "#" + std::to_string(extruder_idx);
const std::string opt_id = pure_key + "#" + std::to_string(variant_index);
if (!printer_added.insert(opt_id).second)
continue;
wxString label, value, unit;
+12 -12
View File
@@ -6225,12 +6225,6 @@ void TabPrinter::toggle_options()
return;
auto nozzle_volumes = m_preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type");
auto extruders = m_config->option<ConfigOptionEnumsGeneric>("extruder_type");
auto get_index_for_extruder =
[this, &extruders](int extruder_id, int stride = 1) {
return m_config->get_index_for_extruder(extruder_id + 1, "printer_extruder_id",
ExtruderType(extruders->values[extruder_id]), get_actual_nozzle_volume_type(extruder_id), "printer_extruder_variant", stride);
};
//BBS: whether the preset is Bambu Lab printer
bool is_BBL_printer = false;
@@ -6311,9 +6305,7 @@ void TabPrinter::toggle_options()
// controls carry field index 0 (i), the values are read for `extruder`.
const size_t i = 0;
const size_t extruder = std::min<size_t>(size_t(get_current_active_extruder()), m_extruders_count - 1);
int variant_index = get_index_for_extruder(extruder);
if (variant_index < 0)
variant_index = int(extruder);
const int variant_index = extruder_variant_index(int(extruder));
bool have_retract_length = m_config->opt_float("retraction_length", variant_index) > 0;
toggle_option("extruder_printable_area", false, i); // disable
@@ -8452,6 +8444,16 @@ int TabPrinter::extruder_page_data_index(const std::string &field_id) const
return -1;
}
int TabPrinter::extruder_variant_index(int extruder)
{
const auto *extruders = m_config->option<ConfigOptionEnumsGeneric>("extruder_type");
const int index = extruder < int(extruders->size()) ?
m_config->get_index_for_extruder(extruder + 1, "printer_extruder_id", ExtruderType(extruders->values[extruder]),
get_actual_nozzle_volume_type(extruder), "printer_extruder_variant") :
-1;
return index < 0 ? extruder : index;
}
void TabPrinter::update_custom_dirty(std::vector<std::string> &dirty_options, std::vector<std::string> &nonsys_options)
{
drop_unchanged_added_entries(dirty_options, *m_config, &m_presets->get_selected_preset());
@@ -8641,9 +8643,7 @@ void Tab::switch_excluder(int extruder_id, bool reload)
if (m_type == Preset::TYPE_PRINTER) {
if (page->title() == "Extruder") {
is_extruder = true;
page_index = page_extruder < int(extruders->size()) ? get_index_for_extruder(page_extruder) : -1;
if (page_index < 0)
page_index = page_extruder;
page_index = static_cast<TabPrinter *>(this)->extruder_variant_index(page_extruder);
} else if (page->title().StartsWith("Motion ability")) {
page_index = get_index_for_extruder(common_extruder, 2);
}
+3
View File
@@ -726,6 +726,9 @@ public:
Page* extruder_page() const;
// Config index an "Extruder" page field (e.g. "retraction_length#0") currently edits, -1 if not on that page.
int extruder_page_data_index(const std::string& field_id) const;
// Config index of an extruder's per-variant options (Retraction, Z-Hop, ...): its variant column
// for the nozzle selected on the switch, or the extruder index on a printer without variants.
int extruder_variant_index(int extruder);
// After the config was restored (roll back): follow its extruder count, if it differs.
void sync_extruders_count();
// Search jump to "Extruder N" / "key#N": selects extruder N on the switch, then activates the