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