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 194f52fb88
commit d557b8e35b
4 changed files with 46 additions and 8 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 @@ namespace Slic3r { namespace GUI {
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))
{
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
@@ -270,15 +273,31 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
});
Bind(EVT_AMS_SHOW_HUMIDITY_TIPS, [this](wxCommandEvent& evt) {
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_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 = evt.GetInt();
if (humidity_value > 0 && humidity_value <= 5) {
m_Humidity_tip_popup.set_humidity_level(humidity_value);
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;
});
Bind(EVT_AMS_ON_SELECTED, &AMSControl::AmsSelectedSwitch, this);
}
@@ -496,6 +515,10 @@ void AMSControl::msw_rescale()
m_down_road->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:
@@ -112,6 +115,7 @@ protected:
ScalableBitmap m_button_ams_setting_press;
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>
@@ -55,6 +57,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);
nozzle_id = ams->nozzle;
@@ -2784,7 +2787,13 @@ AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wx
if (mouse_pos.x > rect.x &&
mouse_pos.y > rect.y) {
wxCommandEvent show_event(EVT_AMS_SHOW_HUMIDITY_TIPS);
show_event.SetInt(m_amsinfo.ams_humidity);
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

@@ -219,6 +219,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;
AMSModelOriginType ext_type = AMSModelOriginType::GENERIC_EXT;
@@ -234,6 +235,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 &&
ext_type == other.ext_type)
{