From 23cff74efbc5ab08e972c109f5c2fc14e7f7dc13 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Tue, 5 Oct 2021 12:26:45 +0200 Subject: [PATCH] Hint notification: selected filament tag check. --- resources/data/hints.ini | 1 + src/slic3r/GUI/HintNotification.cpp | 41 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/resources/data/hints.ini b/resources/data/hints.ini index e7b1bb681..a79a8228a 100644 --- a/resources/data/hints.ini +++ b/resources/data/hints.ini @@ -48,6 +48,7 @@ # enabled_tags = ... # disabled_tags = ... # supported tags are: simple; advanced; expert; FFF; MMU; SLA; Windows; Linux; OSX; +# and all filament types: PLA; PET; ABS; ASA; FLEX; HIPS; EDGE; NGEN; NYLON; PVA; PC; PP; PEI; PEEK; PEKK; POM; PSU; PVDF; SCAFF; # Tags are case sensitive. # FFF is affirmative for both one or more extruder printers. # Algorithm shows hint only if ALL enabled tags are affirmative. (so never do enabled_tags = FFF; SLA;) diff --git a/src/slic3r/GUI/HintNotification.cpp b/src/slic3r/GUI/HintNotification.cpp index 1963e7915..4f298eabf 100644 --- a/src/slic3r/GUI/HintNotification.cpp +++ b/src/slic3r/GUI/HintNotification.cpp @@ -5,10 +5,14 @@ #include "GUI_ObjectList.hpp" #include "GLCanvas3D.hpp" #include "MainFrame.hpp" +#include "Tab.hpp" #include "libslic3r/AppConfig.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/Config.hpp" #include "libslic3r/PresetBundle.hpp" +#include "libslic3r/Preset.hpp" +#include "libslic3r/Config.hpp" +#include "libslic3r/PrintConfig.hpp" #include #include @@ -159,6 +163,33 @@ TagCheckResult tag_check_system(const std::string& tag) return TagCheckNotCompatible; } +TagCheckResult tag_check_material(const std::string& tag) +{ + if (const GUI::Tab* tab = wxGetApp().get_tab(Preset::Type::TYPE_FILAMENT)) { + // search PrintConfig filament_type to find if allowed tag + if (wxGetApp().app_config->get("filament_type").find(tag)) { + const Preset& preset = tab->m_presets->get_edited_preset(); + const auto* opt = preset.config.opt("filament_type"); + if (opt->values[0] == tag) + return TagCheckAffirmative; + return TagCheckNegative; + } + return TagCheckNotCompatible; + } + /* TODO: SLA materials + else if (const GUI::Tab* tab = wxGetApp().get_tab(Preset::Type::TYPE_SLA_MATERIAL)) { + //if (wxGetApp().app_config->get("material_type").find(tag)) { + const Preset& preset = tab->m_presets->get_edited_preset(); + const auto* opt = preset.config.opt("material_type"); + if (opt->values[0] == tag) + return TagCheckAffirmative; + return TagCheckNegative; + //} + return TagCheckNotCompatible; + }*/ + return TagCheckNotCompatible; +} + // return true if NOT in disabled mode. bool tags_check(const std::string& disabled_tags, const std::string& enabled_tags) { @@ -189,6 +220,11 @@ bool tags_check(const std::string& disabled_tags, const std::string& enabled_tag if (result == TagCheckResult::TagCheckAffirmative) continue; result = tag_check_system(tag); + if (result == TagCheckResult::TagCheckNegative) + return false; + if (result == TagCheckResult::TagCheckAffirmative) + continue; + result = tag_check_material(tag); if (result == TagCheckResult::TagCheckNegative) return false; if (result == TagCheckResult::TagCheckAffirmative) @@ -225,6 +261,11 @@ bool tags_check(const std::string& disabled_tags, const std::string& enabled_tag if (result == TagCheckResult::TagCheckAffirmative) return false; result = tag_check_system(tag); + if (result == TagCheckResult::TagCheckAffirmative) + return false; + if (result == TagCheckResult::TagCheckNegative) + continue; + result = tag_check_material(tag); if (result == TagCheckResult::TagCheckAffirmative) return false; if (result == TagCheckResult::TagCheckNegative)