From ba5ecc5470e369a0399ca44ee499d04c5ddbf199 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 7 Oct 2026 13:41:42 +0800 Subject: [PATCH] Edit the selected extruder's machine limits on the Motion ability page --- src/slic3r/GUI/Tab.cpp | 43 ++++++++++++++++++------------------------ src/slic3r/GUI/Tab.hpp | 9 +++++---- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e064043eba..55067f14ca 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -8279,9 +8279,9 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) m_actual_nozzle_volumes.resize(extruder_nums, NozzleVolumeType::nvtStandard); for (int i = 0; i < extruder_nums; i++) m_actual_nozzle_volumes[i] = (NozzleVolumeType)nozzle_volumes->values[i]; - // Orca: a non-Bambu dual-nozzle printer has two extruders but a single variant column, so - // the nozzle switch and sync button have nothing to act on on the variant pages. The printer - // tab still enables the switch to choose the extruder its single "Extruder" page edits. + // Orca: when every extruder uses the same variant (e.g. a non-Bambu dual-nozzle printer), the + // switch has no nozzle variants to select and nothing to sync. The printer tab still enables it + // to choose the extruder its Extruder and Motion ability pages edit. m_extruder_switch_variants = extruder_nums >= 2 && m_preset_bundle->support_different_extruders(); if (m_extruder_switch_variants || (m_type == Preset::TYPE_PRINTER && extruder_nums >= 2)) { auto options = generate_extruder_options(); @@ -8573,7 +8573,7 @@ bool Tab::get_extruder_sync_enable_state(int extruder_id) bool Tab::variant_switch_active() const { if (m_extruder_switch) - return m_extruder_switch->IsThisEnabled() && m_extruder_switch_variants; + return m_extruder_switch->IsThisEnabled(); return m_variant_combo && m_variant_combo->IsThisEnabled(); } @@ -8581,15 +8581,13 @@ void Tab::update_variant_sizer_visibility() { if (!m_variant_sizer) return; - // Orca: the single Extruder page edits the extruder selected on the switch. - const bool on_extruder_page = is_printer_extruder_page(m_active_page); - const bool show = on_extruder_page ? m_extruder_switch && m_extruder_switch->IsThisEnabled() && m_extruder_switch->GetCount() > 1 : - variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty(); + const bool show = variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty(); m_main_sizer->Show(m_variant_sizer, show); if (m_extruder_sync) { m_extruder_sync->Show(show); - // Copying between extruders is offered on the variant pages only. - m_extruder_sync->Enable(!on_extruder_page && variant_switch_active() && get_extruder_sync_enable_state(get_current_active_extruder())); + // Orca: copying between extruders is offered only between nozzle variants, and not on the Extruder page. + m_extruder_sync->Enable(m_extruder_switch_variants && !is_printer_extruder_page(m_active_page) && + get_extruder_sync_enable_state(get_current_active_extruder())); } GetParent()->Layout(); } @@ -8600,15 +8598,16 @@ void Tab::switch_excluder(int extruder_id, bool reload) auto nozzle_volumes = m_preset_bundle->project_config.option("nozzle_volume_type"); auto extruders = printer_preset.config.option("extruder_type"); + // Orca: the printer tab re-targets its pages to the extruder selected on the switch. Resolved before + // the range check below, which keeps the extruder_type read in get_index_for_extruder in range. + if (m_type == Preset::TYPE_PRINTER && extruder_id == -1) + extruder_id = get_current_active_extruder(); if (!m_variant_combo && (extruder_id >= (int)nozzle_volumes->size() || extruder_id >= (int)extruders->size())) extruder_id = 0; - // Orca: the printer's single Extruder page follows the switch for any multi-extruder printer; - // the other pages only when the switch selects nozzle variants. - const bool on_extruder_page = is_printer_extruder_page(m_active_page); if (m_extruder_switch) { int current_extruder = get_current_active_extruder(); bool sync_enable = get_extruder_sync_enable_state(current_extruder); - m_extruder_sync->Enable(variant_switch_active() && sync_enable && !on_extruder_page); + m_extruder_sync->Enable(m_extruder_switch_variants && sync_enable && !is_printer_extruder_page(m_active_page)); m_extruder_sync->Show(); if (m_type != Preset::TYPE_PRINTER) { if (extruder_id == -1) @@ -8630,11 +8629,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) return m_config->get_index_for_extruder(extruder_id + 1, variant_keys.first, ExtruderType(extruders->values[extruder_id]), get_actual_nozzle_volume_type(extruder_id), variant_keys.second, stride); }; - // Extruder of the printer's Extruder page, and of the other pages (the first one when the switch - // does not select variants). - const int page_extruder = extruder_id == -1 ? get_current_active_extruder() : extruder_id; - const int common_extruder = (m_type == Preset::TYPE_PRINTER && !m_extruder_switch_variants) || extruder_id == -1 ? 0 : extruder_id; - auto index = m_variant_combo ? extruder_id : get_index_for_extruder(common_extruder); + auto index = m_variant_combo ? extruder_id : get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id); if (index < 0) return; if (m_extruder_switch) m_extruder_switch->SetClientData(reinterpret_cast(static_cast(index))); @@ -8643,12 +8638,10 @@ void Tab::switch_excluder(int extruder_id, bool reload) bool is_extruder = false; int page_index = index; if (m_type == Preset::TYPE_PRINTER) { - if (page->title() == "Extruder") { + if (page->title() == "Extruder") is_extruder = true; - page_index = static_cast(this)->extruder_variant_index(page_extruder); - } else if (page->title().StartsWith("Motion ability")) { - page_index = get_index_for_extruder(common_extruder, 2); - } + else if (page->title().StartsWith("Motion ability")) + page_index = get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id, 2); } page->m_opt_id_map.clear(); for (auto group : page->m_optgroups) { @@ -8656,7 +8649,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) if (is_extruder && opt.second.second >= 0) { // Per-variant options use the variant column, the others (nozzle_diameter, // extruder_offset, ...) are sized by the extruder count and use the extruder. - const int idx = printer_options_with_variant_1.count(opt.second.first) > 0 ? page_index : page_extruder; + const int idx = printer_options_with_variant_1.count(opt.second.first) > 0 ? page_index : extruder_id; const_cast(opt.second.second) = idx; page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(idx), opt.first}); continue; diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index f7ebafcbe3..e916dd6f7d 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -331,9 +331,9 @@ public: MultiSwitchButton * m_variant_combo = nullptr; ScalableButton *m_extruder_sync = nullptr; wxPanel * m_extruder_sync_box = nullptr; - // Orca: whether m_extruder_switch switches nozzle variants (it is then shown on the variant pages). + // Orca: whether m_extruder_switch switches nozzle variants (it then offers sync between them). // The printer tab also enables the switch for printers without variants, to choose the extruder - // its single "Extruder" page edits. + // its Extruder and Motion ability pages edit. bool m_extruder_switch_variants = false; std::vector m_actual_nozzle_volumes; @@ -391,11 +391,12 @@ public: void update_changed_tree_ui(); void update_undo_buttons(); void update_extruder_switch_colors(); - // Whether the variant switch (m_extruder_switch / m_variant_combo) switches nozzle variants. + // Whether the variant switch (m_extruder_switch / m_variant_combo) is enabled: on the printer tab for + // any multi-extruder printer, on the other tabs when it switches nozzle variants. bool variant_switch_active() const; // Orca: whether `page` is the printer tab's single "Extruder" page, which edits the extruder selected on the switch. bool is_printer_extruder_page(const Page* page) const { return m_type == Preset::TYPE_PRINTER && page && page->title() == "Extruder"; } - // Shows the variant switch row on variant pages, and on the printer tab's "Extruder" page. + // Shows the variant switch row on pages with options that follow it. void update_variant_sizer_visibility(); void update_all_extruder_options_status(); void check_extruder_options_status(int index, bool &sys_extruder, bool &modified_extruder, const std::vector& pages_to_check);