mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 16:21:24 -06:00
Refactored the Config XS bindings
This commit is contained in:
parent
c73378744f
commit
3c862836f2
18 changed files with 104 additions and 194 deletions
|
@ -150,6 +150,16 @@ ConfigBase::setenv_()
|
|||
#endif
|
||||
}
|
||||
|
||||
const ConfigOption*
|
||||
ConfigBase::option(const t_config_option_key &opt_key) const {
|
||||
return const_cast<ConfigBase*>(this)->option(opt_key, false);
|
||||
}
|
||||
|
||||
ConfigOption*
|
||||
ConfigBase::option(const t_config_option_key &opt_key, bool create) {
|
||||
return this->optptr(opt_key, create);
|
||||
}
|
||||
|
||||
DynamicConfig& DynamicConfig::operator= (DynamicConfig other)
|
||||
{
|
||||
this->swap(other);
|
||||
|
@ -175,7 +185,7 @@ DynamicConfig::DynamicConfig (const DynamicConfig& other) {
|
|||
}
|
||||
|
||||
ConfigOption*
|
||||
DynamicConfig::option(const t_config_option_key &opt_key, bool create) {
|
||||
DynamicConfig::optptr(const t_config_option_key &opt_key, bool create) {
|
||||
if (this->options.count(opt_key) == 0) {
|
||||
if (create) {
|
||||
const ConfigOptionDef* optdef = this->def->get(opt_key);
|
||||
|
@ -231,11 +241,6 @@ template ConfigOptionBool* DynamicConfig::opt<ConfigOptionBool>(const t_config_o
|
|||
template ConfigOptionBools* DynamicConfig::opt<ConfigOptionBools>(const t_config_option_key &opt_key, bool create);
|
||||
template ConfigOptionPercent* DynamicConfig::opt<ConfigOptionPercent>(const t_config_option_key &opt_key, bool create);
|
||||
|
||||
const ConfigOption*
|
||||
DynamicConfig::option(const t_config_option_key &opt_key) const {
|
||||
return const_cast<DynamicConfig*>(this)->option(opt_key, false);
|
||||
}
|
||||
|
||||
t_config_option_keys
|
||||
DynamicConfig::keys() const {
|
||||
t_config_option_keys keys;
|
||||
|
@ -273,10 +278,4 @@ StaticConfig::keys() const {
|
|||
return keys;
|
||||
}
|
||||
|
||||
const ConfigOption*
|
||||
StaticConfig::option(const t_config_option_key &opt_key) const
|
||||
{
|
||||
return const_cast<StaticConfig*>(this)->option(opt_key, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -546,9 +546,11 @@ class ConfigBase
|
|||
const ConfigDef* def;
|
||||
|
||||
ConfigBase() : def(NULL) {};
|
||||
virtual ~ConfigBase() {};
|
||||
bool has(const t_config_option_key &opt_key);
|
||||
virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0;
|
||||
virtual const ConfigOption* option(const t_config_option_key &opt_key) const = 0;
|
||||
const ConfigOption* option(const t_config_option_key &opt_key) const;
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false);
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) = 0;
|
||||
virtual t_config_option_keys keys() const = 0;
|
||||
void apply(const ConfigBase &other, bool ignore_nonexistent = false);
|
||||
bool equals(ConfigBase &other);
|
||||
|
@ -567,10 +569,9 @@ class DynamicConfig : public virtual ConfigBase
|
|||
DynamicConfig(const DynamicConfig& other);
|
||||
DynamicConfig& operator= (DynamicConfig other);
|
||||
void swap(DynamicConfig &other);
|
||||
~DynamicConfig();
|
||||
virtual ~DynamicConfig();
|
||||
template<class T> T* opt(const t_config_option_key &opt_key, bool create = false);
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false);
|
||||
const ConfigOption* option(const t_config_option_key &opt_key) const;
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false);
|
||||
t_config_option_keys keys() const;
|
||||
void erase(const t_config_option_key &opt_key);
|
||||
|
||||
|
@ -584,8 +585,7 @@ class StaticConfig : public virtual ConfigBase
|
|||
public:
|
||||
StaticConfig() : ConfigBase() {};
|
||||
t_config_option_keys keys() const;
|
||||
virtual ConfigOption* option(const t_config_option_key &opt_key, bool create = false) = 0;
|
||||
const ConfigOption* option(const t_config_option_key &opt_key) const;
|
||||
//virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) = 0;
|
||||
void set_defaults();
|
||||
};
|
||||
|
||||
|
|
|
@ -93,13 +93,13 @@ class DynamicPrintConfig : public PrintConfigBase, public DynamicConfig
|
|||
void normalize();
|
||||
};
|
||||
|
||||
class StaticPrintConfigBase : public PrintConfigBase, public StaticConfig
|
||||
class StaticPrintConfig : public PrintConfigBase, public StaticConfig
|
||||
{
|
||||
public:
|
||||
StaticPrintConfigBase() : PrintConfigBase(), StaticConfig() {};
|
||||
StaticPrintConfig() : PrintConfigBase(), StaticConfig() {};
|
||||
};
|
||||
|
||||
class PrintObjectConfig : public virtual StaticPrintConfigBase
|
||||
class PrintObjectConfig : public virtual StaticPrintConfig
|
||||
{
|
||||
public:
|
||||
ConfigOptionBool dont_support_bridges;
|
||||
|
@ -126,11 +126,11 @@ class PrintObjectConfig : public virtual StaticPrintConfigBase
|
|||
ConfigOptionInt support_material_threshold;
|
||||
ConfigOptionFloat xy_size_compensation;
|
||||
|
||||
PrintObjectConfig() : StaticPrintConfigBase() {
|
||||
PrintObjectConfig() : StaticPrintConfig() {
|
||||
this->set_defaults();
|
||||
};
|
||||
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||
OPT_PTR(dont_support_bridges);
|
||||
OPT_PTR(extrusion_width);
|
||||
OPT_PTR(first_layer_height);
|
||||
|
@ -159,7 +159,7 @@ class PrintObjectConfig : public virtual StaticPrintConfigBase
|
|||
};
|
||||
};
|
||||
|
||||
class PrintRegionConfig : public virtual StaticPrintConfigBase
|
||||
class PrintRegionConfig : public virtual StaticPrintConfig
|
||||
{
|
||||
public:
|
||||
ConfigOptionInt bottom_solid_layers;
|
||||
|
@ -195,11 +195,11 @@ class PrintRegionConfig : public virtual StaticPrintConfigBase
|
|||
ConfigOptionInt top_solid_layers;
|
||||
ConfigOptionFloatOrPercent top_solid_infill_speed;
|
||||
|
||||
PrintRegionConfig() : StaticPrintConfigBase() {
|
||||
PrintRegionConfig() : StaticPrintConfig() {
|
||||
this->set_defaults();
|
||||
};
|
||||
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||
OPT_PTR(bottom_solid_layers);
|
||||
OPT_PTR(bridge_flow_ratio);
|
||||
OPT_PTR(bridge_speed);
|
||||
|
@ -237,7 +237,7 @@ class PrintRegionConfig : public virtual StaticPrintConfigBase
|
|||
};
|
||||
};
|
||||
|
||||
class GCodeConfig : public virtual StaticPrintConfigBase
|
||||
class GCodeConfig : public virtual StaticPrintConfig
|
||||
{
|
||||
public:
|
||||
ConfigOptionString before_layer_gcode;
|
||||
|
@ -264,11 +264,11 @@ class GCodeConfig : public virtual StaticPrintConfigBase
|
|||
ConfigOptionBool use_relative_e_distances;
|
||||
ConfigOptionBool use_volumetric_e;
|
||||
|
||||
GCodeConfig() : StaticPrintConfigBase() {
|
||||
GCodeConfig() : StaticPrintConfig() {
|
||||
this->set_defaults();
|
||||
};
|
||||
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||
OPT_PTR(before_layer_gcode);
|
||||
OPT_PTR(end_gcode);
|
||||
OPT_PTR(extrusion_axis);
|
||||
|
@ -366,7 +366,7 @@ class PrintConfig : public GCodeConfig
|
|||
this->set_defaults();
|
||||
};
|
||||
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||
OPT_PTR(avoid_crossing_perimeters);
|
||||
OPT_PTR(bed_shape);
|
||||
OPT_PTR(bed_temperature);
|
||||
|
@ -420,13 +420,13 @@ class PrintConfig : public GCodeConfig
|
|||
|
||||
// look in parent class
|
||||
ConfigOption* opt;
|
||||
if ((opt = GCodeConfig::option(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = GCodeConfig::optptr(opt_key, create)) != NULL) return opt;
|
||||
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
||||
class HostConfig : public virtual StaticPrintConfigBase
|
||||
class HostConfig : public virtual StaticPrintConfig
|
||||
{
|
||||
public:
|
||||
ConfigOptionString octoprint_host;
|
||||
|
@ -434,11 +434,11 @@ class HostConfig : public virtual StaticPrintConfigBase
|
|||
ConfigOptionString serial_port;
|
||||
ConfigOptionInt serial_speed;
|
||||
|
||||
HostConfig() : StaticPrintConfigBase() {
|
||||
HostConfig() : StaticPrintConfig() {
|
||||
this->set_defaults();
|
||||
};
|
||||
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||
OPT_PTR(octoprint_host);
|
||||
OPT_PTR(octoprint_apikey);
|
||||
OPT_PTR(serial_port);
|
||||
|
@ -452,12 +452,12 @@ class FullPrintConfig
|
|||
: public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig
|
||||
{
|
||||
public:
|
||||
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||
virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false) {
|
||||
ConfigOption* opt;
|
||||
if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = PrintConfig::option(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = HostConfig::option(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = PrintObjectConfig::optptr(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = PrintRegionConfig::optptr(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = PrintConfig::optptr(opt_key, create)) != NULL) return opt;
|
||||
if ((opt = HostConfig::optptr(opt_key, create)) != NULL) return opt;
|
||||
return NULL;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@ REGISTER_CLASS(Point3, "Point3");
|
|||
REGISTER_CLASS(Pointf, "Pointf");
|
||||
REGISTER_CLASS(Pointf3, "Pointf3");
|
||||
REGISTER_CLASS(DynamicPrintConfig, "Config");
|
||||
REGISTER_CLASS(StaticPrintConfig, "Config::Static");
|
||||
REGISTER_CLASS(PrintObjectConfig, "Config::PrintObject");
|
||||
REGISTER_CLASS(PrintRegionConfig, "Config::PrintRegion");
|
||||
REGISTER_CLASS(GCodeConfig, "Config::GCode");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue