From 33e26a127e06f94d5ee39a26b9d01e58bd6543bc Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Wed, 7 Oct 2026 18:40:41 +0800 Subject: [PATCH] fix: warn when toolhead count differs from the selected printer preset's nozzle_diameter count --- src/slic3r/GUI/StatusPanel.cpp | 36 ++++++++++++++++++++++++++++++++++ src/slic3r/GUI/StatusPanel.hpp | 6 ++++++ 2 files changed, 42 insertions(+) diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index f2ebc0b97d..c2758f4cf8 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -26,6 +26,7 @@ #include "slic3r/GUI/DeviceCore/DevExtruderSystem.h" #include "slic3r/GUI/Widgets/ProgressBar.hpp" #include "libslic3r/calib.hpp" +#include "libslic3r/PresetBundle.hpp" #include #include "libslic3r/Utils.hpp" #include "slic3r/GUI/CameraPopup.hpp" @@ -3171,6 +3172,7 @@ void StatusPanel::update(MachineObject *obj) } update_temp_ctrl(obj); + check_extruder_count_mismatch(obj); update_misc_ctrl(obj); update_ams(obj); @@ -3366,6 +3368,40 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area) } } +void StatusPanel::check_extruder_count_mismatch(MachineObject* obj) +{ + if (!obj || !wxGetApp().preset_bundle) + return; + + // The generic N-extruder layout and virtual-tray recognition are derived from the selected + // printer preset's nozzle_diameter count, while the connected device is authoritative for its + // own toolhead count. Warn once per change when they disagree, so a misconfigured preset is + // visible instead of silently producing wrong layout/mapping. (PR #15905 review, S5.) + if (wxGetApp().preset_bundle->is_bbl_vendor()) + return; + + auto* ext_system = obj->GetExtderSystem(); + if (!ext_system) + return; + + const int device_count = ext_system->GetTotalExtderCount(); + const int preset_count = wxGetApp().preset_bundle->get_printer_extruder_count(); + const std::string dev_id = obj->get_dev_id(); + if (dev_id == m_last_mismatch_dev_id && device_count == m_last_mismatch_device_count && + preset_count == m_last_mismatch_preset_count) + return; + + m_last_mismatch_dev_id = dev_id; + m_last_mismatch_device_count = device_count; + m_last_mismatch_preset_count = preset_count; + if (device_count != preset_count) + BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": connected device reports " << device_count + << " toolhead(s) but the selected printer preset declares " << preset_count + << " nozzle_diameter entr" << (preset_count == 1 ? "y" : "ies") + << "; select a printer matching the device, otherwise the N-extruder layout and " + << "virtual-tray recognition may be wrong"; +} + void StatusPanel::update_temp_ctrl(MachineObject *obj) { if (!obj) return; diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index 141764df04..eaea3c8518 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -531,6 +531,11 @@ protected: std::vector m_tempCtrl_nozzles; std::vector m_temp_nozzle_timeouts; + // Last (dev_id, device toolhead count, preset nozzle count) we warned about, to avoid log spam. + std::string m_last_mismatch_dev_id; + int m_last_mismatch_device_count{-1}; + int m_last_mismatch_preset_count{-1}; + TempInput * m_tempCtrl_bed; int m_temp_bed_timeout {0}; TempInput * m_tempCtrl_chamber; @@ -826,6 +831,7 @@ protected: void update_cloud_subtask(MachineObject *obj); void update_sdcard_subtask(MachineObject *obj); void update_temp_ctrl(MachineObject *obj); + void check_extruder_count_mismatch(MachineObject* obj); void update_misc_ctrl(MachineObject *obj); void update_ams(MachineObject* obj); void update_rack(MachineObject* obj);