mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-07-23 01:44:26 +03:00
Refactoring member variable names for my classes to match our coding style.
This commit is contained in:
@@ -30,15 +30,15 @@ public:
|
||||
};
|
||||
|
||||
AppControllerBoilerplate::AppControllerBoilerplate()
|
||||
:pri_data_(new PriData(std::this_thread::get_id())) {}
|
||||
:m_pri_data(new PriData(std::this_thread::get_id())) {}
|
||||
|
||||
AppControllerBoilerplate::~AppControllerBoilerplate() {
|
||||
pri_data_.reset();
|
||||
m_pri_data.reset();
|
||||
}
|
||||
|
||||
bool AppControllerBoilerplate::is_main_thread() const
|
||||
{
|
||||
return pri_data_->ui_thread == std::this_thread::get_id();
|
||||
return m_pri_data->ui_thread == std::this_thread::get_id();
|
||||
}
|
||||
|
||||
namespace GUI {
|
||||
@@ -58,9 +58,9 @@ AppControllerBoilerplate::ProgresIndicatorPtr
|
||||
AppControllerBoilerplate::global_progress_indicator() {
|
||||
ProgresIndicatorPtr ret;
|
||||
|
||||
pri_data_->m.lock();
|
||||
ret = global_progressind_;
|
||||
pri_data_->m.unlock();
|
||||
m_pri_data->m.lock();
|
||||
ret = m_global_progressind;
|
||||
m_pri_data->m.unlock();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -68,9 +68,9 @@ AppControllerBoilerplate::global_progress_indicator() {
|
||||
void AppControllerBoilerplate::global_progress_indicator(
|
||||
AppControllerBoilerplate::ProgresIndicatorPtr gpri)
|
||||
{
|
||||
pri_data_->m.lock();
|
||||
global_progressind_ = gpri;
|
||||
pri_data_->m.unlock();
|
||||
m_pri_data->m.lock();
|
||||
m_global_progressind = gpri;
|
||||
m_pri_data->m.unlock();
|
||||
}
|
||||
|
||||
PrintController::PngExportData
|
||||
@@ -104,11 +104,11 @@ PrintController::query_png_export_data(const DynamicPrintConfig& conf)
|
||||
|
||||
void PrintController::slice(AppControllerBoilerplate::ProgresIndicatorPtr pri)
|
||||
{
|
||||
print_->set_status_callback([pri](int st, const std::string& msg){
|
||||
m_print->set_status_callback([pri](int st, const std::string& msg){
|
||||
pri->update(unsigned(st), msg);
|
||||
});
|
||||
|
||||
print_->process();
|
||||
m_print->process();
|
||||
}
|
||||
|
||||
void PrintController::slice()
|
||||
@@ -156,7 +156,7 @@ void PrintController::slice_to_png()
|
||||
auto exd = query_png_export_data(conf);
|
||||
if(exd.zippath.empty()) return;
|
||||
|
||||
Print *print = print_;
|
||||
Print *print = m_print;
|
||||
|
||||
try {
|
||||
print->apply_config(conf);
|
||||
@@ -252,7 +252,7 @@ void PrintController::slice_to_png()
|
||||
|
||||
const PrintConfig &PrintController::config() const
|
||||
{
|
||||
return print_->config();
|
||||
return m_print->config();
|
||||
}
|
||||
|
||||
void ProgressIndicator::message_fmt(
|
||||
@@ -286,13 +286,13 @@ void AppController::arrange_model()
|
||||
{
|
||||
using Coord = libnest2d::TCoord<libnest2d::PointImpl>;
|
||||
|
||||
if(arranging_.load()) return;
|
||||
if(m_arranging.load()) return;
|
||||
|
||||
// to prevent UI reentrancies
|
||||
arranging_.store(true);
|
||||
m_arranging.store(true);
|
||||
|
||||
unsigned count = 0;
|
||||
for(auto obj : model_->objects) count += obj->instances.size();
|
||||
for(auto obj : m_model->objects) count += obj->instances.size();
|
||||
|
||||
auto pind = global_progress_indicator();
|
||||
|
||||
@@ -305,7 +305,7 @@ void AppController::arrange_model()
|
||||
pind->max(count);
|
||||
|
||||
pind->on_cancel([this](){
|
||||
arranging_.store(false);
|
||||
m_arranging.store(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ void AppController::arrange_model()
|
||||
// TODO: from Sasha from GUI
|
||||
hint.type = arr::BedShapeType::WHO_KNOWS;
|
||||
|
||||
arr::arrange(*model_,
|
||||
arr::arrange(*m_model,
|
||||
min_obj_distance,
|
||||
bed,
|
||||
hint,
|
||||
@@ -336,7 +336,7 @@ void AppController::arrange_model()
|
||||
pind->update(count - rem, L("Arranging objects..."));
|
||||
|
||||
process_events();
|
||||
}, [this] () { return !arranging_.load(); });
|
||||
}, [this] () { return !m_arranging.load(); });
|
||||
} catch(std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
report_issue(IssueType::ERR,
|
||||
@@ -348,13 +348,13 @@ void AppController::arrange_model()
|
||||
// Restore previous max value
|
||||
if(pind) {
|
||||
pind->max(pmax);
|
||||
pind->update(0, arranging_.load() ? L("Arranging done.") :
|
||||
pind->update(0, m_arranging.load() ? L("Arranging done.") :
|
||||
L("Arranging canceled."));
|
||||
|
||||
pind->on_cancel(/*remove cancel function*/);
|
||||
}
|
||||
|
||||
arranging_.store(false);
|
||||
m_arranging.store(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
class PriData; // Some structure to store progress indication data
|
||||
|
||||
// Pimpl data for thread safe progress indication features
|
||||
std::unique_ptr<PriData> pri_data_;
|
||||
std::unique_ptr<PriData> m_pri_data;
|
||||
|
||||
public:
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
* It should display a file chooser dialog in case of a UI application.
|
||||
* @param title Title of a possible query dialog.
|
||||
* @param extensions Recognized file extensions.
|
||||
* @return Returns a list of paths choosed by the user.
|
||||
* @return Returns a list of paths chosen by the user.
|
||||
*/
|
||||
PathList query_destination_paths(
|
||||
const std::string& title,
|
||||
@@ -162,7 +162,7 @@ protected:
|
||||
|
||||
// This is a global progress indicator placeholder. In the Slic3r UI it can
|
||||
// contain the progress indicator on the statusbar.
|
||||
ProgresIndicatorPtr global_progressind_;
|
||||
ProgresIndicatorPtr m_global_progressind;
|
||||
};
|
||||
|
||||
class Zipper {
|
||||
@@ -186,18 +186,10 @@ public:
|
||||
* @brief Implementation of the printing logic.
|
||||
*/
|
||||
class PrintController: public AppControllerBoilerplate {
|
||||
Print *print_ = nullptr;
|
||||
std::function<void()> rempools_;
|
||||
Print *m_print = nullptr;
|
||||
std::function<void()> m_rempools;
|
||||
protected:
|
||||
|
||||
void make_skirt() {}
|
||||
void make_brim() {}
|
||||
void make_wipe_tower() {}
|
||||
|
||||
void make_perimeters(PrintObject *pobj) {}
|
||||
void infill(PrintObject *pobj) {}
|
||||
void gen_support_material(PrintObject *pobj) {}
|
||||
|
||||
// Data structure with the png export input data
|
||||
struct PngExportData {
|
||||
std::string zippath; // output zip file
|
||||
@@ -215,20 +207,14 @@ protected:
|
||||
PngExportData query_png_export_data(const DynamicPrintConfig&);
|
||||
|
||||
// The previous export data, to pre-populate the dialog
|
||||
PngExportData prev_expdata_;
|
||||
|
||||
/**
|
||||
* @brief Slice one pront object.
|
||||
* @param pobj The print object.
|
||||
*/
|
||||
void slice(PrintObject *pobj);
|
||||
PngExportData m_prev_expdata;
|
||||
|
||||
void slice(ProgresIndicatorPtr pri);
|
||||
|
||||
public:
|
||||
|
||||
// Must be public for perl to use it
|
||||
explicit inline PrintController(Print *print): print_(print) {}
|
||||
explicit inline PrintController(Print *print): m_print(print) {}
|
||||
|
||||
PrintController(const PrintController&) = delete;
|
||||
PrintController(PrintController&&) = delete;
|
||||
@@ -256,9 +242,9 @@ public:
|
||||
* @brief Top level controller.
|
||||
*/
|
||||
class AppController: public AppControllerBoilerplate {
|
||||
Model *model_ = nullptr;
|
||||
Model *m_model = nullptr;
|
||||
PrintController::Ptr printctl;
|
||||
std::atomic<bool> arranging_;
|
||||
std::atomic<bool> m_arranging;
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -275,7 +261,7 @@ public:
|
||||
* @param model A raw pointer to the model object. This can be used from
|
||||
* perl.
|
||||
*/
|
||||
void set_model(Model *model) { model_ = model; }
|
||||
void set_model(Model *model) { m_model = model; }
|
||||
|
||||
/**
|
||||
* @brief Set the print object from perl.
|
||||
|
||||
@@ -103,18 +103,18 @@ bool AppControllerBoilerplate::report_issue(
|
||||
wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent);
|
||||
|
||||
struct Zipper::Impl {
|
||||
wxFileName m_fpath;
|
||||
wxFFileOutputStream m_zipfile;
|
||||
wxZipOutputStream m_zipstream;
|
||||
wxStdOutputStream m_pngstream;
|
||||
wxFileName fpath;
|
||||
wxFFileOutputStream zipfile;
|
||||
wxZipOutputStream zipstream;
|
||||
wxStdOutputStream pngstream;
|
||||
|
||||
Impl(const std::string& zipfile_path):
|
||||
m_fpath(zipfile_path),
|
||||
m_zipfile(zipfile_path),
|
||||
m_zipstream(m_zipfile),
|
||||
m_pngstream(m_zipstream)
|
||||
fpath(zipfile_path),
|
||||
zipfile(zipfile_path),
|
||||
zipstream(zipfile),
|
||||
pngstream(zipstream)
|
||||
{
|
||||
if(!m_zipfile.IsOk())
|
||||
if(!zipfile.IsOk())
|
||||
throw std::runtime_error(L("Cannot create zip file."));
|
||||
}
|
||||
};
|
||||
@@ -128,23 +128,23 @@ Zipper::~Zipper() {}
|
||||
|
||||
void Zipper::next_entry(const std::string &fname)
|
||||
{
|
||||
m_impl->m_zipstream.PutNextEntry(fname);
|
||||
m_impl->zipstream.PutNextEntry(fname);
|
||||
}
|
||||
|
||||
std::string Zipper::get_name() const
|
||||
{
|
||||
return m_impl->m_fpath.GetName().ToStdString();
|
||||
return m_impl->fpath.GetName().ToStdString();
|
||||
}
|
||||
|
||||
std::ostream &Zipper::stream()
|
||||
{
|
||||
return m_impl->m_pngstream;
|
||||
return m_impl->pngstream;
|
||||
}
|
||||
|
||||
void Zipper::close()
|
||||
{
|
||||
m_impl->m_zipstream.Close();
|
||||
m_impl->m_zipfile.Close();
|
||||
m_impl->zipstream.Close();
|
||||
m_impl->zipfile.Close();
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -156,26 +156,26 @@ namespace {
|
||||
class GuiProgressIndicator:
|
||||
public ProgressIndicator, public wxEvtHandler {
|
||||
|
||||
wxProgressDialog gauge_;
|
||||
wxProgressDialog m_gauge;
|
||||
using Base = ProgressIndicator;
|
||||
wxString message_;
|
||||
int range_; wxString title_;
|
||||
bool is_asynch_ = false;
|
||||
wxString m_message;
|
||||
int m_range; wxString m_title;
|
||||
bool m_is_asynch = false;
|
||||
|
||||
const int id_ = wxWindow::NewControlId();
|
||||
const int m_id = wxWindow::NewControlId();
|
||||
|
||||
// status update handler
|
||||
void _state( wxCommandEvent& evt) {
|
||||
unsigned st = evt.GetInt();
|
||||
message_ = evt.GetString();
|
||||
m_message = evt.GetString();
|
||||
_state(st);
|
||||
}
|
||||
|
||||
// Status update implementation
|
||||
void _state( unsigned st) {
|
||||
if(!gauge_.IsShown()) gauge_.ShowModal();
|
||||
if(!m_gauge.IsShown()) m_gauge.ShowModal();
|
||||
Base::state(st);
|
||||
if(!gauge_.Update(static_cast<int>(st), message_)) {
|
||||
if(!m_gauge.Update(static_cast<int>(st), m_message)) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
@@ -183,25 +183,25 @@ class GuiProgressIndicator:
|
||||
public:
|
||||
|
||||
/// Setting whether it will be used from the UI thread or some worker thread
|
||||
inline void asynch(bool is) { is_asynch_ = is; }
|
||||
inline void asynch(bool is) { m_is_asynch = is; }
|
||||
|
||||
/// Get the mode of parallel operation.
|
||||
inline bool asynch() const { return is_asynch_; }
|
||||
inline bool asynch() const { return m_is_asynch; }
|
||||
|
||||
inline GuiProgressIndicator(int range, const wxString& title,
|
||||
const wxString& firstmsg) :
|
||||
gauge_(title, firstmsg, range, wxTheApp->GetTopWindow(),
|
||||
m_gauge(title, firstmsg, range, wxTheApp->GetTopWindow(),
|
||||
wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_CAN_ABORT),
|
||||
|
||||
message_(firstmsg),
|
||||
range_(range), title_(title)
|
||||
m_message(firstmsg),
|
||||
m_range(range), m_title(title)
|
||||
{
|
||||
Base::max(static_cast<float>(range));
|
||||
Base::states(static_cast<unsigned>(range));
|
||||
|
||||
Bind(PROGRESS_STATUS_UPDATE_EVENT,
|
||||
&GuiProgressIndicator::_state,
|
||||
this, id_);
|
||||
this, m_id);
|
||||
}
|
||||
|
||||
virtual void state(float val) override {
|
||||
@@ -210,27 +210,27 @@ public:
|
||||
|
||||
void state(unsigned st) {
|
||||
// send status update event
|
||||
if(is_asynch_) {
|
||||
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_);
|
||||
if(m_is_asynch) {
|
||||
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, m_id);
|
||||
evt->SetInt(st);
|
||||
evt->SetString(message_);
|
||||
evt->SetString(m_message);
|
||||
wxQueueEvent(this, evt);
|
||||
} else _state(st);
|
||||
}
|
||||
|
||||
virtual void message(const std::string & msg) override {
|
||||
message_ = _(msg);
|
||||
m_message = _(msg);
|
||||
}
|
||||
|
||||
virtual void messageFmt(const std::string& fmt, ...) {
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
message_ = wxString::Format(_(fmt), arglist);
|
||||
m_message = wxString::Format(_(fmt), arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
virtual void title(const std::string & title) override {
|
||||
title_ = _(title);
|
||||
m_title = _(title);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -261,20 +261,20 @@ AppControllerBoilerplate::create_progress_indicator(
|
||||
namespace {
|
||||
|
||||
class Wrapper: public ProgressIndicator, public wxEvtHandler {
|
||||
ProgressStatusBar *sbar_;
|
||||
ProgressStatusBar *m_sbar;
|
||||
using Base = ProgressIndicator;
|
||||
wxString message_;
|
||||
AppControllerBoilerplate& ctl_;
|
||||
wxString m_message;
|
||||
AppControllerBoilerplate& m_ctl;
|
||||
|
||||
void showProgress(bool show = true) {
|
||||
sbar_->show_progress(show);
|
||||
m_sbar->show_progress(show);
|
||||
}
|
||||
|
||||
void _state(unsigned st) {
|
||||
if( st <= ProgressIndicator::max() ) {
|
||||
Base::state(st);
|
||||
sbar_->set_status_text(message_);
|
||||
sbar_->set_progress(st);
|
||||
m_sbar->set_status_text(m_message);
|
||||
m_sbar->set_progress(st);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,10 +289,10 @@ public:
|
||||
|
||||
inline Wrapper(ProgressStatusBar *sbar,
|
||||
AppControllerBoilerplate& ctl):
|
||||
sbar_(sbar), ctl_(ctl)
|
||||
m_sbar(sbar), m_ctl(ctl)
|
||||
{
|
||||
Base::max(static_cast<float>(sbar_->get_range()));
|
||||
Base::states(static_cast<unsigned>(sbar_->get_range()));
|
||||
Base::max(static_cast<float>(m_sbar->get_range()));
|
||||
Base::states(static_cast<unsigned>(m_sbar->get_range()));
|
||||
|
||||
Bind(PROGRESS_STATUS_UPDATE_EVENT,
|
||||
&Wrapper::_state,
|
||||
@@ -305,13 +305,13 @@ public:
|
||||
|
||||
virtual void max(float val) override {
|
||||
if(val > 1.0) {
|
||||
sbar_->set_range(static_cast<int>(val));
|
||||
m_sbar->set_range(static_cast<int>(val));
|
||||
ProgressIndicator::max(val);
|
||||
}
|
||||
}
|
||||
|
||||
void state(unsigned st) {
|
||||
if(!ctl_.is_main_thread()) {
|
||||
if(!m_ctl.is_main_thread()) {
|
||||
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_);
|
||||
evt->SetInt(st);
|
||||
wxQueueEvent(this, evt);
|
||||
@@ -321,20 +321,20 @@ public:
|
||||
}
|
||||
|
||||
virtual void message(const std::string & msg) override {
|
||||
message_ = _(msg);
|
||||
m_message = _(msg);
|
||||
}
|
||||
|
||||
virtual void message_fmt(const std::string& fmt, ...) override {
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
message_ = wxString::Format(_(fmt), arglist);
|
||||
m_message = wxString::Format(_(fmt), arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
virtual void title(const std::string & /*title*/) override {}
|
||||
|
||||
virtual void on_cancel(CancelFn fn) override {
|
||||
sbar_->set_cancel_callback(fn);
|
||||
m_sbar->set_cancel_callback(fn);
|
||||
Base::on_cancel(fn);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,31 +14,31 @@ public:
|
||||
using CancelFn = std::function<void(void)>; // Cancel function signature.
|
||||
|
||||
private:
|
||||
float state_ = .0f, max_ = 1.f, step_;
|
||||
CancelFn cancelfunc_ = [](){};
|
||||
float m_state = .0f, m_max = 1.f, m_step;
|
||||
CancelFn m_cancelfunc = [](){};
|
||||
|
||||
public:
|
||||
|
||||
inline virtual ~ProgressIndicator() {}
|
||||
|
||||
/// Get the maximum of the progress range.
|
||||
float max() const { return max_; }
|
||||
float max() const { return m_max; }
|
||||
|
||||
/// Get the current progress state
|
||||
float state() const { return state_; }
|
||||
float state() const { return m_state; }
|
||||
|
||||
/// Set the maximum of the progress range
|
||||
virtual void max(float maxval) { max_ = maxval; }
|
||||
virtual void max(float maxval) { m_max = maxval; }
|
||||
|
||||
/// Set the current state of the progress.
|
||||
virtual void state(float val) { state_ = val; }
|
||||
virtual void state(float val) { m_state = val; }
|
||||
|
||||
/**
|
||||
* @brief Number of states int the progress. Can be used instead of giving a
|
||||
* maximum value.
|
||||
*/
|
||||
virtual void states(unsigned statenum) {
|
||||
step_ = max_ / statenum;
|
||||
m_step = m_max / statenum;
|
||||
}
|
||||
|
||||
/// Message shown on the next status update.
|
||||
@@ -51,13 +51,13 @@ public:
|
||||
virtual void message_fmt(const std::string& fmt, ...);
|
||||
|
||||
/// Set up a cancel callback for the operation if feasible.
|
||||
virtual void on_cancel(CancelFn func = CancelFn()) { cancelfunc_ = func; }
|
||||
virtual void on_cancel(CancelFn func = CancelFn()) { m_cancelfunc = func; }
|
||||
|
||||
/**
|
||||
* Explicitly shut down the progress indicator and call the associated
|
||||
* callback.
|
||||
*/
|
||||
virtual void cancel() { cancelfunc_(); }
|
||||
virtual void cancel() { m_cancelfunc(); }
|
||||
|
||||
/// Convenience function to call message and status update in one function.
|
||||
void update(float st, const std::string& msg) {
|
||||
|
||||
@@ -14,117 +14,117 @@ namespace Slic3r {
|
||||
ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id):
|
||||
self(new wxStatusBar(parent ? parent : GUI::get_main_frame(),
|
||||
id == -1? wxID_ANY : id)),
|
||||
timer_(new wxTimer(self)),
|
||||
prog_ (new wxGauge(self,
|
||||
m_timer(new wxTimer(self)),
|
||||
m_prog (new wxGauge(self,
|
||||
wxGA_HORIZONTAL,
|
||||
100,
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize)),
|
||||
cancelbutton_(new wxButton(self,
|
||||
m_cancelbutton(new wxButton(self,
|
||||
-1,
|
||||
"Cancel",
|
||||
wxDefaultPosition,
|
||||
wxDefaultSize))
|
||||
{
|
||||
prog_->Hide();
|
||||
cancelbutton_->Hide();
|
||||
m_prog->Hide();
|
||||
m_cancelbutton->Hide();
|
||||
|
||||
self->SetFieldsCount(3);
|
||||
int w[] = {-1, 150, 155};
|
||||
self->SetStatusWidths(3, w);
|
||||
|
||||
self->Bind(wxEVT_TIMER, [this](const wxTimerEvent&) {
|
||||
if (prog_->IsShown()) timer_->Stop();
|
||||
if(is_busy()) prog_->Pulse();
|
||||
if (m_prog->IsShown()) m_timer->Stop();
|
||||
if(is_busy()) m_prog->Pulse();
|
||||
});
|
||||
|
||||
self->Bind(wxEVT_SIZE, [this](wxSizeEvent& event){
|
||||
wxRect rect;
|
||||
self->GetFieldRect(1, rect);
|
||||
auto offset = 0;
|
||||
cancelbutton_->Move(rect.GetX() + offset, rect.GetY() + offset);
|
||||
cancelbutton_->SetSize(rect.GetWidth() - offset, rect.GetHeight());
|
||||
m_cancelbutton->Move(rect.GetX() + offset, rect.GetY() + offset);
|
||||
m_cancelbutton->SetSize(rect.GetWidth() - offset, rect.GetHeight());
|
||||
|
||||
self->GetFieldRect(2, rect);
|
||||
prog_->Move(rect.GetX() + offset, rect.GetY() + offset);
|
||||
prog_->SetSize(rect.GetWidth() - offset, rect.GetHeight());
|
||||
m_prog->Move(rect.GetX() + offset, rect.GetY() + offset);
|
||||
m_prog->SetSize(rect.GetWidth() - offset, rect.GetHeight());
|
||||
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
cancelbutton_->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) {
|
||||
if(cancel_cb_) cancel_cb_();
|
||||
m_cancelbutton->Bind(wxEVT_BUTTON, [this](const wxCommandEvent&) {
|
||||
if(m_cancel_cb) m_cancel_cb();
|
||||
m_perl_cancel_callback.call();
|
||||
cancelbutton_->Hide();
|
||||
m_cancelbutton->Hide();
|
||||
});
|
||||
}
|
||||
|
||||
ProgressStatusBar::~ProgressStatusBar() {
|
||||
if(timer_->IsRunning()) timer_->Stop();
|
||||
if(m_timer->IsRunning()) m_timer->Stop();
|
||||
}
|
||||
|
||||
int ProgressStatusBar::get_progress() const
|
||||
{
|
||||
return prog_->GetValue();
|
||||
return m_prog->GetValue();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::set_progress(int val)
|
||||
{
|
||||
if(!prog_->IsShown()) show_progress(true);
|
||||
if(!m_prog->IsShown()) show_progress(true);
|
||||
|
||||
if(val == prog_->GetRange()) {
|
||||
prog_->SetValue(0);
|
||||
if(val == m_prog->GetRange()) {
|
||||
m_prog->SetValue(0);
|
||||
show_progress(false);
|
||||
} else {
|
||||
prog_->SetValue(val);
|
||||
m_prog->SetValue(val);
|
||||
}
|
||||
}
|
||||
|
||||
int ProgressStatusBar::get_range() const
|
||||
{
|
||||
return prog_->GetRange();
|
||||
return m_prog->GetRange();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::set_range(int val)
|
||||
{
|
||||
if(val != prog_->GetRange()) {
|
||||
prog_->SetRange(val);
|
||||
if(val != m_prog->GetRange()) {
|
||||
m_prog->SetRange(val);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressStatusBar::show_progress(bool show)
|
||||
{
|
||||
prog_->Show(show);
|
||||
prog_->Pulse();
|
||||
m_prog->Show(show);
|
||||
m_prog->Pulse();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::start_busy(int rate)
|
||||
{
|
||||
busy_ = true;
|
||||
m_busy = true;
|
||||
show_progress(true);
|
||||
if (!timer_->IsRunning()) {
|
||||
timer_->Start(rate);
|
||||
if (!m_timer->IsRunning()) {
|
||||
m_timer->Start(rate);
|
||||
}
|
||||
}
|
||||
|
||||
void ProgressStatusBar::stop_busy()
|
||||
{
|
||||
timer_->Stop();
|
||||
m_timer->Stop();
|
||||
show_progress(false);
|
||||
prog_->SetValue(0);
|
||||
busy_ = false;
|
||||
m_prog->SetValue(0);
|
||||
m_busy = false;
|
||||
}
|
||||
|
||||
void ProgressStatusBar::set_cancel_callback(ProgressStatusBar::CancelFn ccb) {
|
||||
cancel_cb_ = ccb;
|
||||
if(ccb) cancelbutton_->Show();
|
||||
else cancelbutton_->Hide();
|
||||
m_cancel_cb = ccb;
|
||||
if(ccb) m_cancelbutton->Show();
|
||||
else m_cancelbutton->Hide();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::run(int rate)
|
||||
{
|
||||
if(!timer_->IsRunning()) {
|
||||
timer_->Start(rate);
|
||||
if(!m_timer->IsRunning()) {
|
||||
m_timer->Start(rate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,12 +141,12 @@ void ProgressStatusBar::set_status_text(const wxString& txt)
|
||||
|
||||
void ProgressStatusBar::show_cancel_button()
|
||||
{
|
||||
cancelbutton_->Show();
|
||||
m_cancelbutton->Show();
|
||||
}
|
||||
|
||||
void ProgressStatusBar::hide_cancel_button()
|
||||
{
|
||||
cancelbutton_->Hide();
|
||||
m_cancelbutton->Hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace Slic3r {
|
||||
*/
|
||||
class ProgressStatusBar {
|
||||
wxStatusBar *self; // we cheat! It should be the base class but: perl!
|
||||
wxTimer *timer_;
|
||||
wxGauge *prog_;
|
||||
wxButton *cancelbutton_;
|
||||
wxTimer *m_timer;
|
||||
wxGauge *m_prog;
|
||||
wxButton *m_cancelbutton;
|
||||
public:
|
||||
|
||||
/// Cancel callback function type
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
void show_progress(bool);
|
||||
void start_busy(int = 100);
|
||||
void stop_busy();
|
||||
inline bool is_busy() const { return busy_; }
|
||||
inline bool is_busy() const { return m_busy; }
|
||||
void set_cancel_callback(CancelFn = CancelFn());
|
||||
inline void remove_cancel_callback() { set_cancel_callback(); }
|
||||
void run(int rate);
|
||||
@@ -55,8 +55,8 @@ public:
|
||||
|
||||
PerlCallback m_perl_cancel_callback;
|
||||
private:
|
||||
bool busy_ = false;
|
||||
CancelFn cancel_cb_;
|
||||
bool m_busy = false;
|
||||
CancelFn m_cancel_cb;
|
||||
};
|
||||
|
||||
namespace GUI {
|
||||
|
||||
Reference in New Issue
Block a user