mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
ENH:optimized logic related to fan control
Change-Id: Ia67525bc75d4cc5be02eaf7131764fb0f9584f23
This commit is contained in:
parent
3e07db0c2a
commit
450f3e1c77
4 changed files with 42 additions and 19 deletions
|
@ -176,8 +176,8 @@ void StatusBasePanel::init_bitmaps()
|
||||||
m_bitmap_axis_home = ScalableBitmap(this, "monitor_axis_home", 32);
|
m_bitmap_axis_home = ScalableBitmap(this, "monitor_axis_home", 32);
|
||||||
m_bitmap_lamp_on = ScalableBitmap(this, "monitor_lamp_on", 24);
|
m_bitmap_lamp_on = ScalableBitmap(this, "monitor_lamp_on", 24);
|
||||||
m_bitmap_lamp_off = ScalableBitmap(this, "monitor_lamp_off", 24);
|
m_bitmap_lamp_off = ScalableBitmap(this, "monitor_lamp_off", 24);
|
||||||
m_bitmap_fan_on = ScalableBitmap(this, "monitor_fan_on", 24);
|
m_bitmap_fan_on = ScalableBitmap(this, "monitor_fan_on", 22);
|
||||||
m_bitmap_fan_off = ScalableBitmap(this, "monitor_fan_off", 24);
|
m_bitmap_fan_off = ScalableBitmap(this, "monitor_fan_off", 22);
|
||||||
m_bitmap_speed = ScalableBitmap(this, "monitor_speed", 24);
|
m_bitmap_speed = ScalableBitmap(this, "monitor_speed", 24);
|
||||||
m_bitmap_speed_active = ScalableBitmap(this, "monitor_speed_active", 24);
|
m_bitmap_speed_active = ScalableBitmap(this, "monitor_speed_active", 24);
|
||||||
m_bitmap_use_time = ScalableBitmap(this, "print_info_time", 16);
|
m_bitmap_use_time = ScalableBitmap(this, "print_info_time", 16);
|
||||||
|
@ -2909,15 +2909,18 @@ void StatusPanel::on_printing_fan_switch(wxCommandEvent &event)
|
||||||
|
|
||||||
void StatusPanel::on_nozzle_fan_switch(wxCommandEvent &event)
|
void StatusPanel::on_nozzle_fan_switch(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
m_fan_control_popup->Destroy();
|
m_fan_control_popup->Destroy();
|
||||||
|
m_fan_control_popup = nullptr;
|
||||||
m_fan_control_popup = new FanControlPopup(this);
|
m_fan_control_popup = new FanControlPopup(this);
|
||||||
|
|
||||||
|
if (obj) {
|
||||||
|
bool is_suppt_cham_fun = obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_FAN);
|
||||||
|
m_fan_control_popup->update_show_mode(is_suppt_cham_fun);
|
||||||
|
}
|
||||||
|
|
||||||
auto pos = m_switch_nozzle_fan->GetScreenPosition();
|
auto pos = m_switch_nozzle_fan->GetScreenPosition();
|
||||||
pos.y = pos.y + m_switch_nozzle_fan->GetSize().y;
|
pos.y = pos.y + m_switch_nozzle_fan->GetSize().y;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int display_idx = wxDisplay::GetFromWindow(this);
|
int display_idx = wxDisplay::GetFromWindow(this);
|
||||||
auto display = wxDisplay(display_idx).GetClientArea();
|
auto display = wxDisplay(display_idx).GetClientArea();
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "Label.hpp"
|
#include "Label.hpp"
|
||||||
#include "../BitmapCache.hpp"
|
#include "../BitmapCache.hpp"
|
||||||
#include "../I18N.hpp"
|
#include "../I18N.hpp"
|
||||||
|
#include "../GUI_App.hpp"
|
||||||
|
|
||||||
#include <wx/simplebook.h>
|
#include <wx/simplebook.h>
|
||||||
#include <wx/dcgraph.h>
|
#include <wx/dcgraph.h>
|
||||||
|
@ -542,20 +543,34 @@ FanControlPopup::FanControlPopup(wxWindow* parent)
|
||||||
Bind(wxEVT_LEFT_DOWN, &FanControlPopup::on_left_down, this);
|
Bind(wxEVT_LEFT_DOWN, &FanControlPopup::on_left_down, this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
Bind(wxEVT_SHOW, &FanControlPopup::on_show, this);
|
||||||
SetBackgroundColour(*wxWHITE);
|
SetBackgroundColour(*wxWHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FanControlPopup::update_show_mode(bool support_cham_fun)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (support_cham_fun && !m_is_suppt_cham_fun) {
|
||||||
|
m_cham_fan->Show();
|
||||||
|
m_line_bottom->Show();
|
||||||
|
Layout();
|
||||||
|
Fit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!support_cham_fun && m_is_suppt_cham_fun) {
|
||||||
|
m_cham_fan->Hide();
|
||||||
|
m_line_bottom->Hide();
|
||||||
|
Layout();
|
||||||
|
Fit();
|
||||||
|
}
|
||||||
|
m_is_suppt_cham_fun = support_cham_fun;
|
||||||
|
}
|
||||||
|
|
||||||
void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject* obj)
|
void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject* obj)
|
||||||
{
|
{
|
||||||
bool is_suppt_cham_fun = obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_FAN);
|
m_is_suppt_cham_fun = obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_FAN);
|
||||||
if (is_suppt_cham_fun) {
|
update_show_mode(m_is_suppt_cham_fun);
|
||||||
m_cham_fan->Show();
|
|
||||||
m_line_bottom->Show();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_cham_fan->Hide();
|
|
||||||
m_line_bottom->Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == MachineObject::FanType::COOLING_FAN && obj->cooling_fan_speed >= 0) {
|
if (type == MachineObject::FanType::COOLING_FAN && obj->cooling_fan_speed >= 0) {
|
||||||
m_part_fan->set_fan_speed(obj->cooling_fan_speed);
|
m_part_fan->set_fan_speed(obj->cooling_fan_speed);
|
||||||
|
@ -576,9 +591,6 @@ void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject
|
||||||
Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
|
Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
|
||||||
post_event(e.GetInt(), e.GetString());
|
post_event(e.GetInt(), e.GetString());
|
||||||
});
|
});
|
||||||
|
|
||||||
Layout();
|
|
||||||
Fit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FanControlPopup::on_left_down(wxMouseEvent& evt)
|
void FanControlPopup::on_left_down(wxMouseEvent& evt)
|
||||||
|
@ -619,6 +631,11 @@ bool FanControlPopup::ProcessLeftDown(wxMouseEvent& event)
|
||||||
return wxPopupTransientWindow::ProcessLeftDown(event);
|
return wxPopupTransientWindow::ProcessLeftDown(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FanControlPopup::on_show(wxShowEvent& evt)
|
||||||
|
{
|
||||||
|
wxGetApp().UpdateDarkUIWin(this);
|
||||||
|
}
|
||||||
|
|
||||||
void FanControlPopup::paintEvent(wxPaintEvent& evt)
|
void FanControlPopup::paintEvent(wxPaintEvent& evt)
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
|
@ -150,12 +150,15 @@ private:
|
||||||
FanControl* m_cham_fan;
|
FanControl* m_cham_fan;
|
||||||
wxWindow* m_line_top;
|
wxWindow* m_line_top;
|
||||||
wxWindow* m_line_bottom;
|
wxWindow* m_line_bottom;
|
||||||
|
bool m_is_suppt_cham_fun{true};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
void update_show_mode(bool support_cham_fun);
|
||||||
void update_fan_data(MachineObject::FanType type, MachineObject* obj);
|
void update_fan_data(MachineObject::FanType type, MachineObject* obj);
|
||||||
void on_left_down(wxMouseEvent& evt);
|
void on_left_down(wxMouseEvent& evt);
|
||||||
void paintEvent(wxPaintEvent& evt);
|
void paintEvent(wxPaintEvent& evt);
|
||||||
void post_event(int fan_type, wxString speed);
|
void post_event(int fan_type, wxString speed);
|
||||||
|
void on_show(wxShowEvent& evt);
|
||||||
virtual void OnDismiss() wxOVERRIDE;
|
virtual void OnDismiss() wxOVERRIDE;
|
||||||
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
|
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
|
@ -312,7 +312,7 @@ void FanSwitchButton::render(wxDC& dc)
|
||||||
dc.SetTextForeground(text_color.colorForStates(states));
|
dc.SetTextForeground(text_color.colorForStates(states));
|
||||||
|
|
||||||
pt.x = (size.x - dc.GetTextExtent(speed).x) / 2;
|
pt.x = (size.x - dc.GetTextExtent(speed).x) / 2;
|
||||||
pt.y -= FromDIP(5);
|
pt.y += FromDIP(1);
|
||||||
dc.DrawText(speed, pt);
|
dc.DrawText(speed, pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue