mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-18 19:12:17 +00:00
ENH: update humidity display for AMS-1
JIRA: [STUDIO-13195] Change-Id: I7abcdf821b7ead2cf4a8605ecd95011e74f5dc6b (cherry picked from commit 1c1d34ff7e3fea4492ba07e238ca171e28eb0a3b)
This commit is contained in:
@@ -1814,18 +1814,6 @@ AmsHumidityTipPopup::AmsHumidityTipPopup(wxWindow* parent)
|
||||
wxGetApp().UpdateDarkUIWin(this);
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::OnDismiss() {}
|
||||
|
||||
bool AmsHumidityTipPopup::ProcessLeftDown(wxMouseEvent& event) {
|
||||
return PopupWindow::ProcessLeftDown(event);
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::set_humidity_level(int level)
|
||||
{
|
||||
current_humidity_level = level;
|
||||
@@ -1838,6 +1826,29 @@ void AmsHumidityTipPopup::set_humidity_level(int level)
|
||||
curr_humidity_img->Update();
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::msw_rescale()
|
||||
{
|
||||
// close image
|
||||
close_img.msw_rescale();
|
||||
|
||||
// current humidity level image
|
||||
std::string mode_string = wxGetApp().dark_mode() ? "_dark" : "_light";
|
||||
curr_humidity_img->SetBitmap(create_scaled_bitmap("hum_level" + std::to_string(current_humidity_level) + mode_string, this, 132));
|
||||
|
||||
// the list
|
||||
humidity_level_list->msw_rescale();
|
||||
|
||||
// refresh
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void AmsHumidityTipPopup::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void AmsHumidityTipPopup::render(wxDC& dc)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
@@ -1870,6 +1881,8 @@ void AmsHumidityTipPopup::doRender(wxDC& dc)
|
||||
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AmsTutorialPopup::AmsTutorialPopup(wxWindow* parent)
|
||||
:PopupWindow(parent, wxBORDER_NONE)
|
||||
{
|
||||
@@ -2669,7 +2682,19 @@ AmsHumidityLevelList::AmsHumidityLevelList(wxWindow* parent)
|
||||
|
||||
void AmsHumidityLevelList::msw_rescale()
|
||||
{
|
||||
background_img.msw_rescale();
|
||||
|
||||
for (int i = 0; i < hum_level_img_light.size(); i++)
|
||||
{
|
||||
hum_level_img_light[i].msw_rescale();
|
||||
}
|
||||
|
||||
for (int i = 0; i < hum_level_img_dark.size(); i++)
|
||||
{
|
||||
hum_level_img_dark[i].msw_rescale();
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void AmsHumidityLevelList::paintEvent(wxPaintEvent& evt)
|
||||
|
||||
@@ -324,25 +324,18 @@ public:
|
||||
AmsHumidityLevelList(wxWindow* parent);
|
||||
~AmsHumidityLevelList() {};
|
||||
|
||||
ScalableBitmap background_img;
|
||||
ScalableBitmap hum_level1_img;
|
||||
ScalableBitmap hum_level2_img;
|
||||
ScalableBitmap hum_level3_img;
|
||||
ScalableBitmap hum_level4_img;
|
||||
|
||||
std::vector<ScalableBitmap> hum_level_img_light;
|
||||
std::vector<ScalableBitmap> hum_level_img_dark;
|
||||
|
||||
wxStaticBitmap* hum_level1_bitmap;
|
||||
wxStaticBitmap* hum_level2_bitmap;
|
||||
wxStaticBitmap* hum_level3_bitmap;
|
||||
wxStaticBitmap* hum_level4_bitmap;
|
||||
wxStaticBitmap* hum_level5_bitmap;
|
||||
|
||||
public:
|
||||
void msw_rescale();
|
||||
|
||||
private:
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
|
||||
private:
|
||||
ScalableBitmap background_img;
|
||||
std::vector<ScalableBitmap> hum_level_img_light;
|
||||
std::vector<ScalableBitmap> hum_level_img_dark;
|
||||
};
|
||||
|
||||
class AmsHumidityTipPopup : public PopupWindow
|
||||
@@ -350,24 +343,31 @@ class AmsHumidityTipPopup : public PopupWindow
|
||||
public:
|
||||
AmsHumidityTipPopup(wxWindow* parent);
|
||||
~AmsHumidityTipPopup() {};
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
|
||||
virtual void OnDismiss() wxOVERRIDE;
|
||||
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
|
||||
|
||||
public:
|
||||
void set_humidity_level(int level);
|
||||
void msw_rescale();
|
||||
|
||||
private:
|
||||
virtual void OnDismiss() wxOVERRIDE {};
|
||||
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE { return PopupWindow::ProcessLeftDown(event); };
|
||||
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
|
||||
public:
|
||||
private:
|
||||
int current_humidity_level = 0;
|
||||
|
||||
ScalableBitmap close_img;
|
||||
|
||||
wxStaticBitmap* curr_humidity_img;
|
||||
AmsHumidityLevelList* humidity_level_list{nullptr};
|
||||
wxStaticBitmap* m_img;
|
||||
|
||||
Label* m_staticText;;
|
||||
Label* m_staticText_note;
|
||||
|
||||
AmsHumidityLevelList* humidity_level_list{nullptr};
|
||||
};
|
||||
|
||||
class AmsTutorialPopup : public PopupWindow
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
//**********************************************************/
|
||||
|
||||
#pragma once
|
||||
#include "slic3r/GUI/Widgets/AMSItem.hpp"
|
||||
#include "slic3r/GUI/Widgets/Label.hpp"
|
||||
#include "slic3r/GUI/Widgets/PopupWindow.hpp"
|
||||
|
||||
@@ -19,6 +20,7 @@ namespace Slic3r { namespace GUI {
|
||||
struct uiAmsHumidityInfo
|
||||
{
|
||||
std::string ams_id;
|
||||
AMSModel ams_type;
|
||||
int humidity_level = -1;
|
||||
int humidity_percent = -1;
|
||||
float current_temperature;
|
||||
|
||||
@@ -280,16 +280,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
||||
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->Move(popup_pos);
|
||||
m_percent_humidity_dry_popup->ShowModal();
|
||||
}
|
||||
else
|
||||
if (info->ams_type == AMSModel::GENERIC_AMS)
|
||||
{
|
||||
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));
|
||||
@@ -299,6 +290,15 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
||||
if (humidity_value > 0 && humidity_value <= 5) { m_Humidity_tip_popup.set_humidity_level(humidity_value); }
|
||||
m_Humidity_tip_popup.Popup();
|
||||
}
|
||||
else
|
||||
{
|
||||
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->Move(popup_pos);
|
||||
m_percent_humidity_dry_popup->ShowModal();
|
||||
}
|
||||
}
|
||||
|
||||
delete info;
|
||||
@@ -532,6 +532,8 @@ void AMSControl::msw_rescale()
|
||||
m_percent_humidity_dry_popup->msw_rescale();
|
||||
}
|
||||
|
||||
m_Humidity_tip_popup.msw_rescale();
|
||||
|
||||
Layout();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -1885,7 +1885,7 @@ void AMSRoad::doRender(wxDC &dc)
|
||||
dc.DrawRoundedRectangle(size.x * 0.37 / 2, size.y * 0.6 - size.y / 6, size.x * 0.63, size.y / 3, m_radius);
|
||||
}
|
||||
|
||||
if (m_canindex == 3) {
|
||||
if (m_canindex == 3) /*To check, tao.wang*/{
|
||||
|
||||
if (m_amsinfo.ams_humidity >= 1 && m_amsinfo.ams_humidity <= 5) {m_show_humidity = true;}
|
||||
else {m_show_humidity = false;}
|
||||
@@ -2795,8 +2795,8 @@ AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wx
|
||||
{
|
||||
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_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_light", 20));}
|
||||
for (int i = 1; i <= 5; i++) { ams_humidity_dark_imgs.push_back(ScalableBitmap(this, "hum_level" + std::to_string(i) + "_dark", 20));}
|
||||
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)); }
|
||||
|
||||
@@ -2808,10 +2808,6 @@ AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wx
|
||||
|
||||
Bind(wxEVT_LEFT_UP, [this](wxMouseEvent& e) {
|
||||
if (m_show_humidity) {
|
||||
if (m_amsinfo.ams_type == AMSModel::GENERIC_AMS) {
|
||||
return;/*STUDIO-12083*/
|
||||
}
|
||||
|
||||
auto mouse_pos = ClientToScreen(e.GetPosition());
|
||||
auto rect = ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
@@ -2821,6 +2817,7 @@ AMSHumidity::AMSHumidity(wxWindow* parent, wxWindowID id, AMSinfo info, const wx
|
||||
|
||||
uiAmsHumidityInfo *info = new uiAmsHumidityInfo;
|
||||
info->ams_id = m_amsinfo.ams_id;
|
||||
info->ams_type = m_amsinfo.ams_type;
|
||||
info->humidity_level = m_amsinfo.ams_humidity;
|
||||
info->humidity_percent = m_amsinfo.humidity_raw;
|
||||
info->left_dry_time = m_amsinfo.left_dray_time;
|
||||
@@ -2853,10 +2850,10 @@ void AMSHumidity::Update(AMSinfo amsinfo)
|
||||
void AMSHumidity::update_size()
|
||||
{
|
||||
wxSize size;
|
||||
if (m_amsinfo.humidity_raw != -1) {
|
||||
size = AMS_HUMIDITY_SIZE;
|
||||
} else {
|
||||
if (m_amsinfo.ams_type == AMSModel::GENERIC_AMS) {
|
||||
size = AMS_HUMIDITY_NO_PERCENT_SIZE;
|
||||
} else {
|
||||
size = AMS_HUMIDITY_SIZE;
|
||||
}
|
||||
|
||||
if (!m_amsinfo.support_drying()) { size.x -= AMS_HUMIDITY_DRY_WIDTH; }
|
||||
@@ -2911,7 +2908,20 @@ void AMSHumidity::doRender(wxDC& dc)
|
||||
dc.DrawRoundedRectangle(0, 0, (size.x), (size.y), (size.y / 2));
|
||||
|
||||
wxPoint pot;
|
||||
if (m_amsinfo.humidity_raw != -1) /*image with no number + percentage*/
|
||||
if (m_amsinfo.ams_type == AMSModel::GENERIC_AMS) /*image with stage*/
|
||||
{
|
||||
ScalableBitmap hum_img;
|
||||
if (!wxGetApp().dark_mode()) {
|
||||
hum_img = ams_humidity_imgs[m_amsinfo.ams_humidity - 1];
|
||||
} else {
|
||||
hum_img = ams_humidity_dark_imgs[m_amsinfo.ams_humidity - 1];
|
||||
}
|
||||
|
||||
pot = wxPoint((size.x - hum_img.GetBmpWidth()) / 2, ((size.y - hum_img.GetBmpSize().y) / 2));
|
||||
dc.DrawBitmap(hum_img.bmp(), pot);
|
||||
pot.x = pot.x + hum_img.GetBmpSize().x;
|
||||
}
|
||||
else if (m_amsinfo.humidity_raw != -1) /*image with no number + percentage*/
|
||||
{
|
||||
// hum image
|
||||
ScalableBitmap hum_img;
|
||||
@@ -2946,20 +2956,6 @@ void AMSHumidity::doRender(wxDC& dc)
|
||||
|
||||
pot.x += tsize2.x;
|
||||
}
|
||||
else /*image with number*/
|
||||
{
|
||||
// hum image
|
||||
ScalableBitmap hum_img;
|
||||
if (!wxGetApp().dark_mode()) {
|
||||
hum_img = ams_humidity_imgs[m_amsinfo.ams_humidity - 1];
|
||||
} else {
|
||||
hum_img = ams_humidity_dark_imgs[m_amsinfo.ams_humidity - 1];
|
||||
}
|
||||
|
||||
pot = wxPoint(FromDIP(5), ((size.y - hum_img.GetBmpSize().y) / 2));
|
||||
dc.DrawBitmap(hum_img.bmp(), pot);
|
||||
pot.x = pot.x + hum_img.GetBmpSize().x;
|
||||
}
|
||||
|
||||
if (m_amsinfo.support_drying())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user