diff --git a/src/GUI/Preset.cpp b/src/GUI/Preset.cpp index c98885e8f..c4b5b2638 100644 --- a/src/GUI/Preset.cpp +++ b/src/GUI/Preset.cpp @@ -121,4 +121,14 @@ t_config_option_keys Preset::_group_overrides() const { } } +bool Preset::compatible(const std::string& printer_name) const { + if (!this->_dirty_config->has("compatible_printers") || this->default_preset || this->group == preset_t::Printer) { + return true; + } + 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; }); +} + + }} // namespace Slic3r::GUI diff --git a/src/GUI/Preset.hpp b/src/GUI/Preset.hpp index 53869758b..ba98bde55 100644 --- a/src/GUI/Preset.hpp +++ b/src/GUI/Preset.hpp @@ -48,9 +48,10 @@ public: /// Search the compatible_printers config option list for this preset name. /// Assume that Printer configs are compatible with other Printer configs - bool compatible(std::string printer_name) { return true; } - bool compatible(const wxString& printer_name) { if (group == preset_t::Printer) return true; return true; } - bool compatible(const Preset& other) {return (this->group == preset_t::Printer || (compatible(other.name) && other.group == preset_t::Printer));} + /// @param [in] Printer preset name to use to compare. + bool compatible(const std::string& printer_name) const; + bool compatible(const wxString& printer_name) const { return this->compatible(printer_name.ToStdString()); } + bool compatible(const Preset& other) const {return (this->group == preset_t::Printer || (compatible(other.name) && other.group == preset_t::Printer));} /// Format the name appropriately. wxString dropdown_name() { return (this->dirty() ? this->name << " " << _("(modified)") : this->name); }