Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::ProgressStatusBar Class Reference

The ProgressStatusBar class is the widgets occupying the lower area of the Slicer main window. It consists of a message area to the left and a progress indication area to the right with an optional cancel button. More...

#include <src/slic3r/GUI/ProgressStatusBar.hpp>

+ Inheritance diagram for Slic3r::ProgressStatusBar:
+ Collaboration diagram for Slic3r::ProgressStatusBar:

Public Types

using CancelFn = std::function< void()>
 Cancel callback function type.
 

Public Member Functions

 ProgressStatusBar (wxWindow *parent=nullptr, int id=-1)
 
 ~ProgressStatusBar () override
 
int get_progress () const
 
void set_progress (int) override
 
int get_range () const override
 
void set_range (int=100) override
 
void show_progress (bool)
 
void start_busy (int=100)
 
void stop_busy ()
 
bool is_busy () const
 
void set_cancel_callback (CancelFn=CancelFn()) override
 
void reset_cancel_callback ()
 
void run (int rate)
 
void embed (wxFrame *frame=nullptr)
 
void set_status_text (const wxString &txt)
 
void set_status_text (const std::string &txt)
 
void set_status_text (const char *txt) override
 
wxString get_status_text () const
 
void set_font (const wxFont &font)
 
void show_cancel_button ()
 
void hide_cancel_button ()
 
void update_dark_ui ()
 

Private Attributes

wxStatusBar * self
 
wxGauge * m_prog
 
wxButton * m_cancelbutton
 
std::unique_ptr< wxTimer > m_timer
 
bool m_busy = false
 
CancelFn m_cancel_cb
 

Detailed Description

The ProgressStatusBar class is the widgets occupying the lower area of the Slicer main window. It consists of a message area to the left and a progress indication area to the right with an optional cancel button.

Member Typedef Documentation

◆ CancelFn

using Slic3r::ProgressIndicator::CancelFn = std::function<void()>
inherited

Cancel callback function type.

Constructor & Destructor Documentation

◆ ProgressStatusBar()

Slic3r::ProgressStatusBar::ProgressStatusBar ( wxWindow *  parent = nullptr,
int  id = -1 
)
18 : self{new wxStatusBar(parent, id == -1 ? wxID_ANY : id)}
19 , m_prog{new wxGauge(self,
20 wxGA_HORIZONTAL,
21 100,
22 wxDefaultPosition,
23 wxDefaultSize)}
24 , m_cancelbutton{new wxButton(self,
25 -1,
26 _(L("Cancel")),
27 wxDefaultPosition,
28 wxDefaultSize)}
29 , m_timer{new wxTimer(self)}
30{
32 m_prog->Hide();
33 m_cancelbutton->Hide();
34
35 self->SetFieldsCount(3);
36 int w[] = {-1, 150, 155};
37 self->SetStatusWidths(3, w);
38
39 wxSize s = m_cancelbutton->GetTextExtent(m_cancelbutton->GetLabel());
40 self->SetMinHeight(int(2 * self->GetBorderY() + 1.2 * s.GetHeight()));
41
42 self->Bind(wxEVT_TIMER, [this](const wxTimerEvent&) {
43 if (m_prog->IsShown()) m_timer->Stop();
44 if(is_busy()) m_prog->Pulse();
45 });
46
47 self->Bind(wxEVT_SIZE, [this](wxSizeEvent& event){
48 wxRect rect;
49 self->GetFieldRect(1, rect);
50 auto offset = 0;
51 m_cancelbutton->Move(rect.GetX() + offset, rect.GetY() + offset);
52 m_cancelbutton->SetSize(rect.GetWidth() - offset, rect.GetHeight());
53
54 self->GetFieldRect(2, rect);
55 m_prog->Move(rect.GetX() + offset, rect.GetY() + offset);
56 m_prog->SetSize(rect.GetWidth() - offset, rect.GetHeight());
57
58 event.Skip();
59 });
60
61 m_cancelbutton->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) {
62 if (m_cancel_cb)
64 m_cancelbutton->Hide();
65 });
66}
wxStatusBar * self
Definition ProgressStatusBar.hpp:31
wxGauge * m_prog
Definition ProgressStatusBar.hpp:32
wxButton * m_cancelbutton
Definition ProgressStatusBar.hpp:33
bool is_busy() const
Definition ProgressStatusBar.hpp:50
std::unique_ptr< wxTimer > m_timer
Definition ProgressStatusBar.hpp:34
CancelFn m_cancel_cb
Definition ProgressStatusBar.hpp:69
void update_dark_ui()
Definition ProgressStatusBar.cpp:72
#define _(msgid)
Definition getopt.c:87
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, ClipperLib::JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:416
#define L(s)
Definition I18N.hpp:18
#define wxEVT_BUTTON
Definition wxinit.h:18

References is_busy(), m_cancel_cb, m_cancelbutton, m_prog, m_timer, Slic3r::offset(), self, update_dark_ui(), and wxEVT_BUTTON.

+ Here is the call graph for this function:

◆ ~ProgressStatusBar()

Slic3r::ProgressStatusBar::~ProgressStatusBar ( )
override
68 {
69 if(m_timer && m_timer->IsRunning()) m_timer->Stop();
70}

References m_timer.

Member Function Documentation

◆ embed()

void Slic3r::ProgressStatusBar::embed ( wxFrame *  frame = nullptr)
157{
158 if(frame) frame->SetStatusBar(self);
159}

References self.

◆ get_progress()

int Slic3r::ProgressStatusBar::get_progress ( ) const
80{
81 return m_prog ? m_prog->GetValue() : 0;
82}

References m_prog.

◆ get_range()

int Slic3r::ProgressStatusBar::get_range ( ) const
overridevirtual

Implements Slic3r::ProgressIndicator.

101{
102 return m_prog ? m_prog->GetRange() : 0;
103}

References m_prog.

◆ get_status_text()

wxString Slic3r::ProgressStatusBar::get_status_text ( ) const
177{
178 return self->GetStatusText();
179}

References self.

◆ hide_cancel_button()

void Slic3r::ProgressStatusBar::hide_cancel_button ( )
192{
193 if(m_cancelbutton) m_cancelbutton->Hide();
194}

References m_cancelbutton.

◆ is_busy()

bool Slic3r::ProgressStatusBar::is_busy ( ) const
inline
50{ return m_busy; }
bool m_busy
Definition ProgressStatusBar.hpp:68

References m_busy.

Referenced by ProgressStatusBar().

+ Here is the caller graph for this function:

◆ reset_cancel_callback()

void Slic3r::ProgressStatusBar::reset_cancel_callback ( )
inline
void set_cancel_callback(CancelFn=CancelFn()) override
Definition ProgressStatusBar.cpp:141

References set_cancel_callback().

+ Here is the call graph for this function:

◆ run()

void Slic3r::ProgressStatusBar::run ( int  rate)
150{
151 if(m_timer && !m_timer->IsRunning()) {
152 m_timer->Start(rate);
153 }
154}

References m_timer.

◆ set_cancel_callback()

void Slic3r::ProgressStatusBar::set_cancel_callback ( ProgressStatusBar::CancelFn  ccb = CancelFn())
overridevirtual

Implements Slic3r::ProgressIndicator.

141 {
142 m_cancel_cb = ccb;
143 if(m_cancelbutton) {
144 if(ccb) m_cancelbutton->Show();
145 else m_cancelbutton->Hide();
146 }
147}

References m_cancel_cb, and m_cancelbutton.

Referenced by reset_cancel_callback().

+ Here is the caller graph for this function:

◆ set_font()

void Slic3r::ProgressStatusBar::set_font ( const wxFont &  font)
182{
183 self->SetFont(font);
184}

References self.

◆ set_progress()

void Slic3r::ProgressStatusBar::set_progress ( int  val)
overridevirtual

Implements Slic3r::ProgressIndicator.

85{
86 if(!m_prog) return;
87
88 if(!m_prog->IsShown()) show_progress(true);
89 if(val < 0) return;
90
91 if(val == m_prog->GetRange()) {
92 m_prog->SetValue(0);
93 show_progress(false);
94 }
95 else {
96 m_prog->SetValue(val);
97 }
98}
void show_progress(bool)
Definition ProgressStatusBar.cpp:112

References m_prog, and show_progress().

+ Here is the call graph for this function:

◆ set_range()

void Slic3r::ProgressStatusBar::set_range ( int  val = 100)
overridevirtual

Implements Slic3r::ProgressIndicator.

106{
107 if(m_prog && val != m_prog->GetRange()) {
108 m_prog->SetRange(val);
109 }
110}

References m_prog.

◆ set_status_text() [1/3]

void Slic3r::ProgressStatusBar::set_status_text ( const char *  txt)
overridevirtual

Implements Slic3r::ProgressIndicator.

172{
173 this->set_status_text(wxString::FromUTF8(txt));
174}
void set_status_text(const wxString &txt)
Definition ProgressStatusBar.cpp:161

References set_status_text().

+ Here is the call graph for this function:

◆ set_status_text() [2/3]

void Slic3r::ProgressStatusBar::set_status_text ( const std::string &  txt)
167{
168 this->set_status_text(txt.c_str());
169}

References set_status_text().

+ Here is the call graph for this function:

◆ set_status_text() [3/3]

void Slic3r::ProgressStatusBar::set_status_text ( const wxString &  txt)
162{
163 if(self) self->SetStatusText(txt);
164}

References self.

Referenced by set_status_text(), and set_status_text().

+ Here is the caller graph for this function:

◆ show_cancel_button()

void Slic3r::ProgressStatusBar::show_cancel_button ( )
187{
188 if(m_cancelbutton) m_cancelbutton->Show();
189}

References m_cancelbutton.

◆ show_progress()

void Slic3r::ProgressStatusBar::show_progress ( bool  show)
113{
114 if(m_prog) {
115 m_prog->Show(show);
116 m_prog->Pulse();
117 }
118}

References m_prog.

Referenced by set_progress(), start_busy(), and stop_busy().

+ Here is the caller graph for this function:

◆ start_busy()

void Slic3r::ProgressStatusBar::start_busy ( int  rate = 100)
121{
122 if(!m_prog) return;
123
124 m_busy = true;
125 show_progress(true);
126 if (!m_timer->IsRunning()) {
127 m_timer->Start(rate);
128 }
129}

References m_busy, m_prog, m_timer, and show_progress().

+ Here is the call graph for this function:

◆ stop_busy()

void Slic3r::ProgressStatusBar::stop_busy ( )
132{
133 if(!m_timer || !m_prog) return;
134
135 m_timer->Stop();
136 show_progress(false);
137 m_prog->SetValue(0);
138 m_busy = false;
139}

References m_busy, m_prog, m_timer, and show_progress().

+ Here is the call graph for this function:

◆ update_dark_ui()

void Slic3r::ProgressStatusBar::update_dark_ui ( )
73{
74 GUI::wxGetApp().UpdateDarkUI(self);
75 GUI::wxGetApp().UpdateDarkUI(m_prog);
76 GUI::wxGetApp().UpdateDarkUI(m_cancelbutton);
77}

References m_cancelbutton, m_prog, and self.

Referenced by ProgressStatusBar().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_busy

bool Slic3r::ProgressStatusBar::m_busy = false
private

Referenced by is_busy(), start_busy(), and stop_busy().

◆ m_cancel_cb

CancelFn Slic3r::ProgressStatusBar::m_cancel_cb
private

◆ m_cancelbutton

wxButton* Slic3r::ProgressStatusBar::m_cancelbutton
private

◆ m_prog

wxGauge* Slic3r::ProgressStatusBar::m_prog
private

◆ m_timer

std::unique_ptr<wxTimer> Slic3r::ProgressStatusBar::m_timer
private

◆ self

wxStatusBar* Slic3r::ProgressStatusBar::self
private

The documentation for this class was generated from the following files: