OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Search Namespace Reference

Classes

struct  FoundOption
struct  OptionViewParameters
class  OptionsSearcher
class  SearchItem
class  SearchDialog
class  SearchListModel
class  SearchObjectDialog
struct  InputInfo
struct  GroupAndCategory
struct  Option
class  SettingsIndex

Functions

static char marker_by_type (Preset::Type type, PrinterTechnology pt)
static std::wstring mark_string (const std::wstring &str, const std::vector< uint16_t > &matches, Preset::Type type, PrinterTechnology pt)
static bool fuzzy_match (const std::wstring &search_pattern, const std::wstring &label, int &out_score, std::vector< uint16_t > &out_matches)
static std::string get_key (const std::string &opt_key, Preset::Type type)
template<class T>
void change_opt_key (std::string &opt_key, DynamicPrintConfig *config, int &cnt)
static Option make_option (const std::string &key, Preset::Type type, const wxString &label, const GroupAndCategory &gc, ConfigOptionMode mode, const std::string &tooltip, bool rewrite_extruder_category)
static Option create_option (const std::string &opt_key, const wxString &label, Preset::Type type, const GroupAndCategory &gc)
wxString compose_display_label (const wxString &line_label, const wxString &leaf_label, bool multi)
wxString resolve_setting_title (const wxString &precomposed, const wxString &live_label, bool live_multi)

Variables

static const std::map< const char, int > icon_idxs

Class Documentation

◆ Slic3r::Search::OptionViewParameters

struct Slic3r::Search::OptionViewParameters
Class Members
bool category {false}
bool english {false}
int hovered_id {0}

◆ Slic3r::Search::InputInfo

struct Slic3r::Search::InputInfo
Collaboration diagram for Slic3r::Search::InputInfo:
Class Members
DynamicPrintConfig * config {nullptr}
ConfigOptionMode mode {comSimple}
Type type {Preset::TYPE_INVALID}

◆ Slic3r::Search::GroupAndCategory

struct Slic3r::Search::GroupAndCategory
Collaboration diagram for Slic3r::Search::GroupAndCategory:
Class Members
wxString category
wxString group
wxString icon
wxString line_label
wxString line_label_en
string path

Function Documentation

◆ change_opt_key()

template<class T>
void Slic3r::Search::change_opt_key ( std::string & opt_key,
DynamicPrintConfig * config,
int & cnt )
33{
34 T *opt_cur = static_cast<T *>(config->option(opt_key));
35 cnt = opt_cur->values.size();
36 return;
37
38 if (opt_cur->values.size() > 0) opt_key += "#" + std::to_string(0);
39}
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2768

References Slic3r::ConfigBase::option().

Referenced by Slic3r::Search::SettingsIndex::append_options().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compose_display_label()

wxString Slic3r::Search::compose_display_label ( const wxString & line_label,
const wxString & leaf_label,
bool multi )
inline
40{
41 if (line_label.empty())
42 return leaf_label;
43 if (!multi || leaf_label.empty() || leaf_label == line_label)
44 return line_label;
45 return line_label + L" \u2013 " + leaf_label; // en dash separator
46}
#define L(s)
Definition ExtrusionEntity.cpp:25

References L.

Referenced by Slic3r::GUI::OptionsGroup::append_line().

Here is the caller graph for this function:

◆ create_option()

Option Slic3r::Search::create_option ( const std::string & opt_key,
const wxString & label,
Preset::Type type,
const GroupAndCategory & gc )
static
208{
209 return make_option(get_key(opt_key, type), type, label, gc, comSimple, std::string(), true);
210}
static Option make_option(const std::string &key, Preset::Type type, const wxString &label, const GroupAndCategory &gc, ConfigOptionMode mode, const std::string &tooltip, bool rewrite_extruder_category)
Definition SettingsIndex.cpp:43
static std::string get_key(const std::string &opt_key, Preset::Type type)
Definition SettingsIndex.cpp:26
@ comSimple
Definition Config.hpp:222

References Slic3r::comSimple, get_key(), and make_option().

Referenced by Slic3r::Search::SettingsIndex::get_option().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuzzy_match()

bool Slic3r::Search::fuzzy_match ( const std::wstring & search_pattern,
const std::wstring & label,
int & out_score,
std::vector< uint16_t > & out_matches )
static
128{
129 uint16_t matches[fts::max_matches + 1]; // +1 for the stopper
130 int score;
131 if (fts::fuzzy_match(search_pattern.c_str(), label.c_str(), score, matches)) {
132 size_t cnt = 0;
133 for (; matches[cnt] != fts::stopper; ++cnt)
134 ;
135 out_matches.assign(matches, matches + cnt);
136 out_score = score;
137 return true;
138 } else
139 return false;
140}
static bool fuzzy_match(char_type const *pattern, char_type const *str, int &outScore)
static constexpr int max_matches
Definition fts_fuzzy_match.h:48
static constexpr pos_type stopper
Definition fts_fuzzy_match.h:47

References fts::fuzzy_match(), fts::max_matches, and fts::stopper.

Referenced by Slic3r::Search::OptionsSearcher::search().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_key()

std::string Slic3r::Search::get_key ( const std::string & opt_key,
Preset::Type type )
static
26{ return std::to_string(int(type)) + ";" + opt_key; }

Referenced by Slic3r::Search::SettingsIndex::add_key(), Slic3r::Search::SettingsIndex::append_options(), create_option(), Slic3r::Search::SettingsIndex::get_option(), Slic3r::Search::SettingsIndex::get_option(), Slic3r::Search::SettingsIndex::set_line_label(), and Slic3r::Search::SettingsIndex::set_path().

Here is the caller graph for this function:

◆ make_option()

Option Slic3r::Search::make_option ( const std::string & key,
Preset::Type type,
const wxString & label,
const GroupAndCategory & gc,
ConfigOptionMode mode,
const std::string & tooltip,
bool rewrite_extruder_category )
static
45{
46 wxString suffix;
47 wxString suffix_local;
48 if (gc.category == "Machine limits") {
49 //suffix = key.back() == '1' ? L("Stealth") : L("Normal");
50 suffix = key.back() == '1' ? wxEmptyString : wxEmptyString;
51 suffix_local = " " + _(suffix);
52 suffix = " " + suffix;
53 }
54
55 wxString category = gc.category;
56 if (rewrite_extruder_category && type == Preset::TYPE_PRINTER && category.Contains("Extruder ")) {
57 std::string opt_idx = key.substr(key.find("#") + 1);
58 category = wxString::Format("%s %d", "Extruder", atoi(opt_idx.c_str()) + 1);
59 }
60
61 Option option{boost::nowide::widen(key), type, (label + suffix).ToStdWstring(), (_(label) + suffix_local).ToStdWstring(),
62 gc.group.ToStdWstring(), _(gc.group).ToStdWstring(), into_u8(gc.icon), gc.category.ToStdWstring(),
63 GUI::Tab::translate_category(category, type).ToStdWstring(), false, mode, tooltip, gc.path,
64 // The settings page draws Line::label; carrying it lets the Speed Dial name a setting
65 // the way the page does. `label`/`label_local` stay the search-oriented name.
67 return option;
68}
#define _(s)
Definition 3mf.cpp:306
static wxString translate_category(const wxString &title, Preset::Type preset_type, bool translate=true)
Definition Tab.cpp:823
@ TYPE_PRINTER
Definition Preset.hpp:250
wxString line_label
Definition SettingsIndex.hpp:31
wxString line_label_en
Definition SettingsIndex.hpp:32
wxString group
Definition SettingsIndex.hpp:28
wxString icon
Definition SettingsIndex.hpp:30
std::string path
Definition SettingsIndex.hpp:33
wxString category
Definition SettingsIndex.hpp:29
std::string into_u8(const wxString &str)
Definition GUI.cpp:549

References _, Slic3r::Search::GroupAndCategory::category, Slic3r::Search::GroupAndCategory::group, Slic3r::Search::GroupAndCategory::icon, Slic3r::into_u8(), Slic3r::Search::GroupAndCategory::line_label, Slic3r::Search::GroupAndCategory::line_label_en, Slic3r::Search::GroupAndCategory::path, Slic3r::GUI::Tab::translate_category(), and Slic3r::Preset::TYPE_PRINTER.

Referenced by Slic3r::Search::SettingsIndex::append_options(), and create_option().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mark_string()

std::wstring Slic3r::Search::mark_string ( const std::wstring & str,
const std::vector< uint16_t > & matches,
Preset::Type type,
PrinterTechnology pt )
static
99{
100 std::wstring out;
101 out += marker_by_type(type, pt);
102 if (matches.empty())
103 out += str;
104 else {
105 out.reserve(str.size() * 2);
106 if (matches.front() > 0) out += str.substr(0, matches.front());
107 for (size_t i = 0;;) {
108 // Find the longest string of successive indices.
109 size_t j = i + 1;
110 while (j < matches.size() && matches[j] == matches[j - 1] + 1) ++j;
111 out += ImGui::ColorMarkerStart;
112 out += str.substr(matches[i], matches[j - 1] - matches[i] + 1);
113 out += ImGui::ColorMarkerEnd;
114 if (j == matches.size()) {
115 out += str.substr(matches[j - 1] + 1);
116 break;
117 }
118 out += str.substr(matches[j - 1] + 1, matches[j] - matches[j - 1] - 1);
119 i = j;
120 }
121 }
122 return out;
123}
static char marker_by_type(Preset::Type type, PrinterTechnology pt)
Definition Search.cpp:79

References marker_by_type().

Referenced by Slic3r::Search::OptionsSearcher::search().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ marker_by_type()

char Slic3r::Search::marker_by_type ( Preset::Type type,
PrinterTechnology pt )
static
80{
81 switch (type) {
83 case Preset::TYPE_SLA_PRINT: return ImGui::PrintIconMarker;
84 case Preset::TYPE_FILAMENT: return ImGui::FilamentIconMarker;
85 case Preset::TYPE_SLA_MATERIAL: return ImGui::MaterialIconMarker;
86 case Preset::TYPE_PRINTER: return pt == ptSLA ? ImGui::PrinterSlaIconMarker : ImGui::PrinterIconMarker;
87 default: return ' ';
88 }
89}
@ TYPE_SLA_PRINT
Definition Preset.hpp:247
@ TYPE_PRINT
Definition Preset.hpp:246
@ TYPE_SLA_MATERIAL
Definition Preset.hpp:249
@ TYPE_FILAMENT
Definition Preset.hpp:248
@ ptSLA
Definition Config.hpp:233

References Slic3r::ptSLA, Slic3r::Preset::TYPE_FILAMENT, Slic3r::Preset::TYPE_PRINT, Slic3r::Preset::TYPE_PRINTER, Slic3r::Preset::TYPE_SLA_MATERIAL, and Slic3r::Preset::TYPE_SLA_PRINT.

Referenced by mark_string(), and Slic3r::Search::OptionsSearcher::search().

Here is the caller graph for this function:

◆ resolve_setting_title()

wxString Slic3r::Search::resolve_setting_title ( const wxString & precomposed,
const wxString & live_label,
bool live_multi )
inline
51{
52 if (!live_multi && !live_label.empty())
53 return live_label;
54 return precomposed;
55}

Referenced by Slic3r::GUI::anonymous_namespace{ActionRegistry.cpp}::setting_text().

Here is the caller graph for this function:

Variable Documentation

◆ icon_idxs

const std::map<const char, int> Slic3r::Search::icon_idxs
static
Initial value:
= {
{ImGui::PrintIconMarker, 0}, {ImGui::PrinterIconMarker, 1}, {ImGui::PrinterSlaIconMarker, 2}, {ImGui::FilamentIconMarker, 3}, {ImGui::MaterialIconMarker, 4},
}
438 {
439 {ImGui::PrintIconMarker, 0}, {ImGui::PrinterIconMarker, 1}, {ImGui::PrinterSlaIconMarker, 2}, {ImGui::FilamentIconMarker, 3}, {ImGui::MaterialIconMarker, 4},
440};

Referenced by Slic3r::Search::SearchListModel::Prepend().