From d74712ef7de0e651121151087daf8ce93bb56f22 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Mon, 21 May 2018 16:28:08 -0500 Subject: [PATCH] Moved Preset to its own header. --- src/GUI/GUI.hpp | 12 +++--------- src/GUI/Plater.cpp | 7 +++++++ src/GUI/Plater.hpp | 11 +++-------- src/GUI/Preset.hpp | 23 ++++++++++++++++++++++- 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/GUI/GUI.hpp b/src/GUI/GUI.hpp index 054acd001..96f18ca3b 100644 --- a/src/GUI/GUI.hpp +++ b/src/GUI/GUI.hpp @@ -9,17 +9,11 @@ #include +#include "Preset.hpp" + namespace Slic3r { namespace GUI { -// Friendly indices for the preset lists. -enum class PresetID { - PRINT = 0, - FILAMENT = 1, - PRINTER = 2 -}; -using preset_list = std::vector; - class App: public wxApp { public: @@ -41,7 +35,7 @@ public: private: std::shared_ptr gui_config; // GUI-specific configuration options std::unique_ptr notifier {nullptr}; - std::vector presets { preset_list(), preset_list(), preset_list() }; + std::vector presets { preset_types, Presets() }; void load_presets(); diff --git a/src/GUI/Plater.cpp b/src/GUI/Plater.cpp index b6ae9efcf..40d80fa99 100644 --- a/src/GUI/Plater.cpp +++ b/src/GUI/Plater.cpp @@ -1193,5 +1193,12 @@ void Plater::_on_change_combobox(preset_t preset, wxBitmapComboBox* choice) { */ } +void Plater::load_presets() { + + for (auto group : {preset_t::Printer, preset_t::Material, preset_t::Print}) { + // skip presets not compatible with selected printer + } +} + }} // Namespace Slic3r::GUI diff --git a/src/GUI/Plater.hpp b/src/GUI/Plater.hpp index 712277975..11b8c9dfa 100644 --- a/src/GUI/Plater.hpp +++ b/src/GUI/Plater.hpp @@ -18,6 +18,8 @@ #include "Config.hpp" #include "misc_ui.hpp" +#include "Preset.hpp" + #include "Plater/PlaterObject.hpp" #include "Plater/Plate2D.hpp" #include "Plater/Plate3D.hpp" @@ -37,13 +39,6 @@ enum class UndoCmd { Remove, Add, Reset, Increase, Decrease, Rotate }; -/// Preset tab list -enum class preset_t : uint8_t { - Print = 0, Material, Printer, - Last // This MUST be the last enumeration. Don't use it for anything. -}; -/// Convenience counter to determine how many preset tabs exist. -constexpr size_t preset_count = static_cast(preset_t::Last); enum class Zoom { In, Out @@ -262,7 +257,7 @@ private: void show_preset_editor(preset_t preset, unsigned int idx) { }; void _on_select_preset(preset_t preset) {}; - void load_presets() {}; + void load_presets(); }; diff --git a/src/GUI/Preset.hpp b/src/GUI/Preset.hpp index e169c4827..826e6c05c 100644 --- a/src/GUI/Preset.hpp +++ b/src/GUI/Preset.hpp @@ -5,9 +5,30 @@ namespace Slic3r { namespace GUI { -class Preset { +/// Preset types list. We assign numbers to permit static_casts and use as preset tab indices +enum class preset_t : uint8_t { + Print = 0, Material, Printer, + Last // This MUST be the last enumeration. Don't use it for anything. +}; +/// Convenience counter to determine how many preset tabs exist. +constexpr size_t preset_types = static_cast(preset_t::Last); + +class Preset; + +using Presets = std::vector; + +class Preset { + preset_t type; + std::string name {""}; + + + /// 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 Preset& other) {return (this->type == preset_t::Printer || (compatible(other.name) && other.type == preset_t::Printer));} private: + /// store to keep config options for this preset Slic3r::DynamicPrintConfig config { Slic3r::DynamicPrintConfig() }; };