OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{HintNotification.cpp} Namespace Reference

Enumerations

enum  TagCheckResult { TagCheckAffirmative , TagCheckNegative , TagCheckNotCompatible }

Functions

void push_style_color (ImGuiCol idx, const ImVec4 &col, bool fading_out, float current_fade_opacity)
void write_used_binary (const std::vector< std::string > &ids)
void read_used_binary (std::vector< std::string > &ids)
TagCheckResult tag_check_mode (const std::string &tag)
TagCheckResult tag_check_tech (const std::string &tag)
TagCheckResult tag_check_system (const std::string &tag)
TagCheckResult tag_check_material (const std::string &tag)
bool tags_check (const std::string &disabled_tags, const std::string &enabled_tags)
void launch_browser_if_allowed (const std::string &url)

Enumeration Type Documentation

◆ TagCheckResult

enum Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::TagCheckResult
Enumerator
TagCheckAffirmative 
TagCheckNegative 
TagCheckNotCompatible 
125 {
129 };
@ TagCheckNotCompatible
Definition HintNotification.cpp:128
@ TagCheckAffirmative
Definition HintNotification.cpp:126
@ TagCheckNegative
Definition HintNotification.cpp:127

Function Documentation

◆ launch_browser_if_allowed()

void Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::launch_browser_if_allowed ( const std::string & url)
307 {
308 wxGetApp().open_browser_with_warning_dialog(url);
309 }

References launch_browser_if_allowed().

Referenced by launch_browser_if_allowed().

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

◆ push_style_color()

void Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::push_style_color ( ImGuiCol idx,
const ImVec4 & col,
bool fading_out,
float current_fade_opacity )
inline
82 {
83 if (fading_out)
84 ImGui::PushStyleColor(idx, ImVec4(col.x, col.y, col.z, col.w * current_fade_opacity));
85 else
86 ImGui::PushStyleColor(idx, col);
87 }

References push_style_color().

Referenced by push_style_color().

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

◆ read_used_binary()

void Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::read_used_binary ( std::vector< std::string > & ids)
104 {
105 boost::filesystem::path path(boost::filesystem::path(data_dir()) / "user" / "hints.cereal");
106 if (!boost::filesystem::exists(path)) {
107 BOOST_LOG_TRIVIAL(warning) << "Failed to load to hints.cereal. File does not exists. " << path.string();
108 return;
109 }
110 boost::nowide::ifstream file(path.string());
111 cereal::BinaryInputArchive archive(file);
113 try
114 {
115 archive(cd);
116 }
117 catch (const std::exception& ex)
118 {
119 BOOST_LOG_TRIVIAL(error) << "Failed to load to hints.cereal. " << ex.what();
120 return;
121 }
122 ids = cd.my_data;
123 }
const std::string & data_dir()
Definition utils.cpp:365
Definition HintNotification.cpp:53
std::vector< std::string > my_data
Definition HintNotification.cpp:54

References Slic3r::data_dir(), HintsCerealData::my_data, and read_used_binary().

Referenced by read_used_binary().

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

◆ tag_check_material()

TagCheckResult Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::tag_check_material ( const std::string & tag)
193 {
194 if (const GUI::Tab* tab = wxGetApp().get_tab(Preset::Type::TYPE_FILAMENT)) {
195 // search PrintConfig filament_type to find if allowed tag
196 if (wxGetApp().app_config->get("filament_type").find(tag)) {
197 const Preset& preset = tab->m_presets->get_edited_preset();
198 const auto* opt = preset.config.opt<ConfigOptionStrings>("filament_type");
199 if (opt->values[0] == tag)
200 return TagCheckAffirmative;
201 return TagCheckNegative;
202 }
204 }
205 /* TODO: SLA materials
206 else if (const GUI::Tab* tab = wxGetApp().get_tab(Preset::Type::TYPE_SLA_MATERIAL)) {
207 //if (wxGetApp().app_config->get("material_type").find(tag)) {
208 const Preset& preset = tab->m_presets->get_edited_preset();
209 const auto* opt = preset.config.opt<ConfigOptionStrings>("material_type");
210 if (opt->values[0] == tag)
211 return TagCheckAffirmative;
212 return TagCheckNegative;
213 //}
214 return TagCheckNotCompatible;
215 }*/
217 }
Definition Config.hpp:1190
T * opt(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:3007
Definition Tab.hpp:152
Definition Preset.hpp:241
DynamicPrintConfig config
Definition Preset.hpp:300
@ TYPE_FILAMENT
Definition Preset.hpp:248
Definition BruteforceOptimizer.hpp:11

References Slic3r::Preset::config, Slic3r::DynamicConfig::opt(), tag_check_material(), TagCheckAffirmative, TagCheckNegative, TagCheckNotCompatible, and Slic3r::Preset::TYPE_FILAMENT.

Referenced by tag_check_material(), and tags_check().

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

◆ tag_check_mode()

TagCheckResult Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::tag_check_mode ( const std::string & tag)
132 {
133 std::vector<std::string> allowed_tags = { "simple", "advanced", "expert" };
134 if (std::find(allowed_tags.begin(), allowed_tags.end(), tag) != allowed_tags.end())
135 {
136 ConfigOptionMode config_mode = wxGetApp().get_mode();
137 if (config_mode == ConfigOptionMode::comSimple) return (tag == "simple" ? TagCheckAffirmative : TagCheckNegative);
138 else if (config_mode == ConfigOptionMode::comAdvanced) return (tag == "advanced" ? TagCheckAffirmative : TagCheckNegative);
139 else if (config_mode == ConfigOptionMode::comExpert || config_mode == ConfigOptionMode::comDevelop)
140 return (tag == "expert" ? TagCheckAffirmative : TagCheckNegative);
141 }
143 }
ConfigOptionMode
Definition Config.hpp:221
@ comSimple
Definition Config.hpp:222
@ comDevelop
Definition Config.hpp:225
@ comAdvanced
Definition Config.hpp:223
@ comExpert
Definition Config.hpp:224

References Slic3r::comAdvanced, Slic3r::comDevelop, Slic3r::comExpert, Slic3r::comSimple, tag_check_mode(), TagCheckAffirmative, TagCheckNegative, and TagCheckNotCompatible.

Referenced by tag_check_mode(), and tags_check().

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

◆ tag_check_system()

TagCheckResult Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::tag_check_system ( const std::string & tag)
165 {
166 std::vector<std::string> allowed_tags = { "Windows", "Linux", "OSX" };
167 if (std::find(allowed_tags.begin(), allowed_tags.end(), tag) != allowed_tags.end()) {
168 if (tag == "Windows")
169#ifdef WIN32
170 return TagCheckAffirmative;
171#else
172 return TagCheckNegative;
173#endif // WIN32
174
175 if (tag == "Linux")
176#ifdef __linux__
177 return TagCheckAffirmative;
178#else
179 return TagCheckNegative;
180#endif // __linux__
181
182 if (tag == "OSX")
183#ifdef __APPLE__
184 return TagCheckAffirmative;
185#else
186 return TagCheckNegative;
187#endif // __apple__
188 }
190 }

References tag_check_system(), TagCheckAffirmative, TagCheckNegative, and TagCheckNotCompatible.

Referenced by tag_check_system(), and tags_check().

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

◆ tag_check_tech()

TagCheckResult Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::tag_check_tech ( const std::string & tag)
146 {
147 std::vector<std::string> allowed_tags = { "FFF", "MMU", "SLA" };
148 if (std::find(allowed_tags.begin(), allowed_tags.end(), tag) != allowed_tags.end()) {
149 const PrinterTechnology tech = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
150 if (tech == ptFFF) {
151 // MMU / FFF
152 bool is_mmu = wxGetApp().extruders_edited_cnt() > 1;
153 if (tag == "MMU") return (is_mmu ? TagCheckAffirmative : TagCheckNegative);
154 return (tag == "FFF" ? TagCheckAffirmative : TagCheckNegative);
155 }
156 else {
157 // SLA
158 return (tag == "SLA" ? TagCheckAffirmative : TagCheckNegative);
159 }
160 }
162 }
PrinterTechnology
Definition Config.hpp:229
@ ptFFF
Definition Config.hpp:231

References Slic3r::ptFFF, tag_check_tech(), TagCheckAffirmative, TagCheckNegative, and TagCheckNotCompatible.

Referenced by tag_check_tech(), and tags_check().

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

◆ tags_check()

bool Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::tags_check ( const std::string & disabled_tags,
const std::string & enabled_tags )
221 {
222 if (disabled_tags.empty() && enabled_tags.empty())
223 return true;
224 // enabled tags must ALL return affirmative or check fails
225 if (!enabled_tags.empty()) {
226 std::string tag;
227 for (size_t i = 0; i < enabled_tags.size(); i++) {
228 if (enabled_tags[i] == ' ') {
229 tag.erase();
230 continue;
231 }
232 if (enabled_tags[i] != ';') {
233 tag += enabled_tags[i];
234 }
235 if (enabled_tags[i] == ';' || i == enabled_tags.size() - 1) {
236 if (!tag.empty()) {
237 TagCheckResult result;
238 result = tag_check_mode(tag);
240 return false;
242 continue;
243 result = tag_check_tech(tag);
245 return false;
247 continue;
248 result = tag_check_system(tag);
250 return false;
252 continue;
253 result = tag_check_material(tag);
255 return false;
257 continue;
258 BOOST_LOG_TRIVIAL(error) << "Hint Notification: Tag " << tag << " in enabled_tags not compatible.";
259 // non compatible in enabled means return false since all enabled must be affirmative.
260 return false;
261 }
262 }
263 }
264 }
265 // disabled tags must all NOT return affirmative or check fails
266 if (!disabled_tags.empty()) {
267 std::string tag;
268 for (size_t i = 0; i < disabled_tags.size(); i++) {
269 if (disabled_tags[i] == ' ') {
270 tag.erase();
271 continue;
272 }
273 if (disabled_tags[i] != ';') {
274 tag += disabled_tags[i];
275 }
276 if (disabled_tags[i] == ';' || i == disabled_tags.size() - 1) {
277 if (!tag.empty()) {
278 TagCheckResult result;
279 result = tag_check_mode(tag);
281 continue;
283 return false;
284 result = tag_check_tech(tag);
286 continue;
288 return false;
289 result = tag_check_system(tag);
291 return false;
293 continue;
294 result = tag_check_material(tag);
296 return false;
298 continue;
299 BOOST_LOG_TRIVIAL(error) << "Hint Notification: Tag " << tag << " in disabled_tags not compatible.";
300 }
301 }
302 }
303 }
304 return true;
305 }
TagCheckResult tag_check_material(const std::string &tag)
Definition HintNotification.cpp:192
TagCheckResult
Definition HintNotification.cpp:125
TagCheckResult tag_check_system(const std::string &tag)
Definition HintNotification.cpp:164
TagCheckResult tag_check_mode(const std::string &tag)
Definition HintNotification.cpp:131
TagCheckResult tag_check_tech(const std::string &tag)
Definition HintNotification.cpp:145

References tag_check_material(), tag_check_mode(), tag_check_system(), tag_check_tech(), TagCheckAffirmative, TagCheckNegative, and tags_check().

Referenced by tags_check().

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

◆ write_used_binary()

void Slic3r::GUI::anonymous_namespace{HintNotification.cpp}::write_used_binary ( const std::vector< std::string > & ids)
90 {
91 boost::nowide::ofstream file((boost::filesystem::path(data_dir()) / "user" / "hints.cereal").string(), std::ios::binary);
92 cereal::BinaryOutputArchive archive(file);
93 HintsCerealData cd{ ids };
94 try
95 {
96 archive(cd);
97 }
98 catch (const std::exception& ex)
99 {
100 BOOST_LOG_TRIVIAL(error) << "Failed to write to hints.cereal. " << ex.what();
101 }
102 }

References Slic3r::data_dir(), and write_used_binary().

Referenced by write_used_binary().

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