Fixed wrong saving of "percent or millimeters" parameters
This commit is contained in:
parent
6ad38f80fb
commit
23f96e30c3
@ -53,7 +53,7 @@ namespace Slic3r { namespace GUI {
|
|||||||
return std::regex_match(string, regex_pattern);
|
return std::regex_match(string, regex_pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::any Field::get_value_by_opt_type(wxString str, ConfigOptionType type)
|
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){
|
||||||
@ -72,16 +72,9 @@ namespace Slic3r { namespace GUI {
|
|||||||
break; }
|
break; }
|
||||||
case coString:
|
case coString:
|
||||||
case coStrings:
|
case coStrings:
|
||||||
|
case coFloatOrPercent:
|
||||||
ret_val = str.ToStdString();
|
ret_val = str.ToStdString();
|
||||||
break;
|
break;
|
||||||
case coFloatOrPercent:{
|
|
||||||
if (str.Last() == '%')
|
|
||||||
str.RemoveLast();
|
|
||||||
double val;
|
|
||||||
str.ToCDouble(&val);
|
|
||||||
ret_val = val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -165,7 +158,7 @@ namespace Slic3r { namespace GUI {
|
|||||||
boost::any TextCtrl::get_value()
|
boost::any TextCtrl::get_value()
|
||||||
{
|
{
|
||||||
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
|
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
|
||||||
boost::any ret_val = get_value_by_opt_type(ret_str, m_opt.type);
|
boost::any ret_val = get_value_by_opt_type(ret_str);
|
||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
@ -420,7 +413,7 @@ boost::any Choice::get_value()
|
|||||||
wxString ret_str = static_cast<wxComboBox*>(window)->GetValue();
|
wxString ret_str = static_cast<wxComboBox*>(window)->GetValue();
|
||||||
|
|
||||||
if (m_opt.type != coEnum)
|
if (m_opt.type != coEnum)
|
||||||
ret_val = get_value_by_opt_type(ret_str, m_opt.type);
|
ret_val = get_value_by_opt_type(ret_str);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
|
int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
virtual wxWindow* getWindow() { return nullptr; }
|
virtual wxWindow* getWindow() { return nullptr; }
|
||||||
|
|
||||||
bool is_matched(std::string string, std::string pattern);
|
bool is_matched(std::string string, std::string pattern);
|
||||||
boost::any get_value_by_opt_type(wxString str, ConfigOptionType type);
|
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>
|
||||||
|
@ -384,8 +384,14 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
|
|||||||
try{
|
try{
|
||||||
switch (config.def()->get(opt_key)->type){
|
switch (config.def()->get(opt_key)->type){
|
||||||
case coFloatOrPercent:{
|
case coFloatOrPercent:{
|
||||||
const auto &val = *config.option<ConfigOptionFloatOrPercent>(opt_key);
|
std::string str = boost::any_cast<std::string>(value);
|
||||||
config.set_key_value(opt_key, new ConfigOptionFloatOrPercent(boost::any_cast<double>(value), val.percent));
|
bool percent = false;
|
||||||
|
if (str.back() == '%'){
|
||||||
|
str.pop_back();
|
||||||
|
percent = true;
|
||||||
|
}
|
||||||
|
double val = stod(str);
|
||||||
|
config.set_key_value(opt_key, new ConfigOptionFloatOrPercent(val, percent));
|
||||||
break;}
|
break;}
|
||||||
case coPercent:
|
case coPercent:
|
||||||
config.set_key_value(opt_key, new ConfigOptionPercent(boost::any_cast<double>(value)));
|
config.set_key_value(opt_key, new ConfigOptionPercent(boost::any_cast<double>(value)));
|
||||||
|
Loading…
Reference in New Issue
Block a user