diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 3aac187cb..a087dd854 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -194,7 +194,8 @@ enum ConfigOptionType { enum ConfigOptionMode { comSimple = 0, comAdvanced, - comExpert + comExpert, + comUndef }; enum PrinterTechnology : unsigned char diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index df631f35f..369e8ca26 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1483,22 +1483,18 @@ bool Sidebar::is_multifilament() return p->combos_filament.size() > 1; } -static std::vector get_search_inputs(ConfigOptionMode mode) +void Sidebar::check_and_update_searcher(bool respect_mode /*= false*/) { - std::vector ret {}; + std::vector search_inputs{}; auto& tabs_list = wxGetApp().tabs_list; auto print_tech = wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology(); for (auto tab : tabs_list) if (tab->supports_printer_technology(print_tech)) - ret.emplace_back(Search::InputInfo {tab->get_config(), tab->type(), mode}); + search_inputs.emplace_back(Search::InputInfo{ tab->get_config(), tab->type() }); - return ret; -} - -void Sidebar::update_searcher() -{ - p->searcher.init(get_search_inputs(m_mode)); + p->searcher.check_and_update(wxGetApp().preset_bundle->printers.get_selected_preset().printer_technology(), + respect_mode ? m_mode : comExpert, search_inputs); } void Sidebar::update_mode() @@ -1507,7 +1503,6 @@ void Sidebar::update_mode() update_reslice_btn_tooltip(); update_mode_sizer(); - update_searcher(); wxWindowUpdateLocker noUpdates(this); @@ -1565,6 +1560,8 @@ Search::OptionsSearcher& Sidebar::get_searcher() std::string& Sidebar::get_search_line() { + // update searcher before show imGui search dialog on the plater, if printer technology or mode was changed + check_and_update_searcher(true); return p->searcher.search_string(); } @@ -6290,8 +6287,6 @@ void Plater::on_config_change(const DynamicPrintConfig &config) p->config->set_key_value(opt_key, config.option(opt_key)->clone()); if (opt_key == "printer_technology") { this->set_printer_technology(config.opt_enum(opt_key)); - // print technology is changed, so we should to update a search list - p->sidebar->update_searcher(); p->sidebar->show_sliced_info_sizer(false); p->reset_gcode_toolpaths(); p->view3D->get_canvas3d()->reset_sequential_print_clearance(); @@ -6537,8 +6532,6 @@ bool Plater::set_printer_technology(PrinterTechnology printer_technology) p->update_main_toolbar_tooltips(); - p->sidebar->get_searcher().set_printer_technology(printer_technology); - p->notification_manager->set_fff(printer_technology == ptFFF); p->notification_manager->set_slicing_progress_hidden(); @@ -6703,8 +6696,10 @@ void Plater::search(bool plater_is_active) evt.SetControlDown(true); canvas3D()->on_char(evt); } - else + else { + p->sidebar->check_and_update_searcher(true); p->sidebar->get_searcher().show_dialog(); + } } void Plater::msw_rescale() diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 581e63034..f59f138d4 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -111,7 +111,7 @@ public: void update_mode(); bool is_collapsed(); void collapse(bool collapse); - void update_searcher(); + void check_and_update_searcher(bool respect_mode = false); void update_ui_from_settings(); #ifdef _MSW_DARK_MODE diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index add5dc002..cc7cf2f8d 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -76,7 +76,7 @@ static std::string get_key(const std::string& opt_key, Preset::Type type) return std::to_string(int(type)) + ";" + opt_key; } -void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type type, ConfigOptionMode mode) +void OptionsSearcher::append_options(DynamicPrintConfig* config, Preset::Type type) { auto emplace = [this, type](const std::string key, const wxString& label) { @@ -297,27 +297,18 @@ OptionsSearcher::~OptionsSearcher() { } -void OptionsSearcher::init(std::vector input_values) +void OptionsSearcher::check_and_update(PrinterTechnology pt_in, ConfigOptionMode mode_in, std::vector input_values) { - options.clear(); - for (auto i : input_values) - append_options(i.config, i.type, i.mode); - sort_options(); - - search(search_line, true); -} - -void OptionsSearcher::apply(DynamicPrintConfig* config, Preset::Type type, ConfigOptionMode mode) -{ - if (options.empty()) + if (printer_technology == pt_in && mode == mode_in) return; - options.erase(std::remove_if(options.begin(), options.end(), [type](Option opt) { - return opt.type == type; - }), options.end()); + options.clear(); - append_options(config, type, mode); + printer_technology = pt_in; + mode = mode_in; + for (auto i : input_values) + append_options(i.config, i.type); sort_options(); search(search_line, true); diff --git a/src/slic3r/GUI/Search.hpp b/src/slic3r/GUI/Search.hpp index d5add9262..cdabe9358 100644 --- a/src/slic3r/GUI/Search.hpp +++ b/src/slic3r/GUI/Search.hpp @@ -32,7 +32,6 @@ struct InputInfo { DynamicPrintConfig* config {nullptr}; Preset::Type type {Preset::TYPE_INVALID}; - ConfigOptionMode mode {comSimple}; }; struct GroupAndCategory { @@ -82,12 +81,13 @@ class OptionsSearcher { std::string search_line; std::map groups_and_categories; - PrinterTechnology printer_technology; + PrinterTechnology printer_technology {ptAny}; + ConfigOptionMode mode{ comUndef }; std::vector