Removed Strings.hpp, replaced with wxString
Fixed UTF8 rendering of status messages.
This commit is contained in:
parent
0235f1a821
commit
bb70ad6090
@ -78,6 +78,7 @@ sub new {
|
||||
$self->{statusbar}->Embed;
|
||||
$self->{statusbar}->SetStatusText(L("Version ").$Slic3r::VERSION.L(" - Remember to check for updates at http://github.com/prusa3d/slic3r/releases"));
|
||||
# Make the global status bar and its progress indicator available in C++
|
||||
Slic3r::GUI::set_progress_status_bar($self->{statusbar});
|
||||
$appController->set_global_progress_indicator($self->{statusbar});
|
||||
|
||||
$appController->set_model($self->{plater}->{model});
|
||||
|
@ -263,6 +263,7 @@ add_library(libslic3r_gui STATIC
|
||||
${LIBDIR}/slic3r/GUI/UpdateDialogs.hpp
|
||||
${LIBDIR}/slic3r/GUI/FirmwareDialog.cpp
|
||||
${LIBDIR}/slic3r/GUI/FirmwareDialog.hpp
|
||||
${LIBDIR}/slic3r/GUI/ProgressIndicator.hpp
|
||||
${LIBDIR}/slic3r/GUI/ProgressStatusBar.hpp
|
||||
${LIBDIR}/slic3r/GUI/ProgressStatusBar.cpp
|
||||
${LIBDIR}/slic3r/Utils/Http.cpp
|
||||
@ -285,11 +286,9 @@ add_library(libslic3r_gui STATIC
|
||||
${LIBDIR}/slic3r/Utils/Time.hpp
|
||||
${LIBDIR}/slic3r/Utils/HexFile.cpp
|
||||
${LIBDIR}/slic3r/Utils/HexFile.hpp
|
||||
${LIBDIR}/slic3r/ProgressIndicator.hpp
|
||||
${LIBDIR}/slic3r/AppController.hpp
|
||||
${LIBDIR}/slic3r/AppController.cpp
|
||||
${LIBDIR}/slic3r/AppControllerWx.cpp
|
||||
${LIBDIR}/slic3r/Strings.hpp
|
||||
)
|
||||
|
||||
add_library(admesh STATIC
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
//#include "slic3r/ProgressIndicator.hpp"
|
||||
#include "PrintExport.hpp"
|
||||
|
||||
//! macro used to mark string used at localization,
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <ModelArrange.hpp>
|
||||
#include <slic3r/GUI/PresetBundle.hpp>
|
||||
|
||||
#include <PrintConfig.hpp>
|
||||
#include <Print.hpp>
|
||||
#include <PrintExport.hpp>
|
||||
#include <Geometry.hpp>
|
||||
@ -409,7 +408,7 @@ const PrintConfig &PrintController::config() const
|
||||
#endif
|
||||
|
||||
void ProgressIndicator::message_fmt(
|
||||
const string &fmtstr, ...) {
|
||||
const wxString &fmtstr, ...) {
|
||||
std::stringstream ss;
|
||||
va_list args;
|
||||
va_start(args, fmtstr);
|
||||
|
@ -7,7 +7,9 @@
|
||||
#include <atomic>
|
||||
#include <iostream>
|
||||
|
||||
#include "ProgressIndicator.hpp"
|
||||
#include "GUI/ProgressIndicator.hpp"
|
||||
|
||||
#include <PrintConfig.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@ -46,7 +48,7 @@ public:
|
||||
AppControllerBoilerplate();
|
||||
~AppControllerBoilerplate();
|
||||
|
||||
using Path = string;
|
||||
using Path = wxString;
|
||||
using PathList = std::vector<Path>;
|
||||
|
||||
/// Common runtime issue types
|
||||
@ -67,20 +69,20 @@ public:
|
||||
* @return Returns a list of paths choosed by the user.
|
||||
*/
|
||||
PathList query_destination_paths(
|
||||
const string& title,
|
||||
const wxString& title,
|
||||
const std::string& extensions) const;
|
||||
|
||||
/**
|
||||
* @brief Same as query_destination_paths but works for directories only.
|
||||
*/
|
||||
PathList query_destination_dirs(
|
||||
const string& title) const;
|
||||
const wxString& title) const;
|
||||
|
||||
/**
|
||||
* @brief Same as query_destination_paths but returns only one path.
|
||||
*/
|
||||
Path query_destination_path(
|
||||
const string& title,
|
||||
const wxString& title,
|
||||
const std::string& extensions,
|
||||
const std::string& hint = "") const;
|
||||
|
||||
@ -95,11 +97,11 @@ public:
|
||||
* title.
|
||||
*/
|
||||
bool report_issue(IssueType issuetype,
|
||||
const string& description,
|
||||
const string& brief);
|
||||
const wxString& description,
|
||||
const wxString& brief);
|
||||
|
||||
bool report_issue(IssueType issuetype,
|
||||
const string& description);
|
||||
const wxString& description);
|
||||
|
||||
/**
|
||||
* @brief Return the global progress indicator for the current controller.
|
||||
@ -150,12 +152,12 @@ protected:
|
||||
*/
|
||||
ProgresIndicatorPtr create_progress_indicator(
|
||||
unsigned statenum,
|
||||
const string& title,
|
||||
const string& firstmsg) const;
|
||||
const wxString& title,
|
||||
const wxString& firstmsg) const;
|
||||
|
||||
ProgresIndicatorPtr create_progress_indicator(
|
||||
unsigned statenum,
|
||||
const string& title) const;
|
||||
const wxString& title) const;
|
||||
|
||||
// This is a global progress indicator placeholder. In the Slic3r UI it can
|
||||
// contain the progress indicator on the statusbar.
|
||||
|
@ -33,7 +33,7 @@ void AppControllerBoilerplate::process_events()
|
||||
|
||||
AppControllerBoilerplate::PathList
|
||||
AppControllerBoilerplate::query_destination_paths(
|
||||
const string &title,
|
||||
const wxString &title,
|
||||
const std::string &extensions) const
|
||||
{
|
||||
|
||||
@ -53,7 +53,7 @@ AppControllerBoilerplate::query_destination_paths(
|
||||
|
||||
AppControllerBoilerplate::Path
|
||||
AppControllerBoilerplate::query_destination_path(
|
||||
const string &title,
|
||||
const wxString &title,
|
||||
const std::string &extensions,
|
||||
const std::string& hint) const
|
||||
{
|
||||
@ -72,8 +72,8 @@ AppControllerBoilerplate::query_destination_path(
|
||||
}
|
||||
|
||||
bool AppControllerBoilerplate::report_issue(IssueType issuetype,
|
||||
const string &description,
|
||||
const string &brief)
|
||||
const wxString &description,
|
||||
const wxString &brief)
|
||||
{
|
||||
auto icon = wxICON_INFORMATION;
|
||||
auto style = wxOK|wxCENTRE;
|
||||
@ -91,9 +91,9 @@ bool AppControllerBoilerplate::report_issue(IssueType issuetype,
|
||||
|
||||
bool AppControllerBoilerplate::report_issue(
|
||||
AppControllerBoilerplate::IssueType issuetype,
|
||||
const string &description)
|
||||
const wxString &description)
|
||||
{
|
||||
return report_issue(issuetype, description, string());
|
||||
return report_issue(issuetype, description, wxString());
|
||||
}
|
||||
|
||||
wxDEFINE_EVENT(PROGRESS_STATUS_UPDATE_EVENT, wxCommandEvent);
|
||||
@ -137,8 +137,8 @@ public:
|
||||
/// Get the mode of parallel operation.
|
||||
inline bool asynch() const { return is_asynch_; }
|
||||
|
||||
inline GuiProgressIndicator(int range, const string& title,
|
||||
const string& firstmsg) :
|
||||
inline GuiProgressIndicator(int range, const wxString& title,
|
||||
const wxString& firstmsg) :
|
||||
gauge_(title, firstmsg, range, wxTheApp->GetTopWindow(),
|
||||
wxPD_APP_MODAL | wxPD_AUTO_HIDE),
|
||||
message_(firstmsg),
|
||||
@ -171,18 +171,18 @@ public:
|
||||
} else _state(st);
|
||||
}
|
||||
|
||||
virtual void message(const string & msg) override {
|
||||
virtual void message(const wxString & msg) override {
|
||||
message_ = msg;
|
||||
}
|
||||
|
||||
virtual void messageFmt(const string& fmt, ...) {
|
||||
virtual void messageFmt(const wxString& fmt, ...) {
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
message_ = wxString::Format(wxString(fmt), arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
virtual void title(const string & title) override {
|
||||
virtual void title(const wxString & title) override {
|
||||
title_ = title;
|
||||
}
|
||||
};
|
||||
@ -190,7 +190,7 @@ public:
|
||||
|
||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||
AppControllerBoilerplate::create_progress_indicator(
|
||||
unsigned statenum, const string& title, const string& firstmsg) const
|
||||
unsigned statenum, const wxString& title, const wxString& firstmsg) const
|
||||
{
|
||||
auto pri =
|
||||
std::make_shared<GuiProgressIndicator>(statenum, title, firstmsg);
|
||||
@ -204,9 +204,9 @@ AppControllerBoilerplate::create_progress_indicator(
|
||||
|
||||
AppControllerBoilerplate::ProgresIndicatorPtr
|
||||
AppControllerBoilerplate::create_progress_indicator(unsigned statenum,
|
||||
const string &title) const
|
||||
const wxString &title) const
|
||||
{
|
||||
return create_progress_indicator(statenum, title, string());
|
||||
return create_progress_indicator(statenum, title, wxString());
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -271,18 +271,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void message(const string & msg) override {
|
||||
virtual void message(const wxString & msg) override {
|
||||
message_ = msg;
|
||||
}
|
||||
|
||||
virtual void message_fmt(const string& fmt, ...) override {
|
||||
virtual void message_fmt(const wxString& fmt, ...) override {
|
||||
va_list arglist;
|
||||
va_start(arglist, fmt);
|
||||
message_ = wxString::Format(fmt, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
||||
virtual void title(const string & /*title*/) override {}
|
||||
virtual void title(const wxString & /*title*/) override {}
|
||||
|
||||
virtual void on_cancel(CancelFn fn) override {
|
||||
sbar_->set_cancel_callback(fn);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <wx/image.h>
|
||||
#include <wx/settings.h>
|
||||
|
||||
// Print now includes tbb, and tbb includes Windows. This breaks compilation of wxWidgets if included before wx.
|
||||
#include "../../libslic3r/Print.hpp"
|
||||
|
||||
#include <tbb/parallel_for.h>
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "AboutDialog.hpp"
|
||||
#include "AppConfig.hpp"
|
||||
#include "ConfigSnapshotDialog.hpp"
|
||||
#include "ProgressStatusBar.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
@ -114,6 +115,7 @@ void break_to_debugger()
|
||||
// Passing the wxWidgets GUI classes instantiated by the Perl part to C++.
|
||||
wxApp *g_wxApp = nullptr;
|
||||
wxFrame *g_wxMainFrame = nullptr;
|
||||
ProgressStatusBar *g_progress_status_bar = nullptr;
|
||||
wxNotebook *g_wxTabPanel = nullptr;
|
||||
wxPanel *g_wxPlater = nullptr;
|
||||
AppConfig *g_AppConfig = nullptr;
|
||||
@ -207,6 +209,13 @@ void set_main_frame(wxFrame *main_frame)
|
||||
|
||||
wxFrame* get_main_frame() { return g_wxMainFrame; }
|
||||
|
||||
void set_progress_status_bar(ProgressStatusBar *prsb)
|
||||
{
|
||||
g_progress_status_bar = prsb;
|
||||
}
|
||||
|
||||
ProgressStatusBar* get_progress_status_bar() { return g_progress_status_bar; }
|
||||
|
||||
void set_tab_panel(wxNotebook *tab_panel)
|
||||
{
|
||||
g_wxTabPanel = tab_panel;
|
||||
|
@ -33,6 +33,7 @@ namespace Slic3r {
|
||||
class PresetBundle;
|
||||
class PresetCollection;
|
||||
class Print;
|
||||
class ProgressStatusBar;
|
||||
class AppConfig;
|
||||
class PresetUpdater;
|
||||
class DynamicPrintConfig;
|
||||
@ -99,6 +100,7 @@ void break_to_debugger();
|
||||
// Passing the wxWidgets GUI classes instantiated by the Perl part to C++.
|
||||
void set_wxapp(wxApp *app);
|
||||
void set_main_frame(wxFrame *main_frame);
|
||||
void set_progress_status_bar(ProgressStatusBar *prsb);
|
||||
void set_tab_panel(wxNotebook *tab_panel);
|
||||
void set_plater(wxPanel *plater);
|
||||
void set_app_config(AppConfig *app_config);
|
||||
@ -123,6 +125,7 @@ AppConfig* get_app_config();
|
||||
wxApp* get_app();
|
||||
PresetBundle* get_preset_bundle();
|
||||
wxFrame* get_main_frame();
|
||||
ProgressStatusBar* get_progress_status_bar();
|
||||
wxNotebook * get_tab_panel();
|
||||
wxNotebook* get_tab_panel();
|
||||
|
||||
|
@ -135,7 +135,7 @@ void ProgressStatusBar::embed(wxFrame *frame)
|
||||
|
||||
void ProgressStatusBar::set_status_text(const std::string& txt)
|
||||
{
|
||||
self->SetStatusText(txt);
|
||||
self->SetStatusText(wxString::FromUTF8(txt.c_str()));
|
||||
}
|
||||
|
||||
void ProgressStatusBar::show_cancel_button()
|
||||
|
@ -1,71 +0,0 @@
|
||||
#ifndef IPROGRESSINDICATOR_HPP
|
||||
#define IPROGRESSINDICATOR_HPP
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include "Strings.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
/**
|
||||
* @brief Generic progress indication interface.
|
||||
*/
|
||||
class ProgressIndicator {
|
||||
public:
|
||||
using CancelFn = std::function<void(void)>; // Cancel function signature.
|
||||
|
||||
private:
|
||||
float state_ = .0f, max_ = 1.f, step_;
|
||||
CancelFn cancelfunc_ = [](){};
|
||||
|
||||
public:
|
||||
|
||||
inline virtual ~ProgressIndicator() {}
|
||||
|
||||
/// Get the maximum of the progress range.
|
||||
float max() const { return max_; }
|
||||
|
||||
/// Get the current progress state
|
||||
float state() const { return state_; }
|
||||
|
||||
/// Set the maximum of the progress range
|
||||
virtual void max(float maxval) { max_ = maxval; }
|
||||
|
||||
/// Set the current state of the progress.
|
||||
virtual void state(float val) { 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;
|
||||
}
|
||||
|
||||
/// Message shown on the next status update.
|
||||
virtual void message(const string&) = 0;
|
||||
|
||||
/// Title of the operation.
|
||||
virtual void title(const string&) = 0;
|
||||
|
||||
/// Formatted message for the next status update. Works just like sprintf.
|
||||
virtual void message_fmt(const string& fmt, ...);
|
||||
|
||||
/// Set up a cancel callback for the operation if feasible.
|
||||
virtual void on_cancel(CancelFn func = CancelFn()) { cancelfunc_ = func; }
|
||||
|
||||
/**
|
||||
* Explicitly shut down the progress indicator and call the associated
|
||||
* callback.
|
||||
*/
|
||||
virtual void cancel() { cancelfunc_(); }
|
||||
|
||||
/// Convenience function to call message and status update in one function.
|
||||
void update(float st, const string& msg) {
|
||||
message(msg); state(st);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // IPROGRESSINDICATOR_HPP
|
@ -1,10 +0,0 @@
|
||||
#ifndef STRINGS_HPP
|
||||
#define STRINGS_HPP
|
||||
|
||||
#include "GUI/GUI.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
using string = wxString;
|
||||
}
|
||||
|
||||
#endif // STRINGS_HPP
|
@ -35,6 +35,9 @@ bool is_windows10()
|
||||
void set_wxapp(SV *ui)
|
||||
%code%{ Slic3r::GUI::set_wxapp((wxApp*)wxPli_sv_2_object(aTHX_ ui, "Wx::App")); %};
|
||||
|
||||
void set_progress_status_bar(ProgressStatusBar *prs)
|
||||
%code%{ Slic3r::GUI::set_progress_status_bar(prs); %};
|
||||
|
||||
void set_main_frame(SV *ui)
|
||||
%code%{ Slic3r::GUI::set_main_frame((wxFrame*)wxPli_sv_2_object(aTHX_ ui, "Wx::Frame")); %};
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
void Embed()
|
||||
%code%{ THIS->embed(); %};
|
||||
|
||||
void SetStatusText(std::string txt)
|
||||
void SetStatusText(const char *txt)
|
||||
%code%{ THIS->set_status_text(txt); %};
|
||||
|
||||
void ShowCancelButton()
|
||||
|
Loading…
Reference in New Issue
Block a user