Fixed set_value() bug. Fixed Infill density.
* Got rid of try/catch at PointCtrl::set_value(). * Optimized localization: got rid of redundant macro _LU8(s).
This commit is contained in:
parent
4d9eac0750
commit
f330eb9567
5 changed files with 46 additions and 47 deletions
Binary file not shown.
|
@ -5,7 +5,7 @@ msgstr ""
|
||||||
"Project-Id-Version: SLIC3R PE VERSION\n"
|
"Project-Id-Version: SLIC3R PE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2018-02-13 17:18+0100\n"
|
"POT-Creation-Date: 2018-02-13 17:18+0100\n"
|
||||||
"PO-Revision-Date: 2018-02-16 15:23+0100\n"
|
"PO-Revision-Date: 2018-02-17 22:28+0100\n"
|
||||||
"Last-Translator: Filip Hurka <filip.hurka@prusa3d.cz>\n"
|
"Last-Translator: Filip Hurka <filip.hurka@prusa3d.cz>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
|
@ -602,7 +602,7 @@ msgstr ""
|
||||||
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1503
|
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1503
|
||||||
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1633
|
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:1633
|
||||||
msgid "mm/s or %"
|
msgid "mm/s or %"
|
||||||
msgstr "mm nebo %"
|
msgstr "mm/s nebo %"
|
||||||
|
|
||||||
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:293
|
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:293
|
||||||
msgid "External perimeters first"
|
msgid "External perimeters first"
|
||||||
|
@ -983,9 +983,9 @@ msgid ""
|
||||||
"the print moves of the first layer, regardless of their type. If expressed "
|
"the print moves of the first layer, regardless of their type. If expressed "
|
||||||
"as a percentage (for example: 40%) it will scale the default speeds."
|
"as a percentage (for example: 40%) it will scale the default speeds."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Pokud je vyjádřena jako absolutní hodnota v mm / s, bude tato rychlost "
|
"Pokud je vyjádřena jako absolutní hodnota v mm/s, bude tato rychlost použita "
|
||||||
"použita pro všechny pohyby tisku první vrstvy bez ohledu na jejich typ. "
|
"pro všechny pohyby tisku první vrstvy bez ohledu na jejich typ. Pokud je "
|
||||||
"Pokud je vyjádřeno jako procento (například: 40%), změní se výchozí rychlost."
|
"vyjádřeno jako procento (například: 40%), změní se výchozí rychlost."
|
||||||
|
|
||||||
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:628
|
#: C:\src\Slic3r\xs\src\libslic3r\PrintConfig.cpp:628
|
||||||
msgid ""
|
msgid ""
|
||||||
|
|
|
@ -56,7 +56,8 @@ namespace Slic3r { namespace GUI {
|
||||||
case coPercents:
|
case coPercents:
|
||||||
case coFloats:
|
case coFloats:
|
||||||
case coFloat:{
|
case coFloat:{
|
||||||
if (m_opt.type == coPercent) str.RemoveLast();
|
if (m_opt.type == coPercent && str.Last() == '%')
|
||||||
|
str.RemoveLast();
|
||||||
double val;
|
double val;
|
||||||
str.ToCDouble(&val);
|
str.ToCDouble(&val);
|
||||||
ret_val = val;
|
ret_val = val;
|
||||||
|
@ -87,7 +88,7 @@ namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
wxString text_value = wxString("");
|
wxString text_value = wxString("");
|
||||||
|
|
||||||
switch (m_opt.type) {
|
/* switch (m_opt.type) {
|
||||||
case coFloatOrPercent:
|
case coFloatOrPercent:
|
||||||
{
|
{
|
||||||
if (static_cast<const ConfigOptionFloatOrPercent*>(m_opt.default_value)->percent)
|
if (static_cast<const ConfigOptionFloatOrPercent*>(m_opt.default_value)->percent)
|
||||||
|
@ -147,7 +148,7 @@ namespace Slic3r { namespace GUI {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, (m_opt.multiline ? wxTE_MULTILINE : 0));
|
*/ auto temp = new wxTextCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, (m_opt.multiline ? wxTE_MULTILINE : 0));
|
||||||
|
|
||||||
temp->SetToolTip(get_tooltip_text(text_value));
|
temp->SetToolTip(get_tooltip_text(text_value));
|
||||||
|
|
||||||
|
@ -303,7 +304,7 @@ void Choice::set_selection()
|
||||||
break;
|
break;
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
if (m_opt.type == coPercent) text_value += "%";
|
// if (m_opt.type == coPercent) text_value += "%";
|
||||||
idx == m_opt.enum_values.size() ?
|
idx == m_opt.enum_values.size() ?
|
||||||
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
|
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
|
||||||
dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
|
dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
|
||||||
|
@ -387,7 +388,7 @@ void Choice::set_value(boost::any value)
|
||||||
break;
|
break;
|
||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
if (m_opt.type == coPercent) text_value += "%";
|
// if (m_opt.type == coPercent) text_value += "%";
|
||||||
idx == m_opt.enum_values.size() ?
|
idx == m_opt.enum_values.size() ?
|
||||||
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
|
dynamic_cast<wxComboBox*>(window)->SetValue(text_value) :
|
||||||
dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
|
dynamic_cast<wxComboBox*>(window)->SetSelection(idx);
|
||||||
|
@ -535,21 +536,29 @@ void PointCtrl::set_value(const Pointf value)
|
||||||
void PointCtrl::set_value(boost::any value)
|
void PointCtrl::set_value(boost::any value)
|
||||||
{
|
{
|
||||||
Pointf pt;
|
Pointf pt;
|
||||||
try
|
Pointf *ptf = boost::any_cast<Pointf>(&value);
|
||||||
|
if (!ptf)
|
||||||
{
|
{
|
||||||
pt = boost::any_cast<ConfigOptionPoints*>(value)->values.at(0);
|
ConfigOptionPoints* pts = boost::any_cast<ConfigOptionPoints*>(value);
|
||||||
}
|
pt = pts->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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
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);
|
set_value(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
//! macro used to localization, return const CharType *
|
|
||||||
#define _LU8(s) wxGetTranslation(s).ToUTF8().data()
|
|
||||||
|
|
||||||
const t_field& OptionsGroup::build_field(const Option& opt) {
|
const t_field& OptionsGroup::build_field(const Option& opt) {
|
||||||
return build_field(opt.opt_id, opt.opt);
|
return build_field(opt.opt_id, opt.opt);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +152,7 @@ void OptionsGroup::append_line(const Line& line) {
|
||||||
ConfigOptionDef option = opt.opt;
|
ConfigOptionDef option = opt.opt;
|
||||||
// add label if any
|
// add label if any
|
||||||
if (option.label != "") {
|
if (option.label != "") {
|
||||||
auto field_label = new wxStaticText(parent(), wxID_ANY, wxString::FromUTF8(option.label.c_str()) + ":", wxDefaultPosition, wxDefaultSize);
|
auto field_label = new wxStaticText(parent(), wxID_ANY, _L(option.label) + ":", wxDefaultPosition, wxDefaultSize);
|
||||||
field_label->SetFont(label_font);
|
field_label->SetFont(label_font);
|
||||||
sizer->Add(field_label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
sizer->Add(field_label, 0, wxALIGN_CENTER_VERTICAL, 0);
|
||||||
}
|
}
|
||||||
|
@ -169,7 +166,9 @@ void OptionsGroup::append_line(const Line& line) {
|
||||||
|
|
||||||
// add sidetext if any
|
// add sidetext if any
|
||||||
if (option.sidetext != "") {
|
if (option.sidetext != "") {
|
||||||
auto sidetext = new wxStaticText(parent(), wxID_ANY, wxString::FromUTF8(option.sidetext.c_str()), wxDefaultPosition, wxDefaultSize);
|
// Explicitly specify that the source string is already in UTF-8 encoding
|
||||||
|
wxString sidetext_str(option.sidetext.c_str(), wxConvUTF8);
|
||||||
|
auto sidetext = new wxStaticText(parent(), wxID_ANY, _L(sidetext_str), wxDefaultPosition, wxDefaultSize);
|
||||||
sidetext->SetFont(sidetext_font);
|
sidetext->SetFont(sidetext_font);
|
||||||
sizer->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
sizer->Add(sidetext, 0, wxLEFT | wxALIGN_CENTER_VERTICAL, 4);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +190,7 @@ void OptionsGroup::append_line(const Line& line) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Line OptionsGroup::create_single_option_line(const Option& option) const {
|
Line OptionsGroup::create_single_option_line(const Option& option) const {
|
||||||
Line retval{ wxString::FromUTF8(option.opt.label.c_str()), wxString::FromUTF8(option.opt.tooltip.c_str()) };
|
Line retval{ _L(option.opt.label), _L(option.opt.tooltip) };
|
||||||
Option tmp(option);
|
Option tmp(option);
|
||||||
tmp.opt.label = std::string("");
|
tmp.opt.label = std::string("");
|
||||||
retval.append_option(tmp);
|
retval.append_option(tmp);
|
||||||
|
@ -206,7 +205,7 @@ void OptionsGroup::on_change_OG(t_config_option_key id, /*config_value*/boost::a
|
||||||
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)) {
|
||||||
//! exception ("No $opt_key in ConfigOptionsGroup config");
|
std::cerr << "No " << opt_key << " in ConfigOptionsGroup config.";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string opt_id = opt_index == -1 ? opt_key : opt_key + "#" + std::to_string(opt_index);
|
std::string opt_id = opt_index == -1 ? opt_key : opt_key + "#" + std::to_string(opt_index);
|
||||||
|
@ -328,9 +327,9 @@ boost::any ConfigOptionsGroup::get_config_value(DynamicPrintConfig& config, std:
|
||||||
case coFloats:
|
case coFloats:
|
||||||
case coFloat:{
|
case coFloat:{
|
||||||
double val = opt->type == coFloats ?
|
double val = opt->type == coFloats ?
|
||||||
config.opt_float(opt_key, idx/*0opt_index*/) :
|
config.opt_float(opt_key, idx) :
|
||||||
opt->type == coFloat ? config.opt_float(opt_key) :
|
opt->type == coFloat ? config.opt_float(opt_key) :
|
||||||
config.option<ConfigOptionPercents>(opt_key)->values.at(idx/*0*/);
|
config.option<ConfigOptionPercents>(opt_key)->values.at(idx);
|
||||||
ret = double_to_string(val);
|
ret = double_to_string(val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -341,19 +340,19 @@ boost::any ConfigOptionsGroup::get_config_value(DynamicPrintConfig& config, std:
|
||||||
if (config.option<ConfigOptionStrings>(opt_key)->values.empty())
|
if (config.option<ConfigOptionStrings>(opt_key)->values.empty())
|
||||||
ret = text_value;
|
ret = text_value;
|
||||||
else
|
else
|
||||||
ret = static_cast<wxString>(config.opt_string(opt_key, static_cast<unsigned int>(idx/*0*/)/*opt_index*/));
|
ret = static_cast<wxString>(config.opt_string(opt_key, static_cast<unsigned int>(idx)));
|
||||||
break;
|
break;
|
||||||
case coBool:
|
case coBool:
|
||||||
ret = config.opt_bool(opt_key);
|
ret = config.opt_bool(opt_key);
|
||||||
break;
|
break;
|
||||||
case coBools:
|
case coBools:
|
||||||
ret = config.opt_bool(opt_key, idx/*0opt_index*/);
|
ret = config.opt_bool(opt_key, idx);
|
||||||
break;
|
break;
|
||||||
case coInt:
|
case coInt:
|
||||||
ret = config.opt_int(opt_key);
|
ret = config.opt_int(opt_key);
|
||||||
break;
|
break;
|
||||||
case coInts:
|
case coInts:
|
||||||
ret = config.opt_int(opt_key, idx/*0/*opt_index*/);
|
ret = config.opt_int(opt_key, idx);
|
||||||
break;
|
break;
|
||||||
case coEnum:{
|
case coEnum:{
|
||||||
if (opt_key.compare("external_fill_pattern") == 0 ||
|
if (opt_key.compare("external_fill_pattern") == 0 ||
|
||||||
|
@ -372,7 +371,7 @@ boost::any ConfigOptionsGroup::get_config_value(DynamicPrintConfig& config, std:
|
||||||
break;
|
break;
|
||||||
case coPoints:{
|
case coPoints:{
|
||||||
const auto &value = *config.option<ConfigOptionPoints>(opt_key);
|
const auto &value = *config.option<ConfigOptionPoints>(opt_key);
|
||||||
ret = value.values.at(idx/*0*/);
|
ret = value.values.at(idx);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case coNone:
|
case coNone:
|
||||||
|
@ -400,14 +399,5 @@ void ogStaticText::SetText(wxString value)
|
||||||
GetParent()->Layout();
|
GetParent()->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Option::translate()
|
|
||||||
{
|
|
||||||
opt.label = _LU8(opt.label);
|
|
||||||
opt.tooltip = _LU8(opt.tooltip);
|
|
||||||
opt.sidetext = _LU8(opt.sidetext);
|
|
||||||
opt.full_label = _LU8(opt.full_label);
|
|
||||||
opt.category = _LU8(opt.category);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
|
|
@ -35,8 +35,7 @@ struct Option {
|
||||||
bool readonly {false};
|
bool readonly {false};
|
||||||
|
|
||||||
Option(const ConfigOptionDef& _opt, t_config_option_key id) :
|
Option(const ConfigOptionDef& _opt, t_config_option_key id) :
|
||||||
opt(_opt), opt_id(id) { translate(); }
|
opt(_opt), opt_id(id) {}
|
||||||
void translate();
|
|
||||||
};
|
};
|
||||||
using t_option = std::unique_ptr<Option>; //!
|
using t_option = std::unique_ptr<Option>; //!
|
||||||
|
|
||||||
|
@ -96,6 +95,7 @@ public:
|
||||||
}
|
}
|
||||||
bool set_value(t_config_option_key id, boost::any value) {
|
bool set_value(t_config_option_key id, boost::any value) {
|
||||||
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);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
boost::any get_value(t_config_option_key id) {
|
boost::any get_value(t_config_option_key id) {
|
||||||
|
|
Loading…
Reference in a new issue