OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::ProgressStatusBar Class Referenceabstract

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 </home/runner/work/OrcaSlicer/OrcaSlicer/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 ()
virtual void clear_percent ()=0
virtual void show_error_info (wxString msg, int code, wxString description, wxString extra)=0

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

References _, is_busy(), L, m_cancel_cb, m_cancelbutton, m_prog, m_timer, Slic3r::offset(), self, update_dark_ui(), wxButton, and wxGauge.

Here is the call graph for this function:

◆ ~ProgressStatusBar()

Slic3r::ProgressStatusBar::~ProgressStatusBar ( )
override
72 {
73 if(m_timer && m_timer->IsRunning()) m_timer->Stop();
74}

References m_timer.

Member Function Documentation

◆ clear_percent()

virtual void Slic3r::ProgressIndicator::clear_percent ( )
pure virtualinherited

◆ embed()

void Slic3r::ProgressStatusBar::embed ( wxFrame * frame = nullptr)
161{
162 if(frame) frame->SetStatusBar(self);
163}

References self.

◆ get_progress()

int Slic3r::ProgressStatusBar::get_progress ( ) const
84{
85 return m_prog ? m_prog->GetValue() : 0;
86}

References m_prog.

◆ get_range()

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

Implements Slic3r::ProgressIndicator.

105{
106 return m_prog ? m_prog->GetRange() : 0;
107}

References m_prog.

◆ get_status_text()

wxString Slic3r::ProgressStatusBar::get_status_text ( ) const
181{
182 return self->GetStatusText();
183}

References self.

◆ hide_cancel_button()

void Slic3r::ProgressStatusBar::hide_cancel_button ( )
196{
197 if(m_cancelbutton) m_cancelbutton->Hide();
198}

References m_cancelbutton.

◆ is_busy()

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

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:145

References set_cancel_callback().

Here is the call graph for this function:

◆ run()

void Slic3r::ProgressStatusBar::run ( int rate)
154{
155 if(m_timer && !m_timer->IsRunning()) {
156 m_timer->Start(rate);
157 }
158}

References m_timer.

◆ set_cancel_callback()

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

Implements Slic3r::ProgressIndicator.

145 {
146 m_cancel_cb = ccb;
147 if(m_cancelbutton) {
148 if(ccb) m_cancelbutton->Show();
149 else m_cancelbutton->Hide();
150 }
151}

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)
186{
187 self->SetFont(font);
188}

References self.

◆ set_progress()

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

Implements Slic3r::ProgressIndicator.

89{
90 if(!m_prog) return;
91
92 if(!m_prog->IsShown()) show_progress(true);
93 if(val < 0) return;
94
95 if(val == m_prog->GetRange()) {
96 m_prog->SetValue(0);
97 show_progress(false);
98 }
99 else {
100 m_prog->SetValue(val);
101 }
102}
void show_progress(bool)
Definition ProgressStatusBar.cpp:116

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.

110{
111 if(m_prog && val != m_prog->GetRange()) {
112 m_prog->SetRange(val);
113 }
114}

References m_prog.

◆ set_status_text() [1/3]

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

Implements Slic3r::ProgressIndicator.

176{
177 this->set_status_text(wxString::FromUTF8(txt));
178}
void set_status_text(const wxString &txt)
Definition ProgressStatusBar.cpp:165

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)
171{
172 this->set_status_text(txt.c_str());
173}

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)
166{
167 if(self) self->SetStatusText(txt);
168}

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 ( )
191{
192 if(m_cancelbutton) m_cancelbutton->Show();
193}

References m_cancelbutton.

◆ show_error_info()

virtual void Slic3r::ProgressIndicator::show_error_info ( wxString msg,
int code,
wxString description,
wxString extra )
pure virtualinherited

◆ show_progress()

void Slic3r::ProgressStatusBar::show_progress ( bool show)
117{
118 if(m_prog) {
119 m_prog->Show(show);
120 m_prog->Pulse();
121 }
122}

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)
125{
126 if(!m_prog) return;
127
128 m_busy = true;
129 show_progress(true);
130 if (!m_timer->IsRunning()) {
131 m_timer->Start(rate);
132 }
133}

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 ( )
136{
137 if(!m_timer || !m_prog) return;
138
139 m_timer->Stop();
140 show_progress(false);
141 m_prog->SetValue(0);
142 m_busy = false;
143}

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 ( )
77{
78 GUI::wxGetApp().UpdateDarkUI(self);
79 GUI::wxGetApp().UpdateDarkUI(m_prog);
80 GUI::wxGetApp().UpdateDarkUI(m_cancelbutton);
81}

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

◆ 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: