Forward compatibility, parameter susbtitution: Substitute vector values

(extruder specific) with their default, if the default
is a single value vector.
Show the "Physical Printers" label in the substitution window.
This commit is contained in:
bubnikv 2021-07-01 08:44:02 +02:00 committed by Vojtech Bubnik
parent 3a0b71deed
commit 26822347ed
3 changed files with 31 additions and 12 deletions

View file

@ -546,9 +546,18 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con
bool substituted = false;
if (optdef->type == coBools && substitutions_ctxt.rule != ForwardCompatibilitySubstitutionRule::Disable) {
//FIXME Special handling of vectors of bools, quick and not so dirty solution before PrusaSlicer 2.3.2 release.
auto result = opt->nullable() ?
static_cast<ConfigOptionBoolsNullable*>(opt)->deserialize_with_substitutions(value, append, true) :
static_cast<ConfigOptionBools*>(opt)->deserialize_with_substitutions(value, append, true);
bool nullable = opt->nullable();
ConfigHelpers::DeserializationSubstitution default_value = ConfigHelpers::DeserializationSubstitution::DefaultsToFalse;
if (optdef->default_value) {
// Default value for vectors of booleans used in a "per extruder" context, thus the default contains just a single value.
assert(dynamic_cast<const ConfigOptionVector<unsigned char>*>(optdef->default_value.get()));
auto &values = static_cast<const ConfigOptionVector<unsigned char>*>(optdef->default_value.get())->values;
if (values.size() == 1 && values.front() == 1)
default_value = ConfigHelpers::DeserializationSubstitution::DefaultsToTrue;
}
auto result = nullable ?
static_cast<ConfigOptionBoolsNullable*>(opt)->deserialize_with_substitutions(value, append, default_value) :
static_cast<ConfigOptionBools*>(opt)->deserialize_with_substitutions(value, append, default_value);
success = result != ConfigHelpers::DeserializationResult::Failed;
substituted = result == ConfigHelpers::DeserializationResult::Substituted;
} else {