From f37b9c4d515d7f50e91ea499be59315231e90cb4 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 15 Dec 2020 21:21:09 +0100 Subject: [PATCH] Set limits to the "extrusion_multiplier" value and show warning message, if out of range value was inputted --- src/libslic3r/PrintConfig.cpp | 2 ++ src/slic3r/GUI/Field.cpp | 29 +++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index ada089187..76bae268b 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -607,6 +607,7 @@ void PrintConfigDef::init_fff_params() "this setting to get nice surface finish and correct single wall widths. " "Usual values are between 0.9 and 1.1. If you think you need to change this more, " "check filament diameter and your firmware E steps."); + def->max = 2; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloats { 1. }); @@ -619,6 +620,7 @@ void PrintConfigDef::init_fff_params() "If expressed as percentage (for example: 230%), it will be computed over layer height."); def->sidetext = L("mm or %"); def->min = 0; + def->max = 1000; def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(0, false)); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index e65d87b31..85c043c3b 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -259,10 +259,22 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true m_value.clear(); break; } - show_error(m_parent, _(L("Input value is out of range"))); - if (m_opt.min > val) val = m_opt.min; - if (val > m_opt.max) val = m_opt.max; - set_value(double_to_string(val), true); + auto set_val = [this](double& val) { + if (m_opt.min > val) val = m_opt.min; + if (val > m_opt.max) val = m_opt.max; + set_value(double_to_string(val), true); + }; + if (m_opt_id == "extrusion_multiplier") { + wxString msg_text = format_wxstr(_L("Input value is out of range\n" + "Are you sure that %s is a correct value and you want to continue?"), str); + wxMessageDialog dialog(m_parent, msg_text, _L("Parameter validation") + ": " + m_opt_id, wxICON_WARNING | wxYES | wxNO); + if (dialog.ShowModal() == wxID_NO) + set_val(val); + } + else { + show_error(m_parent, _L("Input value is out of range")); + set_val(val); + } } } m_value = val; @@ -561,8 +573,13 @@ void TextCtrl::propagate_value() // on_kill_focus() cause a call of OptionsGroup::reload_config(), // Thus, do it only when it's really needed (when undefined value was input) on_kill_focus(); - else if (value_was_changed()) - on_change_field(); + else if (value_was_changed() && m_on_change != nullptr && !m_disable_change_event) { + // For this moment m_value is already updated in value_was_changed() + // so instead of call on_change_field() { m_on_change(m_opt_id, get_value()); } + // just do next: + m_on_change(m_opt_id, m_value); +// on_change_field(); // #ysFIXME delete after testing + } } void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/) {