mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-05 16:30:43 +08:00
Added factory function for new_from_defaults. Stubbed out new_from_cli.
This commit is contained in:
parent
6e541d4867
commit
eb563be888
@ -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
|
||||
|
31
xs/src/libslic3r/Config.cpp
Normal file
31
xs/src/libslic3r/Config.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "Config.hpp"
|
||||
#include "Log.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
std::shared_ptr<Config>
|
||||
Config::new_from_defaults()
|
||||
{
|
||||
return std::make_shared<Config>();
|
||||
}
|
||||
std::shared_ptr<Config>
|
||||
Config::new_from_defaults(std::initializer_list<std::string> init)
|
||||
{
|
||||
auto my_config(std::make_shared<Config>());
|
||||
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<Config>
|
||||
new_from_cli(const int& argc, const char* argv[])
|
||||
{
|
||||
return std::make_shared<Config>();
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
@ -1,19 +1,21 @@
|
||||
#ifndef CONFIG_HPP
|
||||
#define CONFIG_HPP
|
||||
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
|
||||
#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<Config> new_from_defaults();
|
||||
static std::shared_ptr<Config> new_from_defaults(std::initializer_list<std::string> init);
|
||||
static std::shared_ptr<Config> 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user