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);
|
||||
}
|
||||
|
||||
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;
|
||||
switch (m_opt.type){
|
||||
@ -72,16 +72,9 @@ namespace Slic3r { namespace GUI {
|
||||
break; }
|
||||
case coString:
|
||||
case coStrings:
|
||||
case coFloatOrPercent:
|
||||
ret_val = str.ToStdString();
|
||||
break;
|
||||
case coFloatOrPercent:{
|
||||
if (str.Last() == '%')
|
||||
str.RemoveLast();
|
||||
double val;
|
||||
str.ToCDouble(&val);
|
||||
ret_val = val;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -165,7 +158,7 @@ namespace Slic3r { namespace GUI {
|
||||
boost::any TextCtrl::get_value()
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -420,7 +413,7 @@ boost::any Choice::get_value()
|
||||
wxString ret_str = static_cast<wxComboBox*>(window)->GetValue();
|
||||
|
||||
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
|
||||
{
|
||||
int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
virtual wxWindow* getWindow() { return nullptr; }
|
||||
|
||||
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.
|
||||
template<class T>
|
||||
|
@ -384,8 +384,14 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b
|
||||
try{
|
||||
switch (config.def()->get(opt_key)->type){
|
||||
case coFloatOrPercent:{
|
||||
const auto &val = *config.option<ConfigOptionFloatOrPercent>(opt_key);
|
||||
config.set_key_value(opt_key, new ConfigOptionFloatOrPercent(boost::any_cast<double>(value), val.percent));
|
||||
std::string str = boost::any_cast<std::string>(value);
|
||||
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;}
|
||||
case coPercent:
|
||||
config.set_key_value(opt_key, new ConfigOptionPercent(boost::any_cast<double>(value)));
|
||||
|
Loading…
Reference in New Issue
Block a user