FIX: the AMS EXT image fault
jira: [STUDIO-10044] Change-Id: I71d142cd763deff33f1c42047b5ae6ac81574b3f
This commit is contained in:
parent
0730c4ec51
commit
d50fc6a0ce
|
@ -3491,7 +3491,8 @@ AMSRoadShowMode AMSControl::findFirstMode(AMSPanelPos pos) {
|
|||
}
|
||||
}
|
||||
|
||||
void AMSControl::createAmsPanel(wxSimplebook* parent, int& idx, std::vector<AMSinfo>infos, AMSPanelPos pos) {
|
||||
void AMSControl::createAmsPanel(wxSimplebook *parent, int &idx, std::vector<AMSinfo> infos, AMSPanelPos pos, int total_ext_num)
|
||||
{
|
||||
if (infos.size() <= 0) return;
|
||||
|
||||
wxPanel* book_panel = new wxPanel(parent);
|
||||
|
@ -3502,8 +3503,12 @@ void AMSControl::createAmsPanel(wxSimplebook* parent, int& idx, std::vector<AMSi
|
|||
|
||||
AmsItem* ams1 = nullptr, * ams2 = nullptr;
|
||||
ams1 = new AmsItem(book_panel, infos[0], infos[0].ams_type, pos);
|
||||
if (ams1->get_ext_image()) { ams1->get_ext_image()->setTotalExtNum(total_ext_num); }
|
||||
|
||||
if (infos.size() == MAX_AMS_NUM_IN_PANEL) { //n3s and ? in a panel
|
||||
ams2 = new AmsItem(book_panel, infos[1], infos[1].ams_type, pos);
|
||||
if (ams2->get_ext_image()) { ams2->get_ext_image()->setTotalExtNum(total_ext_num); }
|
||||
|
||||
if (pos == AMSPanelPos::LEFT_PANEL) {
|
||||
book_sizer->Add(ams1, 0, wxLEFT, FromDIP(4));
|
||||
book_sizer->Add(ams2, 0, wxLEFT, FromDIP(30));
|
||||
|
@ -3514,8 +3519,8 @@ void AMSControl::createAmsPanel(wxSimplebook* parent, int& idx, std::vector<AMSi
|
|||
}
|
||||
}
|
||||
else { //only an ext in a panel
|
||||
if (ams1->get_ext_image()) { ams1->get_ext_image()->setShowState(false);
|
||||
}
|
||||
if (ams1->get_ext_image()) { ams1->get_ext_image()->setShowAmsExt(false);}
|
||||
|
||||
if (ams1->get_ams_model() == AMSModel::EXT_AMS) {
|
||||
if (ams1->get_ext_type() == LITE_EXT) {
|
||||
//book_sizer->Add(ams1, 0, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
|
@ -3590,18 +3595,18 @@ void AMSControl::AddAms(std::vector<AMSinfo>single_info, AMSPanelPos pos) {
|
|||
}
|
||||
if (m_extder_data.total_extder_count == 2) {
|
||||
if (single_info[0].nozzle_id == MAIN_NOZZLE_ID) {
|
||||
createAmsPanel(m_simplebook_ams_right, m_right_page_index, single_info, AMSPanelPos::RIGHT_PANEL);
|
||||
createAmsPanel(m_simplebook_ams_right, m_right_page_index, single_info, AMSPanelPos::RIGHT_PANEL, m_extder_data.total_extder_count);
|
||||
}
|
||||
else if (single_info[0].nozzle_id == DEPUTY_NOZZLE_ID) {
|
||||
createAmsPanel(m_simplebook_ams_left, m_left_page_index, single_info, AMSPanelPos::LEFT_PANEL);
|
||||
createAmsPanel(m_simplebook_ams_left, m_left_page_index, single_info, AMSPanelPos::LEFT_PANEL, m_extder_data.total_extder_count);
|
||||
}
|
||||
}
|
||||
else if (m_extder_data.total_extder_count == 1) {
|
||||
if (pos == AMSPanelPos::RIGHT_PANEL) {
|
||||
createAmsPanel(m_simplebook_ams_right, m_right_page_index, single_info, AMSPanelPos::RIGHT_PANEL);
|
||||
createAmsPanel(m_simplebook_ams_right, m_right_page_index, single_info, AMSPanelPos::RIGHT_PANEL, m_extder_data.total_extder_count);
|
||||
}
|
||||
else {
|
||||
createAmsPanel(m_simplebook_ams_left, m_left_page_index, single_info, AMSPanelPos::LEFT_PANEL);
|
||||
createAmsPanel(m_simplebook_ams_left, m_left_page_index, single_info, AMSPanelPos::LEFT_PANEL, m_extder_data.total_extder_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
bool IsAmsInRightPanel(std::string ams_id);
|
||||
wxColour GetCanColour(std::string amsid, std::string canid);
|
||||
void createAms(wxSimplebook* parent, int& idx, AMSinfo info, AMSPanelPos pos);
|
||||
void createAmsPanel(wxSimplebook* parent, int& idx, std::vector<AMSinfo>infos, AMSPanelPos pos);
|
||||
void createAmsPanel(wxSimplebook* parent, int& idx, std::vector<AMSinfo>infos, AMSPanelPos pos, int total_ext_num);
|
||||
AMSRoadShowMode findFirstMode(AMSPanelPos pos);
|
||||
|
||||
AMSModel m_ams_model{AMSModel::EXT_AMS};
|
||||
|
|
|
@ -543,21 +543,28 @@ Description:AMSExtImage upon ext lib
|
|||
|
||||
AMSExtImage::AMSExtImage(wxWindow* parent, AMSPanelPos ext_pos, ExtderData *data, wxWindowID id, const wxPoint& pos)
|
||||
{
|
||||
if (data == nullptr){
|
||||
if (data == nullptr)
|
||||
{
|
||||
wxWindow::Create(parent, id, pos, AMS_HUMIDITY_SIZE);
|
||||
m_show_ams_ext = true;
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
wxWindow::Create(parent, id, pos, wxSize(FromDIP(98), FromDIP(99)));
|
||||
m_show_ext = true;
|
||||
total_ext_num = data->total_extder_count;
|
||||
}
|
||||
|
||||
m_ext_pos = ext_pos;
|
||||
m_ext_left = ScalableBitmap(this, "ext_image_left", 98);
|
||||
m_ext_right = ScalableBitmap(this, "ext_image_right", 98);
|
||||
m_ext_single_nozzle = ScalableBitmap(this, "ext_image_single_nozzle", 98);
|
||||
|
||||
m_ams_single_ext = ScalableBitmap(this, "ams_ext_image", 25);
|
||||
m_ams_ext_left = ScalableBitmap(this, "ext_image_left", 25);
|
||||
m_ams_ext_right = ScalableBitmap(this, "ext_image_right", 25);
|
||||
|
||||
SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR));
|
||||
m_ext_pos = ext_pos;
|
||||
if (data != nullptr) m_extder_data = data;
|
||||
|
||||
m_ams_ext_left = ScalableBitmap(this, "ext_image_left", 98);
|
||||
m_ams_ext_right = ScalableBitmap(this, "ext_image_right", 98);
|
||||
m_ams_ext_single_nozzle = ScalableBitmap(this, "ext_image_single_nozzle", 98);
|
||||
m_ams_ext = ScalableBitmap(this, "ams_ext_image", 25);
|
||||
|
||||
Bind(wxEVT_PAINT, &AMSExtImage::paintEvent, this);
|
||||
}
|
||||
|
@ -568,15 +575,37 @@ void AMSExtImage::msw_rescale()
|
|||
{
|
||||
//m_ams_extruder.SetSize(AMS_EXTRUDER_BITMAP_SIZE);
|
||||
//auto image = m_ams_extruder.ConvertToImage();
|
||||
m_ams_ext_left = ScalableBitmap(this, "ext_image_left", 98);
|
||||
m_ams_ext_right = ScalableBitmap(this, "ext_image_right", 98);
|
||||
m_ams_ext_single_nozzle = ScalableBitmap(this, "ext_image_single_nozzle", 98);
|
||||
m_ams_ext = ScalableBitmap(this, "ams_ext_image", 25);
|
||||
m_ext_left = ScalableBitmap(this, "ext_image_left", 98);
|
||||
m_ext_right = ScalableBitmap(this, "ext_image_right", 98);
|
||||
m_ext_single_nozzle = ScalableBitmap(this, "ext_image_single_nozzle", 98);
|
||||
|
||||
m_ams_single_ext = ScalableBitmap(this, "ams_ext_image", 25);
|
||||
m_ams_ext_left = ScalableBitmap(this, "ext_image_left", 25);
|
||||
m_ams_ext_right = ScalableBitmap(this, "ext_image_right", 25);
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void AMSExtImage::setShowAmsExt(bool show)
|
||||
{
|
||||
if (m_show_ams_ext != show)
|
||||
{
|
||||
m_show_ams_ext = show;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void AMSExtImage::setTotalExtNum(int num)
|
||||
{
|
||||
if (total_ext_num != num)
|
||||
{
|
||||
total_ext_num = num;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void AMSExtImage::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
@ -608,27 +637,50 @@ void AMSExtImage::doRender(wxDC& dc)
|
|||
{
|
||||
auto size = GetSize();
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
//dc.DrawRectangle(0, FromDIP(5), size.x, size.y - FromDIP(5) - FromDIP(2));
|
||||
if (m_extder_data == nullptr){
|
||||
if (m_ext_show) {
|
||||
dc.DrawBitmap(m_ams_ext.bmp(), wxPoint((size.x - m_ams_ext.GetBmpSize().x) / 2, 0));
|
||||
|
||||
if (m_show_ams_ext)
|
||||
{
|
||||
if (total_ext_num < 2)
|
||||
{
|
||||
dc.DrawBitmap(m_ams_single_ext.bmp(), wxPoint((size.x - m_ams_single_ext.GetBmpSize().x) / 2, 0));
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (m_extder_data->total_extder_count < 2) {
|
||||
dc.DrawBitmap(m_ams_ext_single_nozzle.bmp(), wxPoint((size.x - m_ams_ext_right.GetBmpSize().x) / 2, (size.y - m_ams_ext_right.GetBmpSize().y) / 2));
|
||||
}
|
||||
else {
|
||||
if (m_ext_pos == AMSPanelPos::LEFT_PANEL) {
|
||||
dc.DrawBitmap(m_ams_ext_left.bmp(), wxPoint((size.x - m_ams_ext_left.GetBmpSize().x) / 2, (size.y - m_ams_ext_left.GetBmpSize().y) / 2));
|
||||
else
|
||||
{
|
||||
if (m_ext_pos == AMSPanelPos::LEFT_PANEL)
|
||||
{
|
||||
dc.DrawBitmap(m_ams_ext_left.bmp(), wxPoint((size.x - m_ams_ext_left.GetBmpSize().x) / 2, 0));
|
||||
}
|
||||
else {
|
||||
dc.DrawBitmap(m_ams_ext_right.bmp(), wxPoint((size.x - m_ams_ext_right.GetBmpSize().x) / 2, (size.y - m_ams_ext_right.GetBmpSize().y) / 2));
|
||||
else
|
||||
{
|
||||
dc.DrawBitmap(m_ams_ext_right.bmp(), wxPoint((size.x - m_ams_ext_right.GetBmpSize().x) / 2, 0));
|
||||
}
|
||||
}
|
||||
|
||||
Layout();
|
||||
return;
|
||||
}
|
||||
|
||||
Layout();
|
||||
if (m_show_ext)
|
||||
{
|
||||
if (total_ext_num < 2)
|
||||
{
|
||||
dc.DrawBitmap(m_ext_single_nozzle.bmp(), wxPoint((size.x - m_ext_right.GetBmpSize().x) / 2, (size.y - m_ext_right.GetBmpSize().y) / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_ext_pos == AMSPanelPos::LEFT_PANEL)
|
||||
{
|
||||
dc.DrawBitmap(m_ext_left.bmp(), wxPoint((size.x - m_ext_left.GetBmpSize().x) / 2, (size.y - m_ext_left.GetBmpSize().y) / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
dc.DrawBitmap(m_ext_right.bmp(), wxPoint((size.x - m_ext_right.GetBmpSize().x) / 2, (size.y - m_ext_right.GetBmpSize().y) / 2));
|
||||
}
|
||||
}
|
||||
|
||||
Layout();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2896,7 +2948,7 @@ void AmsItem::create(wxWindow *parent)
|
|||
}
|
||||
else{
|
||||
if (m_ams_model == EXT_AMS){
|
||||
m_ext_image = new AMSExtImage(this, AMSPanelPos::RIGHT_PANEL);
|
||||
m_ext_image = new AMSExtImage(this, m_panel_pos);
|
||||
sizer_item->Add(m_ext_image, 0, wxALIGN_CENTER_HORIZONTAL, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,24 +347,33 @@ public:
|
|||
//AMSExtImage upon ext lib
|
||||
class AMSExtImage : public wxWindow
|
||||
{
|
||||
private:
|
||||
bool m_ext_show = true;
|
||||
ExtderData* m_extder_data = nullptr;
|
||||
AMSPanelPos m_ext_pos;
|
||||
public:
|
||||
void msw_rescale();
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void setShowState(bool show) { m_ext_show = show; };
|
||||
private:
|
||||
bool m_show_ams_ext = false;
|
||||
bool m_show_ext = false;
|
||||
|
||||
void render(wxDC& dc);
|
||||
ScalableBitmap m_ams_ext;
|
||||
ScalableBitmap m_ams_ext_left;
|
||||
ScalableBitmap m_ams_ext_right;
|
||||
ScalableBitmap m_ams_ext_single_nozzle;
|
||||
void doRender(wxDC& dc);
|
||||
AMSExtImage(wxWindow* parent, AMSPanelPos ext_pos = AMSPanelPos::RIGHT_PANEL, ExtderData *data = nullptr,
|
||||
wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition);
|
||||
AMSPanelPos m_ext_pos;
|
||||
int total_ext_num = 1;
|
||||
|
||||
ScalableBitmap m_ams_ext_left;
|
||||
ScalableBitmap m_ams_ext_right;
|
||||
ScalableBitmap m_ams_single_ext;
|
||||
|
||||
ScalableBitmap m_ext_left;
|
||||
ScalableBitmap m_ext_right;
|
||||
ScalableBitmap m_ext_single_nozzle;
|
||||
|
||||
public:
|
||||
AMSExtImage(wxWindow *parent, AMSPanelPos ext_pos = AMSPanelPos::RIGHT_PANEL, ExtderData *data = nullptr, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition);
|
||||
~AMSExtImage();
|
||||
|
||||
void msw_rescale();
|
||||
void setShowAmsExt(bool show);
|
||||
void setTotalExtNum(int num);
|
||||
|
||||
private:
|
||||
void paintEvent(wxPaintEvent &evt);
|
||||
void render(wxDC &dc);
|
||||
void doRender(wxDC &dc);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue