mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Fixed #1225 (Added "Parameter validation" for "mm or %" values)
+ fixed correct updating of the "Contact Z distance" parameter
This commit is contained in:
parent
01edb23ffc
commit
17164ee333
1 changed files with 36 additions and 7 deletions
|
@ -163,9 +163,31 @@ void Field::get_value_by_opt_type(wxString& str)
|
||||||
break; }
|
break; }
|
||||||
case coString:
|
case coString:
|
||||||
case coStrings:
|
case coStrings:
|
||||||
case coFloatOrPercent:
|
case coFloatOrPercent: {
|
||||||
|
if (m_opt.type == coFloatOrPercent && !str.IsEmpty() && str.Last() != '%')
|
||||||
|
{
|
||||||
|
double val;
|
||||||
|
if (!str.ToCDouble(&val))
|
||||||
|
{
|
||||||
|
show_error(m_parent, _(L("Input value contains incorrect symbol(s).\nUse, please, only digits")));
|
||||||
|
set_value(double_to_string(val), true);
|
||||||
|
}
|
||||||
|
else if (val > 1)
|
||||||
|
{
|
||||||
|
const int nVal = int(val);
|
||||||
|
wxString msg_text = wxString::Format(_(L("Do you mean %d%% instead of %dmm?\n"
|
||||||
|
"Select YES if you want to change this value to %d%%, \n"
|
||||||
|
"or NO if you are sure that %dmm is a correct value.")), nVal, nVal, nVal, nVal);
|
||||||
|
auto dialog = new wxMessageDialog(m_parent, msg_text, _(L("Parameter validation")), wxICON_WARNING | wxYES | wxNO);
|
||||||
|
if (dialog->ShowModal() == wxID_YES) {
|
||||||
|
set_value(wxString::Format("%s%%", str), true);
|
||||||
|
str += "%%";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_value = str.ToStdString();
|
m_value = str.ToStdString();
|
||||||
break;
|
break; }
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -611,9 +633,7 @@ boost::any& Choice::get_value()
|
||||||
if (m_opt_id == rp_option)
|
if (m_opt_id == rp_option)
|
||||||
return m_value = boost::any(ret_str);
|
return m_value = boost::any(ret_str);
|
||||||
|
|
||||||
if (m_opt.type != coEnum)
|
if (m_opt.type == coEnum)
|
||||||
/*m_value = */get_value_by_opt_type(ret_str);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
|
int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
|
||||||
if (m_opt_id.compare("external_fill_pattern") == 0)
|
if (m_opt_id.compare("external_fill_pattern") == 0)
|
||||||
|
@ -641,6 +661,15 @@ boost::any& Choice::get_value()
|
||||||
else if (m_opt_id.compare("display_orientation") == 0)
|
else if (m_opt_id.compare("display_orientation") == 0)
|
||||||
m_value = static_cast<SLADisplayOrientation>(ret_enum);
|
m_value = static_cast<SLADisplayOrientation>(ret_enum);
|
||||||
}
|
}
|
||||||
|
else if (m_opt.gui_type == "f_enum_open") {
|
||||||
|
const int ret_enum = static_cast<wxComboBox*>(window)->GetSelection();
|
||||||
|
if (ret_enum < 0 || m_opt.enum_values.empty())
|
||||||
|
get_value_by_opt_type(ret_str);
|
||||||
|
else
|
||||||
|
m_value = m_opt.enum_values[ret_enum];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
get_value_by_opt_type(ret_str);
|
||||||
|
|
||||||
return m_value;
|
return m_value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue