Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::Search Namespace Reference

Classes

struct  FoundOption
 
struct  GroupAndCategory
 
struct  InputInfo
 
struct  Option
 
class  OptionsSearcher
 
struct  OptionViewParameters
 
class  SearchDialog
 
class  SearchListModel
 

Functions

static char marker_by_type (Preset::Type type, PrinterTechnology pt)
 
template<class T >
void change_opt_key (std::string &opt_key, DynamicPrintConfig *config, int &cnt)
 
static std::string get_key (const std::string &opt_key, Preset::Type type)
 
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 Option create_option (const std::string &opt_key, const wxString &label, Preset::Type type, const GroupAndCategory &gc)
 

Variables

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

Class Documentation

◆ Slic3r::Search::GroupAndCategory

struct Slic3r::Search::GroupAndCategory
Class Members
wxString category
wxString group

◆ Slic3r::Search::InputInfo

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

◆ Slic3r::Search::OptionViewParameters

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

Function Documentation

◆ change_opt_key()

template<class T >
void Slic3r::Search::change_opt_key ( std::string &  opt_key,
DynamicPrintConfig config,
int &  cnt 
)
68{
69 T* opt_cur = static_cast<T*>(config->option(opt_key));
70 cnt = opt_cur->values.size();
71 return;
72
73 if (opt_cur->values.size() > 0)
74 opt_key += "#" + std::to_string(0);
75}
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2169

References Slic3r::ConfigBase::option().

+ Here is the call graph for this function:

◆ create_option()

static Option Slic3r::Search::create_option ( const std::string &  opt_key,
const wxString &  label,
Preset::Type  type,
const GroupAndCategory gc 
)
static
387{
388 wxString suffix;
389 wxString suffix_local;
390 if (gc.category == "Machine limits") {
391 suffix = opt_key.back() == '1' ? L("Stealth") : L("Normal");
392 suffix_local = " " + _(suffix);
393 suffix = " " + suffix;
394 }
395
396 wxString category = gc.category;
397 if (type == Preset::TYPE_PRINTER && category.Contains("Extruder ")) {
398 std::string opt_idx = opt_key.substr(opt_key.find("#") + 1);
399 category = wxString::Format("%s %d", "Extruder", atoi(opt_idx.c_str()) + 1);
400 }
401
402 return Option{ boost::nowide::widen(get_key(opt_key, type)), type,
403 (label + suffix).ToStdWstring(), (_(label) + suffix_local).ToStdWstring(),
404 gc.group.ToStdWstring(), _(gc.group).ToStdWstring(),
405 gc.category.ToStdWstring(), GUI::Tab::translate_category(category, type).ToStdWstring() };
406}
#define _(msgid)
Definition getopt.c:87
wxString group
Definition Search.hpp:39
wxString category
Definition Search.hpp:40
wchar_t * widen(wchar_t *output, size_t output_size, char const *source)
Convert NULL terminated UTF source string to NULL terminated output string of size at most output_siz...
Definition convert.hpp:95
#define L(s)
Definition I18N.hpp:18

References _, Slic3r::Search::GroupAndCategory::category, get_key(), Slic3r::Search::GroupAndCategory::group, L, Slic3r::GUI::Tab::translate_category(), Slic3r::Preset::TYPE_PRINTER, and boost::nowide::widen().

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

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

◆ fuzzy_match()

static bool Slic3r::Search::fuzzy_match ( const std::wstring &  search_pattern,
const std::wstring &  label,
int &  out_score,
std::vector< uint16_t > &  out_matches 
)
static
181{
182 uint16_t matches[fts::max_matches + 1]; // +1 for the stopper
183 int score;
184 if (fts::fuzzy_match(search_pattern.c_str(), label.c_str(), score, matches)) {
185 size_t cnt = 0;
186 for (; matches[cnt] != fts::stopper; ++cnt);
187 out_matches.assign(matches, matches + cnt);
188 out_score = score;
189 return true;
190 } else
191 return false;
192}
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
unsigned __int16 uint16_t
Definition unistd.h:78

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()

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

Referenced by Slic3r::Search::OptionsSearcher::add_key(), Slic3r::Search::OptionsSearcher::append_options(), Slic3r::Search::OptionsSearcher::append_preferences_option(), create_option(), Slic3r::Search::OptionsSearcher::get_option(), and Slic3r::Search::OptionsSearcher::get_option().

+ Here is the caller graph for this function:

◆ mark_string()

static std::wstring Slic3r::Search::mark_string ( const std::wstring &  str,
const std::vector< uint16_t > &  matches,
Preset::Type  type,
PrinterTechnology  pt 
)
static
147{
148 std::wstring out;
149 out += marker_by_type(type, pt);
150 if (matches.empty())
151 out += str;
152 else {
153 out.reserve(str.size() * 2);
154 if (matches.front() > 0)
155 out += str.substr(0, matches.front());
156 for (size_t i = 0;;) {
157 // Find the longest string of successive indices.
158 size_t j = i + 1;
159 while (j < matches.size() && matches[j] == matches[j - 1] + 1)
160 ++ j;
162 out += str.substr(matches[i], matches[j - 1] - matches[i] + 1);
164 if (j == matches.size()) {
165 out += str.substr(matches[j - 1] + 1);
166 break;
167 }
168 out += str.substr(matches[j - 1] + 1, matches[j] - matches[j - 1] - 1);
169 i = j;
170 }
171 }
172 return out;
173}
const char ColorMarkerStart
Definition imconfig.h:123
const char ColorMarkerEnd
Definition imconfig.h:124
static char marker_by_type(Preset::Type type, PrinterTechnology pt)
Definition Search.cpp:35

References ImGui::ColorMarkerEnd, ImGui::ColorMarkerStart, and 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()

static char Slic3r::Search::marker_by_type ( Preset::Type  type,
PrinterTechnology  pt 
)
static
36{
37 switch(type) {
38 case Preset::TYPE_PRINT:
39 case Preset::TYPE_SLA_PRINT:
41 case Preset::TYPE_FILAMENT:
43 case Preset::TYPE_SLA_MATERIAL:
45 case Preset::TYPE_PRINTER:
47 case Preset::TYPE_PREFERENCES:
49 default:
50 return ' ';
51 }
52}
const wchar_t PreferencesButton
Definition imconfig.h:147
const wchar_t PrinterIconMarker
Definition imconfig.h:128
const wchar_t FilamentIconMarker
Definition imconfig.h:130
const wchar_t MaterialIconMarker
Definition imconfig.h:131
const wchar_t PrinterSlaIconMarker
Definition imconfig.h:129
const wchar_t PrintIconMarker
Definition imconfig.h:127
@ ptSLA
Definition Config.hpp:209

References ImGui::FilamentIconMarker, ImGui::MaterialIconMarker, ImGui::PreferencesButton, ImGui::PrinterIconMarker, ImGui::PrinterSlaIconMarker, ImGui::PrintIconMarker, Slic3r::ptSLA, Slic3r::Preset::TYPE_FILAMENT, Slic3r::Preset::TYPE_PREFERENCES, 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:

Variable Documentation

◆ icon_idxs

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