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

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

Inheritance diagram for Slic3r::GUI::Fan:
Collaboration diagram for Slic3r::GUI::Fan:

Public Member Functions

 Fan (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 ~Fan ()
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 set_fan_speeds (int g)

Protected Member Functions

virtual void DoSetSize (int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO)

Protected Attributes

std::vector< wxPoint > m_scale_pos_array
ScalableBitmap m_bitmap_bk
ScalableBitmap m_bitmap_scale_0
ScalableBitmap m_bitmap_scale_1
ScalableBitmap m_bitmap_scale_2
ScalableBitmap m_bitmap_scale_3
ScalableBitmap m_bitmap_scale_4
ScalableBitmap m_bitmap_scale_5
ScalableBitmap m_bitmap_scale_6
ScalableBitmap m_bitmap_scale_7
ScalableBitmap m_bitmap_scale_8
ScalableBitmap m_bitmap_scale_9
ScalableBitmap m_bitmap_scale_10
std::vector< ScalableBitmap > m_bitmap_scales
wxImage m_img_pointer

Private Attributes

int m_current_speeds
std::vector< RotateOffSet > m_rotate_offsets

Detailed Description

Constructor & Destructor Documentation

◆ Fan()

Slic3r::GUI::Fan::Fan ( wxWindow * parent,
wxWindowID id,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize )
48{
49 create(parent, id, pos, size);
50}
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
Definition FanControl.cpp:52

References create().

Here is the call graph for this function:

◆ ~Fan()

Slic3r::GUI::Fan::~Fan ( )
inline
65{};

Member Function Documentation

◆ create()

void Slic3r::GUI::Fan::create ( wxWindow * parent,
wxWindowID id,
const wxPoint & pos,
const wxSize & size )
53{
55
56 wxWindow::Create(parent, id, pos, size, wxBORDER_NONE);
57 SetBackgroundColour(*wxWHITE);
58
59 m_rotate_offsets.push_back(RotateOffSet{ 2.5, wxPoint(-FromDIP(16), FromDIP(11)) });
60 m_rotate_offsets.push_back(RotateOffSet{ 2.2, wxPoint(-FromDIP(20), FromDIP(11)) });
61 m_rotate_offsets.push_back(RotateOffSet{ 1.7, wxPoint(-FromDIP(24), FromDIP(12)) });
62 m_rotate_offsets.push_back(RotateOffSet{ 1.2, wxPoint(-FromDIP(22), FromDIP(4)) });
63 m_rotate_offsets.push_back(RotateOffSet{ 0.7, wxPoint(-FromDIP(17), -FromDIP(6)) });
64 m_rotate_offsets.push_back(RotateOffSet{ 0.3, wxPoint(-FromDIP(8), -FromDIP(11)) });
65 m_rotate_offsets.push_back(RotateOffSet{ 6.1, wxPoint(-FromDIP(0), -FromDIP(9)) });
66 m_rotate_offsets.push_back(RotateOffSet{ 5.5, wxPoint(-FromDIP(4), -FromDIP(2)) });
67 m_rotate_offsets.push_back(RotateOffSet{ 5.1, wxPoint(-FromDIP(3), FromDIP(5)) });
68 m_rotate_offsets.push_back(RotateOffSet{ 4.6, wxPoint(-FromDIP(3), FromDIP(14)) });
69 m_rotate_offsets.push_back(RotateOffSet{ 4.0, wxPoint(-FromDIP(2), FromDIP(11)) });
70
71 //auto m_bitmap_pointer = ScalableBitmap(this, "fan_pointer", FromDIP(25));
72 //m_img_pointer = m_bitmap_pointer.bmp().ConvertToImage();
73
74 m_bitmap_bk = ScalableBitmap(this, "fan_dash_bk", 80);
75
76 for (auto i = 0; i <= 10; i++) {
77#ifdef __APPLE__
78 auto m_bitmap_scale = ScalableBitmap(this, wxString::Format("fan_scale_%d", i).ToStdString(), 60);
79 m_bitmap_scales.push_back(m_bitmap_scale);
80#else
81 auto m_bitmap_scale = ScalableBitmap(this, wxString::Format("fan_scale_%d", i).ToStdString(), 46);
82 m_bitmap_scales.push_back(m_bitmap_scale);
83#endif
84 }
85
86//#ifdef __APPLE__
87// SetMinSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
88// SetMaxSize(wxSize(FromDIP(100), FromDIP(100) + FromDIP(6)));
89//#else
90 SetMinSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
91 SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
92//#endif // __APPLE__
93
94 Bind(wxEVT_PAINT, &Fan::paintEvent, this);
95}
void paintEvent(wxPaintEvent &evt)
Definition FanControl.cpp:111
std::vector< ScalableBitmap > m_bitmap_scales
Definition FanControl.hpp:94
int m_current_speeds
Definition FanControl.hpp:75
std::vector< RotateOffSet > m_rotate_offsets
Definition FanControl.hpp:76
ScalableBitmap m_bitmap_bk
Definition FanControl.hpp:81

References m_bitmap_bk, m_bitmap_scales, m_current_speeds, m_rotate_offsets, and paintEvent().

Referenced by Fan().

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

◆ doRender()

void Slic3r::GUI::Fan::doRender ( wxDC & dc)
139{
140 auto rpm = wxT("rpm");
141
142 wxSize size = GetSize();
143 dc.DrawBitmap(m_bitmap_bk.bmp(), wxPoint(0,0));
144
145 //fan scale
146 /*auto central_point = wxPoint(size.x / 2, size.y / 2 + FromDIP(15));
147 dc.DrawBitmap(m_bitmap_scale_0.bmp(), central_point.x - FromDIP(38), central_point.y);
148 dc.DrawBitmap(m_bitmap_scale_1.bmp(), central_point.x - FromDIP(40), central_point.y - FromDIP(17));
149 dc.DrawBitmap(m_bitmap_scale_2.bmp(), central_point.x - FromDIP(40), central_point.y - FromDIP(36));
150 dc.DrawBitmap(m_bitmap_scale_3.bmp(), central_point.x - FromDIP(32), central_point.y - FromDIP(48));
151 dc.DrawBitmap(m_bitmap_scale_4.bmp(), central_point.x - FromDIP(18), central_point.y - FromDIP(53));
152 dc.DrawBitmap(m_bitmap_scale_5.bmp(), central_point.x - FromDIP(0), central_point.y - FromDIP(53));
153 dc.DrawBitmap(m_bitmap_scale_6.bmp(), central_point.x + FromDIP(18), central_point.y - FromDIP(48));
154 dc.DrawBitmap(m_bitmap_scale_7.bmp(), central_point.x + FromDIP(31), central_point.y - FromDIP(36));
155 dc.DrawBitmap(m_bitmap_scale_8.bmp(), central_point.x + FromDIP(36), central_point.y - FromDIP(17));
156 dc.DrawBitmap(m_bitmap_scale_9.bmp(), central_point.x + FromDIP(28), central_point.y);*/
157
158 //fan pointer
159 //auto pointer_central_point = wxPoint((size.x - m_img_pointer.GetSize().x) / 2, (size.y - m_img_pointer.GetSize().y) / 2);
160 //auto bmp = m_img_pointer.Rotate(m_rotate_offsets[m_current_speeds].rotate, wxPoint(size.x / 2,size.y / 2));
161 auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetBmpSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetBmpSize().y) / 2 - FromDIP(4));
162 dc.DrawBitmap(m_bitmap_scales[m_current_speeds].bmp(), central_point.x, central_point.y);
163
164 //fan val
165 dc.SetTextForeground(DRAW_TEXT_COLOUR);
166 dc.SetFont(::Label::Head_13);
167 auto speeds = wxString::Format("%d%%", m_current_speeds * 10);
168 dc.DrawText(speeds, (size.x - dc.GetTextExtent(speeds).x) / 2 + FromDIP(2), size.y - dc.GetTextExtent(speeds).y - FromDIP(5));
169
170 //rpm
171 //dc.SetFont(::Label::Body_13);
172 //dc.DrawText(rpm, (size.x - dc.GetTextExtent(rpm).x) / 2, size.y - dc.GetTextExtent(rpm).y);
173}
#define DRAW_TEXT_COLOUR
Definition FanControl.hpp:41
static wxFont Head_13
Definition Label.hpp:46

References DRAW_TEXT_COLOUR, Label::Head_13, m_bitmap_bk, m_bitmap_scales, and m_current_speeds.

Referenced by render().

Here is the caller graph for this function:

◆ DoSetSize()

void Slic3r::GUI::Fan::DoSetSize ( int x,
int y,
int width,
int height,
int sizeFlags = wxSIZE_AUTO )
protectedvirtual
181{
182 wxWindow::DoSetSize(x, y, width, height, sizeFlags);
183}

◆ msw_rescale()

void Slic3r::GUI::Fan::msw_rescale ( )
176{
177 m_bitmap_bk.msw_rescale();
178}

References m_bitmap_bk.

◆ paintEvent()

void Slic3r::GUI::Fan::paintEvent ( wxPaintEvent & evt)
112{
113 wxPaintDC dc(this);
114 render(dc);
115}
void render(wxDC &dc)
Definition FanControl.cpp:117

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::Fan::post_event ( wxCommandEvent && event)
104{
105 /*event.SetString(m_info.can_id);
106 event.SetEventObject(m_parent);
107 wxPostEvent(m_parent, event);
108 event.Skip();*/
109}

◆ render()

void Slic3r::GUI::Fan::render ( wxDC & dc)
118{
119#ifdef __WXMSW__
120 wxSize size = GetSize();
121 wxMemoryDC memdc;
122 wxBitmap bmp(size.x, size.y);
123 memdc.SelectObject(bmp);
124 memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
125
126 {
127 wxGCDC dc2(memdc);
128 doRender(dc2);
129 }
130
131 memdc.SelectObject(wxNullBitmap);
132 dc.DrawBitmap(bmp, 0, 0);
133#else
134 doRender(dc);
135#endif
136}
void doRender(wxDC &dc)
Definition FanControl.cpp:138

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::Fan::set_fan_speeds ( int g)
98{
100 Refresh();
101}

References m_current_speeds.

Member Data Documentation

◆ m_bitmap_bk

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_bk
protected

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

◆ m_bitmap_scale_0

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_0
protected

◆ m_bitmap_scale_1

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_1
protected

◆ m_bitmap_scale_10

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_10
protected

◆ m_bitmap_scale_2

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_2
protected

◆ m_bitmap_scale_3

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_3
protected

◆ m_bitmap_scale_4

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_4
protected

◆ m_bitmap_scale_5

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_5
protected

◆ m_bitmap_scale_6

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_6
protected

◆ m_bitmap_scale_7

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_7
protected

◆ m_bitmap_scale_8

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_8
protected

◆ m_bitmap_scale_9

ScalableBitmap Slic3r::GUI::Fan::m_bitmap_scale_9
protected

◆ m_bitmap_scales

std::vector<ScalableBitmap> Slic3r::GUI::Fan::m_bitmap_scales
protected

Referenced by create(), and doRender().

◆ m_current_speeds

int Slic3r::GUI::Fan::m_current_speeds
private

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

◆ m_img_pointer

wxImage Slic3r::GUI::Fan::m_img_pointer
protected

◆ m_rotate_offsets

std::vector<RotateOffSet> Slic3r::GUI::Fan::m_rotate_offsets
private

Referenced by create().

◆ m_scale_pos_array

std::vector<wxPoint> Slic3r::GUI::Fan::m_scale_pos_array
protected

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