From d3e4b3ae5f904977570cbfdf1f8d7d2462b21356 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 18 Nov 2018 16:44:59 -0600 Subject: [PATCH] Add debug string translation for presets. --- src/GUI/Preset.cpp | 12 ++++++++++++ src/GUI/Preset.hpp | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/GUI/Preset.cpp b/src/GUI/Preset.cpp index c4b5b2638..4ab934437 100644 --- a/src/GUI/Preset.cpp +++ b/src/GUI/Preset.cpp @@ -128,6 +128,18 @@ bool Preset::compatible(const std::string& printer_name) const { auto compatible_list {this->_dirty_config->get("compatible_printers").values}; if (compatible_list.size() == 0) return true; return std::any_of(compatible_list.cbegin(), compatible_list.cend(), [printer_name] (const std::string& x) -> bool { return x.compare(printer_name) == 0; }); + +const std::string preset_name(preset_t group) { + switch(group) { + case preset_t::Print: + return "Print"s; + case preset_t::Printer: + return "Printer"s; + case preset_t::Material: + return "Material"s; + default: + return "N/A"s; + } } diff --git a/src/GUI/Preset.hpp b/src/GUI/Preset.hpp index fd7d79748..086fc58b8 100644 --- a/src/GUI/Preset.hpp +++ b/src/GUI/Preset.hpp @@ -15,7 +15,7 @@ #endif namespace Slic3r { namespace GUI { - +using namespace std::literals::string_literals; /// Preset types list. We assign numbers to permit static_casts and use as preset tab indices. /// Don't skip numbers in the enumeration, we use this as an index into vectors (instead of using std::map). @@ -30,6 +30,10 @@ constexpr preset_t to_preset(uint8_t preset) { return static_cast(pres /// Convenience counter to determine how many preset tabs exist. constexpr size_t preset_types = get_preset(preset_t::Last); +/// Convenience/debug method to get a useful name from the enumeration. +const std::string preset_name(preset_t group); + + class Preset; using Presets = std::vector;