Moved Preset to its own header.

This commit is contained in:
Joseph Lenox 2018-05-21 16:28:08 -05:00
parent c5653a1435
commit d74712ef7d
4 changed files with 35 additions and 18 deletions

View File

@ -9,17 +9,11 @@
#include <mutex> #include <mutex>
#include "Preset.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
// Friendly indices for the preset lists.
enum class PresetID {
PRINT = 0,
FILAMENT = 1,
PRINTER = 2
};
using preset_list = std::vector<std::string>;
class App: public wxApp class App: public wxApp
{ {
public: public:
@ -41,7 +35,7 @@ public:
private: private:
std::shared_ptr<Settings> gui_config; // GUI-specific configuration options std::shared_ptr<Settings> gui_config; // GUI-specific configuration options
std::unique_ptr<Notifier> notifier {nullptr}; std::unique_ptr<Notifier> notifier {nullptr};
std::vector<preset_list> presets { preset_list(), preset_list(), preset_list() }; std::vector<Presets> presets { preset_types, Presets() };
void load_presets(); void load_presets();

View File

@ -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 }} // Namespace Slic3r::GUI

View File

@ -18,6 +18,8 @@
#include "Config.hpp" #include "Config.hpp"
#include "misc_ui.hpp" #include "misc_ui.hpp"
#include "Preset.hpp"
#include "Plater/PlaterObject.hpp" #include "Plater/PlaterObject.hpp"
#include "Plater/Plate2D.hpp" #include "Plater/Plate2D.hpp"
#include "Plater/Plate3D.hpp" #include "Plater/Plate3D.hpp"
@ -37,13 +39,6 @@ enum class UndoCmd {
Remove, Add, Reset, Increase, Decrease, Rotate 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<uint8_t>(preset_t::Last);
enum class Zoom { enum class Zoom {
In, Out In, Out
@ -262,7 +257,7 @@ private:
void show_preset_editor(preset_t preset, unsigned int idx) { }; void show_preset_editor(preset_t preset, unsigned int idx) { };
void _on_select_preset(preset_t preset) {}; void _on_select_preset(preset_t preset) {};
void load_presets() {}; void load_presets();
}; };

View File

@ -5,9 +5,30 @@
namespace Slic3r { namespace GUI { 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<uint8_t>(preset_t::Last);
class Preset;
using Presets = std::vector<Preset>;
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: private:
/// store to keep config options for this preset
Slic3r::DynamicPrintConfig config { Slic3r::DynamicPrintConfig() }; Slic3r::DynamicPrintConfig config { Slic3r::DynamicPrintConfig() };
}; };