Localization for app controller.
This commit is contained in:
parent
ddb4945586
commit
27b0926c19
6 changed files with 134 additions and 111 deletions
|
@ -262,6 +262,7 @@ add_library(libslic3r_gui STATIC
|
||||||
${LIBDIR}/slic3r/AppController.hpp
|
${LIBDIR}/slic3r/AppController.hpp
|
||||||
${LIBDIR}/slic3r/AppController.cpp
|
${LIBDIR}/slic3r/AppController.cpp
|
||||||
${LIBDIR}/slic3r/AppControllerWx.cpp
|
${LIBDIR}/slic3r/AppControllerWx.cpp
|
||||||
|
${LIBDIR}/slic3r/Strings.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(admesh STATIC
|
add_library(admesh STATIC
|
||||||
|
|
|
@ -60,18 +60,23 @@ void AppControllerBoilerplate::progress_indicator(
|
||||||
progressind_->m.unlock();
|
progressind_->m.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
void AppControllerBoilerplate::progress_indicator(unsigned statenum,
|
||||||
AppControllerBoilerplate::progress_indicator(
|
const string &title,
|
||||||
unsigned statenum,
|
const string &firstmsg)
|
||||||
const std::string &title,
|
|
||||||
const std::string &firstmsg)
|
|
||||||
{
|
{
|
||||||
progressind_->m.lock();
|
progressind_->m.lock();
|
||||||
auto ret = progressind_->store[std::this_thread::get_id()] =
|
progressind_->store[std::this_thread::get_id()] =
|
||||||
create_progress_indicator(statenum, title, firstmsg);;
|
create_progress_indicator(statenum, title, firstmsg);
|
||||||
progressind_->m.unlock();
|
progressind_->m.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
void AppControllerBoilerplate::progress_indicator(unsigned statenum,
|
||||||
|
const string &title)
|
||||||
|
{
|
||||||
|
progressind_->m.lock();
|
||||||
|
progressind_->store[std::this_thread::get_id()] =
|
||||||
|
create_progress_indicator(statenum, title);
|
||||||
|
progressind_->m.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||||
|
@ -177,8 +182,8 @@ void PrintController::slice(PrintObject *pobj)
|
||||||
|
|
||||||
if(pobj->layers.empty())
|
if(pobj->layers.empty())
|
||||||
report_issue(IssueType::ERR,
|
report_issue(IssueType::ERR,
|
||||||
"No layers were detected. You might want to repair your "
|
_(L("No layers were detected. You might want to repair your "
|
||||||
"STL file(s) or check their size or thickness and retry"
|
"STL file(s) or check their size or thickness and retry"))
|
||||||
);
|
);
|
||||||
|
|
||||||
pobj->state.set_done(STEP_SLICE);
|
pobj->state.set_done(STEP_SLICE);
|
||||||
|
@ -235,50 +240,51 @@ void PrintController::gen_support_material(PrintObject *pobj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintController::slice()
|
void PrintController::slice(AppControllerBoilerplate::ProgresIndicatorPtr pri)
|
||||||
{
|
{
|
||||||
|
auto st = pri->state();
|
||||||
|
|
||||||
Slic3r::trace(3, "Starting the slicing process.");
|
Slic3r::trace(3, "Starting the slicing process.");
|
||||||
|
|
||||||
progress_indicator()->update(20u, "Generating perimeters");
|
pri->update(st+20, _(L("Generating perimeters")));
|
||||||
for(auto obj : print_->objects) make_perimeters(obj);
|
for(auto obj : print_->objects) make_perimeters(obj);
|
||||||
|
|
||||||
progress_indicator()->update(60u, "Infilling layers");
|
pri->update(st+60, _(L("Infilling layers")));
|
||||||
for(auto obj : print_->objects) infill(obj);
|
for(auto obj : print_->objects) infill(obj);
|
||||||
|
|
||||||
progress_indicator()->update(70u, "Generating support material");
|
pri->update(st+70, _(L("Generating support material")));
|
||||||
for(auto obj : print_->objects) gen_support_material(obj);
|
for(auto obj : print_->objects) gen_support_material(obj);
|
||||||
|
|
||||||
progress_indicator()->message_fmt("Weight: %.1fg, Cost: %.1f",
|
pri->message_fmt(_(L("Weight: %.1fg, Cost: %.1f")),
|
||||||
print_->total_weight,
|
print_->total_weight, print_->total_cost);
|
||||||
print_->total_cost);
|
pri->state(st+85);
|
||||||
|
|
||||||
progress_indicator()->state(85u);
|
|
||||||
|
|
||||||
|
|
||||||
progress_indicator()->update(88u, "Generating skirt");
|
pri->update(st+88, _(L("Generating skirt")));
|
||||||
make_skirt();
|
make_skirt();
|
||||||
|
|
||||||
|
|
||||||
progress_indicator()->update(90u, "Generating brim");
|
pri->update(st+90, _(L("Generating brim")));
|
||||||
make_brim();
|
make_brim();
|
||||||
|
|
||||||
progress_indicator()->update(95u, "Generating wipe tower");
|
pri->update(st+95, _(L("Generating wipe tower")));
|
||||||
make_wipe_tower();
|
make_wipe_tower();
|
||||||
|
|
||||||
progress_indicator()->update(100u, "Done");
|
pri->update(st+100, _(L("Done")));
|
||||||
|
|
||||||
// time to make some statistics..
|
// time to make some statistics..
|
||||||
|
|
||||||
Slic3r::trace(3, "Slicing process finished.");
|
Slic3r::trace(3, _(L("Slicing process finished.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
const PrintConfig &PrintController::config() const
|
void PrintController::slice()
|
||||||
{
|
{
|
||||||
return print_->config;
|
auto pri = progress_indicator();
|
||||||
|
slice(pri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IProgressIndicator::message_fmt(
|
void IProgressIndicator::message_fmt(
|
||||||
const std::string &fmtstr, ...) {
|
const string &fmtstr, ...) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmtstr);
|
va_start(args, fmtstr);
|
||||||
|
@ -304,6 +310,11 @@ void IProgressIndicator::message_fmt(
|
||||||
message(ss.str());
|
message(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PrintConfig &PrintController::config() const
|
||||||
|
{
|
||||||
|
return print_->config;
|
||||||
|
}
|
||||||
|
|
||||||
void AppController::arrange_model()
|
void AppController::arrange_model()
|
||||||
{
|
{
|
||||||
auto ftr = std::async(
|
auto ftr = std::async(
|
||||||
|
@ -329,24 +340,24 @@ void AppController::arrange_model()
|
||||||
|
|
||||||
BoundingBoxf bb(print_ctl()->config().bed_shape.values);
|
BoundingBoxf bb(print_ctl()->config().bed_shape.values);
|
||||||
|
|
||||||
if(pind) pind->update(0, "Arranging objects...");
|
if(pind) pind->update(0, _(L("Arranging objects...")));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
model_->arrange_objects(dist, &bb, [pind, count](unsigned rem){
|
model_->arrange_objects(dist, &bb, [pind, count](unsigned rem){
|
||||||
if(pind) pind->update(count - rem, "Arranging objects...");
|
if(pind) pind->update(count - rem, _(L("Arranging objects...")));
|
||||||
});
|
});
|
||||||
} catch(std::exception& e) {
|
} catch(std::exception& e) {
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
report_issue(IssueType::ERR,
|
report_issue(IssueType::ERR,
|
||||||
"Could not arrange model objects! "
|
_(L("Could not arrange model objects! "
|
||||||
"Some geometries may be invalid.",
|
"Some geometries may be invalid.")),
|
||||||
"Exception occurred");
|
_(L("Exception occurred")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore previous max value
|
// Restore previous max value
|
||||||
if(pind) {
|
if(pind) {
|
||||||
pind->max(pmax);
|
pind->max(pmax);
|
||||||
pind->update(0, "Arranging done.");
|
pind->update(0, _(L("Arranging done.")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Print;
|
||||||
class PrintObject;
|
class PrintObject;
|
||||||
class PrintConfig;
|
class PrintConfig;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A boilerplate class for creating application logic. It should provide
|
* @brief A boilerplate class for creating application logic. It should provide
|
||||||
* features as issue reporting and progress indication, etc...
|
* features as issue reporting and progress indication, etc...
|
||||||
|
@ -45,7 +46,7 @@ public:
|
||||||
AppControllerBoilerplate();
|
AppControllerBoilerplate();
|
||||||
~AppControllerBoilerplate();
|
~AppControllerBoilerplate();
|
||||||
|
|
||||||
using Path = std::string;
|
using Path = string;
|
||||||
using PathList = std::vector<Path>;
|
using PathList = std::vector<Path>;
|
||||||
|
|
||||||
/// Common runtime issue types
|
/// Common runtime issue types
|
||||||
|
@ -66,20 +67,20 @@ public:
|
||||||
* @return Returns a list of paths choosed by the user.
|
* @return Returns a list of paths choosed by the user.
|
||||||
*/
|
*/
|
||||||
PathList query_destination_paths(
|
PathList query_destination_paths(
|
||||||
const std::string& title,
|
const string& title,
|
||||||
const std::string& extensions) const;
|
const std::string& extensions) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Same as query_destination_paths but works for directories only.
|
* @brief Same as query_destination_paths but works for directories only.
|
||||||
*/
|
*/
|
||||||
PathList query_destination_dirs(
|
PathList query_destination_dirs(
|
||||||
const std::string& title) const;
|
const string& title) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Same as query_destination_paths but returns only one path.
|
* @brief Same as query_destination_paths but returns only one path.
|
||||||
*/
|
*/
|
||||||
Path query_destination_path(
|
Path query_destination_path(
|
||||||
const std::string& title,
|
const string& title,
|
||||||
const std::string& extensions,
|
const std::string& extensions,
|
||||||
const std::string& hint = "") const;
|
const std::string& hint = "") const;
|
||||||
|
|
||||||
|
@ -94,8 +95,11 @@ public:
|
||||||
* title.
|
* title.
|
||||||
*/
|
*/
|
||||||
bool report_issue(IssueType issuetype,
|
bool report_issue(IssueType issuetype,
|
||||||
const std::string& description,
|
const string& description,
|
||||||
const std::string& brief = "");
|
const string& brief);
|
||||||
|
|
||||||
|
bool report_issue(IssueType issuetype,
|
||||||
|
const string& description);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set up a progress indicator for the current thread.
|
* @brief Set up a progress indicator for the current thread.
|
||||||
|
@ -109,9 +113,12 @@ public:
|
||||||
* @param title The title of the procedure.
|
* @param title The title of the procedure.
|
||||||
* @param firstmsg The message for the first subtask to be displayed.
|
* @param firstmsg The message for the first subtask to be displayed.
|
||||||
*/
|
*/
|
||||||
ProgresIndicatorPtr progress_indicator(unsigned statenum,
|
void progress_indicator(unsigned statenum,
|
||||||
const std::string& title,
|
const string& title,
|
||||||
const std::string& firstmsg = "");
|
const string& firstmsg);
|
||||||
|
|
||||||
|
void progress_indicator(unsigned statenum,
|
||||||
|
const string& title);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Return the progress indicator set up for the current thread. This
|
* @brief Return the progress indicator set up for the current thread. This
|
||||||
|
@ -161,8 +168,12 @@ protected:
|
||||||
*/
|
*/
|
||||||
ProgresIndicatorPtr create_progress_indicator(
|
ProgresIndicatorPtr create_progress_indicator(
|
||||||
unsigned statenum,
|
unsigned statenum,
|
||||||
const std::string& title,
|
const string& title,
|
||||||
const std::string& firstmsg = "") const;
|
const string& firstmsg) const;
|
||||||
|
|
||||||
|
ProgresIndicatorPtr create_progress_indicator(
|
||||||
|
unsigned statenum,
|
||||||
|
const string& title) const;
|
||||||
|
|
||||||
// This is a global progress indicator placeholder. In the Slic3r UI it can
|
// This is a global progress indicator placeholder. In the Slic3r UI it can
|
||||||
// contain the progress indicator on the statusbar.
|
// contain the progress indicator on the statusbar.
|
||||||
|
@ -184,6 +195,14 @@ protected:
|
||||||
void infill(PrintObject *pobj);
|
void infill(PrintObject *pobj);
|
||||||
void gen_support_material(PrintObject *pobj);
|
void gen_support_material(PrintObject *pobj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Slice one pront object.
|
||||||
|
* @param pobj The print object.
|
||||||
|
*/
|
||||||
|
void slice(PrintObject *pobj);
|
||||||
|
|
||||||
|
void slice(ProgresIndicatorPtr pri);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Must be public for perl to use it
|
// Must be public for perl to use it
|
||||||
|
@ -198,12 +217,6 @@ public:
|
||||||
return PrintController::Ptr( new PrintController(print) );
|
return PrintController::Ptr( new PrintController(print) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Slice one pront object.
|
|
||||||
* @param pobj The print object.
|
|
||||||
*/
|
|
||||||
void slice(PrintObject *pobj);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Slice the loaded print scene.
|
* @brief Slice the loaded print scene.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,11 +32,11 @@ void AppControllerBoilerplate::process_events()
|
||||||
|
|
||||||
AppControllerBoilerplate::PathList
|
AppControllerBoilerplate::PathList
|
||||||
AppControllerBoilerplate::query_destination_paths(
|
AppControllerBoilerplate::query_destination_paths(
|
||||||
const std::string &title,
|
const string &title,
|
||||||
const std::string &extensions) const
|
const std::string &extensions) const
|
||||||
{
|
{
|
||||||
|
|
||||||
wxFileDialog dlg(wxTheApp->GetTopWindow(), wxString(title) );
|
wxFileDialog dlg(wxTheApp->GetTopWindow(), title );
|
||||||
dlg.SetWildcard(extensions);
|
dlg.SetWildcard(extensions);
|
||||||
|
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
|
@ -52,7 +52,7 @@ AppControllerBoilerplate::query_destination_paths(
|
||||||
|
|
||||||
AppControllerBoilerplate::Path
|
AppControllerBoilerplate::Path
|
||||||
AppControllerBoilerplate::query_destination_path(
|
AppControllerBoilerplate::query_destination_path(
|
||||||
const std::string &title,
|
const string &title,
|
||||||
const std::string &extensions,
|
const std::string &extensions,
|
||||||
const std::string& hint) const
|
const std::string& hint) const
|
||||||
{
|
{
|
||||||
|
@ -71,8 +71,8 @@ AppControllerBoilerplate::query_destination_path(
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppControllerBoilerplate::report_issue(IssueType issuetype,
|
bool AppControllerBoilerplate::report_issue(IssueType issuetype,
|
||||||
const std::string &description,
|
const string &description,
|
||||||
const std::string &brief)
|
const string &brief)
|
||||||
{
|
{
|
||||||
auto icon = wxICON_INFORMATION;
|
auto icon = wxICON_INFORMATION;
|
||||||
auto style = wxOK|wxCENTRE;
|
auto style = wxOK|wxCENTRE;
|
||||||
|
@ -84,10 +84,17 @@ bool AppControllerBoilerplate::report_issue(IssueType issuetype,
|
||||||
case IssueType::FATAL: icon = wxICON_ERROR;
|
case IssueType::FATAL: icon = wxICON_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ret = wxMessageBox(_(description), _(brief), icon | style);
|
auto ret = wxMessageBox(description, brief, icon | style);
|
||||||
return ret != wxCANCEL;
|
return ret != wxCANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AppControllerBoilerplate::report_issue(
|
||||||
|
AppControllerBoilerplate::IssueType issuetype,
|
||||||
|
const string &description)
|
||||||
|
{
|
||||||
|
return report_issue(issuetype, description, string());
|
||||||
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent);
|
wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -99,11 +106,10 @@ namespace {
|
||||||
class GuiProgressIndicator:
|
class GuiProgressIndicator:
|
||||||
public IProgressIndicator, public wxEvtHandler {
|
public IProgressIndicator, public wxEvtHandler {
|
||||||
|
|
||||||
std::shared_ptr<wxProgressDialog> gauge_;
|
wxProgressDialog gauge_;
|
||||||
using Base = IProgressIndicator;
|
using Base = IProgressIndicator;
|
||||||
wxString message_;
|
wxString message_;
|
||||||
int range_; wxString title_;
|
int range_; wxString title_;
|
||||||
unsigned prc_ = 0;
|
|
||||||
bool is_asynch_ = false;
|
bool is_asynch_ = false;
|
||||||
|
|
||||||
const int id_ = wxWindow::NewControlId();
|
const int id_ = wxWindow::NewControlId();
|
||||||
|
@ -111,29 +117,15 @@ class GuiProgressIndicator:
|
||||||
// status update handler
|
// status update handler
|
||||||
void _state( wxCommandEvent& evt) {
|
void _state( wxCommandEvent& evt) {
|
||||||
unsigned st = evt.GetInt();
|
unsigned st = evt.GetInt();
|
||||||
|
message_ = evt.GetString();
|
||||||
_state(st);
|
_state(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status update implementation
|
// Status update implementation
|
||||||
void _state( unsigned st) {
|
void _state( unsigned st) {
|
||||||
if(st < max()) {
|
if(!gauge_.IsShown()) gauge_.ShowModal();
|
||||||
if(!gauge_) gauge_ = std::make_shared<wxProgressDialog>(
|
Base::state(st);
|
||||||
title_, message_, range_, wxTheApp->GetTopWindow(),
|
gauge_.Update(static_cast<int>(st), message_);
|
||||||
wxPD_APP_MODAL | wxPD_AUTO_HIDE
|
|
||||||
);
|
|
||||||
|
|
||||||
if(!gauge_->IsShown()) gauge_->ShowModal();
|
|
||||||
Base::state(st);
|
|
||||||
gauge_->Update(static_cast<int>(st), message_);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(st == max()) {
|
|
||||||
prc_++;
|
|
||||||
if(prc_ == Base::procedure_count()) {
|
|
||||||
gauge_.reset();
|
|
||||||
prc_ = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -144,9 +136,12 @@ public:
|
||||||
/// Get the mode of parallel operation.
|
/// Get the mode of parallel operation.
|
||||||
inline bool asynch() const { return is_asynch_; }
|
inline bool asynch() const { return is_asynch_; }
|
||||||
|
|
||||||
inline GuiProgressIndicator(int range, const std::string& title,
|
inline GuiProgressIndicator(int range, const string& title,
|
||||||
const std::string& firstmsg) :
|
const string& firstmsg) :
|
||||||
range_(range), message_(_(firstmsg)), title_(_(title))
|
gauge_(title, firstmsg, range, wxTheApp->GetTopWindow(),
|
||||||
|
wxPD_APP_MODAL | wxPD_AUTO_HIDE),
|
||||||
|
message_(firstmsg),
|
||||||
|
range_(range), title_(title)
|
||||||
{
|
{
|
||||||
Base::max(static_cast<float>(range));
|
Base::max(static_cast<float>(range));
|
||||||
Base::states(static_cast<unsigned>(range));
|
Base::states(static_cast<unsigned>(range));
|
||||||
|
@ -162,7 +157,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void state(float val) override {
|
virtual void state(float val) override {
|
||||||
if( val >= 1.0) state(static_cast<unsigned>(val));
|
state(static_cast<unsigned>(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void state(unsigned st) {
|
void state(unsigned st) {
|
||||||
|
@ -170,31 +165,31 @@ public:
|
||||||
if(is_asynch_) {
|
if(is_asynch_) {
|
||||||
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_);
|
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_);
|
||||||
evt->SetInt(st);
|
evt->SetInt(st);
|
||||||
|
evt->SetString(message_);
|
||||||
wxQueueEvent(this, evt);
|
wxQueueEvent(this, evt);
|
||||||
} else _state(st);
|
} else _state(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void message(const std::string & msg) override {
|
virtual void message(const string & msg) override {
|
||||||
message_ = _(msg);
|
message_ = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void messageFmt(const std::string& fmt, ...) {
|
virtual void messageFmt(const string& fmt, ...) {
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
va_start(arglist, fmt);
|
va_start(arglist, fmt);
|
||||||
message_ = wxString::Format(_(fmt), arglist);
|
message_ = wxString::Format(wxString(fmt), arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void title(const std::string & title) override {
|
virtual void title(const string & title) override {
|
||||||
title_ = _(title);
|
title_ = title;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||||
AppControllerBoilerplate::create_progress_indicator(
|
AppControllerBoilerplate::create_progress_indicator(
|
||||||
unsigned statenum, const std::string& title,
|
unsigned statenum, const string& title, const string& firstmsg) const
|
||||||
const std::string& firstmsg) const
|
|
||||||
{
|
{
|
||||||
auto pri =
|
auto pri =
|
||||||
std::make_shared<GuiProgressIndicator>(statenum, title, firstmsg);
|
std::make_shared<GuiProgressIndicator>(statenum, title, firstmsg);
|
||||||
|
@ -206,6 +201,13 @@ AppControllerBoilerplate::create_progress_indicator(
|
||||||
return pri;
|
return pri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||||
|
AppControllerBoilerplate::create_progress_indicator(unsigned statenum,
|
||||||
|
const string &title) const
|
||||||
|
{
|
||||||
|
return create_progress_indicator(statenum, title, string());
|
||||||
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// A wrapper progress indicator class around the statusbar created in perl.
|
// A wrapper progress indicator class around the statusbar created in perl.
|
||||||
|
@ -278,18 +280,18 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void message(const std::string & msg) override {
|
virtual void message(const string & msg) override {
|
||||||
message_ = msg;
|
message_ = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void message_fmt(const std::string& fmt, ...) override {
|
virtual void message_fmt(const string& fmt, ...) override {
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
va_start(arglist, fmt);
|
va_start(arglist, fmt);
|
||||||
message_ = wxString::Format(_(fmt), arglist);
|
message_ = wxString::Format(fmt, arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void title(const std::string & /*title*/) override {}
|
virtual void title(const string & /*title*/) override {}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -305,5 +307,4 @@ void AppController::set_global_progress_indicator(
|
||||||
global_progressind_ = std::make_shared<Wrapper>(gauge, sb, *this);
|
global_progressind_ = std::make_shared<Wrapper>(gauge, sb, *this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include "Strings.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
|
@ -16,7 +17,6 @@ public:
|
||||||
private:
|
private:
|
||||||
float state_ = .0f, max_ = 1.f, step_;
|
float state_ = .0f, max_ = 1.f, step_;
|
||||||
CancelFn cancelfunc_ = [](){};
|
CancelFn cancelfunc_ = [](){};
|
||||||
unsigned proc_count_ = 1;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Message shown on the next status update.
|
/// Message shown on the next status update.
|
||||||
virtual void message(const std::string&) = 0;
|
virtual void message(const string&) = 0;
|
||||||
|
|
||||||
/// Title of the operaton.
|
/// Title of the operaton.
|
||||||
virtual void title(const std::string&) = 0;
|
virtual void title(const string&) = 0;
|
||||||
|
|
||||||
/// Formatted message for the next status update. Works just like sprinf.
|
/// Formatted message for the next status update. Works just like sprinf.
|
||||||
virtual void message_fmt(const std::string& fmt, ...);
|
virtual void message_fmt(const string& fmt, ...);
|
||||||
|
|
||||||
/// Set up a cancel callback for the operation if feasible.
|
/// Set up a cancel callback for the operation if feasible.
|
||||||
inline void on_cancel(CancelFn func) { cancelfunc_ = func; }
|
inline void on_cancel(CancelFn func) { cancelfunc_ = func; }
|
||||||
|
@ -60,21 +60,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void cancel() { cancelfunc_(); }
|
virtual void cancel() { cancelfunc_(); }
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set up how many subprocedures does the whole operation contain.
|
|
||||||
*
|
|
||||||
* This was neccesary from practical reasons. If the progress indicator is
|
|
||||||
* a dialog and we want to show the progress of a few sub operations than
|
|
||||||
* the dialog wont be closed and reopened each time a new sub operation is
|
|
||||||
* started. This is not a mandatory feature and can be ignored completely.
|
|
||||||
*/
|
|
||||||
inline void procedure_count(unsigned pc) { proc_count_ = pc; }
|
|
||||||
|
|
||||||
/// Get the current procedure count
|
|
||||||
inline unsigned procedure_count() const { return proc_count_; }
|
|
||||||
|
|
||||||
/// Convinience function to call message and status update in one function.
|
/// Convinience function to call message and status update in one function.
|
||||||
void update(float st, const std::string& msg) {
|
void update(float st, const string& msg) {
|
||||||
message(msg); state(st);
|
message(msg); state(st);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
10
xs/src/slic3r/Strings.hpp
Normal file
10
xs/src/slic3r/Strings.hpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef STRINGS_HPP
|
||||||
|
#define STRINGS_HPP
|
||||||
|
|
||||||
|
#include "GUI/GUI.hpp"
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
using string = wxString;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // STRINGS_HPP
|
Loading…
Reference in a new issue