OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::FanOperate Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/FanControl.hpp>

Inheritance diagram for Slic3r::GUI::FanOperate:
Collaboration diagram for Slic3r::GUI::FanOperate:

Public Member Functions

 FanOperate (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 ~FanOperate ()
void post_event (wxCommandEvent &&event)
void paintEvent (wxPaintEvent &evt)
void render (wxDC &dc)
void doRender (wxDC &dc)
void msw_rescale ()
void create (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
void on_left_down (wxMouseEvent &event)
void set_machine_obj (MachineObject *obj)
void set_fan_speeds (int g)
bool check_printing_state ()
void add_fan_speeds ()
void decrease_fan_speeds ()

Private Attributes

int m_current_speeds
int m_min_speeds
int m_max_speeds
ScalableBitmap m_bitmap_add
ScalableBitmap m_bitmap_decrease
MachineObject * m_obj

Detailed Description

Constructor & Destructor Documentation

◆ FanOperate()

Slic3r::GUI::FanOperate::FanOperate ( wxWindow * parent,
wxWindowID id,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize )
190{
192 m_min_speeds = 1;
193 m_max_speeds = 10;
194 create(parent, id, pos, size);
195 wxGetApp().UpdateDarkUIWin(this);
196}
int m_current_speeds
Definition FanControl.hpp:125
int m_max_speeds
Definition FanControl.hpp:127
int m_min_speeds
Definition FanControl.hpp:126
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
Definition FanControl.cpp:198

References create(), m_current_speeds, m_max_speeds, and m_min_speeds.

Here is the call graph for this function:

◆ ~FanOperate()

Slic3r::GUI::FanOperate::~FanOperate ( )
inline
108{};

Member Function Documentation

◆ add_fan_speeds()

void Slic3r::GUI::FanOperate::add_fan_speeds ( )
255{
256 if (!check_printing_state()) {
257 return;
258 }
259
260 if (m_current_speeds + 1 > m_max_speeds) return;
262 post_event(wxCommandEvent(EVT_FAN_ADD));
263 post_event(wxCommandEvent(EVT_FAN_SWITCH_ON));
264}
void set_fan_speeds(int g)
Definition FanControl.cpp:237
bool check_printing_state()
Definition FanControl.cpp:243
void post_event(wxCommandEvent &&event)
Definition FanControl.cpp:285

References check_printing_state(), m_current_speeds, m_max_speeds, post_event(), and set_fan_speeds().

Referenced by on_left_down().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_printing_state()

bool Slic3r::GUI::FanOperate::check_printing_state ( )
244{
245 if (m_obj && !not_show_fan_speed_warning_dlg && m_obj->is_in_printing()) {
246 MessageDialog msg_wingow(nullptr, _L("Changing fan speed during printing may affect print quality, please choose carefully."), "", wxICON_WARNING | wxCANCEL | wxOK);
247 msg_wingow.SetButtonLabel(wxID_OK, _L("Change Anyway"));
249 return (msg_wingow.ShowModal() == wxID_OK);
250 }
251 return true;
252}
#define _L(s)
Definition OBJ.cpp:34
MachineObject * m_obj
Definition FanControl.hpp:131
static bool not_show_fan_speed_warning_dlg
Definition FanControl.cpp:42

References _L, m_obj, Slic3r::GUI::not_show_fan_speed_warning_dlg, Slic3r::GUI::MsgDialog::SetButtonLabel(), and Slic3r::GUI::DPIAware< P >::ShowModal().

Referenced by add_fan_speeds(), and decrease_fan_speeds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create()

void Slic3r::GUI::FanOperate::create ( wxWindow * parent,
wxWindowID id,
const wxPoint & pos,
const wxSize & size )
199{
200 wxWindow::Create(parent, id, pos, size, wxBORDER_NONE);
201 SetBackgroundColour(*wxWHITE);
202
203 m_bitmap_add = ScalableBitmap(this, "fan_control_add", 24);
204 m_bitmap_decrease = ScalableBitmap(this, "fan_control_decrease", 24);
205
206 SetMinSize(wxSize(FromDIP(SIZE_OF_FAN_OPERATE.x), FromDIP(SIZE_OF_FAN_OPERATE.y)));
207 Bind(wxEVT_PAINT, &FanOperate::paintEvent, this);
208 Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND);});
209 Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_ARROW);});
210 Bind(wxEVT_LEFT_DOWN, &FanOperate::on_left_down, this);
211}
#define SIZE_OF_FAN_OPERATE
Definition FanControl.hpp:39
ScalableBitmap m_bitmap_decrease
Definition FanControl.hpp:129
void on_left_down(wxMouseEvent &event)
Definition FanControl.cpp:213
void paintEvent(wxPaintEvent &evt)
Definition FanControl.cpp:293
ScalableBitmap m_bitmap_add
Definition FanControl.hpp:128

References m_bitmap_add, m_bitmap_decrease, on_left_down(), paintEvent(), and SIZE_OF_FAN_OPERATE.

Referenced by FanOperate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decrease_fan_speeds()

void Slic3r::GUI::FanOperate::decrease_fan_speeds ( )
267{
268 if (!check_printing_state()) {
269 return;
270 }
271
272 //turn off
273 if (m_current_speeds - 1 < m_min_speeds) {
276 post_event(wxCommandEvent(EVT_FAN_SWITCH_OFF));
277 }
278 else {
280 }
281 post_event(wxCommandEvent(EVT_FAN_DEC));
282
283}

References check_printing_state(), m_current_speeds, m_min_speeds, post_event(), and set_fan_speeds().

Referenced by on_left_down().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doRender()

void Slic3r::GUI::FanOperate::doRender ( wxDC & dc)
321{
322 wxSize size = GetSize();
323 dc.SetPen(wxPen(DRAW_OPERATE_LINE_COLOUR));
324 dc.SetBrush(*wxTRANSPARENT_BRUSH);
325 dc.DrawRoundedRectangle(0,0,size.x,size.y,5);
326
327 //splt
328 auto left_fir = size.x / 3;
329
330 dc.DrawBitmap(m_bitmap_decrease.bmp(), 0, (size.y - m_bitmap_decrease.GetBmpHeight()) / 2);
331 dc.DrawBitmap(m_bitmap_add.bmp(), size.x - m_bitmap_add.GetBmpWidth(), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
332
333 wxPoint pot(m_bitmap_decrease.GetBmpWidth(), (size.y - m_bitmap_decrease.GetBmpHeight()) / 2);
334 dc.DrawLine(pot.x, 0, pot.x, size.y);
335 dc.DrawLine(size.x - m_bitmap_add.GetBmpWidth(), 0, size.x - m_bitmap_add.GetBmpWidth(), size.y);
336
337 //txt
338 dc.SetFont(::Label::Body_12);
339 dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#898989")));
340 wxString text = wxString::Format("%d%%", m_current_speeds * 10);
341 wxSize text_size = dc.GetTextExtent(text);
342 auto text_width = size.x - m_bitmap_decrease.GetBmpWidth() * 2;
343 dc.DrawText(text, wxPoint(pot.x + (text_width - text_size.x) / 2, (size.y - text_size.y) / 2));
344}
#define DRAW_OPERATE_LINE_COLOUR
Definition FanControl.hpp:43
static wxFont Body_12
Definition Label.hpp:55
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References Label::Body_12, StateColor::darkModeColorFor(), DRAW_OPERATE_LINE_COLOUR, m_bitmap_add, m_bitmap_decrease, and m_current_speeds.

Referenced by render().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ msw_rescale()

void Slic3r::GUI::FanOperate::msw_rescale ( )
346 {
347 m_bitmap_add.msw_rescale();
348 m_bitmap_decrease.msw_rescale();
349 Refresh();
350}

References m_bitmap_add, and m_bitmap_decrease.

◆ on_left_down()

void Slic3r::GUI::FanOperate::on_left_down ( wxMouseEvent & event)
214{
215 auto mouse_pos = ClientToScreen(event.GetPosition());
216 auto win_pos = ClientToScreen(wxPoint(0, 0));
217
218 auto decrease_fir = FromDIP(24);
219 auto add_fir = GetSize().x - FromDIP(24);
220
221 if (mouse_pos.x > win_pos.x && mouse_pos.x < (decrease_fir + win_pos.x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
223 return;
224 }
225
226 if (mouse_pos.x > (add_fir + win_pos.x) && mouse_pos.x < (win_pos.x + GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
228 return;
229 }
230}
void add_fan_speeds()
Definition FanControl.cpp:254
void decrease_fan_speeds()
Definition FanControl.cpp:266

References add_fan_speeds(), decrease_fan_speeds(), and Slic3r::GUI::wxMouseEvent.

Referenced by create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ paintEvent()

void Slic3r::GUI::FanOperate::paintEvent ( wxPaintEvent & evt)
294{
295 wxPaintDC dc(this);
296 render(dc);
297}
void render(wxDC &dc)
Definition FanControl.cpp:299

References render().

Referenced by create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ post_event()

void Slic3r::GUI::FanOperate::post_event ( wxCommandEvent && event)
286{
287 event.SetInt(m_current_speeds);
288 event.SetEventObject(this);
289 wxPostEvent(this, event);
290 event.Skip();
291}

References m_current_speeds.

Referenced by add_fan_speeds(), and decrease_fan_speeds().

Here is the caller graph for this function:

◆ render()

void Slic3r::GUI::FanOperate::render ( wxDC & dc)
300{
301#ifdef __WXMSW__
302 wxSize size = GetSize();
303 wxMemoryDC memdc;
304 wxBitmap bmp(size.x, size.y);
305 memdc.SelectObject(bmp);
306 memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
307
308 {
309 wxGCDC dc2(memdc);
310 doRender(dc2);
311 }
312
313 memdc.SelectObject(wxNullBitmap);
314 dc.DrawBitmap(bmp, 0, 0);
315#else
316 doRender(dc);
317#endif
318}
void doRender(wxDC &dc)
Definition FanControl.cpp:320

References doRender().

Referenced by paintEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_fan_speeds()

void Slic3r::GUI::FanOperate::set_fan_speeds ( int g)
238{
240 Refresh();
241}

References m_current_speeds.

Referenced by add_fan_speeds(), and decrease_fan_speeds().

Here is the caller graph for this function:

◆ set_machine_obj()

void Slic3r::GUI::FanOperate::set_machine_obj ( MachineObject * obj)
233{
234 m_obj = obj;
235}

References m_obj.

Member Data Documentation

◆ m_bitmap_add

ScalableBitmap Slic3r::GUI::FanOperate::m_bitmap_add
private

Referenced by create(), doRender(), and msw_rescale().

◆ m_bitmap_decrease

ScalableBitmap Slic3r::GUI::FanOperate::m_bitmap_decrease
private

Referenced by create(), doRender(), and msw_rescale().

◆ m_current_speeds

int Slic3r::GUI::FanOperate::m_current_speeds
private

◆ m_max_speeds

int Slic3r::GUI::FanOperate::m_max_speeds
private

Referenced by FanOperate(), and add_fan_speeds().

◆ m_min_speeds

int Slic3r::GUI::FanOperate::m_min_speeds
private

Referenced by FanOperate(), and decrease_fan_speeds().

◆ m_obj

MachineObject* Slic3r::GUI::FanOperate::m_obj
private

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/FanControl.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/FanControl.cpp