From 738d72575df34239a604f095564d2f08bb5cd42d Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Wed, 18 Nov 2026 17:08:19 +0800 Subject: [PATCH] feat: generalize tool layouts and AMS sync indicators --- docs/HLSD/multi-extruder-ams.md | 13 +- src/slic3r/GUI/FilamentMapDialog.cpp | 22 +- src/slic3r/GUI/Plater.cpp | 389 ++++++++++++++++++-------- src/slic3r/GUI/SelectMachine.cpp | 41 ++- src/slic3r/GUI/StatusPanel.cpp | 75 ++--- src/slic3r/GUI/Widgets/AMSControl.cpp | 92 +++--- src/slic3r/GUI/Widgets/AMSItem.cpp | 15 +- src/slic3r/GUI/Widgets/TextInput.cpp | 27 +- src/slic3r/GUI/Widgets/TextInput.hpp | 4 + 9 files changed, 452 insertions(+), 226 deletions(-) diff --git a/docs/HLSD/multi-extruder-ams.md b/docs/HLSD/multi-extruder-ams.md index d6774d1578..f27c9cfc7c 100644 --- a/docs/HLSD/multi-extruder-ams.md +++ b/docs/HLSD/multi-extruder-ams.md @@ -196,10 +196,9 @@ The device-control widgets follow the same device-reported counts. - The status panel builds external-spool entries from `MachineObject::vt_slot`; generic slot synthesis keeps one empty entry available for each live toolhead even when the printer does not report external-spool state. -- The status panel's `ExtruderImage` renders one per-toolhead state per nozzle and is resized to - `GetTotalExtderCount()`. Non-Bambu printers choose the active toolhead through - `m_generic_nozzle_selector` (shown when more than one toolhead exists); Bambu keeps its left/right - `m_nozzle_btn_panel`. Nozzle temperature controls are created on demand per toolhead. +- The status panel uses the single or left/right nozzle presentation for one or two toolheads, + and an indexed `ExtruderImage` and toolhead selector for three or more. Nozzle temperature + controls are created on demand for generic printers and printers with more than two toolheads. ## Constraints @@ -219,9 +218,9 @@ The device-control widgets follow the same device-reported counts. `nozzle_diameter` entries as the device has toolheads. A mismatch is surfaced only as a log warning (`StatusPanel::check_extruder_count_mismatch()`), deliberately log-only, because the sidebar and extruder logic would otherwise silently disagree. -- **Bambu compatibility.** Bambu-specific presentation (left/right pair, fixed 4-slot units, fixed - virtual ids, physical/logical inversion) is preserved behind the vendor check. Generic paths do - not alter it. +- **Bambu compatibility.** The two-tool left/right presentation is shared across vendors. + Bambu protocol details, including fixed 4-slot units, fixed virtual ids and physical/logical + inversion, remain separate from generic paths. - **Tray-index invariant.** The generic tray-index map is cumulative, so payload tray ids must be unique, 0-based, and contiguous per unit. A malformed id is a producer error. - **Protocol markers.** The dialect has no neutral equivalent for some Bambu state, so agents that diff --git a/src/slic3r/GUI/FilamentMapDialog.cpp b/src/slic3r/GUI/FilamentMapDialog.cpp index 00fdfe6d21..135a700069 100644 --- a/src/slic3r/GUI/FilamentMapDialog.cpp +++ b/src/slic3r/GUI/FilamentMapDialog.cpp @@ -9,6 +9,7 @@ #include "MsgDialog.hpp" #include "libslic3r/PrintConfig.hpp" #include "libslic3r/Config.hpp" +#include #include #include #include @@ -131,12 +132,10 @@ bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* p if (nozzle_diameters->size() <= 1) return true; - // The filament-grouping dialog is specifically designed for BBL dual-nozzle printers - // (e.g. H2D) where filaments must be assigned to a left or right nozzle. - // For toolchangers (≥3 tools) and all non-BBL printers the dialog is irrelevant and - // confusing; skip it entirely so slicing proceeds without interruption. (#12390) + // Generic automatic grouping does not implement the modes described by this dialog. + // The dialog also has exactly two destinations. PresetBundle* preset = wxGetApp().preset_bundle; - if (!preset || !preset->is_bbl_vendor() || nozzle_diameters->size() != 2) + if (!preset || !preset->is_bbl_vendor() || preset->get_printer_extruder_count() != 2) return true; bool sync_plate = true; @@ -146,12 +145,19 @@ bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* p FilamentMapMode applied_mode = get_applied_map_mode(full_config, plater_ref,partplate_ref, sync_plate); std::vector applied_maps = get_applied_map(full_config, plater_ref, partplate_ref, sync_plate); std::vector applied_volume_maps = get_applied_volume_map(full_config, plater_ref, partplate_ref, sync_plate); - applied_maps.resize(filament_colors.size(), 1); - applied_volume_maps.resize(filament_colors.size(), 0); - if (!force_pop_up && applied_mode != fmmManual) return true; + if (std::any_of(applied_maps.begin(), applied_maps.end(), [](int tool) { return tool < 1 || tool > 2; })) { + MessageDialog dlg(plater_ref, _L("The saved filament grouping refers to an extruder that is not available on this printer. Select a compatible printer before editing the grouping."), + _L("Filament grouping"), wxOK | wxICON_WARNING); + dlg.ShowModal(); + return false; + } + + applied_maps.resize(filament_colors.size(), 1); + applied_volume_maps.resize(filament_colors.size(), 0); + std::vector filament_lists; if (is_slice_all) { filament_lists.resize(filament_colors.size()); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 67e4858bcd..fe82f7f792 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -785,6 +785,8 @@ struct ExtruderGroup : StaticBox Label * prefix = nullptr; Label * diameter_label = nullptr; // read-only nozzle diameter of this extruder + wxStaticBitmap *diameter_badge = nullptr; + bool nozzle_synced = false; ComboBox * flow = nullptr; wxBoxSizer *row_sizer = nullptr; // the row's line, moved between the two columns as needed }; @@ -820,7 +822,7 @@ struct ExtruderGroup : StaticBox wxBoxSizer * rows_sizer = nullptr; wxBoxSizer * row_columns[2] = {}; // row i is dealt into column i % 2 bool rows_single_column = false; - int group_index = -1; // ctor index, the extruder a single-row group edits + int group_index = -1; // preset extruder edited by a single-row group // Show `count` nozzle rows, one per extruder, each prefixed with T when count > 1. void SetNozzleRowCount(size_t count); @@ -853,6 +855,8 @@ struct ExtruderGroup : StaticBox // Nozzle diameter readout of the shown rows, one value per extruder. A listing card cannot edit // it: the diameter belongs to the machine variant the printer preset selects, not to the extruder. void SetRowDiameters(const std::vector &diameters); + void SetNozzleSynced(size_t row, bool synced); + void ClearNozzleSynced(); NozzleRow create_nozzle_row(); // Widths the prefix and diameter labels of the visible rows so that the flow combos of a column @@ -889,9 +893,13 @@ struct ExtruderGroup : StaticBox btn_up->msw_rescale(); btn_down->msw_rescale(); combo_diameter->Rescale(); + if (group_index >= 0) + combo_diameter->SetMinSize(wxSize(combo_diameter->GetTextExtent("0.25").x + combo_diameter->FromDIP(40), + combo_diameter->GetMinSize().y)); for (const NozzleRow &row : rows) { row.prefix->SetFont(NozzleRow::prefix_font()); row.diameter_label->SetFont(NozzleRow::diameter_font()); + row.diameter_badge->SetBitmap(ScalableBitmap(this, "badge", 14).bmp()); row.flow->Rescale(); } update_row_widths(); @@ -1211,11 +1219,9 @@ void Sidebar::priv::layout_printer(bool isBBL, bool isDual) int extruder_count = 0; const bool has_flow_variant = cfg.support_different_extruders(extruder_count); - // ORCA: a non-Bambu printer with several extruders lists nozzle rows per tool; Bambu's own - // multi-extruder printers keep the left/right pair above. Beyond two tools the card shows one - // tool at a time, chosen with the selector, so the AMS section has room to stay visible. - const bool multi_extruder_rows = !preset_bundle.is_bbl_vendor() && extruder_count > 1; - const bool generic_multi_tool = multi_extruder_rows && extruder_count > 2; + // Three or more tools use an indexed card rather than the two left/right cards. + const bool multi_extruder_rows = extruder_count > 2; + const bool generic_multi_tool = multi_extruder_rows; update_tool_selector(extruder_count, generic_multi_tool); const auto &diameters = cfg.option("nozzle_diameter")->values; @@ -1738,6 +1744,29 @@ static std::vector generic_preset_to_device_map(const PresetBundle &bundle, return map; } +// Bambu's preset indices already follow left/right order. Generic preset indices do not: +// the device tab places device tool 1 on the left and tool 0 on the right. +static std::pair dual_card_preset_indices(PresetBundle &bundle) +{ + if (bundle.is_bbl_vendor()) + return {0, 1}; + const auto map = generic_preset_to_device_map(bundle, 2); + if (map[0] == 1 && map[1] == 0) + return {0, 1}; + if (map[0] == 0 && map[1] == 1) + return {1, 0}; + // No unique left/right assignment. Use indexed titles until the map is corrected. + return {0, 1}; +} + +static bool has_generic_dual_sides(PresetBundle &bundle) +{ + if (bundle.is_bbl_vendor()) + return true; + const auto map = generic_preset_to_device_map(bundle, 2); + return (map[0] == 0 && map[1] == 1) || (map[0] == 1 && map[1] == 0); +} + // Actual AMS capacity reported by a generic printer: one map entry per unit slot count, indexed by // the preset extruder order used by extruder_ams_counts and the slice config. Each AMS binding names // a device toolhead, which is translated to the preset index through preset_to_device. A unit bound @@ -1798,7 +1827,6 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title SetForegroundColour(wxColour("#CECECE")); SetBorderColor(wxColour("#EEEEEE")); SetCornerRadius(FromDIP(PRINTER_PANEL_RADIUS)); // ORCA match radius with other boxes - ShowBadge(true); SetTopMargin(FromDIP(7)); // ORCA // The title lives in an interactive row inside the card (with the nozzle-count badge and its edit button) @@ -1812,6 +1840,9 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title combo_diameter->SetToolTip(_L("Diameter")); combo_diameter->Show(index >= 0); use_nozzle_row_font(combo_diameter); + if (index >= 0) + combo_diameter->SetMinSize(wxSize(combo_diameter->GetTextExtent("0.25").x + combo_diameter->FromDIP(40), + combo_diameter->GetMinSize().y)); // AMS ams_panel = new wxPanel(this, wxID_ANY); @@ -1947,6 +1978,8 @@ ExtruderGroup::NozzleRow ExtruderGroup::create_nozzle_row() row.diameter_label = new Label(this, NozzleRow::diameter_font()); row.diameter_label->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#363636"))); row.diameter_label->Hide(); + row.diameter_badge = new wxStaticBitmap(this, wxID_ANY, ScalableBitmap(this, "badge", 14).bmp()); + row.diameter_badge->Hide(); auto combo_flow = new ComboBox(this, wxID_ANY, wxString(""), wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY); combo_flow->GetDropDown().SetUseContentWidth(true); @@ -1974,6 +2007,7 @@ ExtruderGroup::NozzleRow ExtruderGroup::create_nozzle_row() if (row_index == 0) row_sizer->Add(combo_diameter, 1, wxRIGHT, FromDIP(5)); row_sizer->Add(row.diameter_label, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, FromDIP(5)); + row_sizer->Add(row.diameter_badge, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, FromDIP(5)); row_sizer->Add(row.flow, 1); row.row_sizer = row_sizer; // Row-major: T1 T2 on the first line, T3 T4 on the second, and so on. A single-tool card keeps @@ -1984,6 +2018,24 @@ ExtruderGroup::NozzleRow ExtruderGroup::create_nozzle_row() return row; } +void ExtruderGroup::SetNozzleSynced(size_t row, bool synced) +{ + if (row < rows.size()) { + rows[row].nozzle_synced = synced; + if (group_index >= 0 && row == 0) + combo_diameter->ShowCornerBadge(synced && IsNozzleRowVisible(row)); + else + rows[row].diameter_badge->Show(synced && IsNozzleRowVisible(row)); + Layout(); + } +} + +void ExtruderGroup::ClearNozzleSynced() +{ + for (size_t i = 0; i < rows.size(); ++i) + SetNozzleSynced(i, false); +} + void ExtruderGroup::update_row_widths() { // Measured from the rows on screen rather than fixed, so no gap is reserved for a "T10" or a @@ -2068,6 +2120,10 @@ void ExtruderGroup::apply_nozzle_row_visibility() const bool show = IsNozzleRowVisible(i); rows[i].prefix->Show(show && nozzle_row_count > 1); rows[i].diameter_label->Show(show && group_index < 0); // the dual left/right cards show combo_diameter + if (group_index >= 0 && i == 0) + combo_diameter->ShowCornerBadge(show && rows[i].nozzle_synced); + else + rows[i].diameter_badge->Show(show && rows[i].nozzle_synced); // The flow combo's own visibility follows its choices and the selected row, see update_extruder_variant. rows[i].flow->Show(show && rows[i].flow->GetCount() > 0); } @@ -2249,8 +2305,9 @@ bool Sidebar::priv::switch_diameter(bool single) if (printer_tab == nullptr || nozzle_diameter_opt == nullptr || nozzle_diameter_opt->size() < 2) return false; - nozzle_diameter_opt->values[0] = left_value; - nozzle_diameter_opt->values[1] = right_value; + const auto [left_index, right_index] = dual_card_preset_indices(*wxGetApp().preset_bundle); + nozzle_diameter_opt->values[left_index] = left_value; + nozzle_diameter_opt->values[right_index] = right_value; printer_tab->load_config(new_conf); return true; } @@ -2265,9 +2322,11 @@ bool Sidebar::priv::switch_diameter_to(const wxString &diameter) // ORCA: Check if the selected diameter matches the current nozzle diameter in the config Preset& printer_preset = wxGetApp().preset_bundle->printers.get_edited_preset(); auto* nozzle_diameter = dynamic_cast(printer_preset.config.option("nozzle_diameter")); - // ORCA: the left/right combos of a BBL multi-nozzle printer set the nozzles apart without leaving - // the preset (see switch_diameter), so there the preset is only kept while every nozzle matches. - const bool nozzles_apart = nozzle_diameter && nozzle_diameter->size() > 1 && wxGetApp().preset_bundle->is_bbl_vendor() && + // The left/right combos set the nozzles independently, so retain the preset only + // when every nozzle already matches. + const bool is_bbl_vendor = wxGetApp().preset_bundle->is_bbl_vendor(); + const bool nozzles_apart = nozzle_diameter && nozzle_diameter->size() > 1 && + (is_bbl_vendor || nozzle_diameter->size() == 2) && std::any_of(nozzle_diameter->values.begin(), nozzle_diameter->values.end(), [&diameter](double value) { return get_diameter_string(value) != diameter.ToStdString(); }); // The combo lists printer variants, and the variant of a mixed-nozzle machine ("0.4+0.6") is no @@ -2281,7 +2340,7 @@ bool Sidebar::priv::switch_diameter_to(const wxString &diameter) if (printer_variant.empty() && nozzle_diameter && nozzle_diameter->size() > 0) { auto current_nozzle_dia = get_diameter_string(nozzle_diameter->values[0]); // If the selected diameter is the same as current nozzle, don't switch profiles - if (current_nozzle_dia == diameter.ToStdString()) { + if (current_nozzle_dia == diameter.ToStdString() && (!nozzles_apart || is_bbl_vendor)) { return true; } } @@ -2744,7 +2803,7 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man const Preset &cur_preset = preset_bundle->printers.get_selected_preset(); int extruder_nums = preset_bundle->get_printer_extruder_count(); // The left/right cards and their two-entry AMS-count model do not describe an N-tool printer. - const bool generic_multi_tool = !preset_bundle->is_bbl_vendor() && extruder_nums > 2; + const bool generic_multi_tool = extruder_nums > 2; std::vector extruder_map(extruder_nums); std::iota(extruder_map.begin(), extruder_map.end(), 0); if (preset_bundle->is_bbl_vendor()) { @@ -2772,6 +2831,16 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man dlg.ShowModal(); return false; } + if (extruder_nums == 2 && !has_generic_dual_sides(*preset_bundle)) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": physical extruder mapping does not identify both tools"; + if (is_manual) { + MessageDialog dlg(this->plater, + _L("The physical extruder mapping must identify both tools before syncing."), + _L("Sync printer information"), wxOK | wxICON_WARNING); + dlg.ShowModal(); + } + return false; + } // Multi-nozzle: resolve the nozzle option (pops MultiNozzleSyncDialog when is_manual). No-op for every // existing printer — support_multi_nozzle is false unless some extruder_max_nozzle_count entry is a real @@ -2791,7 +2860,14 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man std::vector target_types(extruder_nums, NozzleVolumeType::nvtStandard); for (size_t index = 0; index < extruder_nums; ++index) { int extruder_id = extruder_map[index]; - nozzle_diameters[extruder_id] = nozzle_option ? string_to_double_decimal_point(nozzle_option->diameter) : obj->GetExtderSystem()->GetNozzleDiameter(index); + if (extruder_id < 0 || extruder_id >= extruder_nums) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": invalid physical extruder mapping"; + return false; + } + const bool generic_vendor = !preset_bundle->is_bbl_vendor(); + const size_t preset_index = generic_vendor ? index : size_t(extruder_id); + const size_t device_index = generic_vendor ? size_t(extruder_id) : index; + nozzle_diameters[preset_index] = nozzle_option ? string_to_double_decimal_point(nozzle_option->diameter) : obj->GetExtderSystem()->GetNozzleDiameter(device_index); NozzleVolumeType target_type = NozzleVolumeType::nvtStandard; std::optional select_type; if (nozzle_option && nozzle_option->extruder_nozzle_stats.count(index)) { @@ -2803,17 +2879,17 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man select_type = stats.begin()->first; } if (obj->is_nozzle_flow_type_supported()) { - if (obj->GetExtderSystem()->GetNozzleFlowType(index) == NozzleFlowType::NONE_FLOWTYPE) { + if (obj->GetExtderSystem()->GetNozzleFlowType(device_index) == NozzleFlowType::NONE_FLOWTYPE) { MessageDialog dlg(this->plater, _L("There are unset nozzle types. Please set the nozzle types of all extruders before synchronizing."), _L("Sync extruder infomation"), wxICON_WARNING | wxOK); dlg.ShowModal(); continue; } // hack code, only use standard flow for 0.2 - if (std::fabs(nozzle_diameters[extruder_id] - 0.2) > EPSILON) + if (std::fabs(nozzle_diameters[preset_index] - 0.2) > EPSILON) // Map device flow->volume via the table, not `flowtype - 1`. // The arithmetic only aligns for S_FLOW/H_FLOW; U_FLOW(3)-1 would yield nvtHybrid(2), not nvtTPUHighFlow(3). - target_type = DevNozzle::ToNozzleVolumeType(obj->GetExtderSystem()->GetNozzleFlowType(extruder_id)); + target_type = DevNozzle::ToNozzleVolumeType(obj->GetExtderSystem()->GetNozzleFlowType(generic_vendor ? device_index : extruder_id)); } if (select_type) target_type = *select_type; @@ -2895,9 +2971,10 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man if (!generic_multi_tool) { if (extruder_nums > 1) { + const auto [left_tool, right_tool] = dual_card_preset_indices(*preset_bundle); if (nozzle_diameters_match) { - int left_index = left_extruder->combo_diameter->FindString(get_diameter_string(nozzle_diameters[0])); - int right_index = left_extruder->combo_diameter->FindString(get_diameter_string(nozzle_diameters[1])); + int left_index = left_extruder->combo_diameter->FindString(get_diameter_string(nozzle_diameters[left_tool])); + int right_index = right_extruder->combo_diameter->FindString(get_diameter_string(nozzle_diameters[right_tool])); assert(left_index != -1 && right_index != -1); left_extruder->combo_diameter->SetSelection(left_index); right_extruder->combo_diameter->SetSelection(right_index); @@ -2912,8 +2989,8 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man const std::vector generic_map = generic_preset_to_device_map(*preset_bundle, extruder_nums); set_generic_ams_counts(generic_preset_ams_counts(obj, generic_map)); } - AMSCountPopupWindow::UpdateAMSCount(0, left_extruder); - AMSCountPopupWindow::UpdateAMSCount(1, right_extruder); + AMSCountPopupWindow::UpdateAMSCount(left_tool, left_extruder); + AMSCountPopupWindow::UpdateAMSCount(right_tool, right_extruder); } else { if (nozzle_diameters_match) { int index = single_extruder->combo_diameter->FindString(get_diameter_string(nozzle_diameters[0])); @@ -2956,6 +3033,9 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) panel_printer_preset->ShowBadge(false); panel_printer_bed->ShowBadge(false); panel_nozzle_dia->ShowBadge(false); // ORCA add support for nozzle sync + left_extruder->ClearNozzleSynced(); + right_extruder->ClearNozzleSynced(); + single_extruder->ClearNozzleSynced(); left_extruder->ShowBadge(false); left_extruder->sync_ams(nullptr, {}, {}); right_extruder->ShowBadge(false); @@ -3011,7 +3091,7 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) struct ExtruderInfo { - float diameter{0.4}; + float diameter{0.0}; //int nozzle_volue_type{0}; int ams_4{0}; int ams_1{0}; @@ -3021,11 +3101,9 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) std::vector ams_v4; std::vector ams_v1; - bool operator==(const ExtruderInfo &other) const + bool same_ams(const ExtruderInfo &other) const { - return abs(diameter - other.diameter) < EPSILON - && /*nozzle_volue_type == other.nozzle_volue_type - &&*/ ams_4 == other.ams_4 + return ams_4 == other.ams_4 && ams_1 == other.ams_1 && ams_slot_counts == other.ams_slot_counts; } @@ -3035,15 +3113,16 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) bool is_same_nozzle_type = true; if (obj->is_nozzle_flow_type_supported()) is_same_nozzle_type = true;//left.nozzle_volue_type == right.nozzle_volue_type; // TODO: Orca hack - return abs(left.diameter - right.diameter) < EPSILON && is_same_nozzle_type; + return std::isfinite(left.diameter) && left.diameter > 0 && + std::isfinite(right.diameter) && right.diameter > 0 && + std::fabs(left.diameter - right.diameter) < EPSILON && is_same_nozzle_type; }; // 2. update extruder status int extruder_nums = preset_bundle->get_printer_extruder_count(); const bool generic_vendor = !preset_bundle->is_bbl_vendor(); - // A generic printer with more than two tools shows one tool at a time. Its AMS units are - // attributed by their own extruder bindings; the Bambu left/right conventions do not apply. - const bool generic_multi_tool = generic_vendor && extruder_nums > 2; + // More than two tools show one indexed card at a time. + const bool generic_multi_tool = extruder_nums > 2; if (extruder_nums != obj->GetExtderSystem()->GetTotalExtderCount()) { // A count mismatch means the card cannot be trusted. Clear the previous device's previews // and make sure the selected tool still exists instead of keeping a stale card. @@ -3054,6 +3133,10 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) } return; } + if (extruder_nums == 2 && !has_generic_dual_sides(*preset_bundle)) { + clear_all_sync_status(); + return; + } // Filament Track Switch: only ever surfaced on multi-extruder machines. When installed, tip/warn // and show the status icon (green ready / red not-calibrated); when absent the icon stays hidden. @@ -3100,46 +3183,35 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) } } - if (extruder_nums == 1) { - double value = 0.0; - single_extruder->diameter.ToDouble(&value); - extruder_infos[0].diameter = float(value); - } - else if(extruder_nums == 2){ - double value = 0.0; - left_extruder->diameter.ToDouble(&value); - extruder_infos[0].diameter = float(value); - - value = 0.0; - right_extruder->diameter.ToDouble(&value); - extruder_infos[1].diameter = float(value); - } - else if (generic_multi_tool) { - // The selected card reads the nozzle diameter from the preset, one value per tool. - if (const auto *nozzle_diameter = preset_bundle->printers.get_edited_preset().config.option("nozzle_diameter")) { - for (size_t i = 0; i < extruder_infos.size() && i < nozzle_diameter->values.size(); ++i) - extruder_infos[i].diameter = float(nozzle_diameter->values[i]); - } + if (const auto *nozzle_diameter = cur_preset.config.option("nozzle_diameter")) { + for (size_t i = 0; i < extruder_infos.size() && i < nozzle_diameter->values.size(); ++i) + extruder_infos[i].diameter = float(nozzle_diameter->values[i]); } std::vector machine_extruder_infos(obj->GetExtderSystem()->GetTotalExtderCount()); + bool ams_topology_usable = true; const auto& extruders = obj->GetExtderSystem()->GetExtruders(); for (const DevExtder &extruder : extruders) { //machine_extruder_infos[extruder.GetExtId()].nozzle_volue_type = int(extruder.GetNozzleFlowType()) - 1; - machine_extruder_infos[extruder.GetExtId()].diameter = extruder.GetNozzleDiameter(); + if (extruder.GetExtId() >= 0 && extruder.GetExtId() < int(machine_extruder_infos.size())) + machine_extruder_infos[extruder.GetExtId()].diameter = extruder.GetNozzleDiameter(); } for (auto &item : obj->GetFilaSystem()->GetAmsList()) { - auto add_to_extruder = [&machine_extruder_infos, generic_vendor](DevAms *ams, int extruder_id) { - if (extruder_id < 0 || extruder_id >= int(machine_extruder_infos.size())) + auto add_to_extruder = [&machine_extruder_infos, &ams_topology_usable, generic_vendor](DevAms *ams, int extruder_id) { + if (extruder_id < 0 || extruder_id >= int(machine_extruder_infos.size())) { + ams_topology_usable = false; return; + } if (generic_vendor) { // Generic units are bucketed by their actual slot width, the same signal the stored // map uses. A one-slot unit is a single-slot preview even when its device type is // the four-slot AMS type, so the two sides cannot disagree after sync. const int slots = ams->GetSlotCount(); - if (slots < 0) + if (slots < 0) { + ams_topology_usable = false; return; + } machine_extruder_infos[extruder_id].ams_slot_counts[slots]++; if (slots == 1) { machine_extruder_infos[extruder_id].ams_1++; @@ -3179,14 +3251,18 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) // yields the same attribution as before. if (fila_switch_flag) { auto switcher_pos = item.second->GetSwitcherPos(); - if (!switcher_pos) + if (!switcher_pos) { + ams_topology_usable = false; continue; + } extruder_id = obj->is_main_extruder_on_left() ? (1 - static_cast(switcher_pos.value())) : static_cast(switcher_pos.value()); } else { const auto &uniq_extruder_id = item.second->GetUniqueBindedExtruderId(); - if (!uniq_extruder_id) + if (!uniq_extruder_id) { + ams_topology_usable = false; continue; + } extruder_id = uniq_extruder_id.value(); } @@ -3196,7 +3272,7 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) // Bambu's dual-tool cards put the deputy on the left, hence the reversal. A generic card is // indexed by preset/logical extruder: physical_extruder_map[i] names the device toolhead that // logical extruder drives, so reorder through it (identity when the preset authors no swap). - if (generic_vendor) { + if (generic_vendor || extruder_nums > 2) { const std::vector preset_to_device = generic_preset_to_device_map(*preset_bundle, extruder_nums); std::vector reordered(static_cast(extruder_nums)); for (size_t i = 0; i < preset_to_device.size(); ++i) { @@ -3210,48 +3286,41 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) } std::vector extruder_synced(extruder_nums, false); + std::vector nozzle_synced(extruder_nums, false); + std::vector ams_synced(extruder_nums, false); + std::vector ams_badge(extruder_nums, false); + for (size_t i = 0; i < extruder_infos.size(); ++i) { + nozzle_synced[i] = is_same_nozzle_info(extruder_infos[i], machine_extruder_infos[i]); + ams_synced[i] = extruder_infos[i].same_ams(machine_extruder_infos[i]); + // An empty list can mean either no AMS or topology not yet received. Only show the card + // badge when at least one bound live unit confirms this tool's matching saved counts. + ams_badge[i] = ams_topology_usable && i < extruder_ams_counts.size() && + (!machine_extruder_infos[i].ams_v4.empty() || !machine_extruder_infos[i].ams_v1.empty()) && + ams_synced[i]; + const float device_diameter = machine_extruder_infos[i].diameter; + const bool nozzle_reported = std::isfinite(device_diameter) && device_diameter > 0; + extruder_synced[i] = (!nozzle_reported || nozzle_synced[i]) && ams_synced[i]; + } if (extruder_nums == 1) { - if (is_same_nozzle_info(extruder_infos[0], machine_extruder_infos[0])) { - single_extruder->ShowBadge(true); - panel_nozzle_dia->ShowBadge(true); // ORCA add support for nozzle sync - single_extruder->sync_ams(obj, machine_extruder_infos[0].ams_v4, machine_extruder_infos[0].ams_v1); - extruder_synced[0] = true; - } - else { - single_extruder->ShowBadge(false); - panel_nozzle_dia->ShowBadge(false); // ORCA add support for nozzle sync - single_extruder->sync_ams(obj, {}, {}); - } + single_extruder->SetNozzleSynced(0, nozzle_synced[0]); + single_extruder->ShowBadge(ams_badge[0]); + single_extruder->sync_ams(obj, machine_extruder_infos[0].ams_v4, machine_extruder_infos[0].ams_v1, true); } else if (extruder_nums == 2) { - if (extruder_infos[0] == machine_extruder_infos[0]) { - left_extruder->ShowBadge(true); - left_extruder->sync_ams(obj, machine_extruder_infos[0].ams_v4, machine_extruder_infos[0].ams_v1, generic_vendor); - extruder_synced[0] = true; - } - else { - left_extruder->ShowBadge(false); - left_extruder->sync_ams(obj, {}, {}, generic_vendor); - } - - if (extruder_infos[1] == machine_extruder_infos[1]) { - right_extruder->ShowBadge(true); - right_extruder->sync_ams(obj, machine_extruder_infos[1].ams_v4, machine_extruder_infos[1].ams_v1, generic_vendor); - extruder_synced[1] = true; - } - else { - right_extruder->ShowBadge(false); - right_extruder->sync_ams(obj, {}, {}, generic_vendor); - } + const auto [left_tool, right_tool] = dual_card_preset_indices(*preset_bundle); + left_extruder->SetNozzleSynced(0, nozzle_synced[left_tool]); + right_extruder->SetNozzleSynced(0, nozzle_synced[right_tool]); + left_extruder->ShowBadge(ams_badge[left_tool]); + right_extruder->ShowBadge(ams_badge[right_tool]); + left_extruder->sync_ams(obj, machine_extruder_infos[left_tool].ams_v4, machine_extruder_infos[left_tool].ams_v1, true); + right_extruder->sync_ams(obj, machine_extruder_infos[right_tool].ams_v4, machine_extruder_infos[right_tool].ams_v1, true); } else if (generic_multi_tool) { - // Show the selected tool's AMS previews and badge. The other tools keep their sync state for - // the status icon but have no card of their own. - for (size_t i = 0; i < extruder_infos.size(); ++i) - extruder_synced[i] = is_same_nozzle_info(extruder_infos[i], machine_extruder_infos[i]); - + // Rows remain alive when switching tools, so update every row's nozzle badge. + for (size_t i = 0; i < nozzle_synced.size(); ++i) + single_extruder->SetNozzleSynced(i, nozzle_synced[i]); const size_t tool = size_t(std::clamp(selected_tool, 0, extruder_nums - 1)); - single_extruder->ShowBadge(extruder_synced[tool]); + single_extruder->ShowBadge(ams_badge[tool]); single_extruder->sync_ams(obj, machine_extruder_infos[tool].ams_v4, machine_extruder_infos[tool].ams_v1, true); } @@ -3739,8 +3808,8 @@ Sidebar::Sidebar(Plater *parent) // manuallySetNozzleCount refreshes the badge and the plater itself; it is a no-op unless the // printer has a multi-nozzle extruder (and the edit button is only enabled then, see // enable_nozzle_count_edit). - p->left_extruder->SetOnHoverClick([]() { GUI::manuallySetNozzleCount(0); }); - p->right_extruder->SetOnHoverClick([]() { GUI::manuallySetNozzleCount(1); }); + p->left_extruder->SetOnHoverClick([this]() { GUI::manuallySetNozzleCount(p->left_extruder->group_index); }); + p->right_extruder->SetOnHoverClick([this]() { GUI::manuallySetNozzleCount(p->right_extruder->group_index); }); p->single_extruder->SetEditEnabled(false); // Orca: keep the floating switcher icon aligned with the left extruder's AMS row when the // extruder card is resized (the overlay is absolutely positioned, not managed by a sizer). @@ -4532,21 +4601,27 @@ void Sidebar::update_presets(Preset::Type preset_type) auto extruder_variants = printer_preset.config.option("extruder_variant_list"); std::string printer_model = printer_preset.config.option("printer_model")->value; - bool isBBL = preset_bundle.is_bbl_vendor(); - bool is_dual_extruder = extruder_variants->size() == 2; + bool is_dual_extruder = preset_bundle.get_printer_extruder_count() == 2; // why: agent mode drives the native device tab, so the sidebar lays out like BBL // (no physical-printer connect button). p->layout_printer(preset_bundle.use_bbl_network() || wxGetApp().app_config->get_bool("use_printer_agents"), - isBBL && is_dual_extruder); + is_dual_extruder); - // Update nozzle titles from printer config (e.g. "Main Nozzle" / "Auxiliary Nozzle" for N6) - // UI left = DEPUTY_EXTRUDER_ID(1), UI right = MAIN_EXTRUDER_ID(0) + // Cards are positioned by device side, but their controls edit preset indices. if (is_dual_extruder) { - std::string printer_type = printer_preset.get_printer_type(wxGetApp().preset_bundle); - auto left_title = DevPrinterConfigUtil::get_toolhead_display_name(printer_type, DEPUTY_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase); - auto right_title = DevPrinterConfigUtil::get_toolhead_display_name(printer_type, MAIN_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase); - p->left_extruder->SetTitle(_L(left_title)); - p->right_extruder->SetTitle(_L(right_title)); + const auto [left_tool, right_tool] = dual_card_preset_indices(preset_bundle); + p->left_extruder->group_index = left_tool; + p->right_extruder->group_index = right_tool; + if (has_generic_dual_sides(preset_bundle)) { + std::string printer_type = printer_preset.get_printer_type(wxGetApp().preset_bundle); + auto left_title = DevPrinterConfigUtil::get_toolhead_display_name(printer_type, DEPUTY_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase); + auto right_title = DevPrinterConfigUtil::get_toolhead_display_name(printer_type, MAIN_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase); + p->left_extruder->SetTitle(_L(left_title)); + p->right_extruder->SetTitle(_L(right_title)); + } else { + p->left_extruder->SetTitle(wxString::Format(_L("Tool %d"), left_tool + 1)); + p->right_extruder->SetTitle(wxString::Format(_L("Tool %d"), right_tool + 1)); + } } auto extruders_def = printer_preset.config.def()->get("extruder_type"); @@ -4629,16 +4704,15 @@ void Sidebar::update_presets(Preset::Type preset_type) auto image_path = get_cur_select_bed_image(); const bool multi_extruder_rows = p->single_extruder->NozzleRowCount() > 1; if (is_dual_extruder && !multi_extruder_rows) { - std::string printer_type = printer_preset.get_printer_type(wxGetApp().preset_bundle); - p->left_extruder->SetTitle(_L(DevPrinterConfigUtil::get_toolhead_display_name(printer_type, DEPUTY_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase))); - p->right_extruder->SetTitle(_L(DevPrinterConfigUtil::get_toolhead_display_name(printer_type, MAIN_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase))); - AMSCountPopupWindow::UpdateAMSCount(0, p->left_extruder); - AMSCountPopupWindow::UpdateAMSCount(1, p->right_extruder); - update_extruder_variant(*p->left_extruder, 0, 0); - update_extruder_variant(*p->right_extruder, 0, 1); + const int left_tool = p->left_extruder->group_index; + const int right_tool = p->right_extruder->group_index; + AMSCountPopupWindow::UpdateAMSCount(left_tool, p->left_extruder); + AMSCountPopupWindow::UpdateAMSCount(right_tool, p->right_extruder); + update_extruder_variant(*p->left_extruder, 0, left_tool); + update_extruder_variant(*p->right_extruder, 0, right_tool); //if (!p->is_switching_diameter) { - update_extruder_diameter(0, *p->left_extruder); - update_extruder_diameter(1, *p->right_extruder); + update_extruder_diameter(left_tool, *p->left_extruder); + update_extruder_diameter(right_tool, *p->right_extruder); //} p->image_printer_bed->SetBitmap(create_scaled_bitmap(image_path, this, PRINTER_THUMBNAIL_SIZE.GetHeight())); } else { @@ -7229,6 +7303,72 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn) } } } + + // Filament sync and printer sync are separate actions. For generic printers, accept the live + // AMS topology as well when filament sync actually used an AMS tray; otherwise the previews can + // be current while the stored unit counts (and card badges) remain stale. + PresetBundle &bundle = *wxGetApp().preset_bundle; + if (!bundle.is_bbl_vendor() && obj->is_info_ready()) { + const auto &live_ams = obj->GetFilaSystem()->GetAmsList(); + auto is_live_ams_tray = [&live_ams](const DynamicPrintConfig &tray) { + const std::string ams_id = tray.opt_string("ams_id", 0u); + const std::string slot_id = tray.opt_string("slot_id", 0u); + const auto ams = live_ams.find(ams_id); + return ams != live_ams.end() && ams->second && ams->second->GetTrays().count(slot_id) > 0 && + !(tray.has("filament_slot_placeholder") && tray.opt_bool("filament_slot_placeholder", 0u)); + }; + bool synced_ams_tray = false; + for (const auto &entry : list) { + if (!is_live_ams_tray(entry.second)) + continue; + if (sync_result.direct_sync) { + const auto &tray = entry.second; + if (!tray.opt_string("filament_id", 0u).empty() || !tray.opt_string("filament_type", 0u).empty() || + (tray.has("filament_exist") && tray.opt_bool("filament_exist", 0u))) { + synced_ams_tray = true; + break; + } + continue; + } + for (const auto &mapping : sync_result.sync_maps) { + if (mapping.second.ams_id == entry.second.opt_string("ams_id", 0u) && + mapping.second.slot_id == entry.second.opt_string("slot_id", 0u)) { + synced_ams_tray = true; + break; + } + } + if (synced_ams_tray) + break; + } + + const int count = bundle.get_printer_extruder_count(); + const std::vector map = generic_preset_to_device_map(bundle, count); + std::set mapped_tools(map.begin(), map.end()); + bool valid_topology = count > 0 && obj->GetExtderSystem()->GetTotalExtderCount() == count && + mapped_tools.size() == size_t(count) && *mapped_tools.begin() == 0 && + *mapped_tools.rbegin() == count - 1; + for (const auto &item : live_ams) { + const DevAms *ams = item.second; + if (!ams || ams->GetSlotCount() < 0) { + valid_topology = false; + break; + } + const auto &bindings = ams->GetBindedExtruderSet(); + if (bindings.empty()) { + valid_topology &= mapped_tools.count(ams->GetExtruderId()) != 0; + } else { + for (int id : bindings) + valid_topology &= mapped_tools.count(id) != 0; + } + } + if (synced_ams_tray && valid_topology) { + auto counts = generic_preset_ams_counts(obj, map); + if (bundle.extruder_ams_counts.size() != size_t(count) || + positive_ams_counts(bundle.extruder_ams_counts, size_t(count)) != counts) + set_generic_ams_counts(std::move(counts)); + p->update_sync_status(obj); + } + } BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "begin pop_finsish_sync_ams_dialog"; pop_finsish_sync_ams_dialog(); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "finish pop_finsish_sync_ams_dialog"; @@ -7287,12 +7427,12 @@ void Sidebar::set_extruder_nozzle_count(int extruder_id, int nozzle_count) { if (!p) return; - if (extruder_id == 0) { + if (extruder_id == p->left_extruder->group_index) p->left_extruder->SetCount(nozzle_count); + if (extruder_id == 0) p->single_extruder->SetCount(nozzle_count); - } else if (extruder_id == 1) { + if (extruder_id == p->right_extruder->group_index) p->right_extruder->SetCount(nozzle_count); - } } void Sidebar::enable_nozzle_count_edit(bool enable) @@ -24355,6 +24495,12 @@ void Plater::open_platesettings_dialog(wxCommandEvent& evt) { void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt) { + if (!wxGetApp().preset_bundle->is_bbl_vendor() || wxGetApp().preset_bundle->get_printer_extruder_count() != 2) { + MessageDialog dlg(this, _L("Filament grouping is not available for this printer."), + _L("Filament grouping"), wxOK | wxICON_INFORMATION); + dlg.ShowModal(); + return; + } PartPlate* curr_plate = p->partplate_list.get_curr_plate(); int value = evt.GetInt(); //1 means from gcode view bool need_slice = value ==1; // If from gcode view, should slice @@ -24366,6 +24512,13 @@ void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt) auto plate_filament_maps = curr_plate->get_real_filament_maps(project_config); auto plate_filament_map_mode = curr_plate->get_filament_map_mode(); auto plate_filament_volume_maps = curr_plate->get_real_filament_volume_maps(project_config); + if (std::any_of(plate_filament_maps.begin(), plate_filament_maps.end(), [](int tool) { return tool < 1 || tool > 2; })) { + MessageDialog dlg(this, _L("The saved filament grouping refers to an extruder that is not available on this printer. Select a compatible printer before editing the grouping."), + _L("Filament grouping"), wxOK | wxICON_WARNING); + dlg.ShowModal(); + return; + } + if (plate_filament_maps.size() != filament_colors.size()) // refine it later, save filament map to app config plate_filament_maps.resize(filament_colors.size(), 1); if (plate_filament_volume_maps.size() != filament_colors.size()) diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 6172e976f6..30aa47a7ab 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -1709,7 +1709,8 @@ std::map SelectMachineDialog::get_mapped_nozzles(int fila_id) co total_ext_count = opt ? opt->values.size() : 0; } - if (total_ext_count != obj_->GetExtderSystem()->GetTotalExtderCount()) { + const int device_ext_count = obj_->GetExtderSystem()->GetTotalExtderCount(); + if (device_ext_count <= 2 && total_ext_count != device_ext_count) { BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": total_ext_count not match"; return nozzle_map; } @@ -1718,9 +1719,9 @@ std::map SelectMachineDialog::get_mapped_nozzles(int fila_id) co if (!nozzle_system) { return nozzle_map; } if (!nozzle_system->GetNozzleRack()->IsSupported()) { - if (total_ext_count == 1) { + if (device_ext_count == 1) { nozzle_map[MAIN_EXTRUDER_ID] = nozzle_system->GetNozzleByPosId(MAIN_EXTRUDER_ID); - } else if (total_ext_count == 2) { + } else if (device_ext_count == 2) { if (fila_id >= 0 && (size_t)fila_id < m_filaments_map.size()) { if (m_filaments_map[fila_id] == 1) { nozzle_map[DEPUTY_EXTRUDER_ID] = nozzle_system->GetNozzleByPosId(DEPUTY_EXTRUDER_ID); @@ -1728,6 +1729,16 @@ std::map SelectMachineDialog::get_mapped_nozzles(int fila_id) co nozzle_map[MAIN_EXTRUDER_ID] = nozzle_system->GetNozzleByPosId(MAIN_EXTRUDER_ID); } } + } else if (device_ext_count > 2 && fila_id >= 0 && size_t(fila_id) < m_filaments_map.size()) { + const int logical = m_filaments_map[fila_id] - 1; + const auto& config = m_print_type == FROM_NORMAL ? wxGetApp().preset_bundle->full_config() : m_required_data_config; + const auto* physical_map = config.option("physical_extruder_map"); + const auto map = effective_physical_extruder_map(physical_map, total_ext_count); + if (logical >= 0 && size_t(logical) < map.values.size()) { + const int physical = map.values[logical]; + if (physical >= 0 && physical < device_ext_count) + nozzle_map[physical] = nozzle_system->GetExtNozzle(physical); + } } } else if (m_print_type == FROM_NORMAL) { // Rack printer (H2C): resolve the physical rack nozzle(s) the print-dispatch mapping assigned @@ -4523,6 +4534,9 @@ static wxString _get_nozzle_name(int total_ext_count, int ext_id) } } + if (total_ext_count > 2) + return wxString::Format(_L("nozzle T%d"), ext_id); + return _L("nozzle"); } @@ -4802,7 +4816,7 @@ bool SelectMachineDialog::CheckErrorExtruderNozzleWithSlicing(MachineObject* obj if (installed_ext_nozzle.GetNozzleDiameter() > 0.0f && slicing_ext.nozzle_diameter != installed_ext_nozzle.GetNozzleDiameter()) { std::vector msg_params; - if (ext_sys->GetTotalExtderCount() == 2) { + if (ext_sys->GetTotalExtderCount() > 1) { const wxString& mismatch_nozzle_str = _get_nozzle_name(ext_sys->GetTotalExtderCount(), slicing_ext_idx); const wxString& nozzle_message = wxString::Format(_L("The %s diameter(%.1fmm) of current printer doesn't match with the slicing file (%.1fmm). " "Please make sure the nozzle installed matches with settings in printer, then set the " @@ -4861,6 +4875,15 @@ static wxString _get_ext_loc_str(const std::unordered_set& extruders, int t } } + if (total_ext_num > 2) { + wxString tools; + for (int id : std::set(extruders.begin(), extruders.end())) { + if (!tools.empty()) + tools += ", "; + tools += wxString::Format("T%d", id); + } + return wxString::Format(_L_PLURAL("extruder %s", "extruders %s", extruders.size()), tools); + } return wxEmptyString; } @@ -7181,8 +7204,14 @@ static wxString _get_tips(MachineObject* obj_) ext_diameter += format_nozzle_diameter(obj_->GetExtderSystem()->GetNozzleDiameter(1));//Left ext_diameter += "/"; ext_diameter += format_nozzle_diameter(obj_->GetExtderSystem()->GetNozzleDiameter(0)); - } else { - assert(0); + } else if (obj_->GetExtderSystem()->GetTotalExtderCount() > 2) { + for (int i = 0; i < obj_->GetExtderSystem()->GetTotalExtderCount(); ++i) { + if (!ext_diameter.empty()) + ext_diameter += "/"; + ext_diameter += wxString::Format("T%d: ", i); + const float diameter = obj_->GetExtderSystem()->GetNozzleDiameter(i); + ext_diameter += diameter > 0.0f ? format_nozzle_diameter(diameter) : _L("Unknown"); + } } if (!ext_diameter.empty()) { diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index bcd6ea300e..43bdc06576 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2152,13 +2152,12 @@ void StatusBasePanel::reset_temp_misc_control() m_tempCtrl_nozzle->Enable(true); m_tempCtrl_nozzle_deputy->Enable(true); - } else { - for (auto& tempCtrl : m_tempCtrl_nozzles) { - tempCtrl->SetIconNormal(); - tempCtrl->SetLabel(TEMP_BLANK_STR); - tempCtrl->GetTextCtrl()->SetValue(TEMP_BLANK_STR); - tempCtrl->Enable(true); - } + } + for (auto& tempCtrl : m_tempCtrl_nozzles) { + tempCtrl->SetIconNormal(); + tempCtrl->SetLabel(TEMP_BLANK_STR); + tempCtrl->GetTextCtrl()->SetValue(TEMP_BLANK_STR); + tempCtrl->Enable(true); } m_tempCtrl_bed->SetIconNormal(); @@ -2815,7 +2814,8 @@ void StatusPanel::wire_controls() if (id == m_tempCtrl_bed->GetType()) { on_set_bed_temp(); } else if (id == m_nozzle_temp_control_id) { - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (wxGetApp().preset_bundle->is_bbl_vendor() && + (!obj || obj->GetExtderSystem()->GetTotalExtderCount() <= 2)) { if (e.GetString() == wxString::Format("%d", MAIN_EXTRUDER_ID)) { on_set_nozzle_temp(MAIN_EXTRUDER_ID); } else if (e.GetString() == wxString::Format("%d", DEPUTY_EXTRUDER_ID)) { @@ -2930,11 +2930,10 @@ StatusPanel::~StatusPanel() m_tempCtrl_nozzle_deputy->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_kill_focus), NULL, this); m_tempCtrl_nozzle_deputy->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this); - } else { - for (auto& tempCtrl : m_tempCtrl_nozzles) { - tempCtrl->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_kill_focus), NULL, this); - tempCtrl->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this); - } + } + for (auto& tempCtrl : m_tempCtrl_nozzles) { + tempCtrl->Disconnect(wxEVT_KILL_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_kill_focus), NULL, this); + tempCtrl->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this); } m_switch_lamp->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this); @@ -3408,7 +3407,8 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) } if (!temp_area) { - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (wxGetApp().preset_bundle->is_bbl_vendor() && + (!obj || obj->GetExtderSystem()->GetTotalExtderCount() <= 2)) { m_tempCtrl_nozzle->Enable(false); m_tempCtrl_nozzle_deputy->Enable(false); } else { @@ -3426,7 +3426,8 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) m_switch_cham_fan->Enable(false);*/ m_switch_fan->Enable(false); } else { - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (wxGetApp().preset_bundle->is_bbl_vendor() && + (!obj || obj->GetExtderSystem()->GetTotalExtderCount() <= 2)) { m_tempCtrl_nozzle->Enable(); m_tempCtrl_nozzle_deputy->Enable(); } else { @@ -3485,7 +3486,8 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) if (!obj) return; const int nozzle_num = obj->GetExtderSystem()->GetTotalExtderCount(); - if (!wxGetApp().preset_bundle->is_bbl_vendor()) + const bool legacy_bbl_temps = wxGetApp().preset_bundle->is_bbl_vendor() && nozzle_num <= 2; + if (!legacy_bbl_temps) sync_nozzle_temp_controls(nozzle_num); DevBed* bed = obj->GetBed(); @@ -3500,7 +3502,7 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) m_tempCtrl_bed->SetMaxTemp(limit); if (obj->nozzle_temp_range.size() >= 2) { - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (legacy_bbl_temps) { m_tempCtrl_nozzle->SetMinTemp(obj->nozzle_temp_range[0]); m_tempCtrl_nozzle->SetMaxTemp(obj->nozzle_temp_range[1]); @@ -3529,7 +3531,7 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) bool to_update_layout = false; - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (legacy_bbl_temps) { for (auto& tempCtrl : m_tempCtrl_nozzles) { if (tempCtrl->IsShown()) { tempCtrl->Hide(); @@ -3600,7 +3602,7 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) } } - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (legacy_bbl_temps) { if (m_temp_nozzle_timeout > 0) { m_temp_nozzle_timeout--; } else { @@ -3737,15 +3739,14 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj) /*extder*/ auto extder_system = obj->GetExtderSystem(); m_nozzle_num = extder_system->GetTotalExtderCount(); - const bool is_bbl_vendor = wxGetApp().preset_bundle->is_bbl_vendor(); const bool bbl_selector_was_shown = m_nozzle_btn_panel->IsShown(); const bool generic_selector_was_shown = m_generic_nozzle_selector->IsShown(); if (m_nozzle_num <= 0) { m_nozzle_btn_panel->Hide(); m_generic_nozzle_selector->Hide(); m_extruder_book->SetSelection(0); - } else if (is_bbl_vendor) { - // Preserve Bambu's existing main/deputy presentation and left/right selector. + } else if (m_nozzle_num <= 2) { + // The legacy single/dual presentation addresses tool 0 on the right and tool 1 on the left. const int display_num = std::min(m_nozzle_num, static_cast(m_extruderImage.size())); const int select_index = display_num - 1; ExtruderImage* image = m_extruderImage[select_index]; @@ -3828,7 +3829,7 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj) // best size untouched. bool book_size_changed = false; { - const bool generic_grid = !is_bbl_vendor && m_nozzle_num > 2; + const bool generic_grid = m_nozzle_num > 2; const bool book_has_explicit_size = m_extruder_book->GetMinSize() != wxDefaultSize || m_extruder_book->GetMaxSize() != wxDefaultSize; @@ -4001,9 +4002,7 @@ void StatusPanel::update_ams(MachineObject *obj) // must select a current can m_ams_control->UpdateAms(obj->get_printer_series_str(), obj->printer_type, ams_info, ext_info, *obj->GetExtderSystem(), obj->get_dev_id(), obj, false); - const bool show_generic_nozzle_switch = - obj->GetExtderSystem()->GetTotalExtderCount() > 2 && - !wxGetApp().preset_bundle->is_bbl_vendor(); + const bool show_generic_nozzle_switch = obj->GetExtderSystem()->GetTotalExtderCount() > 2; const bool ams_nozzle_switch_was_shown = m_ams_nozzle_switch->IsShown(); if (show_generic_nozzle_switch) { std::vector nozzle_options; @@ -4057,7 +4056,7 @@ void StatusPanel::update_ams(MachineObject *obj) // m_ams_control->SetExtruder(obj->is_filament_at_extruder(), obj->m_extder_data.extders[MAIN_NOZZLE_ID].snow.ams_id, obj->m_extder_data.extders[MAIN_NOZZLE_ID].snow.slot_id); //} else { - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (wxGetApp().preset_bundle->is_bbl_vendor() && obj->GetExtderSystem()->GetTotalExtderCount() <= 2) { /*right*/ if (obj->GetExtderSystem()->GetTotalExtderCount() > 0) { auto ext = obj->GetExtderSystem()->GetExtderById(MAIN_EXTRUDER_ID); @@ -4817,7 +4816,7 @@ void StatusPanel::on_set_nozzle_temp(int nozzle_id) try { long nozzle_temp; - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (wxGetApp().preset_bundle->is_bbl_vendor() && obj->GetExtderSystem()->GetTotalExtderCount() <= 2) { if (nozzle_id == MAIN_EXTRUDER_ID) { wxString str = m_tempCtrl_nozzle->GetTextCtrl()->GetValue(); if (str.ToLong(&nozzle_temp) && obj) { @@ -5092,7 +5091,7 @@ void StatusPanel::on_ams_switch(SimpleEvent &event) if (m_ams_nozzle_switch && m_ams_nozzle_switch->IsShown()) m_ams_nozzle_switch->SetSelection(m_ams_control->GetActiveNozzleId()); - if (wxGetApp().preset_bundle->is_bbl_vendor()) { + if (wxGetApp().preset_bundle->is_bbl_vendor() && obj->GetExtderSystem()->GetTotalExtderCount() <= 2) { /*right*/ if (obj->GetExtderSystem()->GetTotalExtderCount() > 0) { auto ext = obj->GetExtderSystem()->GetExtderById(MAIN_EXTRUDER_ID); @@ -5725,6 +5724,7 @@ void StatusPanel::on_xyz_abs(wxCommandEvent &event) void StatusPanel::on_nozzle_selected(wxCommandEvent &event) { const bool is_bbl_vendor = wxGetApp().preset_bundle->is_bbl_vendor(); + const bool indexed_selector = event.GetEventType() == wxEVT_CHOICE; if (obj) { const int nozzle_id = event.GetInt(); const auto extder_system = obj->GetExtderSystem(); @@ -5732,9 +5732,10 @@ void StatusPanel::on_nozzle_selected(wxCommandEvent &event) const int current_selection = current_nozzle_id >= 0 && current_nozzle_id < extder_system->GetTotalExtderCount() ? current_nozzle_id : wxNOT_FOUND; - const bool nozzle_change_in_progress = !is_bbl_vendor && obj->targ_nozzle_id_from_pc != INVALID_EXTRUDER_ID; - if (!is_bbl_vendor && (nozzle_id < 0 || nozzle_id >= extder_system->GetTotalExtderCount())) { - m_generic_nozzle_selector->SetSelection(current_selection); + const bool nozzle_change_in_progress = (!is_bbl_vendor || indexed_selector) && obj->targ_nozzle_id_from_pc != INVALID_EXTRUDER_ID; + if (nozzle_id < 0 || nozzle_id >= extder_system->GetTotalExtderCount()) { + if (indexed_selector) + m_generic_nozzle_selector->SetSelection(current_selection); return; } @@ -5743,16 +5744,16 @@ void StatusPanel::on_nozzle_selected(wxCommandEvent &event) obj->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE || nozzle_change_in_progress) { MessageDialog dlg(nullptr, _L("The printer is busy with another print job."), _L("Error"), wxICON_WARNING | wxOK); dlg.ShowModal(); - if (!is_bbl_vendor) + if (indexed_selector) m_generic_nozzle_selector->SetSelection(current_selection); return; } - if (!is_bbl_vendor) + if (indexed_selector) m_generic_nozzle_selector->Disable(); - if (obj->GetCtrl()->command_select_extruder(nozzle_id) == 0) + if (obj->GetCtrl()->command_select_extruder(nozzle_id) != 0) { - if (!is_bbl_vendor) { + if (indexed_selector) { // The command did not start; restore the previous selection and // re-enable the selector so the user is not stuck. m_generic_nozzle_selector->SetSelection(current_selection); @@ -5762,7 +5763,7 @@ void StatusPanel::on_nozzle_selected(wxCommandEvent &event) } } - if (is_bbl_vendor) + if (!indexed_selector) m_nozzle_btn_panel->Enable(); else m_generic_nozzle_selector->Enable(); diff --git a/src/slic3r/GUI/Widgets/AMSControl.cpp b/src/slic3r/GUI/Widgets/AMSControl.cpp index 3ef5201cf1..ebe6e67d97 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.cpp +++ b/src/slic3r/GUI/Widgets/AMSControl.cpp @@ -673,8 +673,7 @@ void AMSControl::restore_legacy_ams_layout() bool AMSControl::use_multi_nozzle_layout() const { - const bool is_bbl = wxGetApp().preset_bundle && wxGetApp().preset_bundle->is_bbl_vendor(); - return is_bbl ? m_total_ext_count > 2 : m_nozzle_book != nullptr; + return m_total_ext_count > 2 && m_nozzle_book != nullptr; } void AMSControl::CreateAmsMultiNozzle(const std::string &series_name, const std::string &printer_type) { @@ -812,7 +811,9 @@ void AMSControl::CreateAmsDoubleNozzle(const std::string &series_name, const std // Orca: place each AMS by its switch inlet when a Filament Track Switch is installed, else by the pinned // nozzle_id (routes_to_main_extruder). Switch-less machines are unaffected; ext spools keep nozzle_id. for (auto ams_info = m_ams_info.begin(); ams_info != m_ams_info.end(); ams_info++){ - if (ams_info->cans.size() == GENERIC_AMS_SLOT_NUM){ + if (ams_info->cans.size() == GENERIC_AMS_SLOT_NUM || + (ams_info->ams_type == AMSModel::GENERIC_AMS && !ams_info->cans.empty() && + (!wxGetApp().preset_bundle || !wxGetApp().preset_bundle->is_bbl_vendor()))){ ams_info->routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(ams_info->ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(ams_info->ams_id); AddAmsPreview(*ams_info, ams_info->ams_type); AddAms(*ams_info); @@ -843,11 +844,6 @@ void AMSControl::CreateAmsDoubleNozzle(const std::string &series_name, const std } } } - if (m_ext_info.size() <= 1) { - BOOST_LOG_TRIVIAL(trace) << "vt_slot empty!"; - assert(0); - return; - } AMSinfo ext_info; for (auto info : m_ext_info){ if (info.ams_id == std::to_string(VIRTUAL_TRAY_MAIN_ID)){ @@ -859,14 +855,16 @@ void AMSControl::CreateAmsDoubleNozzle(const std::string &series_name, const std //wait add - single_info_right[0].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_right[0].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_right[0].ams_id); - if (single_info_right.size() == 2){ - single_info_right[1].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_right[1].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_right[1].ams_id); - pair_id.push_back(std::make_pair(single_info_right[0].ams_id, single_info_right[1].ams_id)); + if (!single_info_right.empty()) { + single_info_right[0].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_right[0].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_right[0].ams_id); + if (single_info_right.size() == 2){ + single_info_right[1].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_right[1].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_right[1].ams_id); + pair_id.push_back(std::make_pair(single_info_right[0].ams_id, single_info_right[1].ams_id)); + } + AddAms(single_info_right, series_name, printer_type); + AddAmsPreview(single_info_right, AMSPanelPos::RIGHT_PANEL); + single_info_right.clear(); } - AddAms(single_info_right, series_name, printer_type); - AddAmsPreview(single_info_right, AMSPanelPos::RIGHT_PANEL); - single_info_right.clear(); for (auto info : m_ext_info) { if (info.ams_id == std::to_string(VIRTUAL_TRAY_DEPUTY_ID)) { @@ -876,14 +874,16 @@ void AMSControl::CreateAmsDoubleNozzle(const std::string &series_name, const std } } //wait add - single_info_left[0].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_left[0].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_left[0].ams_id); - if (single_info_left.size() == 2){ - single_info_left[1].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_left[1].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_left[1].ams_id); - pair_id.push_back(std::make_pair(single_info_left[0].ams_id, single_info_left[1].ams_id)); + if (!single_info_left.empty()) { + single_info_left[0].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_left[0].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_left[0].ams_id); + if (single_info_left.size() == 2){ + single_info_left[1].routes_to_main_extruder() ? m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info_left[1].ams_id) : m_item_ids[DEPUTY_EXTRUDER_ID].push_back(single_info_left[1].ams_id); + pair_id.push_back(std::make_pair(single_info_left[0].ams_id, single_info_left[1].ams_id)); + } + AddAmsPreview(single_info_left, AMSPanelPos::LEFT_PANEL); + AddAms(single_info_left, series_name, printer_type); + single_info_left.clear(); } - AddAmsPreview(single_info_left, AMSPanelPos::LEFT_PANEL); - AddAms(single_info_left, series_name, printer_type); - single_info_left.clear(); m_sizer_prv_left->Layout(); m_sizer_prv_right->Layout(); @@ -935,7 +935,9 @@ void AMSControl::CreateAmsSingleNozzle(const std::string &series_name, const std //add ams data for (auto ams_info = m_ams_info.begin(); ams_info != m_ams_info.end(); ams_info++) { - if (ams_info->cans.size() == GENERIC_AMS_SLOT_NUM) { + if (ams_info->cans.size() == GENERIC_AMS_SLOT_NUM || + (ams_info->ams_type == AMSModel::GENERIC_AMS && !ams_info->cans.empty() && + (!wxGetApp().preset_bundle || !wxGetApp().preset_bundle->is_bbl_vendor()))) { m_item_ids[DEPUTY_EXTRUDER_ID].push_back(ams_info->ams_id); AddAmsPreview(*ams_info, ams_info->ams_type); AddAms(*ams_info, AMSPanelPos::LEFT_PANEL); @@ -967,14 +969,11 @@ void AMSControl::CreateAmsSingleNozzle(const std::string &series_name, const std } // data ext data - if (m_ext_info.size() <= 0){ - BOOST_LOG_TRIVIAL(trace) << "vt_slot empty!"; - return; + if (!m_ext_info.empty()) { + single_info.push_back(m_ext_info[0]); + m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info[0].ams_id); + AddAms(single_info, series_name, printer_type, AMSPanelPos::RIGHT_PANEL); } - - single_info.push_back(m_ext_info[0]); - m_item_ids[MAIN_EXTRUDER_ID].push_back(single_info[0].ams_id); - AddAms(single_info, series_name, printer_type, AMSPanelPos::RIGHT_PANEL); auto left_init_mode = findFirstMode(AMSPanelPos::LEFT_PANEL); auto right_init_mode = findFirstMode(AMSPanelPos::RIGHT_PANEL); @@ -1159,6 +1158,10 @@ void AMSControl::UpdateAms(const std::string &series_name, if (m_ams_info[i].nozzle_id != ams_info[i].nozzle_id) { fresh = true; } + if (m_ams_info[i].cans.size() != ams_info[i].cans.size() || + m_ams_info[i].ams_type != ams_info[i].ams_type) { + fresh = true; + } } for (int i = 0; i < static_cast(m_ext_info.size()); ++i) { @@ -1328,7 +1331,7 @@ void AMSControl::createAms(wxSimplebook* parent, int& idx, AMSinfo info, AMSPane // laid out fully instead of being clipped by the old minimum width. if (info.ams_type == AMSModel::GENERIC_AMS) { const int required_width = ams_item->GetMinSize().x; - if (required_width > 0) { + if (required_width > 0 && use_multi_nozzle_layout()) { const int page_width = std::max(parent->GetMinSize().x, required_width); parent->SetMinSize(wxSize(page_width, -1)); if (auto *page = parent->GetParent()) { @@ -1389,7 +1392,10 @@ AMSRoadShowMode AMSControl::findFirstMode(AMSPanelPos pos) { auto item = m_ams_item_list.find(ams_id); if (ams_id.empty() || item == m_ams_item_list.end()) return init_mode; - if (item->second->get_can_count() == GENERIC_AMS_SLOT_NUM) { + if (item->second->get_can_count() == GENERIC_AMS_SLOT_NUM || + (item->second->get_ams_model() == AMSModel::GENERIC_AMS && item->second->get_can_count() > 0 && + item->second->get_can_count() < GENERIC_AMS_SLOT_NUM && + (!wxGetApp().preset_bundle || !wxGetApp().preset_bundle->is_bbl_vendor()))) { if (item->second->get_ams_model() == AMSModel::AMS_LITE) return AMSRoadShowMode::AMS_ROAD_MODE_AMS_LITE; if (item->second->get_ams_model() == AMSModel::EXT_AMS && item->second->get_ext_type() == AMSModelOriginType::LITE_EXT) return AMSRoadShowMode::AMS_ROAD_MODE_AMS_LITE; return AMSRoadShowMode::AMS_ROAD_MODE_FOUR; @@ -1805,7 +1811,10 @@ void AMSControl::SwitchAms(std::string ams_id) for (auto id : ids) { if (id == item->get_ams_id()) { pos == AMSPanelPos::LEFT_PANEL ? m_simplebook_ams_left->SetSelection(item->get_selection()) : m_simplebook_ams_right->SetSelection(item->get_selection()); - if (item->get_can_count() == GENERIC_AMS_SLOT_NUM) { + if (item->get_can_count() == GENERIC_AMS_SLOT_NUM || + (item->get_ams_model() == AMSModel::GENERIC_AMS && item->get_can_count() > 0 && + item->get_can_count() < GENERIC_AMS_SLOT_NUM && + (!wxGetApp().preset_bundle || !wxGetApp().preset_bundle->is_bbl_vendor()))) { if (item->get_ams_model() == AMSModel::AMS_LITE) { if (pos == AMSPanelPos::LEFT_PANEL) { m_down_road->UpdateLeft(m_total_ext_count, AMSRoadShowMode::AMS_ROAD_MODE_AMS_LITE); @@ -1897,7 +1906,7 @@ void AMSControl::SetExtruder(bool on_off, int nozzle_id, std::string ams_id, std if (m_ams_item_list.find(ams_id) != m_ams_item_list.end()) { item = m_ams_item_list[ams_id]; } if (use_multi_nozzle_layout()) { - if (nozzle_id < 0 || nozzle_id >= static_cast(m_nozzle_panes.size())) + if (nozzle_id < 0 || nozzle_id >= static_cast(m_nozzle_panes.size()) || nozzle_id != m_active_nozzle_id) return; if (!m_extruder) @@ -1966,7 +1975,9 @@ void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadTy //Set path length in different case model = ams->get_ams_model(); - if (ams->get_can_count() == GENERIC_AMS_SLOT_NUM) { + if (ams->get_can_count() == GENERIC_AMS_SLOT_NUM || + (model == AMSModel::GENERIC_AMS && ams->get_can_count() > 0 && + (!wxGetApp().preset_bundle || !wxGetApp().preset_bundle->is_bbl_vendor()))) { length = left ? 129 : 145; } else if (ams->get_can_count() == 1) { for (auto it : pair_id){ @@ -2040,6 +2051,17 @@ void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadTy if (nozzle_id >= static_cast(m_nozzle_panes.size())) return; auto &pane = m_nozzle_panes[nozzle_id]; + if (nozzle_id != m_active_nozzle_id) { + AMSPassRoadSTEP item_step = AMSPassRoadSTEP::AMS_ROAD_STEP_NONE; + if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP1) + item_step = AMSPassRoadSTEP::AMS_ROAD_STEP_1; + else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP2) + item_step = AMSPassRoadSTEP::AMS_ROAD_STEP_2; + else if (step == AMSPassRoadSTEP::AMS_ROAD_STEP_COMBO_LOAD_STEP3) + item_step = AMSPassRoadSTEP::AMS_ROAD_STEP_3; + ams->SetAmsStep(ams_id, canid, type, item_step); + return; + } AMSRoadShowMode road_mode = AMSRoadShowMode::AMS_ROAD_MODE_SINGLE; if (ams->get_can_count() == GENERIC_AMS_SLOT_NUM) road_mode = AMSRoadShowMode::AMS_ROAD_MODE_FOUR; diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index 322a9a27a1..ecf6ad50da 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -2542,6 +2542,7 @@ void AMSRoadDownPart::doRender(wxDC& dc) switch (m_left_rode_mode) { case AMSRoadShowMode::AMS_ROAD_MODE_FOUR: + case AMSRoadShowMode::AMS_ROAD_MODE_GENERIC: dc.DrawLine(left_nozzle_pos.x - FromDIP((129)), (size.y / 2), left_nozzle_pos.x, (size.y / 2)); dc.DrawLine(left_nozzle_pos.x - FromDIP((129)), 0, left_nozzle_pos.x - FromDIP((129)), (size.y / 2)); break; @@ -2561,9 +2562,6 @@ void AMSRoadDownPart::doRender(wxDC& dc) case AMSRoadShowMode::AMS_ROAD_MODE_AMS_LITE: dc.DrawLine(left_nozzle_pos.x, 0, left_nozzle_pos.x, size.y); break; - case AMSRoadShowMode::AMS_ROAD_MODE_GENERIC: - // Generic N-lane geometry is intentionally left unimplemented. - break; default: break; } @@ -2571,6 +2569,7 @@ void AMSRoadDownPart::doRender(wxDC& dc) switch (m_right_rode_mode) { case AMSRoadShowMode::AMS_ROAD_MODE_FOUR: + case AMSRoadShowMode::AMS_ROAD_MODE_GENERIC: dc.DrawLine(right_nozzle_pos.x, (size.y / 2), right_nozzle_pos.x + FromDIP(131), (size.y / 2)); dc.DrawLine(right_nozzle_pos.x + FromDIP(131), 0, right_nozzle_pos.x + FromDIP(131), (size.y / 2)); break; @@ -2591,9 +2590,6 @@ void AMSRoadDownPart::doRender(wxDC& dc) dc.DrawLine(left_nozzle_pos.x, (size.y / 2), left_nozzle_pos.x + FromDIP(145), (size.y / 2)); dc.DrawLine(left_nozzle_pos.x + FromDIP(145), 0, left_nozzle_pos.x + FromDIP(145), (size.y / 2)); break; - case AMSRoadShowMode::AMS_ROAD_MODE_GENERIC: - // Generic N-lane geometry is intentionally left unimplemented. - break; default: break; } @@ -3302,7 +3298,8 @@ AmsItem::AmsItem(wxWindow *parent,AMSinfo info, AMSModel model, AMSPanelPos pos if (m_ams_model == AMSModel::GENERIC_AMS){ const int lane_count = static_cast(m_info.cans.size()); - const int width = use_generic_ams_layout(m_ams_model) && lane_count <= 8 + const int visible_lanes = pos == AMSPanelPos::SINGLE_PANEL ? 8 : 4; + const int width = use_generic_ams_layout(m_ams_model) && lane_count <= visible_lanes ? generic_ams_layout_width(this, lane_count) : FromDIP(264); const wxSize generic_size(width, FromDIP(174)); @@ -3312,7 +3309,7 @@ AmsItem::AmsItem(wxWindow *parent,AMSinfo info, AMSModel model, AMSPanelPos pos // For large lane counts the card is a viewport, not the lane strip. Let // its parent allocate the available width; the scrolled child retains // the wider virtual content size. - if (!(use_generic_ams_layout(m_ams_model) && lane_count > 8)) + if (!(use_generic_ams_layout(m_ams_model) && lane_count > visible_lanes)) SetMaxSize(generic_size); } else{ @@ -3342,7 +3339,7 @@ void AmsItem::create(wxWindow *parent) const bool generic_layout = use_generic_ams_layout(m_ams_model); const int lane_count = static_cast(m_info.cans.size()); const int content_width = generic_layout ? generic_ams_layout_width(this, lane_count) : 0; - const bool scroll_lanes = generic_layout && lane_count > 8; + const bool scroll_lanes = generic_layout && lane_count > (m_panel_pos == AMSPanelPos::SINGLE_PANEL ? 8 : 4); const auto lane_centers = generic_layout ? generic_ams_lane_centers(lane_count, content_width) : std::vector(); diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index fe53f43f87..763422b130 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -155,6 +155,14 @@ void TextInput::SetIcon_1(const wxBitmap &icon) { Rescale(); } +void TextInput::ShowCornerBadge(bool show) +{ + if (show == corner_badge.bmp().IsOk()) + return; + corner_badge = show ? ScalableBitmap(this, "badge", 10) : ScalableBitmap(); + Refresh(); +} + void TextInput::SetLabelColor(StateColor const &color) { label_color = color; @@ -173,6 +181,8 @@ void TextInput::Rescale() this->icon.msw_rescale(); if (!this->icon_1.name().empty()) this->icon_1.msw_rescale(); + if (!corner_badge.name().empty()) + corner_badge.msw_rescale(); apply_input_corner_radius(); messureSize(); Refresh(); @@ -252,6 +262,7 @@ void TextInput::render(wxDC& dc) StaticBox::render(dc); int states = state_handler.states(); wxSize size = GetSize(); + const int badge_space = corner_badge.bmp().IsOk() ? corner_badge.bmp().GetScaledSize().x + FromDIP(3) : 0; bool align_center = GetWindowStyle() & wxALIGN_CENTER_HORIZONTAL; bool align_right = GetWindowStyle() & wxALIGN_RIGHT; // start draw @@ -283,8 +294,8 @@ void TextInput::render(wxDC& dc) wxSize textSize = text_ctrl->GetSize(); if (align_right || align_center) { - if (pt.x + labelSize.x + 5 > size.x) - text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - pt.x - 5); + if (pt.x + labelSize.x + 5 + badge_space > size.x) + text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, std::max(0, size.x - pt.x - 5 - badge_space)); pt.y = (size.y - labelSize.y) / 2; } else @@ -301,8 +312,8 @@ void TextInput::render(wxDC& dc) } else { wxSize textSize = text_ctrl->GetSize(); if (align_right || align_center) { - if (pt.x + labelSize.x + 5 > size.x) - text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, size.x - pt.x - 5); + if (pt.x + labelSize.x + 5 + badge_space > size.x) + text = wxControl::Ellipsize(text, dc, wxELLIPSIZE_END, std::max(0, size.x - pt.x - 5 - badge_space)); pt.y = (size.y - labelSize.y - static_tips_size.y - 8) / 2; } else { pt.x += textSize.x; @@ -316,8 +327,8 @@ void TextInput::render(wxDC& dc) dc.DrawText(text, pt); if (align_right || align_center) { - if (pt.x + static_tips_size.x + 5 > size.x) { - text = wxControl::Ellipsize(static_tips, dc, wxELLIPSIZE_END, size.x - pt.x - 5); + if (pt.x + static_tips_size.x + 5 + badge_space > size.x) { + text = wxControl::Ellipsize(static_tips, dc, wxELLIPSIZE_END, std::max(0, size.x - pt.x - 5 - badge_space)); } pt.y += (labelSize.y + 8); @@ -334,6 +345,10 @@ void TextInput::render(wxDC& dc) dc.DrawText(static_tips, pt); } } + if (corner_badge.bmp().IsOk()) { + const wxSize badge_size = corner_badge.bmp().GetScaledSize(); + dc.DrawBitmap(corner_badge.bmp(), size.x - badge_size.x - FromDIP(1), FromDIP(1)); + } } void TextInput::messureSize() diff --git a/src/slic3r/GUI/Widgets/TextInput.hpp b/src/slic3r/GUI/Widgets/TextInput.hpp index c0404cde98..e1f098403d 100644 --- a/src/slic3r/GUI/Widgets/TextInput.hpp +++ b/src/slic3r/GUI/Widgets/TextInput.hpp @@ -17,6 +17,7 @@ class TextInput : public wxNavigationEnabled wxSize labelSize; ScalableBitmap icon; ScalableBitmap icon_1; + ScalableBitmap corner_badge; StateColor label_color; StateColor text_color; wxTextCtrl * text_ctrl; @@ -61,6 +62,9 @@ public: void SetIcon_1(const wxString &icon); void SetIcon_1(const wxBitmap &icon); + // Small status badge inside the top-right corner, with space reserved from the label. + void ShowCornerBadge(bool show); + void SetLabelColor(StateColor const &color); void SetTextColor(StateColor const &color);