mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
Config: pass value as a reference
This commit is contained in:
parent
ef0050662c
commit
40e49613b1
3 changed files with 35 additions and 35 deletions
|
@ -8,7 +8,7 @@
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ConfigBase::has(const t_config_option_key opt_key) {
|
ConfigBase::has(const t_config_option_key &opt_key) {
|
||||||
return (this->option(opt_key, false) != NULL);
|
return (this->option(opt_key, false) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ ConfigBase::diff(ConfigBase &other) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
ConfigBase::serialize(const t_config_option_key opt_key) {
|
ConfigBase::serialize(const t_config_option_key &opt_key) {
|
||||||
ConfigOption* opt = this->option(opt_key);
|
ConfigOption* opt = this->option(opt_key);
|
||||||
assert(opt != NULL);
|
assert(opt != NULL);
|
||||||
return opt->serialize();
|
return opt->serialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str) {
|
ConfigBase::set_deserialize(const t_config_option_key &opt_key, std::string str) {
|
||||||
if (this->def->count(opt_key) == 0) throw "Calling set_deserialize() on unknown option";
|
if (this->def->count(opt_key) == 0) throw "Calling set_deserialize() on unknown option";
|
||||||
ConfigOptionDef* optdef = &(*this->def)[opt_key];
|
ConfigOptionDef* optdef = &(*this->def)[opt_key];
|
||||||
if (!optdef->shortcut.empty()) {
|
if (!optdef->shortcut.empty()) {
|
||||||
|
@ -75,7 +75,7 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, std::string str)
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
ConfigBase::get_abs_value(const t_config_option_key opt_key) {
|
ConfigBase::get_abs_value(const t_config_option_key &opt_key) {
|
||||||
ConfigOption* opt = this->option(opt_key, false);
|
ConfigOption* opt = this->option(opt_key, false);
|
||||||
if (ConfigOptionFloatOrPercent* optv = dynamic_cast<ConfigOptionFloatOrPercent*>(opt)) {
|
if (ConfigOptionFloatOrPercent* optv = dynamic_cast<ConfigOptionFloatOrPercent*>(opt)) {
|
||||||
// get option definition
|
// get option definition
|
||||||
|
@ -92,7 +92,7 @@ ConfigBase::get_abs_value(const t_config_option_key opt_key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
ConfigBase::get_abs_value(const t_config_option_key opt_key, double ratio_over) {
|
ConfigBase::get_abs_value(const t_config_option_key &opt_key, double ratio_over) {
|
||||||
// get stored option value
|
// get stored option value
|
||||||
ConfigOptionFloatOrPercent* opt = dynamic_cast<ConfigOptionFloatOrPercent*>(this->option(opt_key));
|
ConfigOptionFloatOrPercent* opt = dynamic_cast<ConfigOptionFloatOrPercent*>(this->option(opt_key));
|
||||||
assert(opt != NULL);
|
assert(opt != NULL);
|
||||||
|
@ -282,7 +282,7 @@ ConfigBase::set(t_config_option_key opt_key, SV* value) {
|
||||||
/* This method is implemented as a workaround for this typemap bug:
|
/* This method is implemented as a workaround for this typemap bug:
|
||||||
https://rt.cpan.org/Public/Bug/Display.html?id=94110 */
|
https://rt.cpan.org/Public/Bug/Display.html?id=94110 */
|
||||||
bool
|
bool
|
||||||
ConfigBase::set_deserialize(const t_config_option_key opt_key, SV* str) {
|
ConfigBase::set_deserialize(const t_config_option_key &opt_key, SV* str) {
|
||||||
size_t len;
|
size_t len;
|
||||||
const char * c = SvPV(str, len);
|
const char * c = SvPV(str, len);
|
||||||
std::string value(c, len);
|
std::string value(c, len);
|
||||||
|
@ -328,7 +328,7 @@ DynamicConfig::DynamicConfig (const DynamicConfig& other) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigOption*
|
ConfigOption*
|
||||||
DynamicConfig::option(const t_config_option_key opt_key, bool create) {
|
DynamicConfig::option(const t_config_option_key &opt_key, bool create) {
|
||||||
if (this->options.count(opt_key) == 0) {
|
if (this->options.count(opt_key) == 0) {
|
||||||
if (create) {
|
if (create) {
|
||||||
ConfigOptionDef* optdef = &(*this->def)[opt_key];
|
ConfigOptionDef* optdef = &(*this->def)[opt_key];
|
||||||
|
@ -375,16 +375,16 @@ DynamicConfig::option(const t_config_option_key opt_key, bool create) {
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T*
|
T*
|
||||||
DynamicConfig::opt(const t_config_option_key opt_key, bool create) {
|
DynamicConfig::opt(const t_config_option_key &opt_key, bool create) {
|
||||||
return dynamic_cast<T*>(this->option(opt_key, create));
|
return dynamic_cast<T*>(this->option(opt_key, create));
|
||||||
}
|
}
|
||||||
template ConfigOptionInt* DynamicConfig::opt<ConfigOptionInt>(const t_config_option_key opt_key, bool create);
|
template ConfigOptionInt* DynamicConfig::opt<ConfigOptionInt>(const t_config_option_key &opt_key, bool create);
|
||||||
template ConfigOptionBool* DynamicConfig::opt<ConfigOptionBool>(const t_config_option_key opt_key, bool create);
|
template ConfigOptionBool* DynamicConfig::opt<ConfigOptionBool>(const t_config_option_key &opt_key, bool create);
|
||||||
template ConfigOptionBools* DynamicConfig::opt<ConfigOptionBools>(const t_config_option_key opt_key, bool create);
|
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);
|
template ConfigOptionPercent* DynamicConfig::opt<ConfigOptionPercent>(const t_config_option_key &opt_key, bool create);
|
||||||
|
|
||||||
const ConfigOption*
|
const ConfigOption*
|
||||||
DynamicConfig::option(const t_config_option_key opt_key) const {
|
DynamicConfig::option(const t_config_option_key &opt_key) const {
|
||||||
return const_cast<DynamicConfig*>(this)->option(opt_key, false);
|
return const_cast<DynamicConfig*>(this)->option(opt_key, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ DynamicConfig::keys() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicConfig::erase(const t_config_option_key opt_key) {
|
DynamicConfig::erase(const t_config_option_key &opt_key) {
|
||||||
this->options.erase(opt_key);
|
this->options.erase(opt_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ StaticConfig::keys() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConfigOption*
|
const ConfigOption*
|
||||||
StaticConfig::option(const t_config_option_key opt_key) const
|
StaticConfig::option(const t_config_option_key &opt_key) const
|
||||||
{
|
{
|
||||||
return const_cast<StaticConfig*>(this)->option(opt_key, false);
|
return const_cast<StaticConfig*>(this)->option(opt_key, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,18 +512,18 @@ class ConfigBase
|
||||||
t_optiondef_map* def;
|
t_optiondef_map* def;
|
||||||
|
|
||||||
ConfigBase() : def(NULL) {};
|
ConfigBase() : def(NULL) {};
|
||||||
bool has(const t_config_option_key opt_key);
|
bool has(const t_config_option_key &opt_key);
|
||||||
virtual ConfigOption* option(const t_config_option_key opt_key, bool create = false) = 0;
|
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;
|
virtual const ConfigOption* option(const t_config_option_key &opt_key) const = 0;
|
||||||
virtual t_config_option_keys keys() const = 0;
|
virtual t_config_option_keys keys() const = 0;
|
||||||
void apply(const ConfigBase &other, bool ignore_nonexistent = false);
|
void apply(const ConfigBase &other, bool ignore_nonexistent = false);
|
||||||
bool equals(ConfigBase &other);
|
bool equals(ConfigBase &other);
|
||||||
t_config_option_keys diff(ConfigBase &other);
|
t_config_option_keys diff(ConfigBase &other);
|
||||||
std::string serialize(const t_config_option_key opt_key);
|
std::string serialize(const t_config_option_key &opt_key);
|
||||||
bool set_deserialize(const t_config_option_key opt_key, std::string str);
|
bool set_deserialize(const t_config_option_key &opt_key, std::string str);
|
||||||
void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
|
void set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize = false);
|
||||||
double get_abs_value(const t_config_option_key opt_key);
|
double get_abs_value(const t_config_option_key &opt_key);
|
||||||
double get_abs_value(const t_config_option_key opt_key, double ratio_over);
|
double get_abs_value(const t_config_option_key &opt_key, double ratio_over);
|
||||||
void setenv_();
|
void setenv_();
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
|
@ -531,7 +531,7 @@ class ConfigBase
|
||||||
SV* get(t_config_option_key opt_key);
|
SV* get(t_config_option_key opt_key);
|
||||||
SV* get_at(t_config_option_key opt_key, size_t i);
|
SV* get_at(t_config_option_key opt_key, size_t i);
|
||||||
bool set(t_config_option_key opt_key, SV* value);
|
bool set(t_config_option_key opt_key, SV* value);
|
||||||
bool set_deserialize(const t_config_option_key opt_key, SV* str);
|
bool set_deserialize(const t_config_option_key &opt_key, SV* str);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -543,11 +543,11 @@ class DynamicConfig : public ConfigBase
|
||||||
DynamicConfig& operator= (DynamicConfig other);
|
DynamicConfig& operator= (DynamicConfig other);
|
||||||
void swap(DynamicConfig &other);
|
void swap(DynamicConfig &other);
|
||||||
~DynamicConfig();
|
~DynamicConfig();
|
||||||
template<class T> T* opt(const t_config_option_key opt_key, bool create = false);
|
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);
|
ConfigOption* option(const t_config_option_key &opt_key, bool create = false);
|
||||||
const ConfigOption* option(const t_config_option_key opt_key) const;
|
const ConfigOption* option(const t_config_option_key &opt_key) const;
|
||||||
t_config_option_keys keys() const;
|
t_config_option_keys keys() const;
|
||||||
void erase(const t_config_option_key opt_key);
|
void erase(const t_config_option_key &opt_key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::map<t_config_option_key,ConfigOption*> t_options_map;
|
typedef std::map<t_config_option_key,ConfigOption*> t_options_map;
|
||||||
|
@ -558,8 +558,8 @@ class StaticConfig : public ConfigBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
t_config_option_keys keys() const;
|
t_config_option_keys keys() const;
|
||||||
virtual ConfigOption* option(const t_config_option_key opt_key, bool create = false) = 0;
|
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;
|
const ConfigOption* option(const t_config_option_key &opt_key) const;
|
||||||
|
|
||||||
#ifdef SLIC3RXS
|
#ifdef SLIC3RXS
|
||||||
bool set(t_config_option_key opt_key, SV* value);
|
bool set(t_config_option_key opt_key, SV* value);
|
||||||
|
|
|
@ -150,7 +150,7 @@ class PrintObjectConfig : public virtual StaticPrintConfig
|
||||||
this->xy_size_compensation.value = 0;
|
this->xy_size_compensation.value = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
|
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(dont_support_bridges);
|
OPT_PTR(dont_support_bridges);
|
||||||
OPT_PTR(extrusion_width);
|
OPT_PTR(extrusion_width);
|
||||||
OPT_PTR(first_layer_height);
|
OPT_PTR(first_layer_height);
|
||||||
|
@ -260,7 +260,7 @@ class PrintRegionConfig : public virtual StaticPrintConfig
|
||||||
this->top_solid_layers.value = 3;
|
this->top_solid_layers.value = 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
|
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(bottom_solid_layers);
|
OPT_PTR(bottom_solid_layers);
|
||||||
OPT_PTR(bridge_flow_ratio);
|
OPT_PTR(bridge_flow_ratio);
|
||||||
OPT_PTR(bridge_speed);
|
OPT_PTR(bridge_speed);
|
||||||
|
@ -359,7 +359,7 @@ class GCodeConfig : public virtual StaticPrintConfig
|
||||||
this->use_volumetric_e.value = false;
|
this->use_volumetric_e.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
|
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(before_layer_gcode);
|
OPT_PTR(before_layer_gcode);
|
||||||
OPT_PTR(end_gcode);
|
OPT_PTR(end_gcode);
|
||||||
OPT_PTR(extrusion_axis);
|
OPT_PTR(extrusion_axis);
|
||||||
|
@ -518,7 +518,7 @@ class PrintConfig : public GCodeConfig
|
||||||
this->z_offset.value = 0;
|
this->z_offset.value = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
|
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(avoid_crossing_perimeters);
|
OPT_PTR(avoid_crossing_perimeters);
|
||||||
OPT_PTR(bed_shape);
|
OPT_PTR(bed_shape);
|
||||||
OPT_PTR(bed_temperature);
|
OPT_PTR(bed_temperature);
|
||||||
|
@ -589,7 +589,7 @@ class HostConfig : public virtual StaticPrintConfig
|
||||||
this->octoprint_apikey.value = "";
|
this->octoprint_apikey.value = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
|
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||||
OPT_PTR(octoprint_host);
|
OPT_PTR(octoprint_host);
|
||||||
OPT_PTR(octoprint_apikey);
|
OPT_PTR(octoprint_apikey);
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ class FullPrintConfig
|
||||||
: public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig
|
: public PrintObjectConfig, public PrintRegionConfig, public PrintConfig, public HostConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfigOption* option(const t_config_option_key opt_key, bool create = false) {
|
ConfigOption* option(const t_config_option_key &opt_key, bool create = false) {
|
||||||
ConfigOption* opt;
|
ConfigOption* opt;
|
||||||
if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt;
|
if ((opt = PrintObjectConfig::option(opt_key, create)) != NULL) return opt;
|
||||||
if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt;
|
if ((opt = PrintRegionConfig::option(opt_key, create)) != NULL) return opt;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue