From 77f5ed68511232b62050e4f2dc827d991a759acb Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 23 Mar 2018 12:52:37 +0100 Subject: [PATCH] Fixed bugs from SPE-180 --- xs/src/libslic3r/PrintConfig.cpp | 2 +- xs/src/slic3r/GUI/Field.cpp | 3 ++- xs/src/slic3r/GUI/OptionsGroup.cpp | 5 +++-- xs/src/slic3r/GUI/Preset.cpp | 8 -------- xs/src/slic3r/GUI/Tab.cpp | 19 +++++++------------ 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index a49124f87..657e5a452 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1041,7 +1041,7 @@ PrintConfigDef::PrintConfigDef() def->multiline = true; def->full_width = true; def->height = 60; - def->default_value = new ConfigOptionStrings{ "" }; + def->default_value = new ConfigOptionStrings(); def = this->add("printer_model", coString); def->label = L("Printer type"); diff --git a/xs/src/slic3r/GUI/Field.cpp b/xs/src/slic3r/GUI/Field.cpp index 9bb5f13e5..70a8b84cf 100644 --- a/xs/src/slic3r/GUI/Field.cpp +++ b/xs/src/slic3r/GUI/Field.cpp @@ -404,6 +404,7 @@ void Choice::set_value(boost::any value, bool change_event) case coInt: case coFloat: case coPercent: + case coString: case coStrings:{ wxString text_value; if (m_opt.type == coInt) @@ -417,7 +418,6 @@ void Choice::set_value(boost::any value, bool change_event) break; ++idx; } -// if (m_opt.type == coPercent) text_value += "%"; idx == m_opt.enum_values.size() ? dynamic_cast(window)->SetValue(text_value) : dynamic_cast(window)->SetSelection(idx); @@ -446,6 +446,7 @@ void Choice::set_values(const std::vector values) auto ww = dynamic_cast(window); auto value = ww->GetValue(); ww->Clear(); + ww->Append(""); for (auto el : values) ww->Append(wxString(el)); ww->SetValue(value); diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 3a97c98c7..2c055c9dd 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -406,8 +406,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config ret = text_value; else if (opt->gui_flags.compare("serialized") == 0){ std::vector values = config.option(opt_key)->values; - for (auto el : values) - text_value += el + ";"; + if (!values.empty() && values[0].compare("") != 0) + for (auto el : values) + text_value += el + ";"; ret = text_value; } else diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index a5ab65c9f..c437f8b41 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -584,14 +584,6 @@ std::vector PresetCollection::system_equal_options() const std::vector equal; if (edited != nullptr && reference != nullptr) { equal = reference->config.equal(edited->config); - // The "compatible_printers" option key is handled differently from the others: - // It is not mandatory. If the key is missing, it means it is compatible with any printer. - // If the key exists and it is empty, it means it is compatible with no printer. - std::initializer_list optional_keys{ "compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (reference->config.has(opt_key) == edited->config.has(opt_key)) - equal.emplace_back(opt_key); - } } return equal; } diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index ac972f9e4..e15ffa8c2 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -225,11 +225,6 @@ void Tab::update_changed_ui() m_sys_options.resize(0); const auto sys_preset = m_presets->get_selected_preset_parent(); if (sys_preset){ - std::initializer_list optional_keys{"compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (m_config->has(opt_key) == sys_preset->config.has(opt_key)) - m_sys_options.emplace_back(opt_key); - } for (auto opt_key : m_config->keys()) { if (opt_key == "bed_shape"){ m_sys_options.emplace_back(opt_key); continue; } @@ -241,7 +236,13 @@ void Tab::update_changed_ui() case coStrings: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; case coPercents:add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; case coPoints: add_correct_opts_to_sys_options(opt_key, &m_sys_options, tab); break; - default: m_sys_options.emplace_back(opt_key); break; + default:{ + const ConfigOption *opt_cur = tab->m_config->option(opt_key); + const ConfigOption *opt_sys = sys_preset->config.option(opt_key); + if (opt_cur != nullptr && opt_sys != nullptr && *opt_cur == *opt_sys) + m_sys_options.emplace_back(opt_key); + break; + } } } @@ -358,12 +359,6 @@ void Tab::update_full_options_list() } } m_full_options_list.emplace_back("extruders_count"); - - std::initializer_list optional_keys{ "compatible_printers", "compatible_printers_condition" }; - for (auto &opt_key : optional_keys) { - if (m_config->has(opt_key)) - m_full_options_list.emplace_back(opt_key); - } } void Tab::update_sys_ui_after_sel_preset()