From 60c3ab612ddf05ecca9660eb96d4a2049169c86d Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Mon, 5 Oct 2026 15:22:46 +0800 Subject: [PATCH] refactor: control blocks for generic n nozzles --- src/slic3r/GUI/Widgets/AMSControl.cpp | 28 +++++++--- src/slic3r/GUI/Widgets/AMSControl.hpp | 1 + src/slic3r/GUI/Widgets/AMSItem.cpp | 75 +++++++++++++++++---------- 3 files changed, 70 insertions(+), 34 deletions(-) diff --git a/src/slic3r/GUI/Widgets/AMSControl.cpp b/src/slic3r/GUI/Widgets/AMSControl.cpp index 1abe045942..5bab52d42f 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.cpp +++ b/src/slic3r/GUI/Widgets/AMSControl.cpp @@ -368,7 +368,7 @@ bool AMSControl::IsAmsInRightPanel(std::string ams_id) { return false; } } - else{ + else if (m_total_ext_count == 1){ for (auto id : m_item_ids[MAIN_EXTRUDER_ID]){ if (id == ams_id){ return true; @@ -376,6 +376,10 @@ bool AMSControl::IsAmsInRightPanel(std::string ams_id) { } return false; } + else { + // Generic N Nozzles + } + return false; } void AMSControl::AmsSelectedSwitch(wxCommandEvent& event) { @@ -625,6 +629,10 @@ void AMSControl::ClearAms() { pair_id.clear(); } +void AMSControl::CreateAmsMultiNozzle(const std::string &series_name, const std::string &printer_type) { + // Generic N Nozzles +} + void AMSControl::CreateAmsDoubleNozzle(const std::string &series_name, const std::string &printer_type) { std::vector single_info_left; @@ -990,11 +998,13 @@ void AMSControl::UpdateAms(const std::string &series_name, m_dev_id = dev_id; if (fresh){ ClearAms(); - if (m_total_ext_count >= 2){ - CreateAmsDoubleNozzle(series_name, printer_type); - }else{ + if (m_total_ext_count == 1) CreateAmsSingleNozzle(series_name, printer_type); - } + else if (m_total_ext_count == 2) + CreateAmsDoubleNozzle(series_name, printer_type); + else + CreateAmsMultiNozzle(series_name, printer_type); + SetSize(wxSize(FromDIP(578), -1)); SetMinSize(wxSize(FromDIP(578), -1)); Layout(); @@ -1225,7 +1235,7 @@ void AMSControl::createAmsPanel(wxSimplebook *parent, int &idx, std::vector 1){ + if (m_total_ext_count == 2){ if (info.routes_to_main_extruder()){ createAms(m_simplebook_ams_right, m_right_page_index, info, AMSPanelPos::RIGHT_PANEL); } @@ -1236,6 +1246,9 @@ void AMSControl::AddAms(AMSinfo info, AMSPanelPos pos) else if (m_total_ext_count == 1){ createAms(m_simplebook_ams_left, m_left_page_index, info, AMSPanelPos::LEFT_PANEL); } + else { + // Generic N Nozzles + } m_simplebook_ams_left->Layout(); m_simplebook_ams_right->Layout(); m_simplebook_ams_left->Refresh(); @@ -1282,6 +1295,9 @@ void AMSControl::AddAms(std::vector single_info, const std::string &ser createAmsPanel(m_simplebook_ams_left, m_left_page_index, single_info, series_name, printer_type, AMSPanelPos::LEFT_PANEL, m_total_ext_count); } } + else { + // Generic N Nozzles + } m_simplebook_ams_left->Layout(); m_simplebook_ams_right->Layout(); diff --git a/src/slic3r/GUI/Widgets/AMSControl.hpp b/src/slic3r/GUI/Widgets/AMSControl.hpp index f4c83667c2..2359327553 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.hpp +++ b/src/slic3r/GUI/Widgets/AMSControl.hpp @@ -183,6 +183,7 @@ public: void UpdatePassRoad(string ams_id, AMSPassRoadType type, AMSPassRoadSTEP step); void CreateAms(); + void CreateAmsMultiNozzle(const std::string& series_name, const std::string& printer_type); void CreateAmsDoubleNozzle(const std::string &series_name, const std::string& printer_type); void CreateAmsSingleNozzle(const std::string &series_name, const std::string &printer_type); void ClearAms(); diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index 303b4221bb..025360dc7f 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -880,7 +880,7 @@ void AMSextruder::OnAmsLoading(bool load, int nozzle_id, wxColour col /*= AMS_CO m_left_extruder->OnAmsLoading(load, col); if (load) m_current_colur_deputy = col; } - else if (m_nozzle_num > 1){ + else if (m_nozzle_num == 2){ if (nozzle_id == MAIN_EXTRUDER_ID) { m_right_extruder->OnAmsLoading(load, col); if (m_current_colur != col){ @@ -894,6 +894,9 @@ void AMSextruder::OnAmsLoading(bool load, int nozzle_id, wxColour col /*= AMS_CO } } } + else { + // Generic N Nozzles + } } /*return true if something is updated*/ @@ -907,7 +910,21 @@ bool AMSextruder::updateNozzleNum(int nozzle_num, const string& series_name) m_right_extruder = new AMSextruderImage(this, wxID_ANY, "right_nozzle", AMS_EXTRUDER_DOUBLE_NOZZLE_BITMAP_SIZE); wxBoxSizer* m_bitmap_sizer = new wxBoxSizer(wxHORIZONTAL); - if (m_nozzle_num >= 2) + if (m_nozzle_num == 1) { + if (MachineObject::is_series_n(m_series_name)) { + m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle_n", AMS_EXTRUDER_SINGLE_NOZZLE_N_SIZE); + } else if (MachineObject::is_series_x(m_series_name) || MachineObject::is_series_p(m_series_name)) { + m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle_xp", AMS_EXTRUDER_SINGLE_NOZZLE_XP_SIZE); + } else { + m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle_xp", AMS_EXTRUDER_SINGLE_NOZZLE_XP_SIZE); + } + + m_left_extruder->setShowState(true); + m_right_extruder->setShowState(false); + m_bitmap_sizer->Add(m_left_extruder, 0, wxALIGN_LEFT | wxALIGN_TOP, 0); + m_bitmap_sizer->Add(m_right_extruder, 0, wxLEFT | wxALIGN_TOP, FromDIP(3)); + } + if (m_nozzle_num == 2) { m_left_extruder = new AMSextruderImage(this, wxID_ANY, "left_nozzle", AMS_EXTRUDER_DOUBLE_NOZZLE_BITMAP_SIZE); m_left_extruder->setShowState(true); @@ -918,23 +935,7 @@ bool AMSextruder::updateNozzleNum(int nozzle_num, const string& series_name) } else { - if (MachineObject::is_series_n(m_series_name)) - { - m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle_n", AMS_EXTRUDER_SINGLE_NOZZLE_N_SIZE); - } - else if(MachineObject::is_series_x(m_series_name) || MachineObject::is_series_p(m_series_name)) - { - m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle_xp", AMS_EXTRUDER_SINGLE_NOZZLE_XP_SIZE); - } - else - { - m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle_xp", AMS_EXTRUDER_SINGLE_NOZZLE_XP_SIZE); - } - - m_left_extruder->setShowState(true); - m_right_extruder->setShowState(false); - m_bitmap_sizer->Add(m_left_extruder, 0, wxALIGN_LEFT | wxALIGN_TOP, 0); - m_bitmap_sizer->Add(m_right_extruder, 0, wxLEFT | wxALIGN_TOP, FromDIP(3)); + // Generic N Nozzles } SetSizer(m_bitmap_sizer); @@ -2496,17 +2497,20 @@ void AMSRoadDownPart::doRender(wxDC& dc) } if (m_right_rode_mode != AMSRoadShowMode::AMS_ROAD_MODE_AMS_LITE){ - if (m_nozzle_num == 2) { + if (m_nozzle_num == 1) { + if (m_right_rode_mode != AMSRoadShowMode::AMS_ROAD_MODE_NONE && m_left_rode_mode != AMSRoadShowMode::AMS_ROAD_MODE_NONE) { + dc.DrawLine((left_nozzle_pos.x), (size.y / 2), (right_nozzle_pos.x), (size.y / 2)); + } + dc.DrawLine((left_nozzle_pos.x), (size.y / 2), (left_nozzle_pos.x), (size.y)); + } + else if (m_nozzle_num == 2) { /*dc.DrawLine(FromDIP(left_nozzle_pos.x), FromDIP(size.y / 2), FromDIP(left_nozzle_pos.x), FromDIP(size.y)); dc.DrawLine(FromDIP(right_nozzle_pos.x), FromDIP(size.y / 2), FromDIP(right_nozzle_pos.x), FromDIP(size.y));*/ dc.DrawLine((left_nozzle_pos.x), (size.y / 2), (left_nozzle_pos.x), (size.y)); dc.DrawLine((right_nozzle_pos.x), (size.y / 2), (right_nozzle_pos.x), (size.y)); } else { - if (m_right_rode_mode != AMSRoadShowMode::AMS_ROAD_MODE_NONE && m_left_rode_mode != AMSRoadShowMode::AMS_ROAD_MODE_NONE) { - dc.DrawLine((left_nozzle_pos.x), (size.y / 2), (right_nozzle_pos.x), (size.y / 2)); - } - dc.DrawLine((left_nozzle_pos.x), (size.y / 2), (left_nozzle_pos.x), (size.y)); + // Generic N Nozzles } } @@ -2531,10 +2535,16 @@ void AMSRoadDownPart::doRender(wxDC& dc) dc.DrawLine(xpos, size.y / 2, xpos, size.y);*/ int x = left_nozzle_pos.x; int len = m_right_road_length; - if (m_nozzle_num == 2) { + if (m_nozzle_num == 1) { + // Keep the single-nozzle path anchored at the left nozzle. + } + else if (m_nozzle_num == 2) { x = right_nozzle_pos.x; len = len - 14; } + else { + // Generic N Nozzles + } dc.DrawLine(((x)), (size.y / 2), x + FromDIP(len), (size.y / 2)); dc.DrawLine(x + FromDIP(len), (0), x + FromDIP(len), (size.y / 2)); dc.DrawLine((x), (size.y / 2), (x), (size.y)); @@ -2542,10 +2552,16 @@ void AMSRoadDownPart::doRender(wxDC& dc) else{ int x = left_nozzle_pos.x; int len = m_right_road_length; - if (m_nozzle_num == 2) { + if (m_nozzle_num == 1) { + // Keep the single-nozzle path anchored at the left nozzle. + } + else if (m_nozzle_num == 2) { x = right_nozzle_pos.x; len = len - 14; } + else { + // Generic N Nozzles + } dc.DrawLine(((x)), (size.y / 2), x + FromDIP(len), (size.y / 2)); dc.DrawLine(x + FromDIP(len), (0), x + FromDIP(len), (size.y / 2)); dc.DrawLine((x), (size.y / 2), (x), (size.y)); @@ -2569,7 +2585,7 @@ void AMSRoadDownPart::doRender(wxDC& dc) } void AMSRoadDownPart::UpdatePassRoad(AMSPanelPos pos, int len, AMSPassRoadSTEP step) { - if (m_nozzle_num >= 2){ + if (m_nozzle_num == 2){ if (pos == AMSPanelPos::LEFT_PANEL){ if (m_left_road_length == len && m_pass_road_left_step == step){ return; } m_left_road_length = len;; @@ -2581,7 +2597,7 @@ void AMSRoadDownPart::UpdatePassRoad(AMSPanelPos pos, int len, AMSPassRoadSTEP s m_pass_road_right_step = step; } } - else{ + else if (m_nozzle_num == 1){ if (pos == AMSPanelPos::LEFT_PANEL) { if (m_left_road_length == len && m_pass_road_left_step == step && m_right_road_length == -1) { return; } m_left_road_length = len; @@ -2595,6 +2611,9 @@ void AMSRoadDownPart::UpdatePassRoad(AMSPanelPos pos, int len, AMSPassRoadSTEP s m_pass_road_right_step = step; } } + else { + // Generic N Nozzles + } Refresh(); }