Export dialog ready
This commit is contained in:
parent
3efe6675cb
commit
ae682b9cd3
8 changed files with 621 additions and 326 deletions
|
@ -262,6 +262,8 @@ add_library(libslic3r_gui STATIC
|
||||||
${LIBDIR}/slic3r/Utils/PresetUpdater.hpp
|
${LIBDIR}/slic3r/Utils/PresetUpdater.hpp
|
||||||
${LIBDIR}/slic3r/Utils/Time.cpp
|
${LIBDIR}/slic3r/Utils/Time.cpp
|
||||||
${LIBDIR}/slic3r/Utils/Time.hpp
|
${LIBDIR}/slic3r/Utils/Time.hpp
|
||||||
|
${LIBDIR}/slic3r/GUI/PngExportDialog.hpp
|
||||||
|
${LIBDIR}/slic3r/GUI/PngExportDialog.cpp
|
||||||
${LIBDIR}/slic3r/IProgressIndicator.hpp
|
${LIBDIR}/slic3r/IProgressIndicator.hpp
|
||||||
${LIBDIR}/slic3r/AppController.hpp
|
${LIBDIR}/slic3r/AppController.hpp
|
||||||
${LIBDIR}/slic3r/AppController.cpp
|
${LIBDIR}/slic3r/AppController.cpp
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
//#include <slic3r/GUI/GUI.hpp>
|
#include <slic3r/GUI/GUI.hpp>
|
||||||
#include <slic3r/GUI/PresetBundle.hpp>
|
#include <slic3r/GUI/PresetBundle.hpp>
|
||||||
|
|
||||||
#include <PrintConfig.hpp>
|
#include <PrintConfig.hpp>
|
||||||
|
@ -270,10 +270,9 @@ void PrintController::slice_to_png()
|
||||||
{
|
{
|
||||||
assert(model_ != nullptr);
|
assert(model_ != nullptr);
|
||||||
|
|
||||||
auto zipfilepath = query_destination_path( "Path to zip file...",
|
auto exd = query_png_export_data();
|
||||||
"*.zip");
|
|
||||||
|
|
||||||
if(zipfilepath.empty()) return;
|
if(exd.zippath.empty()) return;
|
||||||
|
|
||||||
auto presetbundle = GUI::get_preset_bundle();
|
auto presetbundle = GUI::get_preset_bundle();
|
||||||
|
|
||||||
|
@ -290,16 +289,42 @@ void PrintController::slice_to_png()
|
||||||
report_issue(IssueType::ERR, e.what(), "Error");
|
report_issue(IssueType::ERR, e.what(), "Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::async(std::launch::async, [this, zipfilepath]() {
|
auto print_bb = print_->bounding_box();
|
||||||
|
|
||||||
|
// If the print does not fit into the print area we should cry about it.
|
||||||
|
if(unscale(print_bb.size().x) > exd.width_mm ||
|
||||||
|
unscale(print_bb.size().y) > exd.height_mm) {
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
ss << _("Print will not fit and will be truncated!") << "\n"
|
||||||
|
<< _("Width needed: ") << unscale(print_bb.size().x) << " mm\n"
|
||||||
|
<< _("Height needed: ") << unscale(print_bb.size().y) << " mm\n";
|
||||||
|
|
||||||
|
report_issue(IssueType::WARN, ss.str(), "Warning");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::async(std::launch::async, [this, exd]() {
|
||||||
progress_indicator(100, "Slicing to zipped png files...");
|
progress_indicator(100, "Slicing to zipped png files...");
|
||||||
progress_indicator()->procedure_count(3);
|
progress_indicator()->procedure_count(3);
|
||||||
|
|
||||||
|
try {
|
||||||
slice();
|
slice();
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
report_issue(IssueType::ERR, e.what(), "Exception");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto pbak = print_->progressindicator;
|
auto pbak = print_->progressindicator;
|
||||||
print_->progressindicator = progress_indicator();
|
print_->progressindicator = progress_indicator();
|
||||||
print_->print_to_png(zipfilepath);
|
|
||||||
print_->progressindicator = pbak;
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
print_->print_to_png(exd.zippath, exd.width_px, exd.height_px,
|
||||||
|
exd.width_mm, exd.height_mm);
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
report_issue(IssueType::ERR, e.what(), "Exception");
|
||||||
|
}
|
||||||
|
|
||||||
|
print_->progressindicator = pbak;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ public:
|
||||||
|
|
||||||
ProgresIndicatorPtr progress_indicator();
|
ProgresIndicatorPtr progress_indicator();
|
||||||
|
|
||||||
|
bool is_main_thread() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
ProgresIndicatorPtr create_progress_indicator(
|
ProgresIndicatorPtr create_progress_indicator(
|
||||||
|
@ -70,7 +72,6 @@ protected:
|
||||||
const std::string& title,
|
const std::string& title,
|
||||||
const std::string& firstmsg = "") const;
|
const std::string& firstmsg = "") const;
|
||||||
|
|
||||||
bool is_main_thread() const;
|
|
||||||
|
|
||||||
ProgresIndicatorPtr global_progressind_;
|
ProgresIndicatorPtr global_progressind_;
|
||||||
};
|
};
|
||||||
|
@ -87,6 +88,16 @@ protected:
|
||||||
void infill(PrintObject *pobj);
|
void infill(PrintObject *pobj);
|
||||||
void gen_support_material(PrintObject *pobj);
|
void gen_support_material(PrintObject *pobj);
|
||||||
|
|
||||||
|
struct PngExportData {
|
||||||
|
std::string zippath;
|
||||||
|
unsigned long width_px = 1440;
|
||||||
|
unsigned long height_px = 2560;
|
||||||
|
double width_mm = 68.0, height_mm = 120.0;
|
||||||
|
double corr = 1.0;
|
||||||
|
} query_png_export_data();
|
||||||
|
|
||||||
|
PngExportData prev_expdata_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
using Ptr = std::unique_ptr<PrintController>;
|
using Ptr = std::unique_ptr<PrintController>;
|
||||||
|
@ -103,7 +114,7 @@ public:
|
||||||
void slice_to_png();
|
void slice_to_png();
|
||||||
};
|
};
|
||||||
|
|
||||||
class AppController: protected AppControllerBoilerplate {
|
class AppController: public AppControllerBoilerplate {
|
||||||
Model *model_ = nullptr;
|
Model *model_ = nullptr;
|
||||||
PrintController::Ptr printctl;
|
PrintController::Ptr printctl;
|
||||||
public:
|
public:
|
||||||
|
|
350
xs/src/slic3r/AppControllerWx.cpp
Normal file
350
xs/src/slic3r/AppControllerWx.cpp
Normal file
|
@ -0,0 +1,350 @@
|
||||||
|
#include "AppController.hpp"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
#include <slic3r/GUI/GUI.hpp>
|
||||||
|
#include <slic3r/GUI/PngExportDialog.hpp>
|
||||||
|
|
||||||
|
#include <wx/app.h>
|
||||||
|
#include <wx/filedlg.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
#include <wx/progdlg.h>
|
||||||
|
#include <wx/gauge.h>
|
||||||
|
#include <wx/statusbr.h>
|
||||||
|
#include <wx/event.h>
|
||||||
|
|
||||||
|
namespace Slic3r {
|
||||||
|
|
||||||
|
AppControllerBoilerplate::PathList
|
||||||
|
AppControllerBoilerplate::query_destination_paths(
|
||||||
|
const std::string &title,
|
||||||
|
const std::string &extensions) const
|
||||||
|
{
|
||||||
|
|
||||||
|
wxFileDialog dlg(wxTheApp->GetTopWindow(), wxString(title) );
|
||||||
|
dlg.SetWildcard(extensions);
|
||||||
|
|
||||||
|
dlg.ShowModal();
|
||||||
|
|
||||||
|
wxArrayString paths;
|
||||||
|
dlg.GetPaths(paths);
|
||||||
|
|
||||||
|
PathList ret(paths.size(), "");
|
||||||
|
for(auto& p : paths) ret.push_back(p.ToStdString());
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
AppControllerBoilerplate::Path
|
||||||
|
AppControllerBoilerplate::query_destination_path(
|
||||||
|
const std::string &title,
|
||||||
|
const std::string &extensions,
|
||||||
|
const std::string& hint) const
|
||||||
|
{
|
||||||
|
wxFileDialog dlg(wxTheApp->GetTopWindow(), title );
|
||||||
|
dlg.SetWildcard(extensions);
|
||||||
|
|
||||||
|
dlg.SetFilename(hint);
|
||||||
|
|
||||||
|
Path ret;
|
||||||
|
|
||||||
|
if(dlg.ShowModal() == wxID_OK) {
|
||||||
|
ret = Path(dlg.GetPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppControllerBoilerplate::report_issue(IssueType issuetype,
|
||||||
|
const std::string &description,
|
||||||
|
const std::string &brief)
|
||||||
|
{
|
||||||
|
auto icon = wxICON_INFORMATION;
|
||||||
|
switch(issuetype) {
|
||||||
|
case IssueType::INFO: break;
|
||||||
|
case IssueType::WARN: icon = wxICON_WARNING; break;
|
||||||
|
case IssueType::ERR:
|
||||||
|
case IssueType::FATAL: icon = wxICON_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMessageBox(description, brief, icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent);
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class GuiProgressIndicator:
|
||||||
|
public IProgressIndicator, public wxEvtHandler {
|
||||||
|
|
||||||
|
std::shared_ptr<wxProgressDialog> gauge_;
|
||||||
|
using Base = IProgressIndicator;
|
||||||
|
wxString message_;
|
||||||
|
int range_; wxString title_;
|
||||||
|
unsigned prc_ = 0;
|
||||||
|
bool is_asynch_ = false;
|
||||||
|
|
||||||
|
const int id_ = wxWindow::NewControlId();
|
||||||
|
|
||||||
|
// status update handler
|
||||||
|
void _state( wxCommandEvent& evt) {
|
||||||
|
unsigned st = evt.GetInt();
|
||||||
|
_state(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _state( unsigned st) {
|
||||||
|
if(st < max()) {
|
||||||
|
if(!gauge_) gauge_ = std::make_shared<wxProgressDialog>(
|
||||||
|
title_, message_, range_, wxTheApp->GetTopWindow(),
|
||||||
|
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:
|
||||||
|
|
||||||
|
inline void asynch(bool is) { is_asynch_ = is; }
|
||||||
|
inline bool asynch() const { return is_asynch_; }
|
||||||
|
|
||||||
|
inline GuiProgressIndicator(int range, const std::string& title,
|
||||||
|
const std::string& firstmsg) :
|
||||||
|
range_(range), message_(_(firstmsg)), title_(_(title))
|
||||||
|
{
|
||||||
|
Base::max(static_cast<float>(range));
|
||||||
|
Base::states(static_cast<unsigned>(range));
|
||||||
|
|
||||||
|
Bind(PROGRESS_STATUS_UPDATE_EVENT,
|
||||||
|
&GuiProgressIndicator::_state,
|
||||||
|
this, id_);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void state(float val) override {
|
||||||
|
if( val >= 1.0) state(static_cast<unsigned>(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void state(unsigned st) override {
|
||||||
|
// send status update event
|
||||||
|
if(is_asynch_) {
|
||||||
|
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_);
|
||||||
|
evt->SetInt(st);
|
||||||
|
wxQueueEvent(this, evt);
|
||||||
|
} else _state(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void message(const std::string & msg) override {
|
||||||
|
message_ = _(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void messageFmt(const std::string& fmt, ...) {
|
||||||
|
va_list arglist;
|
||||||
|
va_start(arglist, fmt);
|
||||||
|
message_ = wxString::Format(_(fmt), arglist);
|
||||||
|
va_end(arglist);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void title(const std::string & title) override {
|
||||||
|
title_ = _(title);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||||
|
AppControllerBoilerplate::create_progress_indicator(
|
||||||
|
unsigned statenum, const std::string& title,
|
||||||
|
const std::string& firstmsg) const
|
||||||
|
{
|
||||||
|
auto pri =
|
||||||
|
std::make_shared<GuiProgressIndicator>(statenum, title, firstmsg);
|
||||||
|
|
||||||
|
pri->asynch(!is_main_thread());
|
||||||
|
|
||||||
|
return pri;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class Wrapper: public IProgressIndicator, public wxEvtHandler {
|
||||||
|
wxGauge *gauge_;
|
||||||
|
wxStatusBar *stbar_;
|
||||||
|
using Base = IProgressIndicator;
|
||||||
|
std::string message_;
|
||||||
|
AppControllerBoilerplate& ctl_;
|
||||||
|
|
||||||
|
void showProgress(bool show = true) {
|
||||||
|
gauge_->Show(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _state(unsigned st) {
|
||||||
|
if( st <= max() ) {
|
||||||
|
Base::state(st);
|
||||||
|
|
||||||
|
if(!gauge_->IsShown()) showProgress(true);
|
||||||
|
|
||||||
|
stbar_->SetStatusText(message_);
|
||||||
|
if(st == gauge_->GetRange()) {
|
||||||
|
gauge_->SetValue(0);
|
||||||
|
showProgress(false);
|
||||||
|
} else {
|
||||||
|
gauge_->SetValue(static_cast<int>(st));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// status update handler
|
||||||
|
void _state( wxCommandEvent& evt) {
|
||||||
|
unsigned st = evt.GetInt(); _state(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int id_ = wxWindow::NewControlId();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
inline Wrapper(wxGauge *gauge, wxStatusBar *stbar,
|
||||||
|
AppControllerBoilerplate& ctl):
|
||||||
|
gauge_(gauge), stbar_(stbar), ctl_(ctl)
|
||||||
|
{
|
||||||
|
Base::max(static_cast<float>(gauge->GetRange()));
|
||||||
|
Base::states(static_cast<unsigned>(gauge->GetRange()));
|
||||||
|
|
||||||
|
Bind(PROGRESS_STATUS_UPDATE_EVENT,
|
||||||
|
&Wrapper::_state,
|
||||||
|
this, id_);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void state(float val) override {
|
||||||
|
if(val >= 1.0) state(unsigned(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void state(unsigned st) override {
|
||||||
|
if(!ctl_.is_main_thread()) {
|
||||||
|
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT, id_);
|
||||||
|
evt->SetInt(st);
|
||||||
|
wxQueueEvent(this, evt);
|
||||||
|
} else _state(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void message(const std::string & msg) override {
|
||||||
|
message_ = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void message_fmt(const std::string& fmt, ...) override {
|
||||||
|
va_list arglist;
|
||||||
|
va_start(arglist, fmt);
|
||||||
|
message_ = wxString::Format(_(fmt), arglist);
|
||||||
|
va_end(arglist);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void title(const std::string & /*title*/) override {}
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void AppController::set_global_progress_indicator_id(
|
||||||
|
unsigned gid,
|
||||||
|
unsigned sid)
|
||||||
|
{
|
||||||
|
wxGauge* gauge = dynamic_cast<wxGauge*>(wxWindow::FindWindowById(gid));
|
||||||
|
wxStatusBar* sb = dynamic_cast<wxStatusBar*>(wxWindow::FindWindowById(sid));
|
||||||
|
|
||||||
|
if(gauge && sb) {
|
||||||
|
global_progressind_ = std::make_shared<Wrapper>(gauge, sb, *this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintController::PngExportData PrintController::query_png_export_data()
|
||||||
|
{
|
||||||
|
|
||||||
|
class PngExportView: public PngExportDialog {
|
||||||
|
double ratio_, bs_ratio_;
|
||||||
|
public:
|
||||||
|
|
||||||
|
PngExportView(): PngExportDialog(wxTheApp->GetTopWindow()) {
|
||||||
|
ratio_ = double(spin_reso_width_->GetValue()) /
|
||||||
|
spin_reso_height_->GetValue();
|
||||||
|
|
||||||
|
bs_ratio_ = bed_width_spin_->GetValue() /
|
||||||
|
bed_height_spin_->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
PngExportData export_data() const {
|
||||||
|
PrintController::PngExportData ret;
|
||||||
|
ret.zippath = filepick_ctl_->GetPath();
|
||||||
|
ret.width_px = spin_reso_width_->GetValue();
|
||||||
|
ret.height_px = spin_reso_height_->GetValue();
|
||||||
|
ret.width_mm = bed_width_spin_->GetValue();
|
||||||
|
ret.height_mm = bed_height_spin_->GetValue();
|
||||||
|
ret.corr = corr_spin_->GetValue();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void prefill(const PngExportData& data) {
|
||||||
|
filepick_ctl_->SetPath(data.zippath);
|
||||||
|
spin_reso_width_->SetValue(data.width_px);
|
||||||
|
spin_reso_height_->SetValue(data.height_px);
|
||||||
|
bed_width_spin_->SetValue(data.width_mm);
|
||||||
|
bed_height_spin_->SetValue(data.height_mm);
|
||||||
|
corr_spin_->SetValue(data.corr);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void ResoLock( wxCommandEvent& /*event*/ ) override {
|
||||||
|
ratio_ = double(spin_reso_width_->GetValue()) /
|
||||||
|
double(spin_reso_height_->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void BedsizeLock( wxCommandEvent& /*event*/ ) override {
|
||||||
|
bs_ratio_ = bed_width_spin_->GetValue() /
|
||||||
|
bed_height_spin_->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void EvalResoSpin( wxCommandEvent& event ) override {
|
||||||
|
if(reso_lock_btn_->GetValue()) {
|
||||||
|
|
||||||
|
if(event.GetId() == spin_reso_width_->GetId()) {
|
||||||
|
spin_reso_height_->SetValue(
|
||||||
|
std::round(spin_reso_width_->GetValue()/ratio_));
|
||||||
|
} else {
|
||||||
|
spin_reso_width_->SetValue(
|
||||||
|
std::round(spin_reso_height_->GetValue()*ratio_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void EvalBedSpin( wxCommandEvent& event ) override {
|
||||||
|
if(bedsize_lock_btn_->GetValue()) {
|
||||||
|
|
||||||
|
if(event.GetId() == bed_width_spin_->GetId()) {
|
||||||
|
bed_height_spin_->SetValue(
|
||||||
|
std::round(bed_width_spin_->GetValue()/bs_ratio_));
|
||||||
|
} else {
|
||||||
|
bed_width_spin_->SetValue(
|
||||||
|
std::round(bed_height_spin_->GetValue()*bs_ratio_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PngExportView exdlg;
|
||||||
|
|
||||||
|
exdlg.prefill(prev_expdata_);
|
||||||
|
|
||||||
|
auto r = exdlg.ShowModal();
|
||||||
|
|
||||||
|
auto ret = exdlg.export_data();
|
||||||
|
prev_expdata_ = ret;
|
||||||
|
|
||||||
|
if(r != wxID_OK) ret.zippath.clear();
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
154
xs/src/slic3r/GUI/PngExportDialog.cpp
Normal file
154
xs/src/slic3r/GUI/PngExportDialog.cpp
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "PngExportDialog.hpp"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
PngExportDialog::PngExportDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||||
|
{
|
||||||
|
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||||
|
|
||||||
|
wxBoxSizer* top_layout_;
|
||||||
|
top_layout_ = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizer15;
|
||||||
|
bSizer15 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizer16;
|
||||||
|
bSizer16 = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxGridSizer* gSizer2;
|
||||||
|
gSizer2 = new wxGridSizer( 4, 1, 0, 0 );
|
||||||
|
|
||||||
|
filepick_text_ = new wxStaticText( this, wxID_ANY, _("Target zip file"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
filepick_text_->Wrap( -1 );
|
||||||
|
gSizer2->Add( filepick_text_, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
|
resotext_ = new wxStaticText( this, wxID_ANY, _("Resolution (w, h) [px]"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
resotext_->Wrap( -1 );
|
||||||
|
gSizer2->Add( resotext_, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
|
bed_size_text_ = new wxStaticText( this, wxID_ANY, _("Bed size (w, h) [mm]"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
bed_size_text_->Wrap( -1 );
|
||||||
|
gSizer2->Add( bed_size_text_, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
|
corr_text_ = new wxStaticText( this, wxID_ANY, _("Size correction"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
corr_text_->Wrap( -1 );
|
||||||
|
gSizer2->Add( corr_text_, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizer16->Add( gSizer2, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizer15->Add( bSizer16, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bSizer18;
|
||||||
|
bSizer18 = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxBoxSizer* filepick_layout_;
|
||||||
|
filepick_layout_ = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
filepick_ctl_ = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a file"), wxT("*.zip"), wxDefaultPosition, wxSize( 308,-1 ), wxFLP_DEFAULT_STYLE, wxDefaultValidator, wxT("filepick_ctl") );
|
||||||
|
filepick_layout_->Add( filepick_ctl_, 0, wxALIGN_CENTER|wxALIGN_LEFT|wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizer18->Add( filepick_layout_, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* resolution_layout_;
|
||||||
|
resolution_layout_ = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxBoxSizer* resolution_spins_layout_;
|
||||||
|
resolution_spins_layout_ = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
spin_reso_width_ = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 0, 10000, 1440 );
|
||||||
|
resolution_spins_layout_->Add( spin_reso_width_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||||
|
|
||||||
|
spin_reso_height_ = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 0, 10000, 2560 );
|
||||||
|
resolution_spins_layout_->Add( spin_reso_height_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||||
|
|
||||||
|
reso_lock_btn_ = new wxToggleButton( this, wxID_ANY, _("Lock"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
reso_lock_btn_->SetValue(true);
|
||||||
|
resolution_spins_layout_->Add( reso_lock_btn_, 0, wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
resolution_layout_->Add( resolution_spins_layout_, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizer18->Add( resolution_layout_, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bedsize_layout_;
|
||||||
|
bedsize_layout_ = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxBoxSizer* bedsize_spins_layout_;
|
||||||
|
bedsize_spins_layout_ = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
bed_width_spin_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 0, 1e6, 68.0 );
|
||||||
|
bedsize_spins_layout_->Add( bed_width_spin_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||||
|
|
||||||
|
bed_height_spin_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 0, 1e6, 120.0 );
|
||||||
|
bedsize_spins_layout_->Add( bed_height_spin_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||||
|
|
||||||
|
bedsize_lock_btn_ = new wxToggleButton( this, wxID_ANY, _("Lock"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
bedsize_lock_btn_->SetValue(true);
|
||||||
|
bedsize_spins_layout_->Add( bedsize_lock_btn_, 0, wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bedsize_layout_->Add( bedsize_spins_layout_, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizer18->Add( bedsize_layout_, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* corr_layout_;
|
||||||
|
corr_layout_ = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
corr_spin_ = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 100,-1 ), wxSP_ARROW_KEYS, 0, 100, 1, 0.1 );
|
||||||
|
corr_layout_->Add( corr_spin_, 0, wxALIGN_CENTER|wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
corr_layout_->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
export_btn_ = new wxButton( this, wxID_ANY, _("Export"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("export_btn") );
|
||||||
|
corr_layout_->Add( export_btn_, 0, wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizer18->Add( corr_layout_, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bSizer15->Add( bSizer18, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
top_layout_->Add( bSizer15, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
this->SetSizer( top_layout_ );
|
||||||
|
this->Layout();
|
||||||
|
|
||||||
|
this->Centre( wxBOTH );
|
||||||
|
|
||||||
|
// Connect Events
|
||||||
|
spin_reso_width_->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalResoSpin ), NULL, this );
|
||||||
|
spin_reso_height_->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalResoSpin ), NULL, this );
|
||||||
|
reso_lock_btn_->Connect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler( PngExportDialog::ResoLock ), NULL, this );
|
||||||
|
bed_width_spin_->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalBedSpin ), NULL, this );
|
||||||
|
bed_height_spin_->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalBedSpin ), NULL, this );
|
||||||
|
bedsize_lock_btn_->Connect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler( PngExportDialog::BedsizeLock ), NULL, this );
|
||||||
|
export_btn_->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PngExportDialog::Close ), NULL, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
PngExportDialog::~PngExportDialog()
|
||||||
|
{
|
||||||
|
// Disconnect Events
|
||||||
|
spin_reso_width_->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalResoSpin ), NULL, this );
|
||||||
|
spin_reso_height_->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalResoSpin ), NULL, this );
|
||||||
|
reso_lock_btn_->Disconnect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler( PngExportDialog::ResoLock ), NULL, this );
|
||||||
|
bed_width_spin_->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalBedSpin ), NULL, this );
|
||||||
|
bed_height_spin_->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PngExportDialog::EvalBedSpin ), NULL, this );
|
||||||
|
bedsize_lock_btn_->Disconnect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler( PngExportDialog::BedsizeLock ), NULL, this );
|
||||||
|
export_btn_->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PngExportDialog::Close ), NULL, this );
|
||||||
|
|
||||||
|
}
|
67
xs/src/slic3r/GUI/PngExportDialog.hpp
Normal file
67
xs/src/slic3r/GUI/PngExportDialog.hpp
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Jun 17 2015)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __NONAME_H__
|
||||||
|
#define __NONAME_H__
|
||||||
|
|
||||||
|
#include <wx/artprov.h>
|
||||||
|
#include <wx/xrc/xmlres.h>
|
||||||
|
#include <wx/intl.h>
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/stattext.h>
|
||||||
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
#include <wx/colour.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/filepicker.h>
|
||||||
|
#include <wx/spinctrl.h>
|
||||||
|
#include <wx/tglbtn.h>
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
|
||||||
|
#include "GUI.hpp"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Class PngExportDialog
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
class PngExportDialog : public wxDialog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxStaticText* filepick_text_;
|
||||||
|
wxStaticText* resotext_;
|
||||||
|
wxStaticText* bed_size_text_;
|
||||||
|
wxStaticText* corr_text_;
|
||||||
|
wxFilePickerCtrl* filepick_ctl_;
|
||||||
|
wxSpinCtrl* spin_reso_width_;
|
||||||
|
wxSpinCtrl* spin_reso_height_;
|
||||||
|
wxToggleButton* reso_lock_btn_;
|
||||||
|
wxSpinCtrlDouble* bed_width_spin_;
|
||||||
|
wxSpinCtrlDouble* bed_height_spin_;
|
||||||
|
wxToggleButton* bedsize_lock_btn_;
|
||||||
|
wxSpinCtrlDouble* corr_spin_;
|
||||||
|
wxButton* export_btn_;
|
||||||
|
|
||||||
|
// Virtual event handlers, overide them in your derived class
|
||||||
|
virtual void EvalResoSpin( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
virtual void ResoLock( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
virtual void EvalBedSpin( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
virtual void BedsizeLock( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
virtual void Close( wxCommandEvent& /*event*/ ) { EndModal(wxID_OK); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
PngExportDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Slice to zipped PNG files"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 452,170 ), long style = wxDEFAULT_DIALOG_STYLE );
|
||||||
|
~PngExportDialog();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //__NONAME_H__
|
|
@ -1,314 +0,0 @@
|
||||||
#include "AppController.hpp"
|
|
||||||
|
|
||||||
#include <slic3r/GUI/GUI.hpp>
|
|
||||||
|
|
||||||
#include <wx/app.h>
|
|
||||||
#include <wx/filedlg.h>
|
|
||||||
#include <wx/msgdlg.h>
|
|
||||||
#include <wx/progdlg.h>
|
|
||||||
#include <wx/gauge.h>
|
|
||||||
#include <wx/statusbr.h>
|
|
||||||
#include <wx/event.h>
|
|
||||||
|
|
||||||
namespace Slic3r {
|
|
||||||
|
|
||||||
AppControllerBoilerplate::PathList
|
|
||||||
AppControllerBoilerplate::query_destination_paths(
|
|
||||||
const std::string &title,
|
|
||||||
const std::string &extensions) const
|
|
||||||
{
|
|
||||||
|
|
||||||
wxFileDialog dlg(wxTheApp->GetTopWindow(), wxString(title) );
|
|
||||||
dlg.SetWildcard(extensions);
|
|
||||||
|
|
||||||
dlg.ShowModal();
|
|
||||||
|
|
||||||
wxArrayString paths;
|
|
||||||
dlg.GetPaths(paths);
|
|
||||||
|
|
||||||
PathList ret(paths.size(), "");
|
|
||||||
for(auto& p : paths) ret.push_back(p.ToStdString());
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
AppControllerBoilerplate::Path
|
|
||||||
AppControllerBoilerplate::query_destination_path(
|
|
||||||
const std::string &title,
|
|
||||||
const std::string &extensions,
|
|
||||||
const std::string& hint) const
|
|
||||||
{
|
|
||||||
wxFileDialog dlg(wxTheApp->GetTopWindow(), title );
|
|
||||||
dlg.SetWildcard(extensions);
|
|
||||||
|
|
||||||
dlg.SetFilename(hint);
|
|
||||||
|
|
||||||
Path ret;
|
|
||||||
|
|
||||||
if(dlg.ShowModal() == wxID_OK) {
|
|
||||||
ret = Path(dlg.GetPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppControllerBoilerplate::report_issue(IssueType issuetype,
|
|
||||||
const std::string &description,
|
|
||||||
const std::string &brief)
|
|
||||||
{
|
|
||||||
auto icon = wxICON_INFORMATION;
|
|
||||||
switch(issuetype) {
|
|
||||||
case IssueType::INFO: break;
|
|
||||||
case IssueType::WARN: icon = wxICON_WARNING; break;
|
|
||||||
case IssueType::ERR:
|
|
||||||
case IssueType::FATAL: icon = wxICON_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString str = _("Proba szoveg");
|
|
||||||
wxMessageBox(str + _(description), _(brief), icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent);
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
class GuiProgressIndicator:
|
|
||||||
public IProgressIndicator, public wxEvtHandler {
|
|
||||||
|
|
||||||
std::shared_ptr<wxProgressDialog> gauge_;
|
|
||||||
using Base = IProgressIndicator;
|
|
||||||
wxString message_;
|
|
||||||
int range_; wxString title_;
|
|
||||||
unsigned prc_ = 0;
|
|
||||||
bool is_asynch_ = false;
|
|
||||||
|
|
||||||
// status update handler
|
|
||||||
void _state( wxCommandEvent& evt) {
|
|
||||||
unsigned st = evt.GetInt();
|
|
||||||
_state(st);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _state( unsigned st) {
|
|
||||||
if(st < max()) {
|
|
||||||
if(!gauge_) gauge_ = std::make_shared<wxProgressDialog>(
|
|
||||||
title_, message_, range_, wxTheApp->GetTopWindow(),
|
|
||||||
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:
|
|
||||||
|
|
||||||
inline void asynch(bool is) { is_asynch_ = is; }
|
|
||||||
inline bool asynch() const { return is_asynch_; }
|
|
||||||
|
|
||||||
inline GuiProgressIndicator(int range, const std::string& title,
|
|
||||||
const std::string& firstmsg) :
|
|
||||||
range_(range), message_(_(firstmsg)), title_(_(title))
|
|
||||||
{
|
|
||||||
Base::max(static_cast<float>(range));
|
|
||||||
Base::states(static_cast<unsigned>(range));
|
|
||||||
|
|
||||||
Bind(PROGRESS_STATUS_UPDATE_EVENT,
|
|
||||||
&GuiProgressIndicator::_state,
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void state(float val) override {
|
|
||||||
if( val >= 1.0) state(static_cast<unsigned>(val));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void state(unsigned st) override {
|
|
||||||
// send status update event
|
|
||||||
if(is_asynch_) {
|
|
||||||
auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT);
|
|
||||||
evt->SetInt(st);
|
|
||||||
wxQueueEvent(this, evt);
|
|
||||||
} else _state(st);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void message(const std::string & msg) override {
|
|
||||||
message_ = _(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void messageFmt(const std::string& fmt, ...) {
|
|
||||||
va_list arglist;
|
|
||||||
va_start(arglist, fmt);
|
|
||||||
message_ = wxString::Format(_(fmt), arglist);
|
|
||||||
va_end(arglist);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void title(const std::string & title) override {
|
|
||||||
title_ = _(title);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
|
||||||
AppControllerBoilerplate::create_progress_indicator(
|
|
||||||
unsigned statenum, const std::string& title,
|
|
||||||
const std::string& firstmsg) const
|
|
||||||
{
|
|
||||||
auto pri =
|
|
||||||
std::make_shared<GuiProgressIndicator>(statenum, title, firstmsg);
|
|
||||||
|
|
||||||
pri->asynch(!is_main_thread());
|
|
||||||
|
|
||||||
return pri;
|
|
||||||
}
|
|
||||||
|
|
||||||
//AppControllerBoilerplate::ProgresIndicatorPtr
|
|
||||||
//AppControllerBoilerplate::create_progress_indicator(unsigned statenum,
|
|
||||||
// const std::string& title,
|
|
||||||
// const std::string& firstmsg) const
|
|
||||||
//{
|
|
||||||
// class GuiProgressIndicator: public IProgressIndicator, public wxEvtHandler {
|
|
||||||
// using Base = IProgressIndicator;
|
|
||||||
// wxString message_, title_;
|
|
||||||
// wxProgressDialog gauge_;
|
|
||||||
|
|
||||||
// void _state( wxCommandEvent& evt) {
|
|
||||||
// unsigned st = evt.GetInt();
|
|
||||||
|
|
||||||
// if(title_.compare(gauge_.GetTitle()))
|
|
||||||
// gauge_.SetTitle(title_);
|
|
||||||
|
|
||||||
// if(!gauge_.IsShown()) gauge_.ShowModal();
|
|
||||||
// Base::state(st);
|
|
||||||
// gauge_.Update(static_cast<int>(st), message_);
|
|
||||||
|
|
||||||
// }
|
|
||||||
// public:
|
|
||||||
|
|
||||||
// inline GuiProgressIndicator(int range, const std::string& title,
|
|
||||||
// const std::string& firstmsg):
|
|
||||||
// message_(_(firstmsg)), title_(_(title)),
|
|
||||||
// gauge_(title_, message_, range, wxTheApp->GetTopWindow())
|
|
||||||
// {
|
|
||||||
// gauge_.Show(false);
|
|
||||||
|
|
||||||
// Base::max(static_cast<float>(range));
|
|
||||||
// Base::states(static_cast<unsigned>(range));
|
|
||||||
|
|
||||||
// Bind(PROGRESS_STATUS_UPDATE_EVENT,
|
|
||||||
// &GuiProgressIndicator::_state,
|
|
||||||
// this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// virtual void state(float val) override {
|
|
||||||
// if( val >= 1.0) state(static_cast<unsigned>(val));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// virtual void state(unsigned st) override {
|
|
||||||
// // send status update event
|
|
||||||
// auto evt = new wxCommandEvent(PROGRESS_STATUS_UPDATE_EVENT);
|
|
||||||
// evt->SetInt(st);
|
|
||||||
// wxQueueEvent(this, evt);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// virtual void message(const std::string & msg) override {
|
|
||||||
// message_ = _(msg);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// virtual void message_fmt(const std::string& fmt, ...) override {
|
|
||||||
// va_list arglist;
|
|
||||||
// va_start(arglist, fmt);
|
|
||||||
// message_ = wxString::Format(_(fmt), arglist);
|
|
||||||
// va_end(arglist);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// virtual void title(const std::string & title) override {
|
|
||||||
// title_ = _(title);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// auto pri =
|
|
||||||
// std::make_shared<GuiProgressIndicator>(statenum, title, firstmsg);
|
|
||||||
|
|
||||||
// return pri;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void AppController::set_global_progress_indicator_id(
|
|
||||||
unsigned gid,
|
|
||||||
unsigned sid)
|
|
||||||
{
|
|
||||||
|
|
||||||
class Wrapper: public IProgressIndicator {
|
|
||||||
wxGauge *gauge_;
|
|
||||||
wxStatusBar *stbar_;
|
|
||||||
using Base = IProgressIndicator;
|
|
||||||
std::string message_;
|
|
||||||
|
|
||||||
void showProgress(bool show = true) {
|
|
||||||
gauge_->Show(show);
|
|
||||||
gauge_->Pulse();
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
inline Wrapper(wxGauge *gauge, wxStatusBar *stbar):
|
|
||||||
gauge_(gauge), stbar_(stbar)
|
|
||||||
{
|
|
||||||
Base::max(static_cast<float>(gauge->GetRange()));
|
|
||||||
Base::states(static_cast<unsigned>(gauge->GetRange()));
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void state(float val) override {
|
|
||||||
if( val <= max() && val >= 1.0) {
|
|
||||||
Base::state(val);
|
|
||||||
stbar_->SetStatusText(message_);
|
|
||||||
gauge_->SetValue(static_cast<int>(val));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void state(unsigned st) override {
|
|
||||||
if( st <= max() ) {
|
|
||||||
Base::state(st);
|
|
||||||
|
|
||||||
if(!gauge_->IsShown()) showProgress(true);
|
|
||||||
|
|
||||||
stbar_->SetStatusText(message_);
|
|
||||||
if(st == gauge_->GetRange()) {
|
|
||||||
gauge_->SetValue(0);
|
|
||||||
showProgress(false);
|
|
||||||
} else {
|
|
||||||
gauge_->SetValue(static_cast<int>(st));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void message(const std::string & msg) override {
|
|
||||||
message_ = msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void message_fmt(const std::string& fmt, ...) override {
|
|
||||||
va_list arglist;
|
|
||||||
va_start(arglist, fmt);
|
|
||||||
message_ = wxString::Format(_(fmt), arglist);
|
|
||||||
va_end(arglist);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void title(const std::string & /*title*/) override {}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
wxGauge* gauge = dynamic_cast<wxGauge*>(wxWindow::FindWindowById(gid));
|
|
||||||
wxStatusBar* sb = dynamic_cast<wxStatusBar*>(wxWindow::FindWindowById(sid));
|
|
||||||
|
|
||||||
if(gauge && sb) {
|
|
||||||
global_progressind_ = std::make_shared<Wrapper>(gauge, sb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue