From e86b061473799e34efce53abeb8954e591d87836 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Tue, 7 Jan 2025 10:02:21 +0800 Subject: [PATCH] FIX: the extruder image do not show in mac jira: [STUDIO-9504] Change-Id: I8457b6beaccc30492e1275926a7213c8ce328d15 --- src/slic3r/GUI/Widgets/AMSItem.cpp | 90 ++++++------------------------ src/slic3r/GUI/Widgets/AMSItem.hpp | 9 ++- 2 files changed, 20 insertions(+), 79 deletions(-) diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index e65a390d2..0c2346d7e 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -632,8 +632,7 @@ void AMSExtImage::doRender(wxDC& dc) //Ams Extruder AMSextruder::AMSextruder(wxWindow *parent, wxWindowID id, int nozzle_num, const wxPoint &pos, const wxSize &size) { - create(parent, id, pos, size); - m_nozzle_num = nozzle_num; + create(parent, id, pos, size, nozzle_num); } AMSextruder::~AMSextruder() {} @@ -648,30 +647,12 @@ void AMSextruder::TurnOff() m_left_extruder->TurnOff(); } -void AMSextruder::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) +void AMSextruder::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int nozzle_num) { wxWindow::Create(parent, id, pos, wxSize(-1, FromDIP(36)), wxBORDER_NONE); SetBackgroundColour(*wxWHITE); - wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL); - - m_bitmap_sizer = new wxBoxSizer(wxHORIZONTAL); - - m_right_extruder = new AMSextruderImage(this, wxID_ANY, "right_nozzle", AMS_EXTRUDER_DOUBLE_NOZZLE_BITMAP_SIZE); - m_right_extruder->setShowState(false); - - if (m_nozzle_num >= 2){ - m_left_extruder = new AMSextruderImage(this, wxID_ANY, "left_nozzle", AMS_EXTRUDER_DOUBLE_NOZZLE_BITMAP_SIZE); - } - else { - m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle", AMS_EXTRUDER_SINGLE_NOZZLE_BITMAP_SIZE); - } - m_left_extruder->setShowState(true); - m_bitmap_sizer->Add(m_left_extruder, 0, wxLEFT | wxALIGN_TOP, 0); - m_bitmap_sizer->Add(m_right_extruder, 0, wxLEFT | wxALIGN_TOP, FromDIP(2)); - SetSizer(m_bitmap_sizer); - - Bind(wxEVT_PAINT, &AMSextruder::paintEvent, this); + updateNozzleNum(nozzle_num); Layout(); } @@ -713,68 +694,29 @@ void AMSextruder::updateNozzleNum(int nozzle_num) this->DestroyChildren(); m_right_extruder = new AMSextruderImage(this, wxID_ANY, "right_nozzle", AMS_EXTRUDER_DOUBLE_NOZZLE_BITMAP_SIZE); - m_right_extruder->setShowState(false); - if (m_nozzle_num >= 2) { - m_left_extruder = new AMSextruderImage(this, wxID_ANY, "left_nozzle", AMS_EXTRUDER_DOUBLE_NOZZLE_BITMAP_SIZE); - } - else { - m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle", AMS_EXTRUDER_SINGLE_NOZZLE_BITMAP_SIZE); - } - wxBoxSizer *m_bitmap_sizer = new wxBoxSizer(wxHORIZONTAL); - m_bitmap_sizer->Add(m_left_extruder, 0, wxALIGN_LEFT | wxALIGN_TOP, 0); - if (m_nozzle_num >= 2){ + wxBoxSizer* m_bitmap_sizer = new wxBoxSizer(wxHORIZONTAL); + 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); + m_right_extruder->setShowState(true); + 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(2)); m_bitmap_sizer->AddSpacer(2); } - else{ + else + { + m_left_extruder = new AMSextruderImage(this, wxID_ANY, "single_nozzle", AMS_EXTRUDER_SINGLE_NOZZLE_BITMAP_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)); } SetSizer(m_bitmap_sizer); } -void AMSextruder::paintEvent(wxPaintEvent& evt) -{ - wxPaintDC dc(this); - render(dc); -} - -void AMSextruder::render(wxDC& dc) -{ -#ifdef __WXMSW__ - wxSize size = GetSize(); - wxMemoryDC memdc; - wxBitmap bmp(size.x, size.y); - memdc.SelectObject(bmp); - memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 }); - - { - wxGCDC dc2(memdc); - //doRender(dc2); - } - m_left_extruder->setShowState(true); - if (m_nozzle_num >= 2) { - m_right_extruder->setShowState(true); - } - else { - m_right_extruder->setShowState(false); - } - memdc.SelectObject(wxNullBitmap); - dc.DrawBitmap(bmp, 0, 0); -#else - doRender(dc); -#endif - -} - -void AMSextruder::doRender(wxDC& dc) -{ - //m_current_colur = - wxSize size = GetSize(); - -} - void AMSextruder::msw_rescale() { //m_amsSextruder->msw_rescale(); diff --git a/src/slic3r/GUI/Widgets/AMSItem.hpp b/src/slic3r/GUI/Widgets/AMSItem.hpp index c58871ed4..c84ba8bd3 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.hpp +++ b/src/slic3r/GUI/Widgets/AMSItem.hpp @@ -319,16 +319,12 @@ public: class AMSextruder : public wxWindow { private: - int m_nozzle_num{ 1 }; + int m_nozzle_num = -1; public: void TurnOn(wxColour col); void TurnOff(); - void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size); void OnVamsLoading(bool load, wxColour col = AMS_CONTROL_GRAY500); void OnAmsLoading(bool load, int nozzle_id = 0, wxColour col = AMS_CONTROL_GRAY500); - void paintEvent(wxPaintEvent& evt); - void render(wxDC& dc); - void doRender(wxDC& dc); void msw_rescale(); void has_ams(bool hams) {m_has_vams = hams; Refresh();}; void no_ams_mode(bool mode) {m_none_ams_mode = mode; Refresh();}; @@ -348,6 +344,9 @@ public: AMSextruderImage* m_right_extruder = nullptr; AMSextruder(wxWindow *parent, wxWindowID id, int nozzle_num, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize); ~AMSextruder(); + +private: + void create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int nozzle_num); }; /*************************************************