FIX: update the display of AMSHumidity

jira: [STUDIO-10119]
Change-Id: I7a1be57bd0dff13be149d6450b36fb54ffa9521d
This commit is contained in:
xin.zhang 2025-02-20 20:09:22 +08:00 committed by lane.wei
parent dcfc5af245
commit c3a8690987
5 changed files with 63 additions and 30 deletions

View File

@ -0,0 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.7124 5.11094V7.01094C12.7124 7.40578 12.3947 7.72344 11.9999 7.72344C11.6051 7.72344 11.2874 7.40578 11.2874 7.01094V5.11094C11.2874 4.71609 11.6051 4.39844 11.9999 4.39844C12.3947 4.39844 12.7124 4.71609 12.7124 5.11094ZM17.3733 7.63141L16.0285 8.97625C15.7494 9.25531 15.2982 9.25531 15.0221 8.97625C14.746 8.69719 14.743 8.24594 15.0221 7.96984L16.3669 6.625C16.646 6.34594 17.0972 6.34594 17.3733 6.625C17.6494 6.90406 17.6524 7.35531 17.3733 7.63141ZM7.63287 6.625L8.97771 7.96984C9.25678 8.24891 9.25678 8.70016 8.97771 8.97625C8.69865 9.25234 8.2474 9.25531 7.97131 8.97625L6.62646 7.63141C6.3474 7.35234 6.3474 6.90109 6.62646 6.625C6.90553 6.34891 7.35678 6.34594 7.63287 6.625ZM5.1124 11.2859H7.0124C7.40725 11.2859 7.7249 11.6036 7.7249 11.9984C7.7249 12.3933 7.40725 12.7109 7.0124 12.7109H5.1124C4.71756 12.7109 4.3999 12.3933 4.3999 11.9984C4.3999 11.6036 4.71756 11.2859 5.1124 11.2859ZM16.9874 11.2859H18.8874C19.2822 11.2859 19.5999 11.6036 19.5999 11.9984C19.5999 12.3933 19.2822 12.7109 18.8874 12.7109H16.9874C16.5926 12.7109 16.2749 12.3933 16.2749 11.9984C16.2749 11.6036 16.5926 11.2859 16.9874 11.2859ZM8.97771 16.03L7.63287 17.3719C7.35381 17.6509 6.90256 17.6509 6.62646 17.3719C6.35037 17.0928 6.3474 16.6416 6.62646 16.3655L7.97131 15.0206C8.25037 14.7416 8.70162 14.7416 8.97771 15.0206C9.25381 15.2997 9.25678 15.7509 8.97771 16.027V16.03ZM16.0315 15.0236L17.3733 16.3655C17.6524 16.6445 17.6524 17.0958 17.3733 17.3719C17.0943 17.648 16.643 17.6509 16.3669 17.3719L15.0221 16.027C14.743 15.748 14.743 15.2967 15.0221 15.0206C15.3012 14.7445 15.7524 14.7416 16.0285 15.0206L16.0315 15.0236ZM12.7124 16.9859V18.8859C12.7124 19.2808 12.3947 19.5984 11.9999 19.5984C11.6051 19.5984 11.2874 19.2808 11.2874 18.8859V16.9859C11.2874 16.5911 11.6051 16.2734 11.9999 16.2734C12.3947 16.2734 12.7124 16.5911 12.7124 16.9859ZM13.8999 11.9984C13.8999 11.4945 13.6997 11.0113 13.3434 10.6549C12.9871 10.2986 12.5038 10.0984 11.9999 10.0984C11.496 10.0984 11.0127 10.2986 10.6564 10.6549C10.3001 11.0113 10.0999 11.4945 10.0999 11.9984C10.0999 12.5023 10.3001 12.9856 10.6564 13.3419C11.0127 13.6983 11.496 13.8984 11.9999 13.8984C12.5038 13.8984 12.9871 13.6983 13.3434 13.3419C13.6997 12.9856 13.8999 12.5023 13.8999 11.9984ZM8.6749 11.9984C8.6749 11.1166 9.02521 10.2709 9.64877 9.64731C10.2723 9.02375 11.1181 8.67344 11.9999 8.67344C12.8817 8.67344 13.7275 9.02375 14.351 9.64731C14.9746 10.2709 15.3249 11.1166 15.3249 11.9984C15.3249 12.8803 14.9746 13.726 14.351 14.3496C13.7275 14.9731 12.8817 15.3234 11.9999 15.3234C11.1181 15.3234 10.2723 14.9731 9.64877 14.3496C9.02521 13.726 8.6749 12.8803 8.6749 11.9984Z" fill="#FF6F00"/>
</svg>

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -4445,6 +4445,11 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
if (!curr_ams) continue;
if (it->contains("dry_time") && (*it)["dry_time"].is_number())
{
curr_ams->left_dry_time = (*it)["dry_time"].get<int>();
}
if (it->contains("humidity")) {
std::string humidity = (*it)["humidity"].get<std::string>();

View File

@ -362,6 +362,7 @@ public:
type = type_id;
}
std::string id;
int left_dry_time = 0;
int humidity = 5;
int humidity_raw = -1;// the percentage, -1 means invalid. eg. 100 means 100%
bool startup_read_opt{true};

View File

@ -48,12 +48,13 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, boo
if (ams->type == 1 || ams->type == 3){
this->ams_humidity = ams->humidity;
this->humidity_raw = ams->humidity_raw;
}
else{
this->ams_humidity = -1;
this->humidity_raw = -1;
}
this->humidity_raw = ams->humidity_raw;
this->left_dray_time = ams->left_dry_time;
this->ams_type = AMSModel(ams->type);
nozzle_id = ams->nozzle;
@ -2762,13 +2763,15 @@ AMSHumidity::AMSHumidity() {}
AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wxPoint& pos, const wxSize& size)
: AMSHumidity()
{
create(parent, id, pos, wxDefaultSize);
for (int i = 1; i <= 5; i++) { ams_humidity_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_light", 16));}
for (int i = 1; i <= 5; i++) { ams_humidity_dark_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_dark", 16));}
for (int i = 1; i <= 5; i++) { ams_humidity_no_num_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_no_num_light", 16)); }
for (int i = 1; i <= 5; i++) { ams_humidity_no_num_dark_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_no_num_dark", 16)); }
ams_sun_img = ScalableBitmap(this, "ams_drying", 16);
create(parent, id, pos, wxDefaultSize);
ams_drying_img = ScalableBitmap(this, "ams_is_drying", 16);
Bind(wxEVT_PAINT, &AMSHumidity::paintEvent, this);
//wxWindow::SetBackgroundColour(AMS_CONTROL_DEF_HUMIDITY_BK_COLOUR);
@ -2807,23 +2810,27 @@ void AMSHumidity::Update(AMSinfo amsinfo)
if (m_amsinfo != amsinfo)
{
m_amsinfo = amsinfo;
if (m_amsinfo.humidity_raw != -1)
{
SetSize(AMS_HUMIDITY_SIZE);
SetMinSize(AMS_HUMIDITY_SIZE);
SetMaxSize(AMS_HUMIDITY_SIZE);
}
else
{
SetSize(AMS_HUMIDITY_NO_PERCENT_SIZE);
SetMinSize(AMS_HUMIDITY_NO_PERCENT_SIZE);
SetMaxSize(AMS_HUMIDITY_NO_PERCENT_SIZE);
}
update_size();
Refresh();
}
}
void AMSHumidity::update_size()
{
wxSize size;
if (m_amsinfo.humidity_raw != -1) {
size = AMS_HUMIDITY_SIZE;
} else {
size = AMS_HUMIDITY_NO_PERCENT_SIZE;
}
if (!m_amsinfo.support_drying()) { size.x -= AMS_HUMIDITY_DRY_WIDTH; }
SetMaxSize(size);
SetMinSize(size);
SetSize(size);
}
void AMSHumidity::paintEvent(wxPaintEvent& evt)
{
@ -2919,20 +2926,25 @@ void AMSHumidity::doRender(wxDC& dc)
pot.x = pot.x + hum_img.GetBmpSize().x + FromDIP(3);
}
//vertical line
dc.SetPen(wxPen(wxColour(194, 194, 194)));
dc.SetBrush(wxBrush(wxColour(194, 194, 194)));
//dc.DrawLine(FromDIP(GetSize().x * 0.64), FromDIP(GetSize().y / 2 - 10), FromDIP(GetSize().x * 0.64), FromDIP(GetSize().y / 2 + 10));
dc.DrawLine(pot.x, GetSize().y / 2 - FromDIP(10), pot.x, GetSize().y / 2 + FromDIP(10));
//sun image
/*pot.x = FromDIP(size.x * 0.69);
pot.y = FromDIP((size.y - ams_sun_img.GetBmpHeight()) / 2);*/
pot.x = pot.x + (ams_sun_img.GetBmpWidth() / 2);
pot.y = (size.y - ams_sun_img.GetBmpHeight()) / 2;
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
dc.DrawBitmap(ams_sun_img.bmp(), pot);
if (m_amsinfo.support_drying())
{
// vertical line
dc.SetPen(wxPen(wxColour(194, 194, 194)));
dc.SetBrush(wxBrush(wxColour(194, 194, 194)));
dc.DrawLine(pot.x, GetSize().y / 2 - FromDIP(10), pot.x, GetSize().y / 2 + FromDIP(10));
// sun image
dc.SetPen(wxPen(*wxTRANSPARENT_PEN));
if (m_amsinfo.left_dray_time > 0) {
pot.x = pot.x + (ams_drying_img.GetBmpWidth() / 2);
pot.y = (size.y - ams_drying_img.GetBmpHeight()) / 2;
dc.DrawBitmap(ams_drying_img.bmp(), pot);
} else {
pot.x = pot.x + (ams_sun_img.GetBmpWidth() / 2);
pot.y = (size.y - ams_sun_img.GetBmpHeight()) / 2;
dc.DrawBitmap(ams_sun_img.bmp(), pot);
}
}
}
else {
//to do ...
@ -2945,6 +2957,7 @@ void AMSHumidity::msw_rescale() {
for (auto &img : ams_humidity_no_num_imgs) { img.msw_rescale(); }
for (auto &img : ams_humidity_no_num_dark_imgs) { img.msw_rescale(); }
ams_sun_img.msw_rescale();
ams_drying_img.msw_rescale();
Layout();
Refresh();

View File

@ -160,8 +160,11 @@ enum FilamentStepType {
#define AMS_EXTRUDER_SINGLE_NOZZLE_BITMAP_SIZE wxSize(FromDIP(18), FromDIP(36))
#define AMS_BODY_SIZE wxSize(FromDIP(36), FromDIP(55))
#define AMS_DOWN_ROAD_SIZE wxSize(FromDIP(568), FromDIP(10))
#define AMS_HUMIDITY_SIZE wxSize(FromDIP(93), FromDIP(26))
#define AMS_HUMIDITY_NO_PERCENT_SIZE wxSize(FromDIP(60), FromDIP(26))
#define AMS_HUMIDITY_DRY_WIDTH FromDIP(35)
#define AMS_PANEL_SIZE wxSize(FromDIP(264), FromDIP(150))
#define GENERIC_AMS_SLOT_NUM 4
@ -215,6 +218,7 @@ public:
int curreent_filamentstep;
int ams_humidity = 0;
int humidity_raw = -1;
int left_dray_time = 0;
AMSModel ams_type = AMSModel::GENERIC_AMS;
AMSModelOriginType ext_type = AMSModelOriginType::GENERIC_EXT;
@ -229,6 +233,7 @@ public:
current_action == other.current_action &&
curreent_filamentstep == other.curreent_filamentstep &&
ams_humidity == other.ams_humidity &&
left_dray_time == other.left_dray_time &&
ams_type == other.ams_type &&
ext_type == other.ext_type)
{
@ -250,6 +255,8 @@ public:
bool parse_ams_info(MachineObject* obj, Ams *ams, bool remain_flag = false, bool humidity_flag = false);
void parse_ext_info(MachineObject* obj, AmsTray tray);
bool support_drying() const { return (ams_type == AMSModel::N3S_AMS) || (ams_type == AMSModel::N3F_AMS); };
};
/*************************************************
@ -719,7 +726,8 @@ public:
std::vector<ScalableBitmap> ams_humidity_no_num_imgs;
std::vector<ScalableBitmap> ams_humidity_no_num_dark_imgs;
ScalableBitmap ams_sun_img;
ScalableBitmap ams_sun_img;
ScalableBitmap ams_drying_img;
int m_humidity = { 0 };
@ -731,6 +739,9 @@ public:
void render(wxDC& dc);
void doRender(wxDC& dc);
void msw_rescale();
private:
void update_size();
};