2019-08-19 10:28:25 +00:00
|
|
|
#include "OptionsGroup.hpp"
|
2017-12-13 13:45:10 +00:00
|
|
|
#include "ConfigExceptions.hpp"
|
2017-12-05 14:54:01 +00:00
|
|
|
|
2017-12-13 13:45:10 +00:00
|
|
|
#include <utility>
|
2018-01-09 08:41:07 +00:00
|
|
|
#include <wx/numformatter.h>
|
2018-03-07 14:05:41 +00:00
|
|
|
#include <boost/algorithm/string/split.hpp>
|
|
|
|
#include <boost/algorithm/string/classification.hpp>
|
2018-11-26 13:41:58 +00:00
|
|
|
#include "libslic3r/Utils.hpp"
|
|
|
|
#include "I18N.hpp"
|
2017-12-05 14:54:01 +00:00
|
|
|
|
|
|
|
namespace Slic3r { namespace GUI {
|
|
|
|
|
2018-03-02 08:08:11 +00:00
|
|
|
const t_field& OptionsGroup::build_field(const Option& opt, wxStaticText* label/* = nullptr*/) {
|
|
|
|
return build_field(opt.opt_id, opt.opt, label);
|
2017-12-13 13:45:10 +00:00
|
|
|
}
|
2018-03-02 08:08:11 +00:00
|
|
|
const t_field& OptionsGroup::build_field(const t_config_option_key& id, wxStaticText* label/* = nullptr*/) {
|
2018-01-16 15:28:01 +00:00
|
|
|
const ConfigOptionDef& opt = m_options.at(id).opt;
|
2018-03-02 08:08:11 +00:00
|
|
|
return build_field(id, opt, label);
|
2017-12-13 13:45:10 +00:00
|
|
|
}
|
2017-12-05 14:54:01 +00:00
|
|
|
|
2018-03-02 08:08:11 +00:00
|
|
|
const t_field& OptionsGroup::build_field(const t_config_option_key& id, const ConfigOptionDef& opt, wxStaticText* label/* = nullptr*/) {
|
2017-12-13 13:45:10 +00:00
|
|
|
// Check the gui_type field first, fall through
|
|
|
|
// is the normal type.
|
|
|
|
if (opt.gui_type.compare("select") == 0) {
|
|
|
|
} else if (opt.gui_type.compare("select_open") == 0) {
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(Choice::Create<Choice>(this->ctrl_parent(), opt, id)));
|
2017-12-13 13:45:10 +00:00
|
|
|
} else if (opt.gui_type.compare("color") == 0) {
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(ColourPicker::Create<ColourPicker>(this->ctrl_parent(), opt, id)));
|
2017-12-13 13:45:10 +00:00
|
|
|
} else if (opt.gui_type.compare("f_enum_open") == 0 ||
|
|
|
|
opt.gui_type.compare("i_enum_open") == 0 ||
|
|
|
|
opt.gui_type.compare("i_enum_closed") == 0) {
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(Choice::Create<Choice>(this->ctrl_parent(), opt, id)));
|
2017-12-13 13:45:10 +00:00
|
|
|
} else if (opt.gui_type.compare("slider") == 0) {
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(SliderCtrl::Create<SliderCtrl>(this->ctrl_parent(), opt, id)));
|
2017-12-13 13:45:10 +00:00
|
|
|
} else if (opt.gui_type.compare("i_spin") == 0) { // Spinctrl
|
2018-06-21 14:15:56 +00:00
|
|
|
} else if (opt.gui_type.compare("legend") == 0) { // StaticText
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(StaticText::Create<StaticText>(this->ctrl_parent(), opt, id)));
|
2017-12-13 13:45:10 +00:00
|
|
|
} else {
|
|
|
|
switch (opt.type) {
|
|
|
|
case coFloatOrPercent:
|
|
|
|
case coFloat:
|
2017-12-22 10:50:28 +00:00
|
|
|
case coFloats:
|
2017-12-18 12:58:51 +00:00
|
|
|
case coPercent:
|
2017-12-22 10:50:28 +00:00
|
|
|
case coPercents:
|
2017-12-18 12:58:51 +00:00
|
|
|
case coString:
|
|
|
|
case coStrings:
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(TextCtrl::Create<TextCtrl>(this->ctrl_parent(), opt, id)));
|
2017-12-13 13:45:10 +00:00
|
|
|
break;
|
2017-12-18 12:58:51 +00:00
|
|
|
case coBool:
|
|
|
|
case coBools:
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(CheckBox::Create<CheckBox>(this->ctrl_parent(), opt, id)));
|
2017-12-18 12:58:51 +00:00
|
|
|
break;
|
|
|
|
case coInt:
|
|
|
|
case coInts:
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(SpinCtrl::Create<SpinCtrl>(this->ctrl_parent(), opt, id)));
|
2017-12-18 12:58:51 +00:00
|
|
|
break;
|
|
|
|
case coEnum:
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(Choice::Create<Choice>(this->ctrl_parent(), opt, id)));
|
2017-12-18 12:58:51 +00:00
|
|
|
break;
|
2017-12-22 10:50:28 +00:00
|
|
|
case coPoints:
|
2019-03-18 11:48:39 +00:00
|
|
|
m_fields.emplace(id, std::move(PointCtrl::Create<PointCtrl>(this->ctrl_parent(), opt, id)));
|
2017-12-22 10:50:28 +00:00
|
|
|
break;
|
2017-12-13 13:45:10 +00:00
|
|
|
case coNone: break;
|
|
|
|
default:
|
2017-12-18 12:58:51 +00:00
|
|
|
throw /*//!ConfigGUITypeError("")*/std::logic_error("This control doesn't exist till now"); break;
|
2017-12-13 13:45:10 +00:00
|
|
|
}
|
2017-12-05 14:54:01 +00:00
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
// Grab a reference to fields for convenience
|
2018-01-05 14:11:33 +00:00
|
|
|
const t_field& field = m_fields[id];
|
2018-12-11 12:34:37 +00:00
|
|
|
field->m_on_change = [this](const std::string& opt_id, const boost::any& value) {
|
2018-01-05 14:11:33 +00:00
|
|
|
//! This function will be called from Field.
|
|
|
|
//! Call OptionGroup._on_change(...)
|
2018-09-10 07:11:49 +00:00
|
|
|
if (!m_disabled)
|
2018-01-05 14:11:33 +00:00
|
|
|
this->on_change_OG(opt_id, value);
|
|
|
|
};
|
2018-12-11 12:34:37 +00:00
|
|
|
field->m_on_kill_focus = [this](const std::string& opt_id) {
|
2018-01-31 13:59:44 +00:00
|
|
|
//! This function will be called from Field.
|
2018-09-10 07:11:49 +00:00
|
|
|
if (!m_disabled)
|
2018-12-11 12:34:37 +00:00
|
|
|
this->on_kill_focus(opt_id);
|
2018-01-31 13:59:44 +00:00
|
|
|
};
|
2018-12-11 12:57:50 +00:00
|
|
|
field->m_on_set_focus = [this](const std::string& opt_id) {
|
|
|
|
//! This function will be called from Field.
|
|
|
|
if (!m_disabled)
|
|
|
|
this->on_set_focus(opt_id);
|
|
|
|
};
|
2018-01-05 14:11:33 +00:00
|
|
|
field->m_parent = parent();
|
2018-03-02 08:08:11 +00:00
|
|
|
|
|
|
|
//! Label to change background color, when option is modified
|
2018-03-06 11:34:20 +00:00
|
|
|
field->m_Label = label;
|
2018-10-31 11:56:08 +00:00
|
|
|
field->m_back_to_initial_value = [this](std::string opt_id) {
|
2018-09-10 07:11:49 +00:00
|
|
|
if (!m_disabled)
|
2018-03-06 11:34:20 +00:00
|
|
|
this->back_to_initial_value(opt_id);
|
|
|
|
};
|
2018-10-31 11:56:08 +00:00
|
|
|
field->m_back_to_sys_value = [this](std::string opt_id) {
|
2018-03-16 16:25:11 +00:00
|
|
|
if (!this->m_disabled)
|
|
|
|
this->back_to_sys_value(opt_id);
|
|
|
|
};
|
2018-03-02 08:08:11 +00:00
|
|
|
|
|
|
|
// assign function objects for callbacks, etc.
|
2017-12-13 13:45:10 +00:00
|
|
|
return field;
|
2017-12-05 14:54:01 +00:00
|
|
|
}
|
|
|
|
|
2018-05-24 14:57:35 +00:00
|
|
|
void OptionsGroup::add_undo_buttuns_to_sizer(wxSizer* sizer, const t_field& field)
|
2018-05-17 12:07:50 +00:00
|
|
|
{
|
2018-06-21 14:15:56 +00:00
|
|
|
if (!m_show_modified_btns) {
|
2018-10-21 21:09:24 +00:00
|
|
|
field->m_Undo_btn->set_as_hidden();
|
|
|
|
field->m_Undo_to_sys_btn->set_as_hidden();
|
2018-05-17 12:07:50 +00:00
|
|
|
return;
|
2018-03-15 08:55:31 +00:00
|
|
|
}
|
2018-05-17 12:07:50 +00:00
|
|
|
|
|
|
|
sizer->Add(field->m_Undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL);
|
|
|
|
sizer->Add(field->m_Undo_btn, 0, wxALIGN_CENTER_VERTICAL);
|
2017-12-05 14:54:01 +00:00
|
|
|
}
|
|
|
|
|
2018-11-22 14:12:09 +00:00
|
|
|
void OptionsGroup::append_line(const Line& line, wxStaticText** full_Label/* = nullptr*/) {
|
2018-10-31 11:56:08 +00:00
|
|
|
if ( (line.sizer != nullptr || line.widget != nullptr) && line.full_width) {
|
2017-12-22 10:50:28 +00:00
|
|
|
if (line.sizer != nullptr) {
|
2017-12-13 13:45:10 +00:00
|
|
|
sizer->Add(line.sizer, 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (line.widget != nullptr) {
|
2019-03-18 11:48:39 +00:00
|
|
|
sizer->Add(line.widget(this->ctrl_parent()), 0, wxEXPAND | wxALL, wxOSX ? 0 : 15);
|
2017-12-13 13:45:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-12-05 14:54:01 +00:00
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2017-12-22 10:50:28 +00:00
|
|
|
auto option_set = line.get_options();
|
2018-01-16 15:28:01 +00:00
|
|
|
for (auto opt : option_set)
|
|
|
|
m_options.emplace(opt.opt_id, opt);
|
2017-12-22 10:50:28 +00:00
|
|
|
|
2020-02-12 11:08:43 +00:00
|
|
|
// Set sidetext width for a better alignment of options in line
|
|
|
|
if (option_set.size() > 1)
|
|
|
|
sidetext_width = Field::def_width_thinner();
|
|
|
|
|
2018-10-21 21:09:24 +00:00
|
|
|
// add mode value for current line to m_options_mode
|
|
|
|
if (!option_set.empty())
|
|
|
|
m_options_mode.push_back(option_set[0].opt.mode);
|
|
|
|
|
2017-12-22 10:50:28 +00:00
|
|
|
// if we have a single option with no label, no sidetext just add it directly to sizer
|
2019-09-24 14:01:01 +00:00
|
|
|
if (option_set.size() == 1 && label_width == 0 && option_set.front().opt.full_width &&
|
2019-02-07 13:44:05 +00:00
|
|
|
option_set.front().opt.label.empty() &&
|
2017-12-22 10:50:28 +00:00
|
|
|
option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr &&
|
|
|
|
line.get_extra_widgets().size() == 0) {
|
2018-05-03 14:28:41 +00:00
|
|
|
wxSizer* tmp_sizer;
|
2019-03-20 10:54:48 +00:00
|
|
|
#if 0//#ifdef __WXGTK__
|
2018-05-03 11:49:37 +00:00
|
|
|
tmp_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
m_panel->SetSizer(tmp_sizer);
|
|
|
|
m_panel->Layout();
|
|
|
|
#else
|
|
|
|
tmp_sizer = sizer;
|
|
|
|
#endif /* __WXGTK__ */
|
|
|
|
|
2017-12-22 10:50:28 +00:00
|
|
|
const auto& option = option_set.front();
|
|
|
|
const auto& field = build_field(option);
|
|
|
|
|
2018-03-16 11:56:03 +00:00
|
|
|
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
2018-05-17 12:07:50 +00:00
|
|
|
add_undo_buttuns_to_sizer(btn_sizer, field);
|
2018-05-03 11:49:37 +00:00
|
|
|
tmp_sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0);
|
2017-12-22 10:50:28 +00:00
|
|
|
if (is_window_field(field))
|
2018-05-03 11:49:37 +00:00
|
|
|
tmp_sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
|
2017-12-22 10:50:28 +00:00
|
|
|
if (is_sizer_field(field))
|
2018-05-03 11:49:37 +00:00
|
|
|
tmp_sizer->Add(field->getSizer(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
|
2017-12-22 10:50:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-05 14:11:33 +00:00
|
|
|
auto grid_sizer = m_grid_sizer;
|
2019-03-20 10:54:48 +00:00
|
|
|
#if 0//#ifdef __WXGTK__
|
2018-05-03 11:49:37 +00:00
|
|
|
m_panel->SetSizer(m_grid_sizer);
|
|
|
|
m_panel->Layout();
|
|
|
|
#endif /* __WXGTK__ */
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-07-24 16:39:40 +00:00
|
|
|
// if we have an extra column, build it
|
2019-04-13 21:46:52 +00:00
|
|
|
if (extra_column)
|
|
|
|
{
|
2019-04-16 08:05:45 +00:00
|
|
|
m_extra_column_item_ptrs.push_back(extra_column(this->ctrl_parent(), line));
|
|
|
|
grid_sizer->Add(m_extra_column_item_ptrs.back(), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 3);
|
2019-04-13 21:46:52 +00:00
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
|
|
|
// Build a label if we have it
|
2018-03-02 08:08:11 +00:00
|
|
|
wxStaticText* label=nullptr;
|
2017-12-05 14:54:01 +00:00
|
|
|
if (label_width != 0) {
|
2019-04-24 17:03:05 +00:00
|
|
|
if (! line.near_label_widget || ! line.label.IsEmpty()) {
|
2019-04-26 15:42:51 +00:00
|
|
|
// Only create the label if it is going to be displayed.
|
2019-04-24 17:03:05 +00:00
|
|
|
long label_style = staticbox ? 0 : wxALIGN_RIGHT;
|
2018-06-26 08:37:36 +00:00
|
|
|
#ifdef __WXGTK__
|
2019-04-24 17:03:05 +00:00
|
|
|
// workaround for correct text align of the StaticBox on Linux
|
|
|
|
// flags wxALIGN_RIGHT and wxALIGN_CENTRE don't work when Ellipsize flags are _not_ given.
|
|
|
|
// Text is properly aligned only when Ellipsize is checked.
|
|
|
|
label_style |= staticbox ? 0 : wxST_ELLIPSIZE_END;
|
2018-06-26 08:37:36 +00:00
|
|
|
#endif /* __WXGTK__ */
|
2019-04-24 17:03:05 +00:00
|
|
|
label = new wxStaticText(this->ctrl_parent(), wxID_ANY, line.label + (line.label.IsEmpty() ? "" : ": "),
|
2019-04-26 15:42:51 +00:00
|
|
|
wxDefaultPosition, wxSize(label_width*wxGetApp().em_unit(), -1), label_style);
|
2019-04-24 17:03:05 +00:00
|
|
|
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
2019-04-26 15:42:51 +00:00
|
|
|
label->SetFont(wxGetApp().normal_font());
|
|
|
|
label->Wrap(label_width*wxGetApp().em_unit()); // avoid a Linux/GTK bug
|
2019-04-24 17:03:05 +00:00
|
|
|
}
|
2018-08-28 13:51:53 +00:00
|
|
|
if (!line.near_label_widget)
|
2019-02-07 13:44:05 +00:00
|
|
|
grid_sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, line.label.IsEmpty() ? 0 : 5);
|
2018-08-28 13:51:53 +00:00
|
|
|
else {
|
2019-04-16 08:05:45 +00:00
|
|
|
m_near_label_widget_ptrs.push_back(line.near_label_widget(this->ctrl_parent()));
|
|
|
|
|
|
|
|
if (line.label.IsEmpty())
|
|
|
|
grid_sizer->Add(m_near_label_widget_ptrs.back(), 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 7);
|
|
|
|
else {
|
|
|
|
// If we're here, we have some widget near the label
|
|
|
|
// so we need a horizontal sizer to arrange these things
|
|
|
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
|
2019-07-03 12:52:39 +00:00
|
|
|
sizer->Add(m_near_label_widget_ptrs.back(), 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 7);
|
2019-04-16 08:05:45 +00:00
|
|
|
sizer->Add(label, 0, (staticbox ? 0 : wxALIGN_RIGHT | wxRIGHT) | wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
}
|
2018-08-28 13:51:53 +00:00
|
|
|
}
|
2019-04-24 17:03:05 +00:00
|
|
|
if (label != nullptr && line.label_tooltip != "")
|
2018-02-07 16:13:52 +00:00
|
|
|
label->SetToolTip(line.label_tooltip);
|
2017-12-05 14:54:01 +00:00
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-11-22 14:12:09 +00:00
|
|
|
if (full_Label != nullptr)
|
|
|
|
*full_Label = label; // Initiate the pointer to the control of the full label, if we need this one.
|
2017-12-13 13:45:10 +00:00
|
|
|
// If there's a widget, build it and add the result to the sizer.
|
2018-02-22 10:34:41 +00:00
|
|
|
if (line.widget != nullptr) {
|
2019-03-18 11:48:39 +00:00
|
|
|
auto wgt = line.widget(this->ctrl_parent());
|
2018-04-24 10:12:15 +00:00
|
|
|
// If widget doesn't have label, don't use border
|
|
|
|
grid_sizer->Add(wgt, 0, wxEXPAND | wxBOTTOM | wxTOP, (wxOSX || line.label.IsEmpty()) ? 0 : 5);
|
2018-02-22 10:34:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-22 06:41:33 +00:00
|
|
|
// If we're here, we have more than one option or a single option with sidetext
|
|
|
|
// so we need a horizontal sizer to arrange these things
|
2018-10-19 11:55:29 +00:00
|
|
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
2018-05-24 14:57:35 +00:00
|
|
|
grid_sizer->Add(sizer, 0, wxEXPAND | (staticbox ? wxALL : wxBOTTOM | wxTOP | wxLEFT), staticbox ? 0 : 1);
|
2018-05-22 14:14:41 +00:00
|
|
|
// If we have a single option with no sidetext just add it directly to the grid sizer
|
2018-03-06 08:44:53 +00:00
|
|
|
if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
|
2019-02-07 13:44:05 +00:00
|
|
|
option_set.front().opt.label.empty() &&
|
2018-03-06 08:44:53 +00:00
|
|
|
option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0) {
|
|
|
|
const auto& option = option_set.front();
|
|
|
|
const auto& field = build_field(option, label);
|
2017-12-18 12:58:51 +00:00
|
|
|
|
2018-05-17 12:07:50 +00:00
|
|
|
add_undo_buttuns_to_sizer(sizer, field);
|
2018-03-06 08:44:53 +00:00
|
|
|
if (is_window_field(field))
|
2019-10-29 09:40:34 +00:00
|
|
|
sizer->Add(field->getWindow(), option.opt.full_width ? 1 : 0, //(option.opt.full_width ? wxEXPAND : 0) |
|
2018-09-20 23:33:41 +00:00
|
|
|
wxBOTTOM | wxTOP | (option.opt.full_width ? wxEXPAND : wxALIGN_CENTER_VERTICAL), (wxOSX || !staticbox) ? 0 : 2);
|
2018-03-06 08:44:53 +00:00
|
|
|
if (is_sizer_field(field))
|
2018-09-20 23:33:41 +00:00
|
|
|
sizer->Add(field->getSizer(), 1, /*(*/option.opt.full_width ? wxEXPAND : /*0) |*/ wxALIGN_CENTER_VERTICAL, 0);
|
2018-03-06 08:44:53 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-05-22 06:41:33 +00:00
|
|
|
for (auto opt : option_set) {
|
2017-12-14 13:42:47 +00:00
|
|
|
ConfigOptionDef option = opt.opt;
|
2018-10-19 11:55:29 +00:00
|
|
|
wxSizer* sizer_tmp = sizer;
|
2017-12-14 13:42:47 +00:00
|
|
|
// add label if any
|
|
|
|
if (option.label != "") {
|
2018-02-28 14:39:20 +00:00
|
|
|
//! To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
|
2019-08-27 15:14:03 +00:00
|
|
|
wxString str_label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ?
|
2019-01-22 16:52:14 +00:00
|
|
|
_CTX(option.label, "Layers") :
|
2019-01-21 11:34:28 +00:00
|
|
|
_(option.label);
|
2019-03-18 11:48:39 +00:00
|
|
|
label = new wxStaticText(this->ctrl_parent(), wxID_ANY, str_label + ": ", wxDefaultPosition, wxDefaultSize);
|
|
|
|
label->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
2019-04-13 21:46:52 +00:00
|
|
|
label->SetFont(wxGetApp().normal_font());
|
2018-09-20 23:33:41 +00:00
|
|
|
sizer_tmp->Add(label, 0, /*wxALIGN_RIGHT |*/ wxALIGN_CENTER_VERTICAL, 0);
|
2017-12-14 13:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add field
|
2017-12-18 12:58:51 +00:00
|
|
|
const Option& opt_ref = opt;
|
2018-03-02 08:08:11 +00:00
|
|
|
auto& field = build_field(opt_ref, label);
|
2018-05-23 14:21:42 +00:00
|
|
|
add_undo_buttuns_to_sizer(sizer_tmp, field);
|
2019-02-07 13:44:05 +00:00
|
|
|
if (option_set.size() == 1 && option_set.front().opt.full_width)
|
|
|
|
{
|
|
|
|
const auto v_sizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sizer_tmp->Add(v_sizer, 1, wxEXPAND);
|
|
|
|
is_sizer_field(field) ?
|
|
|
|
v_sizer->Add(field->getSizer(), 0, wxEXPAND) :
|
|
|
|
v_sizer->Add(field->getWindow(), 0, wxEXPAND);
|
2019-07-10 15:50:24 +00:00
|
|
|
break;//return;
|
2019-02-07 13:44:05 +00:00
|
|
|
}
|
|
|
|
|
2017-12-22 10:50:28 +00:00
|
|
|
is_sizer_field(field) ?
|
2018-05-23 14:21:42 +00:00
|
|
|
sizer_tmp->Add(field->getSizer(), 0, wxALIGN_CENTER_VERTICAL, 0) :
|
|
|
|
sizer_tmp->Add(field->getWindow(), 0, wxALIGN_CENTER_VERTICAL, 0);
|
2017-12-14 13:42:47 +00:00
|
|
|
|
|
|
|
// add sidetext if any
|
2020-02-12 11:08:43 +00:00
|
|
|
if (!option.sidetext.empty() || sidetext_width > 0) {
|
2019-03-18 11:48:39 +00:00
|
|
|
auto sidetext = new wxStaticText( this->ctrl_parent(), wxID_ANY, _(option.sidetext), wxDefaultPosition,
|
2020-02-12 11:08:43 +00:00
|
|
|
wxSize(sidetext_width != -1 ? sidetext_width*wxGetApp().em_unit() : -1, -1), wxALIGN_LEFT);
|
2019-03-18 11:48:39 +00:00
|
|
|
sidetext->SetBackgroundStyle(wxBG_STYLE_PAINT);
|
2019-04-13 21:46:52 +00:00
|
|
|
sidetext->SetFont(wxGetApp().normal_font());
|
2018-10-19 11:55:29 +00:00
|
|
|
sizer_tmp->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
2018-07-04 12:52:36 +00:00
|
|
|
field->set_side_text_ptr(sidetext);
|
2017-12-14 13:42:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add side widget if any
|
|
|
|
if (opt.side_widget != nullptr) {
|
2019-03-18 11:48:39 +00:00
|
|
|
sizer_tmp->Add(opt.side_widget(this->ctrl_parent())/*!.target<wxWindow>()*/, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 1); //! requires verification
|
2017-12-14 13:42:47 +00:00
|
|
|
}
|
|
|
|
|
2018-10-19 11:55:29 +00:00
|
|
|
if (opt.opt_id != option_set.back().opt_id) //! istead of (opt != option_set.back())
|
2017-12-14 13:42:47 +00:00
|
|
|
{
|
2018-05-23 14:21:42 +00:00
|
|
|
sizer_tmp->AddSpacer(6);
|
2017-12-14 13:42:47 +00:00
|
|
|
}
|
2017-12-22 10:50:28 +00:00
|
|
|
}
|
|
|
|
// add extra sizers if any
|
2019-02-07 13:44:05 +00:00
|
|
|
for (auto extra_widget : line.get_extra_widgets())
|
|
|
|
{
|
|
|
|
if (line.get_extra_widgets().size() == 1 && !staticbox)
|
|
|
|
{
|
|
|
|
// extra widget for non-staticbox option group (like for the frequently used parameters on the sidebar) should be wxALIGN_RIGHT
|
|
|
|
const auto v_sizer = new wxBoxSizer(wxVERTICAL);
|
2019-07-10 15:50:24 +00:00
|
|
|
sizer->Add(v_sizer, option_set.size() == 1 ? 0 : 1, wxEXPAND);
|
2019-03-18 11:48:39 +00:00
|
|
|
v_sizer->Add(extra_widget(this->ctrl_parent()), 0, wxALIGN_RIGHT);
|
2019-02-07 13:44:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-18 11:48:39 +00:00
|
|
|
sizer->Add(extra_widget(this->ctrl_parent())/*!.target<wxWindow>()*/, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4); //! requires verification
|
2017-12-14 13:42:47 +00:00
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
}
|
2017-12-14 13:42:47 +00:00
|
|
|
|
2017-12-13 13:45:10 +00:00
|
|
|
Line OptionsGroup::create_single_option_line(const Option& option) const {
|
2019-04-26 08:52:38 +00:00
|
|
|
// Line retval{ _(option.opt.label), _(option.opt.tooltip) };
|
|
|
|
wxString tooltip = _(option.opt.tooltip);
|
|
|
|
edit_tooltip(tooltip);
|
|
|
|
Line retval{ _(option.opt.label), tooltip };
|
2017-12-13 13:45:10 +00:00
|
|
|
Option tmp(option);
|
|
|
|
tmp.opt.label = std::string("");
|
|
|
|
retval.append_option(tmp);
|
|
|
|
return retval;
|
2017-12-05 14:54:01 +00:00
|
|
|
}
|
|
|
|
|
2019-05-30 10:41:16 +00:00
|
|
|
void OptionsGroup::clear_fields_except_of(const std::vector<std::string> left_fields)
|
|
|
|
{
|
|
|
|
auto it = m_fields.begin();
|
|
|
|
while (it != m_fields.end()) {
|
|
|
|
if (std::find(left_fields.begin(), left_fields.end(), it->first) == left_fields.end())
|
|
|
|
it = m_fields.erase(it);
|
|
|
|
else
|
|
|
|
it++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-11 12:57:50 +00:00
|
|
|
void OptionsGroup::on_set_focus(const std::string& opt_key)
|
|
|
|
{
|
|
|
|
if (m_set_focus != nullptr)
|
|
|
|
m_set_focus(opt_key);
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:35:04 +00:00
|
|
|
void OptionsGroup::on_change_OG(const t_config_option_key& opt_id, const boost::any& value) {
|
2018-01-05 14:11:33 +00:00
|
|
|
if (m_on_change != nullptr)
|
2018-04-13 10:35:04 +00:00
|
|
|
m_on_change(opt_id, value);
|
2018-01-05 14:11:33 +00:00
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-04-13 10:35:04 +00:00
|
|
|
Option ConfigOptionsGroup::get_option(const std::string& opt_key, int opt_index /*= -1*/)
|
2018-01-07 17:41:40 +00:00
|
|
|
{
|
|
|
|
if (!m_config->has(opt_key)) {
|
2018-05-27 20:12:01 +00:00
|
|
|
std::cerr << "No " << opt_key << " in ConfigOptionsGroup config.\n";
|
2018-01-07 17:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string opt_id = opt_index == -1 ? opt_key : opt_key + "#" + std::to_string(opt_index);
|
|
|
|
std::pair<std::string, int> pair(opt_key, opt_index);
|
|
|
|
m_opt_map.emplace(opt_id, pair);
|
|
|
|
|
|
|
|
return Option(*m_config->def()->get(opt_key), opt_id);
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:35:04 +00:00
|
|
|
void ConfigOptionsGroup::on_change_OG(const t_config_option_key& opt_id, const boost::any& value)
|
2018-01-05 14:11:33 +00:00
|
|
|
{
|
2018-01-07 17:41:40 +00:00
|
|
|
if (!m_opt_map.empty())
|
|
|
|
{
|
2018-01-14 20:52:55 +00:00
|
|
|
auto it = m_opt_map.find(opt_id);
|
|
|
|
if (it == m_opt_map.end())
|
|
|
|
{
|
|
|
|
OptionsGroup::on_change_OG(opt_id, value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto itOption = it->second;
|
|
|
|
std::string opt_key = itOption.first;
|
|
|
|
int opt_index = itOption.second;
|
|
|
|
|
2018-01-16 15:28:01 +00:00
|
|
|
auto option = m_options.at(opt_id).opt;
|
2018-01-05 14:11:33 +00:00
|
|
|
|
2019-07-28 20:00:39 +00:00
|
|
|
change_opt_value(*m_config, opt_key, value, opt_index == -1 ? 0 : opt_index);
|
2018-01-07 17:41:40 +00:00
|
|
|
}
|
2018-01-05 14:11:33 +00:00
|
|
|
|
2019-07-28 20:00:39 +00:00
|
|
|
OptionsGroup::on_change_OG(opt_id, value);
|
2018-01-05 14:11:33 +00:00
|
|
|
}
|
2017-12-13 13:45:10 +00:00
|
|
|
|
2018-04-13 10:35:04 +00:00
|
|
|
void ConfigOptionsGroup::back_to_initial_value(const std::string& opt_key)
|
2018-03-06 11:34:20 +00:00
|
|
|
{
|
|
|
|
if (m_get_initial_config == nullptr)
|
|
|
|
return;
|
2018-03-16 16:25:11 +00:00
|
|
|
back_to_config_value(m_get_initial_config(), opt_key);
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:35:04 +00:00
|
|
|
void ConfigOptionsGroup::back_to_sys_value(const std::string& opt_key)
|
2018-03-16 16:25:11 +00:00
|
|
|
{
|
|
|
|
if (m_get_sys_config == nullptr)
|
|
|
|
return;
|
|
|
|
if (!have_sys_config())
|
|
|
|
return;
|
|
|
|
back_to_config_value(m_get_sys_config(), opt_key);
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:35:04 +00:00
|
|
|
void ConfigOptionsGroup::back_to_config_value(const DynamicPrintConfig& config, const std::string& opt_key)
|
2018-03-16 16:25:11 +00:00
|
|
|
{
|
2018-03-07 14:05:41 +00:00
|
|
|
boost::any value;
|
2018-10-31 11:56:08 +00:00
|
|
|
if (opt_key == "extruders_count") {
|
2018-03-07 14:05:41 +00:00
|
|
|
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(config.option("nozzle_diameter"));
|
|
|
|
value = int(nozzle_diameter->values.size());
|
|
|
|
}
|
2019-05-14 08:08:11 +00:00
|
|
|
else if (m_opt_map.find(opt_key) == m_opt_map.end() || opt_key == "bed_shape") {
|
|
|
|
value = get_config_value(config, opt_key);
|
|
|
|
change_opt_value(*m_config, opt_key, value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-03-08 10:58:06 +00:00
|
|
|
{
|
|
|
|
auto opt_id = m_opt_map.find(opt_key)->first;
|
|
|
|
std::string opt_short_key = m_opt_map.at(opt_id).first;
|
|
|
|
int opt_index = m_opt_map.at(opt_id).second;
|
|
|
|
value = get_config_value(config, opt_short_key, opt_index);
|
|
|
|
}
|
2018-03-07 14:05:41 +00:00
|
|
|
|
2018-03-06 11:34:20 +00:00
|
|
|
set_value(opt_key, value);
|
2018-03-07 14:05:41 +00:00
|
|
|
on_change_OG(opt_key, get_value(opt_key));
|
2018-03-06 11:34:20 +00:00
|
|
|
}
|
|
|
|
|
2018-12-11 12:34:37 +00:00
|
|
|
void ConfigOptionsGroup::on_kill_focus(const std::string& opt_key)
|
|
|
|
{
|
2019-04-24 09:01:59 +00:00
|
|
|
if (m_fill_empty_value)
|
2018-12-11 12:34:37 +00:00
|
|
|
m_fill_empty_value(opt_key);
|
2019-04-24 09:01:59 +00:00
|
|
|
else
|
|
|
|
reload_config();
|
2018-12-11 12:34:37 +00:00
|
|
|
}
|
|
|
|
|
2019-04-24 09:01:59 +00:00
|
|
|
void ConfigOptionsGroup::reload_config()
|
|
|
|
{
|
|
|
|
for (auto &kvp : m_opt_map) {
|
2019-05-10 14:09:42 +00:00
|
|
|
// Name of the option field (name of the configuration key, possibly suffixed with '#' and the index of a scalar inside a vector.
|
2019-04-24 09:01:59 +00:00
|
|
|
const std::string &opt_id = kvp.first;
|
2019-05-10 14:09:42 +00:00
|
|
|
// option key (may be scalar or vector)
|
2019-04-24 09:01:59 +00:00
|
|
|
const std::string &opt_key = kvp.second.first;
|
2019-05-10 14:09:42 +00:00
|
|
|
// index in the vector option, zero for scalars
|
2019-04-24 09:01:59 +00:00
|
|
|
int opt_index = kvp.second.second;
|
|
|
|
const ConfigOptionDef &option = m_options.at(opt_id).opt;
|
2019-05-10 14:09:42 +00:00
|
|
|
this->set_value(opt_id, config_value(opt_key, opt_index, option.gui_flags == "serialized"));
|
2018-01-09 08:41:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
void ConfigOptionsGroup::Hide()
|
|
|
|
{
|
|
|
|
Show(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigOptionsGroup::Show(const bool show)
|
|
|
|
{
|
|
|
|
sizer->ShowItems(show);
|
2019-03-20 10:54:48 +00:00
|
|
|
#if 0//#ifdef __WXGTK__
|
2018-11-09 17:39:07 +00:00
|
|
|
m_panel->Show(show);
|
|
|
|
m_grid_sizer->Show(show);
|
|
|
|
#endif /* __WXGTK__ */
|
|
|
|
}
|
|
|
|
|
2018-10-21 21:09:24 +00:00
|
|
|
bool ConfigOptionsGroup::update_visibility(ConfigOptionMode mode) {
|
2018-10-22 10:07:40 +00:00
|
|
|
if (m_options_mode.empty())
|
|
|
|
return true;
|
2019-09-03 08:59:04 +00:00
|
|
|
int opt_mode_size = m_options_mode.size();
|
|
|
|
if (m_grid_sizer->GetEffectiveRowsCount() != opt_mode_size &&
|
|
|
|
opt_mode_size == 1)
|
2018-10-21 21:09:24 +00:00
|
|
|
return m_options_mode[0] <= mode;
|
|
|
|
|
2018-11-09 17:39:07 +00:00
|
|
|
Show(true);
|
2018-10-19 11:55:29 +00:00
|
|
|
|
|
|
|
int coef = 0;
|
2018-10-22 13:18:05 +00:00
|
|
|
int hidden_row_cnt = 0;
|
2018-10-19 11:55:29 +00:00
|
|
|
const int cols = m_grid_sizer->GetCols();
|
2018-10-21 21:09:24 +00:00
|
|
|
for (auto opt_mode : m_options_mode) {
|
|
|
|
const bool show = opt_mode <= mode;
|
2018-10-19 11:55:29 +00:00
|
|
|
if (!show) {
|
2018-10-22 13:18:05 +00:00
|
|
|
hidden_row_cnt++;
|
2018-10-19 11:55:29 +00:00
|
|
|
for (int i = 0; i < cols; ++i)
|
|
|
|
m_grid_sizer->Show(coef + i, show);
|
|
|
|
}
|
|
|
|
coef+= cols;
|
|
|
|
}
|
|
|
|
|
2019-09-03 08:59:04 +00:00
|
|
|
if (hidden_row_cnt == opt_mode_size) {
|
2018-10-19 11:55:29 +00:00
|
|
|
sizer->ShowItems(false);
|
2018-10-21 21:09:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2018-10-19 11:55:29 +00:00
|
|
|
}
|
|
|
|
|
2019-04-24 23:45:00 +00:00
|
|
|
void ConfigOptionsGroup::msw_rescale()
|
2019-04-13 21:46:52 +00:00
|
|
|
{
|
2019-04-16 08:05:45 +00:00
|
|
|
// update bitmaps for extra column items (like "mode markers" or buttons on settings panel)
|
|
|
|
if (rescale_extra_column_item)
|
|
|
|
for (auto extra_col : m_extra_column_item_ptrs)
|
|
|
|
rescale_extra_column_item(extra_col);
|
|
|
|
|
|
|
|
// update bitmaps for near label widgets (like "Set uniform scale" button on settings panel)
|
|
|
|
if (rescale_near_label_widget)
|
|
|
|
for (auto near_label_widget : m_near_label_widget_ptrs)
|
|
|
|
rescale_near_label_widget(near_label_widget);
|
2019-04-13 21:46:52 +00:00
|
|
|
|
|
|
|
// update undo buttons : rescale bitmaps
|
|
|
|
for (const auto& field : m_fields)
|
2020-02-12 11:08:43 +00:00
|
|
|
field.second->msw_rescale(sidetext_width>0);
|
2019-04-13 21:46:52 +00:00
|
|
|
|
2019-04-18 00:03:40 +00:00
|
|
|
const int em = em_unit(parent());
|
|
|
|
|
2019-04-13 21:46:52 +00:00
|
|
|
// rescale width of label column
|
|
|
|
if (!m_options_mode.empty() && label_width > 1)
|
|
|
|
{
|
|
|
|
const int cols = m_grid_sizer->GetCols();
|
|
|
|
const int rows = m_grid_sizer->GetEffectiveRowsCount();
|
|
|
|
const int label_col = extra_column == nullptr ? 0 : 1;
|
|
|
|
|
|
|
|
for (int i = 0; i < rows; i++)
|
|
|
|
{
|
|
|
|
const wxSizerItem* label_item = m_grid_sizer->GetItem(i*cols+label_col);
|
|
|
|
if (label_item->IsWindow())
|
|
|
|
{
|
|
|
|
auto label = dynamic_cast<wxStaticText*>(label_item->GetWindow());
|
|
|
|
if (label != nullptr) {
|
2019-05-15 13:41:12 +00:00
|
|
|
label->SetMinSize(wxSize(label_width*em, -1));
|
2019-04-13 21:46:52 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-25 13:06:44 +00:00
|
|
|
else if (label_item->IsSizer()) // case when we have near_label_widget
|
2019-04-13 21:46:52 +00:00
|
|
|
{
|
|
|
|
const wxSizerItem* l_item = label_item->GetSizer()->GetItem(1);
|
|
|
|
if (l_item->IsWindow())
|
|
|
|
{
|
|
|
|
auto label = dynamic_cast<wxStaticText*>(l_item->GetWindow());
|
|
|
|
if (label != nullptr) {
|
2019-05-15 13:41:12 +00:00
|
|
|
label->SetMinSize(wxSize(label_width*em, -1));
|
2019-04-13 21:46:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_grid_sizer->Layout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-31 11:56:08 +00:00
|
|
|
boost::any ConfigOptionsGroup::config_value(const std::string& opt_key, int opt_index, bool deserialize) {
|
2018-01-09 08:41:07 +00:00
|
|
|
|
|
|
|
if (deserialize) {
|
|
|
|
// Want to edit a vector value(currently only multi - strings) in a single edit box.
|
|
|
|
// Aggregate the strings the old way.
|
|
|
|
// Currently used for the post_process config value only.
|
|
|
|
if (opt_index != -1)
|
|
|
|
throw std::out_of_range("Can't deserialize option indexed value");
|
|
|
|
// return join(';', m_config->get(opt_key)});
|
|
|
|
return get_config_value(*m_config, opt_key);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// return opt_index == -1 ? m_config->get(opt_key) : m_config->get_at(opt_key, opt_index);
|
|
|
|
return get_config_value(*m_config, opt_key, opt_index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 10:35:04 +00:00
|
|
|
boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config, const std::string& opt_key, int opt_index /*= -1*/)
|
2018-01-09 08:41:07 +00:00
|
|
|
{
|
2018-01-16 15:28:01 +00:00
|
|
|
size_t idx = opt_index == -1 ? 0 : opt_index;
|
|
|
|
|
2018-01-09 08:41:07 +00:00
|
|
|
boost::any ret;
|
|
|
|
wxString text_value = wxString("");
|
|
|
|
const ConfigOptionDef* opt = config.def()->get(opt_key);
|
2019-07-28 20:00:39 +00:00
|
|
|
|
|
|
|
if (opt->nullable)
|
|
|
|
{
|
|
|
|
switch (opt->type)
|
|
|
|
{
|
|
|
|
case coPercents:
|
|
|
|
case coFloats: {
|
2019-07-29 12:00:22 +00:00
|
|
|
if (config.option(opt_key)->is_nil())
|
|
|
|
ret = _(L("N/A"));
|
|
|
|
else {
|
|
|
|
double val = opt->type == coFloats ?
|
|
|
|
config.option<ConfigOptionFloatsNullable>(opt_key)->get_at(idx) :
|
|
|
|
config.option<ConfigOptionPercentsNullable>(opt_key)->get_at(idx);
|
|
|
|
ret = double_to_string(val); }
|
2019-07-28 20:00:39 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case coBools:
|
|
|
|
ret = config.option<ConfigOptionBoolsNullable>(opt_key)->values[idx];
|
|
|
|
break;
|
|
|
|
case coInts:
|
|
|
|
ret = config.option<ConfigOptionIntsNullable>(opt_key)->get_at(idx);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-10-31 11:56:08 +00:00
|
|
|
switch (opt->type) {
|
2018-01-09 08:41:07 +00:00
|
|
|
case coFloatOrPercent:{
|
|
|
|
const auto &value = *config.option<ConfigOptionFloatOrPercent>(opt_key);
|
2019-09-02 12:02:26 +00:00
|
|
|
|
|
|
|
text_value = double_to_string(value.value);
|
2018-01-09 08:41:07 +00:00
|
|
|
if (value.percent)
|
|
|
|
text_value += "%";
|
2019-09-02 12:02:26 +00:00
|
|
|
|
2018-01-09 08:41:07 +00:00
|
|
|
ret = text_value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case coPercent:{
|
|
|
|
double val = config.option<ConfigOptionPercent>(opt_key)->value;
|
|
|
|
text_value = wxString::Format(_T("%i"), int(val));
|
|
|
|
ret = text_value;// += "%";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case coPercents:
|
2018-01-27 13:21:16 +00:00
|
|
|
case coFloats:
|
|
|
|
case coFloat:{
|
2018-01-16 15:28:01 +00:00
|
|
|
double val = opt->type == coFloats ?
|
2018-02-18 22:11:43 +00:00
|
|
|
config.opt_float(opt_key, idx) :
|
2018-01-27 13:21:16 +00:00
|
|
|
opt->type == coFloat ? config.opt_float(opt_key) :
|
2018-03-08 10:58:06 +00:00
|
|
|
config.option<ConfigOptionPercents>(opt_key)->get_at(idx);
|
2018-01-27 13:21:16 +00:00
|
|
|
ret = double_to_string(val);
|
2018-01-09 08:41:07 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case coString:
|
|
|
|
ret = static_cast<wxString>(config.opt_string(opt_key));
|
|
|
|
break;
|
|
|
|
case coStrings:
|
2018-10-31 11:56:08 +00:00
|
|
|
if (opt_key.compare("compatible_printers") == 0) {
|
2018-04-13 16:22:06 +00:00
|
|
|
ret = config.option<ConfigOptionStrings>(opt_key)->values;
|
|
|
|
break;
|
|
|
|
}
|
2018-01-09 08:41:07 +00:00
|
|
|
if (config.option<ConfigOptionStrings>(opt_key)->values.empty())
|
|
|
|
ret = text_value;
|
2018-10-31 11:56:08 +00:00
|
|
|
else if (opt->gui_flags.compare("serialized") == 0) {
|
2018-03-07 14:05:41 +00:00
|
|
|
std::vector<std::string> values = config.option<ConfigOptionStrings>(opt_key)->values;
|
2018-03-23 11:52:37 +00:00
|
|
|
if (!values.empty() && values[0].compare("") != 0)
|
|
|
|
for (auto el : values)
|
|
|
|
text_value += el + ";";
|
2018-03-07 14:05:41 +00:00
|
|
|
ret = text_value;
|
|
|
|
}
|
2018-01-09 08:41:07 +00:00
|
|
|
else
|
2018-02-18 22:11:43 +00:00
|
|
|
ret = static_cast<wxString>(config.opt_string(opt_key, static_cast<unsigned int>(idx)));
|
2018-01-09 08:41:07 +00:00
|
|
|
break;
|
|
|
|
case coBool:
|
|
|
|
ret = config.opt_bool(opt_key);
|
|
|
|
break;
|
|
|
|
case coBools:
|
2018-02-18 22:11:43 +00:00
|
|
|
ret = config.opt_bool(opt_key, idx);
|
2018-01-09 08:41:07 +00:00
|
|
|
break;
|
|
|
|
case coInt:
|
|
|
|
ret = config.opt_int(opt_key);
|
|
|
|
break;
|
|
|
|
case coInts:
|
2018-02-18 22:11:43 +00:00
|
|
|
ret = config.opt_int(opt_key, idx);
|
2018-01-09 08:41:07 +00:00
|
|
|
break;
|
|
|
|
case coEnum:{
|
2019-02-22 14:25:35 +00:00
|
|
|
if (opt_key == "top_fill_pattern" ||
|
|
|
|
opt_key == "bottom_fill_pattern" ||
|
|
|
|
opt_key == "fill_pattern" ) {
|
2018-01-09 08:41:07 +00:00
|
|
|
ret = static_cast<int>(config.option<ConfigOptionEnum<InfillPattern>>(opt_key)->value);
|
|
|
|
}
|
2018-10-31 11:56:08 +00:00
|
|
|
else if (opt_key.compare("gcode_flavor") == 0 ) {
|
2018-01-09 08:41:07 +00:00
|
|
|
ret = static_cast<int>(config.option<ConfigOptionEnum<GCodeFlavor>>(opt_key)->value);
|
|
|
|
}
|
2018-10-31 11:56:08 +00:00
|
|
|
else if (opt_key.compare("support_material_pattern") == 0) {
|
2018-01-09 08:41:07 +00:00
|
|
|
ret = static_cast<int>(config.option<ConfigOptionEnum<SupportMaterialPattern>>(opt_key)->value);
|
|
|
|
}
|
2018-10-31 11:56:08 +00:00
|
|
|
else if (opt_key.compare("seam_position") == 0) {
|
2018-01-09 08:41:07 +00:00
|
|
|
ret = static_cast<int>(config.option<ConfigOptionEnum<SeamPosition>>(opt_key)->value);
|
2018-07-08 12:32:48 +00:00
|
|
|
}
|
2018-10-31 11:56:08 +00:00
|
|
|
else if (opt_key.compare("host_type") == 0) {
|
2018-07-08 12:32:48 +00:00
|
|
|
ret = static_cast<int>(config.option<ConfigOptionEnum<PrintHostType>>(opt_key)->value);
|
|
|
|
}
|
2018-12-13 11:42:45 +00:00
|
|
|
else if (opt_key.compare("display_orientation") == 0) {
|
|
|
|
ret = static_cast<int>(config.option<ConfigOptionEnum<SLADisplayOrientation>>(opt_key)->value);
|
|
|
|
}
|
2019-01-09 11:21:43 +00:00
|
|
|
else if (opt_key.compare("support_pillar_connection_mode") == 0) {
|
|
|
|
ret = static_cast<int>(config.option<ConfigOptionEnum<SLAPillarConnectionMode>>(opt_key)->value);
|
|
|
|
}
|
2018-01-09 08:41:07 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-03-08 10:58:06 +00:00
|
|
|
case coPoints:
|
2018-03-23 16:27:43 +00:00
|
|
|
if (opt_key.compare("bed_shape") == 0)
|
|
|
|
ret = config.option<ConfigOptionPoints>(opt_key)->values;
|
|
|
|
else
|
|
|
|
ret = config.option<ConfigOptionPoints>(opt_key)->get_at(idx);
|
2018-01-09 08:41:07 +00:00
|
|
|
break;
|
|
|
|
case coNone:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-10-31 11:56:08 +00:00
|
|
|
Field* ConfigOptionsGroup::get_fieldc(const t_config_option_key& opt_key, int opt_index)
|
|
|
|
{
|
2018-03-07 14:05:41 +00:00
|
|
|
Field* field = get_field(opt_key);
|
|
|
|
if (field != nullptr)
|
|
|
|
return field;
|
2018-01-11 09:33:17 +00:00
|
|
|
std::string opt_id = "";
|
2018-03-21 21:21:37 +00:00
|
|
|
for (t_opt_map::iterator it = m_opt_map.begin(); it != m_opt_map.end(); ++it) {
|
2018-10-31 11:56:08 +00:00
|
|
|
if (opt_key == m_opt_map.at(it->first).first && opt_index == m_opt_map.at(it->first).second) {
|
2018-01-11 09:33:17 +00:00
|
|
|
opt_id = it->first;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return opt_id.empty() ? nullptr : get_field(opt_id);
|
|
|
|
}
|
|
|
|
|
2018-04-26 10:40:17 +00:00
|
|
|
void ogStaticText::SetText(const wxString& value, bool wrap/* = true*/)
|
2018-01-15 11:13:05 +00:00
|
|
|
{
|
|
|
|
SetLabel(value);
|
2020-02-07 13:15:09 +00:00
|
|
|
if (wrap) Wrap(60 * wxGetApp().em_unit());
|
2018-01-15 11:13:05 +00:00
|
|
|
GetParent()->Layout();
|
|
|
|
}
|
|
|
|
|
2018-01-05 14:11:33 +00:00
|
|
|
} // GUI
|
|
|
|
} // Slic3r
|