Add debug string translation for presets.

This commit is contained in:
Joseph Lenox 2018-11-18 16:44:59 -06:00 committed by Joseph Lenox
parent 17fd8e26cd
commit d3e4b3ae5f
2 changed files with 17 additions and 1 deletions

View File

@ -128,6 +128,18 @@ bool Preset::compatible(const std::string& printer_name) const {
auto compatible_list {this->_dirty_config->get<ConfigOptionStrings>("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;
}
}

View File

@ -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<preset_t>(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<Preset>;