mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-03 20:13:59 -06:00
new cheaper constructor for DynamicPrintConfig from FullPrintConfig:
DynamicPrintConfig::full_print_config() new cheaper constructors of DynamicConfig / DynamicPrintConfig from ConfigBase Unit tests: ported test_model from upstream Slic3r, thanks @lordofhyphens Unit tests refactored to use less autos and initializer lists for readibility, DynamicPrintConfig is handled by value, not by shared pointer.
This commit is contained in:
parent
90d5712091
commit
69c8b1cd21
12 changed files with 190 additions and 107 deletions
|
@ -668,6 +668,12 @@ void ConfigBase::null_nullables()
|
|||
}
|
||||
}
|
||||
|
||||
DynamicConfig::DynamicConfig(const ConfigBase& rhs, const t_config_option_keys& keys)
|
||||
{
|
||||
for (const t_config_option_key& opt_key : keys)
|
||||
this->options[opt_key] = std::unique_ptr<ConfigOption>(rhs.option(opt_key)->clone());
|
||||
}
|
||||
|
||||
bool DynamicConfig::operator==(const DynamicConfig &rhs) const
|
||||
{
|
||||
auto it1 = this->options.begin();
|
||||
|
|
|
@ -1580,9 +1580,11 @@ class DynamicConfig : public virtual ConfigBase
|
|||
{
|
||||
public:
|
||||
DynamicConfig() {}
|
||||
DynamicConfig(const DynamicConfig& other) { *this = other; }
|
||||
DynamicConfig(DynamicConfig&& other) : options(std::move(other.options)) { other.options.clear(); }
|
||||
virtual ~DynamicConfig() override { clear(); }
|
||||
DynamicConfig(const DynamicConfig &rhs) { *this = rhs; }
|
||||
DynamicConfig(DynamicConfig &&rhs) : options(std::move(rhs.options)) { rhs.options.clear(); }
|
||||
explicit DynamicConfig(const ConfigBase &rhs, const t_config_option_keys &keys);
|
||||
explicit DynamicConfig(const ConfigBase& rhs) : DynamicConfig(rhs, rhs.keys()) {}
|
||||
virtual ~DynamicConfig() override { clear(); }
|
||||
|
||||
// Copy a content of one DynamicConfig to another DynamicConfig.
|
||||
// If rhs.def() is not null, then it has to be equal to this->def().
|
||||
|
|
|
@ -2898,9 +2898,13 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
|||
|
||||
const PrintConfigDef print_config_def;
|
||||
|
||||
DynamicPrintConfig* DynamicPrintConfig::new_from_defaults()
|
||||
DynamicPrintConfig DynamicPrintConfig::full_print_config()
|
||||
{
|
||||
return DynamicPrintConfig((const PrintRegionConfig&)FullPrintConfig::defaults());
|
||||
}
|
||||
|
||||
DynamicPrintConfig::DynamicPrintConfig(const StaticPrintConfig& rhs) : DynamicConfig(rhs, rhs.keys_ref())
|
||||
{
|
||||
return new_from_defaults_keys(FullPrintConfig::defaults().keys());
|
||||
}
|
||||
|
||||
DynamicPrintConfig* DynamicPrintConfig::new_from_defaults_keys(const std::vector<std::string> &keys)
|
||||
|
|
|
@ -214,6 +214,8 @@ private:
|
|||
// This definition is constant.
|
||||
extern const PrintConfigDef print_config_def;
|
||||
|
||||
class StaticPrintConfig;
|
||||
|
||||
// Slic3r dynamic configuration, used to override the configuration
|
||||
// per object, per modification volume or per printing material.
|
||||
// The dynamic configuration is also used to store user modifications of the print global parameters,
|
||||
|
@ -224,9 +226,11 @@ class DynamicPrintConfig : public DynamicConfig
|
|||
{
|
||||
public:
|
||||
DynamicPrintConfig() {}
|
||||
DynamicPrintConfig(const DynamicPrintConfig &other) : DynamicConfig(other) {}
|
||||
DynamicPrintConfig(const DynamicPrintConfig &rhs) : DynamicConfig(rhs) {}
|
||||
explicit DynamicPrintConfig(const StaticPrintConfig &rhs);
|
||||
explicit DynamicPrintConfig(const ConfigBase &rhs) : DynamicConfig(rhs) {}
|
||||
|
||||
static DynamicPrintConfig* new_from_defaults();
|
||||
static DynamicPrintConfig full_print_config();
|
||||
static DynamicPrintConfig* new_from_defaults_keys(const std::vector<std::string> &keys);
|
||||
|
||||
// Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here.
|
||||
|
@ -262,6 +266,8 @@ public:
|
|||
|
||||
// Overrides ConfigBase::def(). Static configuration definition. Any value stored into this ConfigBase shall have its definition here.
|
||||
const ConfigDef* def() const override { return &print_config_def; }
|
||||
// Reference to the cached list of keys.
|
||||
virtual const t_config_option_keys& keys_ref() const = 0;
|
||||
|
||||
protected:
|
||||
// Verify whether the opt_key has not been obsoleted or renamed.
|
||||
|
@ -350,6 +356,7 @@ public: \
|
|||
{ return s_cache_##CLASS_NAME.optptr(opt_key, this); } \
|
||||
/* Overrides ConfigBase::keys(). Collect names of all configuration values maintained by this configuration store. */ \
|
||||
t_config_option_keys keys() const override { return s_cache_##CLASS_NAME.keys(); } \
|
||||
const t_config_option_keys& keys_ref() const override { return s_cache_##CLASS_NAME.keys(); } \
|
||||
static const CLASS_NAME& defaults() { initialize_cache(); return s_cache_##CLASS_NAME.defaults(); } \
|
||||
private: \
|
||||
static void initialize_cache() \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue