Parameter "G-code thumbnails": check value for the out of range

This commit is contained in:
YuSanka 2020-12-08 13:29:23 +01:00
parent 2d711d8646
commit 90248bffa5

View file

@ -322,6 +322,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
str.Replace(" ", wxEmptyString, true);
if (!str.IsEmpty()) {
bool invalid_val = false;
bool out_of_range_val = false;
wxStringTokenizer thumbnails(str, ",");
while (thumbnails.HasMoreTokens()) {
wxString token = thumbnails.GetNextToken();
@ -332,8 +333,12 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
if (x_str.ToDouble(&x) && thumbnail.HasMoreTokens()) {
wxString y_str = thumbnail.GetNextToken();
if (y_str.ToDouble(&y) && !thumbnail.HasMoreTokens()) {
out_values.push_back(Vec2d(x, y));
continue;
if (0 < x && x < 1000 && 0 < y && y < 1000) {
out_values.push_back(Vec2d(x, y));
continue;
}
out_of_range_val = true;
break;
}
}
}
@ -341,7 +346,15 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true
break;
}
if (invalid_val) {
if (out_of_range_val) {
wxString text_value;
if (!m_value.empty())
text_value = get_thumbnails_string(boost::any_cast<std::vector<Vec2d>>(m_value));
set_value(text_value, true);
show_error(m_parent, _L("Input value is out of range")
);
}
else if (invalid_val) {
wxString text_value;
if (!m_value.empty())
text_value = get_thumbnails_string(boost::any_cast<std::vector<Vec2d>>(m_value));