diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index bb2dd34d9..454b4874f 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -138,7 +138,7 @@ bool Field::is_matched(const std::string& string, const std::string& pattern) static wxString na_value() { return _(L("N/A")); } -void Field::get_value_by_opt_type(wxString& str) +void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true*/) { switch (m_opt.type) { case coInt: @@ -150,7 +150,7 @@ void Field::get_value_by_opt_type(wxString& str) case coFloat:{ if (m_opt.type == coPercent && !str.IsEmpty() && str.Last() == '%') str.RemoveLast(); - else if (!str.IsEmpty() && str.Last() == '%') { + else if (check_value && !str.IsEmpty() && str.Last() == '%') { wxString label = m_Label->GetLabel(); if (label.Last() == '\n') label.RemoveLast(); while (label.Last() == ' ') label.RemoveLast(); @@ -169,12 +169,12 @@ void Field::get_value_by_opt_type(wxString& str) { if (m_opt.nullable && str == na_value()) val = ConfigOptionFloatsNullable::nil_value(); - else if (!str.ToCDouble(&val)) + else if (check_value && !str.ToCDouble(&val)) { show_error(m_parent, _(L("Invalid numeric input."))); set_value(double_to_string(val), true); } - if (m_opt.min > val || val > m_opt.max) + if (check_value && (m_opt.min > val || val > m_opt.max)) { show_error(m_parent, _(L("Input value is out of range"))); if (m_opt.min > val) val = m_opt.min; @@ -192,12 +192,12 @@ void Field::get_value_by_opt_type(wxString& str) double val; // Replace the first occurence of comma in decimal number. str.Replace(",", ".", false); - if (!str.ToCDouble(&val)) + if (check_value && !str.ToCDouble(&val)) { show_error(m_parent, _(L("Invalid numeric input."))); set_value(double_to_string(val), true); } - else if ((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max || + else if (check_value && (m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max || m_opt.sidetext.rfind("mm ") != std::string::npos && val > 1) && (m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast(m_value))) { @@ -206,7 +206,7 @@ void Field::get_value_by_opt_type(wxString& str) const wxString msg_text = wxString::Format(_(L("Do you mean %s%% instead of %s %s?\n" "Select YES if you want to change this value to %s%%, \n" "or NO if you are sure that %s %s is a correct value.")), stVal, stVal, sidetext, stVal, stVal, sidetext); - wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")), wxICON_WARNING | wxYES | wxNO); + wxMessageDialog dialog(m_parent, msg_text, _(L("Parameter validation")) + ": " + m_opt_id , wxICON_WARNING | wxYES | wxNO); if (dialog.ShowModal() == wxID_YES) { set_value(wxString::Format("%s%%", stVal), false/*true*/); str += "%%"; @@ -396,8 +396,9 @@ void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/) if (!change_event) { wxString ret_str = static_cast(window)->GetValue(); - // update m_value to correct work of next value_was_changed() - get_value_by_opt_type(ret_str); + // update m_value to correct work of next value_was_changed(), + // but don't check/change inputed value and don't show a warning message + get_value_by_opt_type(ret_str, false); } } diff --git a/src/slic3r/GUI/Field.hpp b/src/slic3r/GUI/Field.hpp index 11775a67c..b3cbf573f 100644 --- a/src/slic3r/GUI/Field.hpp +++ b/src/slic3r/GUI/Field.hpp @@ -152,7 +152,7 @@ public: virtual wxWindow* getWindow() { return nullptr; } bool is_matched(const std::string& string, const std::string& pattern); - void get_value_by_opt_type(wxString& str); + void get_value_by_opt_type(wxString& str, const bool check_value = true); /// Factory method for generating new derived classes. template diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index eb014798d..0b89939b6 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1071,9 +1071,11 @@ const std::vector& ObjectList::get_options_for_bundle(const wxStrin return empty; } -static bool improper_category(const std::string& category, const int extruders_cnt) +static bool improper_category(const std::string& category, const int extruders_cnt, const bool is_object_settings = true) { - return category.empty() || (extruders_cnt == 1 && (category == "Extruders" || category == "Wipe options" )); + return category.empty() || + extruders_cnt == 1 && (category == "Extruders" || category == "Wipe options" ) || + !is_object_settings && category == "Support material"; } void ObjectList::get_options_menu(settings_menu_hierarchy& settings_menu, const bool is_part) @@ -1087,7 +1089,7 @@ void ObjectList::get_options_menu(settings_menu_hierarchy& settings_menu, const { auto const opt = config.def()->get(option); auto category = opt->category; - if (improper_category(category, extruders_cnt)) + if (improper_category(category, extruders_cnt, !is_part)) continue; const std::string& label = !opt->full_label.empty() ? opt->full_label : opt->label; @@ -1404,7 +1406,7 @@ wxMenuItem* ObjectList::append_menu_item_settings(wxMenu* menu_) menu->SetFirstSeparator(); // Add frequently settings - create_freq_settings_popupmenu(menu); + create_freq_settings_popupmenu(menu, sel_vol==nullptr); if (mode == comAdvanced) return nullptr; @@ -1598,7 +1600,7 @@ wxMenu* ObjectList::create_settings_popupmenu(wxMenu *parent_menu) return menu; } -void ObjectList::create_freq_settings_popupmenu(wxMenu *menu) +void ObjectList::create_freq_settings_popupmenu(wxMenu *menu, const bool is_object_settings/* = true*/) { // Add default settings bundles const SettingsBundle& bundle = printer_technology() == ptFFF ? @@ -1607,7 +1609,7 @@ void ObjectList::create_freq_settings_popupmenu(wxMenu *menu) const int extruders_cnt = extruders_count(); for (auto& it : bundle) { - if (improper_category(it.first, extruders_cnt)) + if (improper_category(it.first, extruders_cnt, is_object_settings)) continue; append_menu_item(menu, wxID_ANY, _(it.first), "", @@ -2262,7 +2264,7 @@ SettingsBundle ObjectList::get_item_settings_bundle(const DynamicPrintConfig* co for (auto& opt_key : opt_keys) { auto category = config->def()->get(opt_key)->category; - if (improper_category(category, extruders_cnt)) + if (improper_category(category, extruders_cnt, is_object_settings)) continue; std::vector< std::string > new_category; diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 0164d20c1..d19a1002d 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -241,7 +241,7 @@ public: void create_part_popupmenu(wxMenu*menu); void create_instance_popupmenu(wxMenu*menu); wxMenu* create_settings_popupmenu(wxMenu *parent_menu); - void create_freq_settings_popupmenu(wxMenu *parent_menu); + void create_freq_settings_popupmenu(wxMenu *parent_menu, const bool is_object_settings = true); void update_opt_keys(t_config_option_keys& t_optopt_keys, const bool is_object); diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index f40138408..c17569c11 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -589,13 +589,11 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config switch (opt->type) { case coFloatOrPercent:{ const auto &value = *config.option(opt_key); + + text_value = double_to_string(value.value); if (value.percent) - { - text_value = wxString::Format(_T("%i"), int(value.value)); text_value += "%"; - } - else - text_value = double_to_string(value.value); + ret = text_value; break; }