#include "Search.hpp" #include #include #include #include #include #include #include "wx/dataview.h" #include "wx/numformatter.h" #include "Widgets/Label.hpp" #include "libslic3r/PrintConfig.hpp" #include "libslic3r/PresetBundle.hpp" #include "GUI_App.hpp" #include "Plater.hpp" #include "Tab.hpp" #define FTS_FUZZY_MATCH_IMPLEMENTATION #include "fts_fuzzy_match.h" #include "imgui/imconfig.h" #if defined(__WXGTK__) #include "LinuxDisplayBackend.hpp" #endif using boost::optional; namespace Slic3r { wxDEFINE_EVENT(wxCUSTOMEVT_JUMP_TO_OPTION, wxCommandEvent); wxDEFINE_EVENT(wxCUSTOMEVT_EXIT_SEARCH, wxCommandEvent); wxDEFINE_EVENT(wxCUSTOMEVT_JUMP_TO_OBJECT, wxCommandEvent); using GUI::from_u8; using GUI::into_u8; namespace { bool focus_left_popup(wxWindow* popup, wxWindow* focus_window, wxWindow* related_window_1 = nullptr, wxWindow* related_window_2 = nullptr, wxWindow* related_window_3 = nullptr) { return focus_window != popup && !popup->IsDescendant(focus_window) && focus_window != related_window_1 && focus_window != related_window_2 && focus_window != related_window_3; } } // namespace namespace Search { static char marker_by_type(Preset::Type type, PrinterTechnology pt) { switch (type) { case Preset::TYPE_PRINT: case Preset::TYPE_SLA_PRINT: return ImGui::PrintIconMarker; case Preset::TYPE_FILAMENT: return ImGui::FilamentIconMarker; case Preset::TYPE_SLA_MATERIAL: return ImGui::MaterialIconMarker; case Preset::TYPE_PRINTER: return pt == ptSLA ? ImGui::PrinterSlaIconMarker : ImGui::PrinterIconMarker; default: return ' '; } } std::string Option::opt_key() const { return into_u8(key).substr(2); } void FoundOption::get_marked_label_and_tooltip(const char **label_, const char **tooltip_) const { *label_ = marked_label.c_str(); *tooltip_ = tooltip.c_str(); } template // void change_opt_key(std::string& opt_key, DynamicPrintConfig* config) void change_opt_key(std::string &opt_key, DynamicPrintConfig *config, int &cnt) { T *opt_cur = static_cast(config->option(opt_key)); cnt = opt_cur->values.size(); return; if (opt_cur->values.size() > 0) opt_key += "#" + std::to_string(0); } 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) { auto emplace = [this, type](std::vector