mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-30 16:42:43 +00:00
More work here and there
This commit is contained in:
@@ -35,6 +35,14 @@ ConfigBase::serialize(const t_config_option_key opt_key) {
|
||||
|
||||
void
|
||||
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";
|
||||
ConfigOptionDef* optdef = &(*this->def)[opt_key];
|
||||
if (!optdef->shortcut.empty()) {
|
||||
for (std::vector<t_config_option_key>::iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it)
|
||||
this->set_deserialize(*it, str);
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigOption* opt = this->option(opt_key, true);
|
||||
assert(opt != NULL);
|
||||
opt->deserialize(str);
|
||||
@@ -61,6 +69,20 @@ ConfigBase::get_abs_value(const t_config_option_key opt_key) {
|
||||
}
|
||||
}
|
||||
|
||||
double
|
||||
ConfigBase::get_abs_value(const t_config_option_key opt_key, double ratio_over) {
|
||||
// get stored option value
|
||||
ConfigOptionFloatOrPercent* opt = dynamic_cast<ConfigOptionFloatOrPercent*>(this->option(opt_key));
|
||||
assert(opt != NULL);
|
||||
|
||||
// compute absolute value
|
||||
if (opt->percent) {
|
||||
return ratio_over * opt->value / 100;
|
||||
} else {
|
||||
return opt->value;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
SV*
|
||||
ConfigBase::as_hash() {
|
||||
|
||||
@@ -393,6 +393,7 @@ class ConfigBase
|
||||
std::string serialize(const t_config_option_key opt_key);
|
||||
void set_deserialize(const t_config_option_key opt_key, std::string str);
|
||||
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);
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
SV* as_hash();
|
||||
|
||||
@@ -986,7 +986,7 @@ class PrintRegionConfig : public virtual StaticConfig
|
||||
ConfigOptionFloatOrPercent top_infill_extrusion_width;
|
||||
ConfigOptionInt top_solid_layers;
|
||||
|
||||
PrintObjectConfig() {
|
||||
PrintRegionConfig() {
|
||||
this->def = &PrintConfigDef::def;
|
||||
|
||||
this->bottom_solid_layers.value = 3;
|
||||
@@ -1135,7 +1135,7 @@ class PrintConfig : public virtual StaticConfig
|
||||
ConfigOptionFloat z_offset;
|
||||
|
||||
PrintConfig() {
|
||||
this->def = &PrintConfig::PrintConfigDef;
|
||||
this->def = &PrintConfigDef::def;
|
||||
|
||||
this->avoid_crossing_perimeters.value = false;
|
||||
this->bed_size.point = Pointf(200,200);
|
||||
|
||||
@@ -15,15 +15,13 @@
|
||||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
void apply(DynamicPrintConfig* other)
|
||||
%code{% THIS->apply(*other, true); %};
|
||||
void apply_static(PrintConfig* other)
|
||||
%code{% THIS->apply(*other, true); %};
|
||||
std::vector<std::string> get_keys()
|
||||
%code{% THIS->keys(&RETVAL); %};
|
||||
%{
|
||||
|
||||
%}
|
||||
};
|
||||
|
||||
%name{Slic3r::Config::Print} class PrintConfig {
|
||||
@@ -36,13 +34,45 @@
|
||||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
void apply_dynamic(DynamicPrintConfig* other)
|
||||
%code{% THIS->apply(*other, true); %};
|
||||
std::vector<std::string> get_keys()
|
||||
%code{% THIS->keys(&RETVAL); %};
|
||||
%{
|
||||
};
|
||||
|
||||
%}
|
||||
%name{Slic3r::Config::Print} class PrintConfig {
|
||||
PrintConfig();
|
||||
~PrintConfig();
|
||||
bool has(t_config_option_key opt_key);
|
||||
SV* as_hash();
|
||||
SV* get(t_config_option_key opt_key);
|
||||
void set(t_config_option_key opt_key, SV* value);
|
||||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
void apply_dynamic(DynamicPrintConfig* other)
|
||||
%code{% THIS->apply(*other, true); %};
|
||||
std::vector<std::string> get_keys()
|
||||
%code{% THIS->keys(&RETVAL); %};
|
||||
};
|
||||
|
||||
%name{Slic3r::Config::Print} class PrintConfig {
|
||||
PrintConfig();
|
||||
~PrintConfig();
|
||||
bool has(t_config_option_key opt_key);
|
||||
SV* as_hash();
|
||||
SV* get(t_config_option_key opt_key);
|
||||
void set(t_config_option_key opt_key, SV* value);
|
||||
void set_deserialize(t_config_option_key opt_key, std::string str);
|
||||
std::string serialize(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key);
|
||||
double get_abs_value(t_config_option_key opt_key, double ratio_over);
|
||||
void apply_dynamic(DynamicPrintConfig* other)
|
||||
%code{% THIS->apply(*other, true); %};
|
||||
std::vector<std::string> get_keys()
|
||||
%code{% THIS->keys(&RETVAL); %};
|
||||
};
|
||||
|
||||
%package{Slic3r::Config};
|
||||
@@ -53,8 +83,7 @@ PROTOTYPES: DISABLE
|
||||
SV*
|
||||
print_config_def()
|
||||
CODE:
|
||||
PrintConfig config;
|
||||
t_optiondef_map* def = config.def;
|
||||
t_optiondef_map* def = &PrintConfigDef::def;
|
||||
|
||||
HV* options_hv = newHV();
|
||||
for (t_optiondef_map::iterator oit = def->begin(); oit != def->end(); ++oit) {
|
||||
|
||||
Reference in New Issue
Block a user