More work here and there

This commit is contained in:
Alessandro Ranellucci 2014-01-01 17:29:15 +01:00
parent 51b976721d
commit 0883d0f4eb
7 changed files with 85 additions and 32 deletions

View file

@ -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() {

View file

@ -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();

View file

@ -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);