diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1190ee54..12ac4a3b3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,6 +54,7 @@ add_library(libslic3r STATIC ${LIBDIR}/libslic3r/BridgeDetector.cpp ${LIBDIR}/libslic3r/ClipperUtils.cpp ${LIBDIR}/libslic3r/ConfigBase.cpp + ${LIBDIR}/libslic3r/Config.cpp ${LIBDIR}/libslic3r/ExPolygon.cpp ${LIBDIR}/libslic3r/ExPolygonCollection.cpp ${LIBDIR}/libslic3r/Extruder.cpp diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp new file mode 100644 index 000000000..d9f99cbbc --- /dev/null +++ b/xs/src/libslic3r/Config.cpp @@ -0,0 +1,31 @@ +#include "Config.hpp" +#include "Log.hpp" + +namespace Slic3r { + +std::shared_ptr +Config::new_from_defaults() +{ + return std::make_shared(); +} +std::shared_ptr +Config::new_from_defaults(std::initializer_list init) +{ + auto my_config(std::make_shared()); + for (auto& opt_key : init) { + if (print_config_def.has(opt_key)) { + const std::string value { print_config_def.get(opt_key)->default_value->serialize() }; + my_config->set_deserialize(opt_key, value); + } + } + + return my_config; +} + +std::shared_ptr +new_from_cli(const int& argc, const char* argv[]) +{ + return std::make_shared(); +} + +} // namespace Slic3r diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 265cc2201..118309033 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -1,19 +1,21 @@ #ifndef CONFIG_HPP #define CONFIG_HPP +#include +#include + #include "PrintConfig.hpp" namespace Slic3r { class Config : DynamicPrintConfig { public: - static Config *new_from_defaults(); - static Config *new_from_cli(const &argc, const char* argv[]); + static std::shared_ptr new_from_defaults(); + static std::shared_ptr new_from_defaults(std::initializer_list init); + static std::shared_ptr new_from_cli(const int& argc, const char* argv[]); void write_ini(const std::string& file) { save(file); } void read_ini(const std::string& file) { load(file); } - - }; } // namespace Slic3r