FIX: the extruder image do not show in mac

jira: [STUDIO-9504]
Change-Id: I8457b6beaccc30492e1275926a7213c8ce328d15
This commit is contained in:
xin.zhang 2025-01-07 10:02:21 +08:00 committed by lane.wei
parent d994fa4b90
commit e86b061473
2 changed files with 20 additions and 79 deletions

View File

@ -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();

View File

@ -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);
};
/*************************************************