FIX: The humidity popup with humidity_percent/temperature/dry_time

jira: [STUDIO-9268]
Change-Id: Ic6e923ae7cff56fa3e053d48e5dea6e393cd41eb
(cherry picked from commit 75da1db2f926125a0cb3595a8cae9f4d7588c6a8)
This commit is contained in:
xin.zhang
2025-02-21 15:57:10 +08:00
committed by Noisyfox
parent e924a04fb8
commit 0b98094dac
10 changed files with 375 additions and 18 deletions

View File

@@ -4,6 +4,8 @@
#include "../I18N.hpp"
#include "../GUI_App.hpp"
#include "slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h"
#include <wx/simplebook.h>
#include <wx/dcgraph.h>
@@ -21,6 +23,7 @@ Description:AMSControl
AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
: wxSimplebook(parent, wxID_ANY, pos, size)
, m_Humidity_tip_popup(AmsHumidityTipPopup(this))
, m_percent_humidity_dry_popup(new uiAmsPercentHumidityDryPopup(this))
, m_ams_introduce_popup(AmsIntroducePopup(this))
{
SetBackgroundColour(*wxWHITE);
@@ -557,19 +560,31 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
});
Bind(EVT_AMS_SHOW_HUMIDITY_TIPS, [this](wxCommandEvent& evt) {
wxPoint img_pos = ClientToScreen(wxPoint(0, 0));
wxPoint popup_pos(img_pos.x - m_Humidity_tip_popup.GetSize().GetWidth() + FromDIP(150), img_pos.y - FromDIP(80));
m_Humidity_tip_popup.Position(popup_pos, wxSize(0, 0));
if (m_ams_info.size() > 0) {
for (auto i = 0; i < m_ams_info.size(); i++) {
if (m_ams_info[i].ams_id == m_current_show_ams) {
m_Humidity_tip_popup.set_humidity_level(m_ams_info[i].ams_humidity);
}
uiAmsHumidityInfo *info = (uiAmsHumidityInfo *) evt.GetClientData();
if (info)
{
if (info->humidity_percent >= 0)
{
m_percent_humidity_dry_popup->Update(info);
wxPoint img_pos = ClientToScreen(wxPoint(0, 0));
wxPoint popup_pos(img_pos.x - m_percent_humidity_dry_popup->GetSize().GetWidth() + FromDIP(150), img_pos.y - FromDIP(80));
m_percent_humidity_dry_popup->Position(popup_pos, wxSize(0, 0));
m_percent_humidity_dry_popup->Popup();
}
else
{
wxPoint img_pos = ClientToScreen(wxPoint(0, 0));
wxPoint popup_pos(img_pos.x - m_Humidity_tip_popup.GetSize().GetWidth() + FromDIP(150), img_pos.y - FromDIP(80));
m_Humidity_tip_popup.Position(popup_pos, wxSize(0, 0));
int humidity_value = info->humidity_level;
if (humidity_value > 0 && humidity_value <= 5) { m_Humidity_tip_popup.set_humidity_level(humidity_value); }
m_Humidity_tip_popup.Popup();
}
}
m_Humidity_tip_popup.Popup();
delete info;
});
@@ -788,6 +803,10 @@ void AMSControl::msw_rescale()
cans->amsCans->msw_rescale();
}
if (m_percent_humidity_dry_popup){
m_percent_humidity_dry_popup->msw_rescale();
}
Layout();
Refresh();
}

View File

@@ -17,6 +17,9 @@
namespace Slic3r { namespace GUI {
//Previous definitions
class uiAmsPercentHumidityDryPopup;
class AMSControl : public wxSimplebook
{
public:
@@ -94,6 +97,7 @@ protected:
wxHyperlinkCtrl *m_hyperlink = {nullptr};
AmsHumidityTipPopup m_Humidity_tip_popup;
uiAmsPercentHumidityDryPopup* m_percent_humidity_dry_popup;
std::string m_last_ams_id;
std::string m_last_tray_id;

View File

@@ -5,6 +5,8 @@
#include "../GUI_App.hpp"
#include "../Utils/WxFontUtils.hpp"
#include "slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h"
#include <wx/simplebook.h>
#include <wx/dcgraph.h>
@@ -50,6 +52,7 @@ bool AMSinfo::parse_ams_info(MachineObject *obj, Ams *ams, bool remain_flag, boo
this->humidity_raw = ams->humidity_raw;
this->left_dray_time = ams->left_dry_time;
this->current_temperature = ams->current_temperature;
this->ams_type = AMSModel(ams->type);
cans.clear();
@@ -2198,13 +2201,12 @@ AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wx
mouse_pos.y > rect.y) {
wxCommandEvent show_event(EVT_AMS_SHOW_HUMIDITY_TIPS);
//uiAmsHumidityInfo *info = new uiAmsHumidityInfo;
//info->ams_id = m_amsinfo.ams_id;
//info->humidity_level = m_amsinfo.ams_humidity;
//info->humidity_percent = m_amsinfo.humidity_raw;
//info->left_dry_time = m_amsinfo.left_dray_time;
//info->current_temperature = m_amsinfo.current_temperature;
//show_event.SetClientData(info);
uiAmsHumidityInfo *info = new uiAmsHumidityInfo;
info->humidity_level = m_amsinfo.ams_humidity;
info->humidity_percent = m_amsinfo.humidity_raw;
info->left_dry_time = m_amsinfo.left_dray_time;
info->current_temperature = m_amsinfo.current_temperature;
show_event.SetClientData(info);
wxPostEvent(GetParent()->GetParent(), show_event);
#ifdef __WXMSW__

View File

@@ -186,6 +186,7 @@ public:
int ams_humidity = 0;
int humidity_raw = -1;
int left_dray_time = 0;
float current_temperature = INVALID_AMS_TEMPERATURE;
AMSModel ams_type = AMSModel::GENERIC_AMS;
public:
@@ -199,6 +200,7 @@ public:
curreent_filamentstep == other.curreent_filamentstep &&
ams_humidity == other.ams_humidity &&
left_dray_time == other.left_dray_time &&
current_temperature == other.current_temperature &&
ams_type == other.ams_type)
{
return true;