mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 01:37:53 -06:00
Cleaned code
This commit is contained in:
parent
d82505984a
commit
120c1978ae
8 changed files with 120 additions and 136 deletions
|
@ -75,13 +75,13 @@ namespace Slic3r { namespace GUI {
|
||||||
return tooltip_text;
|
return tooltip_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Field::is_matched(std::string string, std::string pattern)
|
bool Field::is_matched(const std::string& string, const std::string& pattern)
|
||||||
{
|
{
|
||||||
std::regex regex_pattern(pattern, std::regex_constants::icase); // use ::icase to make the matching case insensitive like /i in perl
|
std::regex regex_pattern(pattern, std::regex_constants::icase); // use ::icase to make the matching case insensitive like /i in perl
|
||||||
return std::regex_match(string, regex_pattern);
|
return std::regex_match(string, regex_pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::any Field::get_value_by_opt_type(wxString str)
|
boost::any Field::get_value_by_opt_type(wxString& str)
|
||||||
{
|
{
|
||||||
boost::any ret_val;
|
boost::any ret_val;
|
||||||
switch (m_opt.type){
|
switch (m_opt.type){
|
||||||
|
@ -377,7 +377,7 @@ void Choice::set_selection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Choice::set_value(const std::string value, bool change_event) //! Redundant?
|
void Choice::set_value(const std::string& value, bool change_event) //! Redundant?
|
||||||
{
|
{
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ void Choice::set_value(const std::string value, bool change_event) //! Redundan
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Choice::set_value(boost::any value, bool change_event)
|
void Choice::set_value(const boost::any& value, bool change_event)
|
||||||
{
|
{
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ void Choice::set_value(boost::any value, bool change_event)
|
||||||
}
|
}
|
||||||
|
|
||||||
//! it's needed for _update_serial_ports()
|
//! it's needed for _update_serial_ports()
|
||||||
void Choice::set_values(const std::vector<std::string> values)
|
void Choice::set_values(const std::vector<std::string>& values)
|
||||||
{
|
{
|
||||||
if (values.empty())
|
if (values.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -554,7 +554,7 @@ void PointCtrl::BUILD()
|
||||||
y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
|
y_textctrl->SetToolTip(get_tooltip_text(X+", "+Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointCtrl::set_value(const Pointf value, bool change_event)
|
void PointCtrl::set_value(const Pointf& value, bool change_event)
|
||||||
{
|
{
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
|
|
||||||
|
@ -566,10 +566,10 @@ void PointCtrl::set_value(const Pointf value, bool change_event)
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointCtrl::set_value(boost::any value, bool change_event)
|
void PointCtrl::set_value(const boost::any& value, bool change_event)
|
||||||
{
|
{
|
||||||
Pointf pt;
|
Pointf pt;
|
||||||
Pointf *ptf = boost::any_cast<Pointf>(&value);
|
const Pointf *ptf = boost::any_cast<Pointf>(&value);
|
||||||
if (!ptf)
|
if (!ptf)
|
||||||
{
|
{
|
||||||
ConfigOptionPoints* pts = boost::any_cast<ConfigOptionPoints*>(value);
|
ConfigOptionPoints* pts = boost::any_cast<ConfigOptionPoints*>(value);
|
||||||
|
@ -577,21 +577,6 @@ void PointCtrl::set_value(boost::any value, bool change_event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pt = *ptf;
|
pt = *ptf;
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// pt = boost::any_cast<ConfigOptionPoints*>(value)->values.at(0);
|
|
||||||
// }
|
|
||||||
// catch (const std::exception &e)
|
|
||||||
// {
|
|
||||||
// try{
|
|
||||||
// pt = boost::any_cast<Pointf>(value);
|
|
||||||
// }
|
|
||||||
// catch (const std::exception &e)
|
|
||||||
// {
|
|
||||||
// std::cerr << "Error! Can't cast PointCtrl value" << m_opt_id << "\n";
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
set_value(pt, change_event);
|
set_value(pt, change_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ namespace Slic3r { namespace GUI {
|
||||||
class Field;
|
class Field;
|
||||||
using t_field = std::unique_ptr<Field>;
|
using t_field = std::unique_ptr<Field>;
|
||||||
using t_kill_focus = std::function<void()>;
|
using t_kill_focus = std::function<void()>;
|
||||||
using t_change = std::function<void(t_config_option_key, boost::any)>;
|
using t_change = std::function<void(t_config_option_key, const boost::any&)>;
|
||||||
using t_back_to_init = std::function<void(std::string)>;
|
using t_back_to_init = std::function<void(const std::string&)>;
|
||||||
|
|
||||||
wxString double_to_string(double const value);
|
wxString double_to_string(double const value);
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
/// Sets a value for this control.
|
/// Sets a value for this control.
|
||||||
/// subclasses should overload with a specific version
|
/// subclasses should overload with a specific version
|
||||||
/// Postcondition: Method does not fire the on_change event.
|
/// Postcondition: Method does not fire the on_change event.
|
||||||
virtual void set_value(boost::any value, bool change_event) = 0;
|
virtual void set_value(const boost::any& value, bool change_event) = 0;
|
||||||
|
|
||||||
/// Gets a boost::any representing this control.
|
/// Gets a boost::any representing this control.
|
||||||
/// subclasses should overload with a specific version
|
/// subclasses should overload with a specific version
|
||||||
|
@ -100,7 +100,7 @@ public:
|
||||||
virtual wxString get_tooltip_text(const wxString& default_string);
|
virtual wxString get_tooltip_text(const wxString& default_string);
|
||||||
|
|
||||||
// set icon to "UndoToSystemValue" button according to an inheritance of preset
|
// set icon to "UndoToSystemValue" button according to an inheritance of preset
|
||||||
void set_nonsys_btn_icon(const std::string& icon);
|
void set_nonsys_btn_icon(const std::string& icon);
|
||||||
|
|
||||||
Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {};
|
Field(const ConfigOptionDef& opt, const t_config_option_key& id) : m_opt(opt), m_opt_id(id) {};
|
||||||
Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {};
|
Field(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : m_parent(parent), m_opt(opt), m_opt_id(id) {};
|
||||||
|
@ -109,8 +109,8 @@ public:
|
||||||
virtual wxSizer* getSizer() { return nullptr; }
|
virtual wxSizer* getSizer() { return nullptr; }
|
||||||
virtual wxWindow* getWindow() { return nullptr; }
|
virtual wxWindow* getWindow() { return nullptr; }
|
||||||
|
|
||||||
bool is_matched(std::string string, std::string pattern);
|
bool is_matched(const std::string& string, const std::string& pattern);
|
||||||
boost::any get_value_by_opt_type(wxString str);
|
boost::any get_value_by_opt_type(wxString& str);
|
||||||
|
|
||||||
/// Factory method for generating new derived classes.
|
/// Factory method for generating new derived classes.
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -137,16 +137,17 @@ class TextCtrl : public Field {
|
||||||
public:
|
public:
|
||||||
TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
TextCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||||
TextCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
TextCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||||
|
~TextCtrl() {}
|
||||||
|
|
||||||
void BUILD();
|
void BUILD();
|
||||||
wxWindow* window {nullptr};
|
wxWindow* window {nullptr};
|
||||||
|
|
||||||
virtual void set_value(std::string value, bool change_event = false) {
|
virtual void set_value(const std::string& value, bool change_event = false) {
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
dynamic_cast<wxTextCtrl*>(window)->SetValue(wxString(value));
|
dynamic_cast<wxTextCtrl*>(window)->SetValue(wxString(value));
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
virtual void set_value(boost::any value, bool change_event = false) {
|
virtual void set_value(const boost::any& value, bool change_event = false) {
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
dynamic_cast<wxTextCtrl*>(window)->SetValue(boost::any_cast<wxString>(value));
|
dynamic_cast<wxTextCtrl*>(window)->SetValue(boost::any_cast<wxString>(value));
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
|
@ -164,6 +165,7 @@ class CheckBox : public Field {
|
||||||
public:
|
public:
|
||||||
CheckBox(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
CheckBox(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||||
CheckBox(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
CheckBox(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||||
|
~CheckBox() {}
|
||||||
|
|
||||||
wxWindow* window{ nullptr };
|
wxWindow* window{ nullptr };
|
||||||
void BUILD() override;
|
void BUILD() override;
|
||||||
|
@ -173,7 +175,7 @@ public:
|
||||||
dynamic_cast<wxCheckBox*>(window)->SetValue(value);
|
dynamic_cast<wxCheckBox*>(window)->SetValue(value);
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
void set_value(boost::any value, bool change_event = false) {
|
void set_value(const boost::any& value, bool change_event = false) {
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
dynamic_cast<wxCheckBox*>(window)->SetValue(boost::any_cast<bool>(value));
|
dynamic_cast<wxCheckBox*>(window)->SetValue(boost::any_cast<bool>(value));
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
|
@ -190,21 +192,22 @@ class SpinCtrl : public Field {
|
||||||
public:
|
public:
|
||||||
SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(-9999) {}
|
SpinCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id), tmp_value(-9999) {}
|
||||||
SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(-9999) {}
|
SpinCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id), tmp_value(-9999) {}
|
||||||
|
~SpinCtrl() {}
|
||||||
|
|
||||||
int tmp_value;
|
int tmp_value;
|
||||||
|
|
||||||
wxWindow* window{ nullptr };
|
wxWindow* window{ nullptr };
|
||||||
void BUILD() override;
|
void BUILD() override;
|
||||||
|
|
||||||
void set_value(const std::string value, bool change_event = false) {
|
void set_value(const std::string& value, bool change_event = false) {
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(value);
|
dynamic_cast<wxSpinCtrl*>(window)->SetValue(value);
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
void set_value(boost::any value, bool change_event = false) {
|
void set_value(const boost::any& value, bool change_event = false) {
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
tmp_value = boost::any_cast<int>(value);
|
tmp_value = boost::any_cast<int>(value);
|
||||||
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value/*boost::any_cast<int>(value)*/);
|
dynamic_cast<wxSpinCtrl*>(window)->SetValue(tmp_value);
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
boost::any get_value() override {
|
boost::any get_value() override {
|
||||||
|
@ -221,14 +224,15 @@ class Choice : public Field {
|
||||||
public:
|
public:
|
||||||
Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
Choice(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||||
Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
Choice(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||||
|
~Choice() {}
|
||||||
|
|
||||||
wxWindow* window{ nullptr };
|
wxWindow* window{ nullptr };
|
||||||
void BUILD() override;
|
void BUILD() override;
|
||||||
|
|
||||||
void set_selection();
|
void set_selection();
|
||||||
void set_value(const std::string value, bool change_event = false);
|
void set_value(const std::string& value, bool change_event = false);
|
||||||
void set_value(boost::any value, bool change_event = false);
|
void set_value(const boost::any& value, bool change_event = false);
|
||||||
void set_values(const std::vector<std::string> values);
|
void set_values(const std::vector<std::string> &values);
|
||||||
boost::any get_value() override;
|
boost::any get_value() override;
|
||||||
|
|
||||||
void enable() override { dynamic_cast<wxComboBox*>(window)->Enable(); };
|
void enable() override { dynamic_cast<wxComboBox*>(window)->Enable(); };
|
||||||
|
@ -241,16 +245,17 @@ class ColourPicker : public Field {
|
||||||
public:
|
public:
|
||||||
ColourPicker(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
ColourPicker(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||||
ColourPicker(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
ColourPicker(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||||
|
~ColourPicker() {}
|
||||||
|
|
||||||
wxWindow* window{ nullptr };
|
wxWindow* window{ nullptr };
|
||||||
void BUILD() override;
|
void BUILD() override;
|
||||||
|
|
||||||
void set_value(const std::string value, bool change_event = false) {
|
void set_value(const std::string& value, bool change_event = false) {
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
dynamic_cast<wxColourPickerCtrl*>(window)->SetColour(value);
|
dynamic_cast<wxColourPickerCtrl*>(window)->SetColour(value);
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
void set_value(boost::any value, bool change_event = false) {
|
void set_value(const boost::any& value, bool change_event = false) {
|
||||||
m_disable_change_event = !change_event;
|
m_disable_change_event = !change_event;
|
||||||
dynamic_cast<wxColourPickerCtrl*>(window)->SetColour(boost::any_cast<wxString>(value));
|
dynamic_cast<wxColourPickerCtrl*>(window)->SetColour(boost::any_cast<wxString>(value));
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
|
@ -268,23 +273,24 @@ class PointCtrl : public Field {
|
||||||
public:
|
public:
|
||||||
PointCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
PointCtrl(const ConfigOptionDef& opt, const t_config_option_key& id) : Field(opt, id) {}
|
||||||
PointCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
PointCtrl(wxWindow* parent, const ConfigOptionDef& opt, const t_config_option_key& id) : Field(parent, opt, id) {}
|
||||||
|
~PointCtrl() {}
|
||||||
|
|
||||||
wxSizer* sizer{ nullptr };
|
wxSizer* sizer{ nullptr };
|
||||||
wxTextCtrl* x_textctrl;
|
wxTextCtrl* x_textctrl{ nullptr };
|
||||||
wxTextCtrl* y_textctrl;
|
wxTextCtrl* y_textctrl{ nullptr };
|
||||||
|
|
||||||
void BUILD() override;
|
void BUILD() override;
|
||||||
|
|
||||||
void set_value(const Pointf value, bool change_event = false);
|
void set_value(const Pointf& value, bool change_event = false);
|
||||||
void set_value(boost::any value, bool change_event = false);
|
void set_value(const boost::any& value, bool change_event = false);
|
||||||
boost::any get_value() override;
|
boost::any get_value() override;
|
||||||
|
|
||||||
void enable() override {
|
void enable() override {
|
||||||
x_textctrl->Enable();
|
x_textctrl->Enable();
|
||||||
y_textctrl->Enable(); };
|
y_textctrl->Enable(); }
|
||||||
void disable() override{
|
void disable() override{
|
||||||
x_textctrl->Disable();
|
x_textctrl->Disable();
|
||||||
y_textctrl->Disable(); };
|
y_textctrl->Disable(); }
|
||||||
wxSizer* getSizer() override { return sizer; }
|
wxSizer* getSizer() override { return sizer; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -403,7 +403,7 @@ TabIface* get_preset_tab_iface(char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element)
|
// opt_index = 0, by the reason of zero-index in ConfigOptionVector by default (in case only one element)
|
||||||
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index /*= 0*/)
|
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index /*= 0*/)
|
||||||
{
|
{
|
||||||
try{
|
try{
|
||||||
switch (config.def()->get(opt_key)->type){
|
switch (config.def()->get(opt_key)->type){
|
||||||
|
@ -439,10 +439,17 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
|
||||||
config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
|
config.set_key_value(opt_key, new ConfigOptionString(boost::any_cast<std::string>(value)));
|
||||||
break;
|
break;
|
||||||
case coStrings:{
|
case coStrings:{
|
||||||
if (opt_key.compare("compatible_printers") == 0 ||
|
if (opt_key.compare("compatible_printers") == 0) {
|
||||||
config.def()->get(opt_key)->gui_flags.compare("serialized") == 0){
|
config.option<ConfigOptionStrings>(opt_key)->values =
|
||||||
config.option<ConfigOptionStrings>(opt_key)->values.resize(0);
|
boost::any_cast<std::vector<std::string>>(value);
|
||||||
std::vector<std::string> values = boost::any_cast<std::vector<std::string>>(value);
|
}
|
||||||
|
else if (config.def()->get(opt_key)->gui_flags.compare("serialized") == 0){
|
||||||
|
std::string str = boost::any_cast<std::string>(value);
|
||||||
|
if (str.back() == ';') str.pop_back();
|
||||||
|
// Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values.
|
||||||
|
// Currently used for the post_process config value only.
|
||||||
|
std::vector<std::string> values;
|
||||||
|
boost::split(values, str, boost::is_any_of(";"));
|
||||||
if (values.size() == 1 && values[0] == "")
|
if (values.size() == 1 && values[0] == "")
|
||||||
break;
|
break;
|
||||||
config.option<ConfigOptionStrings>(opt_key)->values = values;
|
config.option<ConfigOptionStrings>(opt_key)->values = values;
|
||||||
|
@ -510,17 +517,17 @@ void add_created_tab(Tab* panel)
|
||||||
g_wxTabPanel->AddPage(panel, panel->title());
|
g_wxTabPanel->AddPage(panel, panel->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_error(wxWindow* parent, wxString message){
|
void show_error(wxWindow* parent, const wxString& message){
|
||||||
auto msg_wingow = new wxMessageDialog(parent, message, _(L("Error")), wxOK | wxICON_ERROR);
|
auto msg_wingow = new wxMessageDialog(parent, message, _(L("Error")), wxOK | wxICON_ERROR);
|
||||||
msg_wingow->ShowModal();
|
msg_wingow->ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_info(wxWindow* parent, wxString message, wxString title){
|
void show_info(wxWindow* parent, const wxString& message, const wxString& title){
|
||||||
auto msg_wingow = new wxMessageDialog(parent, message, title.empty() ? _(L("Notice")) : title, wxOK | wxICON_INFORMATION);
|
auto msg_wingow = new wxMessageDialog(parent, message, title.empty() ? _(L("Notice")) : title, wxOK | wxICON_INFORMATION);
|
||||||
msg_wingow->ShowModal();
|
msg_wingow->ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void warning_catcher(wxWindow* parent, wxString message){
|
void warning_catcher(wxWindow* parent, const wxString& message){
|
||||||
if (message == _(L("GLUquadricObjPtr | Attempt to free unreferenced scalar")) )
|
if (message == _(L("GLUquadricObjPtr | Attempt to free unreferenced scalar")) )
|
||||||
return;
|
return;
|
||||||
auto msg = new wxMessageDialog(parent, message, _(L("Warning")), wxOK | wxICON_WARNING);
|
auto msg = new wxMessageDialog(parent, message, _(L("Warning")), wxOK | wxICON_WARNING);
|
||||||
|
|
|
@ -96,11 +96,11 @@ TabIface* get_preset_tab_iface(char *name);
|
||||||
// add it at the end of the tab panel.
|
// add it at the end of the tab panel.
|
||||||
void add_created_tab(Tab* panel);
|
void add_created_tab(Tab* panel);
|
||||||
// Change option value in config
|
// Change option value in config
|
||||||
void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, boost::any value, int opt_index = 0);
|
void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0);
|
||||||
|
|
||||||
void show_error(wxWindow* parent, wxString message);
|
void show_error(wxWindow* parent, const wxString& message);
|
||||||
void show_info(wxWindow* parent, wxString message, wxString title);
|
void show_info(wxWindow* parent, const wxString& message, const wxString& title);
|
||||||
void warning_catcher(wxWindow* parent, wxString message);
|
void warning_catcher(wxWindow* parent, const wxString& message);
|
||||||
|
|
||||||
// load language saved at application config
|
// load language saved at application config
|
||||||
bool load_language();
|
bool load_language();
|
||||||
|
|
|
@ -227,12 +227,12 @@ Line OptionsGroup::create_single_option_line(const Option& option) const {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsGroup::on_change_OG(t_config_option_key id, /*config_value*/boost::any value) {
|
void OptionsGroup::on_change_OG(const t_config_option_key& opt_id, const boost::any& value) {
|
||||||
if (m_on_change != nullptr)
|
if (m_on_change != nullptr)
|
||||||
m_on_change(id, value);
|
m_on_change(opt_id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Option ConfigOptionsGroup::get_option(const std::string opt_key, int opt_index /*= -1*/)
|
Option ConfigOptionsGroup::get_option(const std::string& opt_key, int opt_index /*= -1*/)
|
||||||
{
|
{
|
||||||
if (!m_config->has(opt_key)) {
|
if (!m_config->has(opt_key)) {
|
||||||
std::cerr << "No " << opt_key << " in ConfigOptionsGroup config.";
|
std::cerr << "No " << opt_key << " in ConfigOptionsGroup config.";
|
||||||
|
@ -245,7 +245,7 @@ Option ConfigOptionsGroup::get_option(const std::string opt_key, int opt_index /
|
||||||
return Option(*m_config->def()->get(opt_key), opt_id);
|
return Option(*m_config->def()->get(opt_key), opt_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any value)
|
void ConfigOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const boost::any& value)
|
||||||
{
|
{
|
||||||
if (!m_opt_map.empty())
|
if (!m_opt_map.empty())
|
||||||
{
|
{
|
||||||
|
@ -268,16 +268,7 @@ void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any val
|
||||||
if (opt_index != -1){
|
if (opt_index != -1){
|
||||||
// die "Can't set serialized option indexed value" ;
|
// die "Can't set serialized option indexed value" ;
|
||||||
}
|
}
|
||||||
// # Split a string to multiple strings by a semi - colon.This is the old way of storing multi - string values.
|
change_opt_value(*m_config, opt_key, value);
|
||||||
// # Currently used for the post_process config value only.
|
|
||||||
// my @values = split / ; / , $field_value;
|
|
||||||
// $self->config->set($opt_key, \@values);
|
|
||||||
std::string str = boost::any_cast<std::string>(value);
|
|
||||||
if (str.back() == ';')
|
|
||||||
str.pop_back();
|
|
||||||
std::vector<std::string> values;
|
|
||||||
boost::split(values, str, boost::is_any_of(";"));
|
|
||||||
change_opt_value(*m_config, opt_key, values);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (opt_index == -1) {
|
if (opt_index == -1) {
|
||||||
|
@ -297,14 +288,14 @@ void ConfigOptionsGroup::on_change_OG(t_config_option_key opt_id, boost::any val
|
||||||
OptionsGroup::on_change_OG(opt_id, value); //!? Why doing this
|
OptionsGroup::on_change_OG(opt_id, value); //!? Why doing this
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigOptionsGroup::back_to_initial_value(const std::string opt_key)
|
void ConfigOptionsGroup::back_to_initial_value(const std::string& opt_key)
|
||||||
{
|
{
|
||||||
if (m_get_initial_config == nullptr)
|
if (m_get_initial_config == nullptr)
|
||||||
return;
|
return;
|
||||||
back_to_config_value(m_get_initial_config(), opt_key);
|
back_to_config_value(m_get_initial_config(), opt_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigOptionsGroup::back_to_sys_value(const std::string opt_key)
|
void ConfigOptionsGroup::back_to_sys_value(const std::string& opt_key)
|
||||||
{
|
{
|
||||||
if (m_get_sys_config == nullptr)
|
if (m_get_sys_config == nullptr)
|
||||||
return;
|
return;
|
||||||
|
@ -313,7 +304,7 @@ void ConfigOptionsGroup::back_to_sys_value(const std::string opt_key)
|
||||||
back_to_config_value(m_get_sys_config(), opt_key);
|
back_to_config_value(m_get_sys_config(), opt_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, const std::string opt_key)
|
void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, const std::string& opt_key)
|
||||||
{
|
{
|
||||||
boost::any value;
|
boost::any value;
|
||||||
if (opt_key == "extruders_count"){
|
if (opt_key == "extruders_count"){
|
||||||
|
@ -348,7 +339,7 @@ void ConfigOptionsGroup::reload_config(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index, bool deserialize){
|
boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize){
|
||||||
|
|
||||||
if (deserialize) {
|
if (deserialize) {
|
||||||
// Want to edit a vector value(currently only multi - strings) in a single edit box.
|
// Want to edit a vector value(currently only multi - strings) in a single edit box.
|
||||||
|
@ -365,7 +356,7 @@ boost::any ConfigOptionsGroup::config_value(std::string opt_key, int opt_index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config, std::string opt_key, int opt_index /*= -1*/)
|
boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index /*= -1*/)
|
||||||
{
|
{
|
||||||
size_t idx = opt_index == -1 ? 0 : opt_index;
|
size_t idx = opt_index == -1 ? 0 : opt_index;
|
||||||
|
|
||||||
|
@ -457,7 +448,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field* ConfigOptionsGroup::get_fieldc(t_config_option_key opt_key, int opt_index){
|
Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int opt_index){
|
||||||
Field* field = get_field(opt_key);
|
Field* field = get_field(opt_key);
|
||||||
if (field != nullptr)
|
if (field != nullptr)
|
||||||
return field;
|
return field;
|
||||||
|
@ -471,7 +462,7 @@ Field* ConfigOptionsGroup::get_fieldc(t_config_option_key opt_key, int opt_index
|
||||||
return opt_id.empty() ? nullptr : get_field(opt_id);
|
return opt_id.empty() ? nullptr : get_field(opt_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ogStaticText::SetText(wxString value)
|
void ogStaticText::SetText(const wxString& value)
|
||||||
{
|
{
|
||||||
SetLabel(value);
|
SetLabel(value);
|
||||||
Wrap(400);
|
Wrap(400);
|
||||||
|
|
|
@ -98,16 +98,16 @@ public:
|
||||||
void append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); }
|
void append_single_option_line(const Option& option) { append_line(create_single_option_line(option)); }
|
||||||
|
|
||||||
// return a non-owning pointer reference
|
// return a non-owning pointer reference
|
||||||
inline Field* get_field(t_config_option_key id) const{
|
inline Field* get_field(const t_config_option_key& id) const{
|
||||||
if (m_fields.find(id) == m_fields.end()) return nullptr;
|
if (m_fields.find(id) == m_fields.end()) return nullptr;
|
||||||
return m_fields.at(id).get();
|
return m_fields.at(id).get();
|
||||||
}
|
}
|
||||||
bool set_value(t_config_option_key id, boost::any value, bool change_event = false) {
|
bool set_value(const t_config_option_key& id, const boost::any& value, bool change_event = false) {
|
||||||
if (m_fields.find(id) == m_fields.end()) return false;
|
if (m_fields.find(id) == m_fields.end()) return false;
|
||||||
m_fields.at(id)->set_value(value, change_event);
|
m_fields.at(id)->set_value(value, change_event);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boost::any get_value(t_config_option_key id) {
|
boost::any get_value(const t_config_option_key& id) {
|
||||||
boost::any out;
|
boost::any out;
|
||||||
if (m_fields.find(id) == m_fields.end()) ;
|
if (m_fields.find(id) == m_fields.end()) ;
|
||||||
else
|
else
|
||||||
|
@ -118,7 +118,7 @@ public:
|
||||||
inline void enable() { for (auto& field : m_fields) field.second->enable(); }
|
inline void enable() { for (auto& field : m_fields) field.second->enable(); }
|
||||||
inline void disable() { for (auto& field : m_fields) field.second->disable(); }
|
inline void disable() { for (auto& field : m_fields) field.second->disable(); }
|
||||||
|
|
||||||
OptionsGroup(wxWindow* _parent, wxString title, bool is_tab_opt=false) :
|
OptionsGroup(wxWindow* _parent, const wxString& title, bool is_tab_opt=false) :
|
||||||
m_parent(_parent), title(title), m_is_tab_opt(is_tab_opt), staticbox(title!="") {
|
m_parent(_parent), title(title), m_is_tab_opt(is_tab_opt), staticbox(title!="") {
|
||||||
sizer = (staticbox ? new wxStaticBoxSizer(new wxStaticBox(_parent, wxID_ANY, title), wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
|
sizer = (staticbox ? new wxStaticBoxSizer(new wxStaticBox(_parent, wxID_ANY, title), wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
|
||||||
auto num_columns = 1U;
|
auto num_columns = 1U;
|
||||||
|
@ -152,14 +152,14 @@ protected:
|
||||||
const t_field& build_field(const Option& opt, wxStaticText* label = nullptr);
|
const t_field& build_field(const Option& opt, wxStaticText* label = nullptr);
|
||||||
|
|
||||||
virtual void on_kill_focus (){};
|
virtual void on_kill_focus (){};
|
||||||
virtual void on_change_OG(t_config_option_key opt_id, boost::any value);
|
virtual void on_change_OG(const t_config_option_key& opt_id, const boost::any& value);
|
||||||
virtual void back_to_initial_value(const std::string opt_key){};
|
virtual void back_to_initial_value(const std::string& opt_key){}
|
||||||
virtual void back_to_sys_value(const std::string opt_key){};
|
virtual void back_to_sys_value(const std::string& opt_key){}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigOptionsGroup: public OptionsGroup {
|
class ConfigOptionsGroup: public OptionsGroup {
|
||||||
public:
|
public:
|
||||||
ConfigOptionsGroup(wxWindow* parent, wxString title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false) :
|
ConfigOptionsGroup(wxWindow* parent, const wxString& title, DynamicPrintConfig* _config = nullptr, bool is_tab_opt = false) :
|
||||||
OptionsGroup(parent, title, is_tab_opt), m_config(_config) {}
|
OptionsGroup(parent, title, is_tab_opt), m_config(_config) {}
|
||||||
|
|
||||||
/// reference to libslic3r config, non-owning pointer (?).
|
/// reference to libslic3r config, non-owning pointer (?).
|
||||||
|
@ -167,8 +167,8 @@ public:
|
||||||
bool m_full_labels {0};
|
bool m_full_labels {0};
|
||||||
t_opt_map m_opt_map;
|
t_opt_map m_opt_map;
|
||||||
|
|
||||||
Option get_option(const std::string opt_key, int opt_index = -1);
|
Option get_option(const std::string& opt_key, int opt_index = -1);
|
||||||
Line create_single_option_line(const std::string title, int idx = -1) /*const*/{
|
Line create_single_option_line(const std::string& title, int idx = -1) /*const*/{
|
||||||
Option option = get_option(title, idx);
|
Option option = get_option(title, idx);
|
||||||
return OptionsGroup::create_single_option_line(option);
|
return OptionsGroup::create_single_option_line(option);
|
||||||
}
|
}
|
||||||
|
@ -181,16 +181,16 @@ public:
|
||||||
append_single_option_line(option);
|
append_single_option_line(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_change_OG(t_config_option_key opt_id, boost::any value) override;
|
void on_change_OG(const t_config_option_key& opt_id, const boost::any& value) override;
|
||||||
void back_to_initial_value(const std::string opt_key) override;
|
void back_to_initial_value(const std::string& opt_key) override;
|
||||||
void back_to_sys_value(const std::string opt_key) override;
|
void back_to_sys_value(const std::string& opt_key) override;
|
||||||
void back_to_config_value(const DynamicPrintConfig& config, const std::string opt_key);
|
void back_to_config_value(const DynamicPrintConfig& config, const std::string& opt_key);
|
||||||
void on_kill_focus() override{ reload_config();}
|
void on_kill_focus() override{ reload_config();}
|
||||||
void reload_config();
|
void reload_config();
|
||||||
boost::any config_value(std::string opt_key, int opt_index, bool deserialize);
|
boost::any config_value(const std::string& opt_key, int opt_index, bool deserialize);
|
||||||
// return option value from config
|
// return option value from config
|
||||||
boost::any get_config_value(const DynamicPrintConfig& config, std::string opt_key, int opt_index = -1);
|
boost::any get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index = -1);
|
||||||
Field* get_fieldc(t_config_option_key opt_key, int opt_index);
|
Field* get_fieldc(const t_config_option_key& opt_key, int opt_index);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Static text shown among the options.
|
// Static text shown among the options.
|
||||||
|
@ -200,7 +200,7 @@ public:
|
||||||
ogStaticText(wxWindow* parent, const char *text) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize){}
|
ogStaticText(wxWindow* parent, const char *text) : wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize){}
|
||||||
~ogStaticText(){}
|
~ogStaticText(){}
|
||||||
|
|
||||||
void SetText(wxString value);
|
void SetText(const wxString& value);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -203,11 +203,10 @@ void Tab::load_initial_data()
|
||||||
{
|
{
|
||||||
m_config = &m_presets->get_edited_preset().config;
|
m_config = &m_presets->get_edited_preset().config;
|
||||||
m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ?
|
m_nonsys_btn_icon = m_presets->get_selected_preset_parent() == nullptr ?
|
||||||
"bullet_white.png" : "sys_unlock.png";
|
"bullet_white.png" : "sys_unlock.png";
|
||||||
// wxMSW ? "sys_unlock.png" : "lock_open.png";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PageShp Tab::add_options_page(wxString title, std::string icon, bool is_extruder_pages/* = false*/)
|
PageShp Tab::add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages/* = false*/)
|
||||||
{
|
{
|
||||||
// Index of icon in an icon list $self->{icons}.
|
// Index of icon in an icon list $self->{icons}.
|
||||||
auto icon_idx = 0;
|
auto icon_idx = 0;
|
||||||
|
@ -332,8 +331,8 @@ void Tab::update_changed_ui()
|
||||||
{
|
{
|
||||||
bool is_nonsys_value = false;
|
bool is_nonsys_value = false;
|
||||||
bool is_modified_value = true;
|
bool is_modified_value = true;
|
||||||
std::string sys_icon = /*wxMSW ? */"sys_lock.png"/* : "lock.png"*/;
|
std::string sys_icon = "sys_lock.png";
|
||||||
std::string icon = /*wxMSW ? */"action_undo.png"/* : "arrow_undo.png"*/;
|
std::string icon = "action_undo.png";
|
||||||
wxColour color = get_sys_label_clr();
|
wxColour color = get_sys_label_clr();
|
||||||
if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) {
|
if (find(m_sys_options.begin(), m_sys_options.end(), opt_key) == m_sys_options.end()) {
|
||||||
is_nonsys_value = true;
|
is_nonsys_value = true;
|
||||||
|
@ -478,10 +477,8 @@ void Tab::update_changed_tree_ui()
|
||||||
|
|
||||||
void Tab::update_undo_buttons()
|
void Tab::update_undo_buttons()
|
||||||
{
|
{
|
||||||
const std::string& undo_icon = !m_is_modified_values ? "bullet_white.png" :
|
const std::string& undo_icon = !m_is_modified_values ? "bullet_white.png" : "action_undo.png";
|
||||||
/*wxMSW ? */"action_undo.png"/* : "arrow_undo.png"*/;
|
const std::string& undo_to_sys_icon = m_is_nonsys_values ? m_nonsys_btn_icon : "sys_lock.png";
|
||||||
const std::string& undo_to_sys_icon = m_is_nonsys_values ? m_nonsys_btn_icon :
|
|
||||||
/*wxMSW ? */"sys_lock.png"/* : "lock.png"*/;
|
|
||||||
|
|
||||||
m_undo_btn->SetBitmap(wxBitmap(from_u8(var(undo_icon)), wxBITMAP_TYPE_PNG));
|
m_undo_btn->SetBitmap(wxBitmap(from_u8(var(undo_icon)), wxBITMAP_TYPE_PNG));
|
||||||
m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG));
|
m_undo_to_sys_btn->SetBitmap(wxBitmap(from_u8(var(undo_to_sys_icon)), wxBITMAP_TYPE_PNG));
|
||||||
|
@ -559,7 +556,7 @@ void Tab::update_tab_ui()
|
||||||
|
|
||||||
// Load a provied DynamicConfig into the tab, modifying the active preset.
|
// Load a provied DynamicConfig into the tab, modifying the active preset.
|
||||||
// This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view.
|
// This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view.
|
||||||
void Tab::load_config(DynamicPrintConfig config)
|
void Tab::load_config(const DynamicPrintConfig& config)
|
||||||
{
|
{
|
||||||
bool modified = 0;
|
bool modified = 0;
|
||||||
for(auto opt_key : m_config->diff(config)) {
|
for(auto opt_key : m_config->diff(config)) {
|
||||||
|
@ -582,7 +579,7 @@ void Tab::reload_config(){
|
||||||
Thaw();
|
Thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
Field* Tab::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const
|
Field* Tab::get_field(const t_config_option_key& opt_key, int opt_index/* = -1*/) const
|
||||||
{
|
{
|
||||||
Field* field = nullptr;
|
Field* field = nullptr;
|
||||||
for (auto page : m_pages){
|
for (auto page : m_pages){
|
||||||
|
@ -596,7 +593,7 @@ Field* Tab::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const
|
||||||
// Set a key/value pair on this page. Return true if the value has been modified.
|
// Set a key/value pair on this page. Return true if the value has been modified.
|
||||||
// Currently used for distributing extruders_count over preset pages of Slic3r::GUI::Tab::Printer
|
// Currently used for distributing extruders_count over preset pages of Slic3r::GUI::Tab::Printer
|
||||||
// after a preset is loaded.
|
// after a preset is loaded.
|
||||||
bool Tab::set_value(t_config_option_key opt_key, boost::any value){
|
bool Tab::set_value(const t_config_option_key& opt_key, const boost::any& value){
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for(auto page: m_pages) {
|
for(auto page: m_pages) {
|
||||||
if (page->set_value(opt_key, value))
|
if (page->set_value(opt_key, value))
|
||||||
|
@ -607,7 +604,7 @@ bool Tab::set_value(t_config_option_key opt_key, boost::any value){
|
||||||
|
|
||||||
// To be called by custom widgets, load a value into a config,
|
// To be called by custom widgets, load a value into a config,
|
||||||
// update the preset selection boxes (the dirty flags)
|
// update the preset selection boxes (the dirty flags)
|
||||||
void Tab::load_key_value(std::string opt_key, boost::any value)
|
void Tab::load_key_value(const std::string& opt_key, const boost::any& value)
|
||||||
{
|
{
|
||||||
change_opt_value(*m_config, opt_key, value);
|
change_opt_value(*m_config, opt_key, value);
|
||||||
// Mark the print & filament enabled if they are compatible with the currently selected preset.
|
// Mark the print & filament enabled if they are compatible with the currently selected preset.
|
||||||
|
@ -621,7 +618,7 @@ void Tab::load_key_value(std::string opt_key, boost::any value)
|
||||||
|
|
||||||
extern wxFrame *g_wxMainFrame;
|
extern wxFrame *g_wxMainFrame;
|
||||||
|
|
||||||
void Tab::on_value_change(std::string opt_key, boost::any value)
|
void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
||||||
{
|
{
|
||||||
if (m_event_value_change > 0) {
|
if (m_event_value_change > 0) {
|
||||||
wxCommandEvent event(m_event_value_change);
|
wxCommandEvent event(m_event_value_change);
|
||||||
|
@ -636,8 +633,8 @@ void Tab::on_value_change(std::string opt_key, boost::any value)
|
||||||
}
|
}
|
||||||
if (opt_key == "fill_density")
|
if (opt_key == "fill_density")
|
||||||
{
|
{
|
||||||
value = get_optgroup()->get_config_value(*m_config, opt_key);
|
boost::any val = get_optgroup()->get_config_value(*m_config, opt_key);
|
||||||
get_optgroup()->set_value(opt_key, value);
|
get_optgroup()->set_value(opt_key, val);
|
||||||
}
|
}
|
||||||
if (opt_key == "support_material" || opt_key == "support_material_buildplate_only")
|
if (opt_key == "support_material" || opt_key == "support_material_buildplate_only")
|
||||||
{
|
{
|
||||||
|
@ -1785,9 +1782,7 @@ void Tab::load_current_preset()
|
||||||
// Reload preset pages with the new configuration values.
|
// Reload preset pages with the new configuration values.
|
||||||
reload_config();
|
reload_config();
|
||||||
const Preset* parent = m_presets->get_selected_preset_parent();
|
const Preset* parent = m_presets->get_selected_preset_parent();
|
||||||
m_nonsys_btn_icon = parent == nullptr ?
|
m_nonsys_btn_icon = parent == nullptr ? "bullet_white.png" : "sys_unlock.png";
|
||||||
"bullet_white.png" :
|
|
||||||
/*wxMSW ? */"sys_unlock.png"/* : "lock_open.png"*/;
|
|
||||||
|
|
||||||
// use CallAfter because some field triggers schedule on_change calls using CallAfter,
|
// use CallAfter because some field triggers schedule on_change calls using CallAfter,
|
||||||
// and we don't want them to be called after this update_dirty() as they would mark the
|
// and we don't want them to be called after this update_dirty() as they would mark the
|
||||||
|
@ -1844,7 +1839,7 @@ void Tab::rebuild_page_tree()
|
||||||
// Called by the UI combo box when the user switches profiles.
|
// Called by the UI combo box when the user switches profiles.
|
||||||
// Select a preset by a name.If !defined(name), then the default preset is selected.
|
// Select a preset by a name.If !defined(name), then the default preset is selected.
|
||||||
// If the current profile is modified, user is asked to save the changes.
|
// If the current profile is modified, user is asked to save the changes.
|
||||||
void Tab::select_preset(std::string preset_name /*= ""*/)
|
void Tab::select_preset(const std::string& preset_name /*= ""*/)
|
||||||
{
|
{
|
||||||
std::string name = preset_name;
|
std::string name = preset_name;
|
||||||
auto force = false;
|
auto force = false;
|
||||||
|
@ -1911,7 +1906,7 @@ void Tab::select_preset(std::string preset_name /*= ""*/)
|
||||||
|
|
||||||
// If the current preset is dirty, the user is asked whether the changes may be discarded.
|
// If the current preset is dirty, the user is asked whether the changes may be discarded.
|
||||||
// if the current preset was not dirty, or the user agreed to discard the changes, 1 is returned.
|
// if the current preset was not dirty, or the user agreed to discard the changes, 1 is returned.
|
||||||
bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr*/, std::string new_printer_name /*= ""*/)
|
bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr*/, const std::string& new_printer_name /*= ""*/)
|
||||||
{
|
{
|
||||||
if (presets == nullptr) presets = m_presets;
|
if (presets == nullptr) presets = m_presets;
|
||||||
// Display a dialog showing the dirty options in a human readable form.
|
// Display a dialog showing the dirty options in a human readable form.
|
||||||
|
@ -2339,7 +2334,7 @@ void Page::reload_config()
|
||||||
group->reload_config();
|
group->reload_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
Field* Page::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) const
|
Field* Page::get_field(const t_config_option_key& opt_key, int opt_index /*= -1*/) const
|
||||||
{
|
{
|
||||||
Field* field = nullptr;
|
Field* field = nullptr;
|
||||||
for (auto opt : m_optgroups){
|
for (auto opt : m_optgroups){
|
||||||
|
@ -2350,7 +2345,7 @@ Field* Page::get_field(t_config_option_key opt_key, int opt_index/* = -1*/) cons
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Page::set_value(t_config_option_key opt_key, boost::any value){
|
bool Page::set_value(const t_config_option_key& opt_key, const boost::any& value){
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
for(auto optgroup: m_optgroups) {
|
for(auto optgroup: m_optgroups) {
|
||||||
if (optgroup->set_value(opt_key, value))
|
if (optgroup->set_value(opt_key, value))
|
||||||
|
@ -2360,7 +2355,7 @@ bool Page::set_value(t_config_option_key opt_key, boost::any value){
|
||||||
}
|
}
|
||||||
|
|
||||||
// package Slic3r::GUI::Tab::Page;
|
// package Slic3r::GUI::Tab::Page;
|
||||||
ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_width /*= -1*/)
|
ConfigOptionsGroupShp Page::new_optgroup(const wxString& title, int noncommon_label_width /*= -1*/)
|
||||||
{
|
{
|
||||||
//! config_ have to be "right"
|
//! config_ have to be "right"
|
||||||
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(this, title, m_config, true);
|
ConfigOptionsGroupShp optgroup = std::make_shared<ConfigOptionsGroup>(this, title, m_config, true);
|
||||||
|
@ -2401,7 +2396,7 @@ ConfigOptionsGroupShp Page::new_optgroup(wxString title, int noncommon_label_wid
|
||||||
return optgroup;
|
return optgroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavePresetWindow::build(wxString title, std::string default_name, std::vector<std::string> &values)
|
void SavePresetWindow::build(const wxString& title, const std::string& default_name, std::vector<std::string> &values)
|
||||||
{
|
{
|
||||||
auto text = new wxStaticText(this, wxID_ANY, _(L("Save ")) + title + _(L(" as:")),
|
auto text = new wxStaticText(this, wxID_ANY, _(L("Save ")) + title + _(L(" as:")),
|
||||||
wxDefaultPosition, wxDefaultSize);
|
wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
|
@ -68,9 +68,9 @@ public:
|
||||||
size_t iconID() const { return m_iconID; }
|
size_t iconID() const { return m_iconID; }
|
||||||
void set_config(DynamicPrintConfig* config_in) { m_config = config_in; }
|
void set_config(DynamicPrintConfig* config_in) { m_config = config_in; }
|
||||||
void reload_config();
|
void reload_config();
|
||||||
Field* get_field(t_config_option_key opt_key, int opt_index = -1) const;
|
Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const;
|
||||||
bool set_value(t_config_option_key opt_key, boost::any value);
|
bool set_value(const t_config_option_key& opt_key, const boost::any& value);
|
||||||
ConfigOptionsGroupShp new_optgroup(wxString title, int noncommon_label_width = -1);
|
ConfigOptionsGroupShp new_optgroup(const wxString& title, int noncommon_label_width = -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Slic3r::GUI::Tab;
|
// Slic3r::GUI::Tab;
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Tab() {}
|
Tab() {}
|
||||||
Tab(wxNotebook* parent, wxString title, const char* name, bool no_controller) :
|
Tab(wxNotebook* parent, const wxString& title, const char* name, bool no_controller) :
|
||||||
m_parent(parent), m_title(title), m_name(name), m_no_controller(no_controller) {
|
m_parent(parent), m_title(title), m_name(name), m_no_controller(no_controller) {
|
||||||
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
||||||
get_tabs_list().push_back(this);
|
get_tabs_list().push_back(this);
|
||||||
|
@ -147,12 +147,12 @@ public:
|
||||||
void create_preset_tab(PresetBundle *preset_bundle);
|
void create_preset_tab(PresetBundle *preset_bundle);
|
||||||
void load_current_preset();
|
void load_current_preset();
|
||||||
void rebuild_page_tree();
|
void rebuild_page_tree();
|
||||||
void select_preset(std::string preset_name = "");
|
void select_preset(const std::string& preset_name = "");
|
||||||
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, std::string new_printer_name = "");
|
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "");
|
||||||
wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn);
|
wxSizer* compatible_printers_widget(wxWindow* parent, wxCheckBox** checkbox, wxButton** btn);
|
||||||
|
|
||||||
void update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible);
|
void update_presetsctrl(wxDataViewTreeCtrl* ui, bool show_incompatible);
|
||||||
void load_key_value(std::string opt_key, boost::any value);
|
void load_key_value(const std::string& opt_key, const boost::any& value);
|
||||||
void reload_compatible_printers_widget();
|
void reload_compatible_printers_widget();
|
||||||
|
|
||||||
void OnTreeSelChange(wxTreeEvent& event);
|
void OnTreeSelChange(wxTreeEvent& event);
|
||||||
|
@ -172,7 +172,7 @@ public:
|
||||||
void on_back_to_initial_value();
|
void on_back_to_initial_value();
|
||||||
void on_back_to_sys_value();
|
void on_back_to_sys_value();
|
||||||
|
|
||||||
PageShp add_options_page(wxString title, std::string icon, bool is_extruder_pages = false);
|
PageShp add_options_page(const wxString& title, const std::string& icon, bool is_extruder_pages = false);
|
||||||
|
|
||||||
virtual void OnActivate(){}
|
virtual void OnActivate(){}
|
||||||
virtual void on_preset_loaded(){}
|
virtual void on_preset_loaded(){}
|
||||||
|
@ -181,10 +181,10 @@ public:
|
||||||
void load_initial_data();
|
void load_initial_data();
|
||||||
void update_dirty();
|
void update_dirty();
|
||||||
void update_tab_ui();
|
void update_tab_ui();
|
||||||
void load_config(DynamicPrintConfig config);
|
void load_config(const DynamicPrintConfig& config);
|
||||||
virtual void reload_config();
|
virtual void reload_config();
|
||||||
Field* get_field(t_config_option_key opt_key, int opt_index = -1) const;
|
Field* get_field(const t_config_option_key& opt_key, int opt_index = -1) const;
|
||||||
bool set_value(t_config_option_key opt_key, boost::any value);
|
bool set_value(const t_config_option_key& opt_key, const boost::any& value);
|
||||||
wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText);
|
wxSizer* description_line_widget(wxWindow* parent, ogStaticText** StaticText);
|
||||||
bool current_preset_is_dirty();
|
bool current_preset_is_dirty();
|
||||||
DynamicPrintConfig* get_config() { return m_config; }
|
DynamicPrintConfig* get_config() { return m_config; }
|
||||||
|
@ -194,7 +194,7 @@ public:
|
||||||
}
|
}
|
||||||
std::vector<std::string> get_dependent_tabs() { return m_reload_dependent_tabs; }
|
std::vector<std::string> get_dependent_tabs() { return m_reload_dependent_tabs; }
|
||||||
|
|
||||||
void on_value_change(std::string opt_key, boost::any value);
|
void on_value_change(const std::string& opt_key, const boost::any& value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_presets_changed();
|
void on_presets_changed();
|
||||||
|
@ -270,7 +270,7 @@ public:
|
||||||
std::string m_chosen_name;
|
std::string m_chosen_name;
|
||||||
wxComboBox* m_combo;
|
wxComboBox* m_combo;
|
||||||
|
|
||||||
void build(wxString title, std::string default_name, std::vector<std::string> &values);
|
void build(const wxString& title, const std::string& default_name, std::vector<std::string> &values);
|
||||||
void accept();
|
void accept();
|
||||||
std::string get_name() { return m_chosen_name; }
|
std::string get_name() { return m_chosen_name; }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue