From 1175dc95f688a8b17e75a7cdf5ef1b472905bede Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 26 Jun 2018 10:50:50 +0200 Subject: Storing and recovering the "compatible_printers_condition" and "inherits" fields from / to the AMF/3MF/Config files. The "compatible_printers_condition" are collected over all active profiles (one print, possibly multiple filament, and one printer profile) into a single vector. --- xs/src/libslic3r/Config.cpp | 5 ++++- xs/src/libslic3r/GCode.cpp | 5 ++++- xs/src/libslic3r/PrintConfig.cpp | 14 ++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) (limited to 'xs/src/libslic3r') diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index 8c1349e08..4218fbcf9 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -188,7 +188,10 @@ void ConfigBase::apply_only(const ConfigBase &other, const t_config_option_keys throw UnknownOptionException(opt_key); } const ConfigOption *other_opt = other.option(opt_key); - if (other_opt != nullptr) + if (other_opt == nullptr) { + // The key was not found in the source config, therefore it will not be initialized! +// printf("Not found, therefore not initialized: %s\n", opt_key.c_str()); + } else my_opt->set(other_opt); } } diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 009493113..16f8ac736 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -1419,7 +1419,10 @@ void GCode::append_full_config(const Print& print, std::string& str) str += "; " + key + " = " + cfg->serialize(key) + "\n"; } const DynamicConfig &full_config = print.placeholder_parser.config(); - for (const char *key : { "print_settings_id", "filament_settings_id", "printer_settings_id" }) + for (const char *key : { + "print_settings_id", "filament_settings_id", "printer_settings_id", + "printer_model", "printer_variant", "default_print_profile", "default_filament_profile", + "compatible_printers_condition", "inherits" }) str += std::string("; ") + key + " = " + full_config.serialize(key) + "\n"; } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 486e6fe18..02961493e 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -147,12 +147,15 @@ PrintConfigDef::PrintConfigDef() def->label = L("Compatible printers"); def->default_value = new ConfigOptionStrings(); - def = this->add("compatible_printers_condition", coString); + // The following value is defined as a vector of strings, so it could + // collect the "inherits" values over the print and filaments profiles + // when storing into a project file (AMF, 3MF, Config ...) + def = this->add("compatible_printers_condition", coStrings); def->label = L("Compatible printers condition"); def->tooltip = L("A boolean expression using the configuration values of an active printer profile. " "If this expression evaluates to true, this profile is considered compatible " "with the active printer profile."); - def->default_value = new ConfigOptionString(); + def->default_value = new ConfigOptionStrings { "" }; def = this->add("complete_objects", coBool); def->label = L("Complete individual objects"); @@ -819,12 +822,15 @@ PrintConfigDef::PrintConfigDef() def->min = 0; def->default_value = new ConfigOptionFloat(80); - def = this->add("inherits", coString); + // The following value is defined as a vector of strings, so it could + // collect the "inherits" values over the print and filaments profiles + // when storing into a project file (AMF, 3MF, Config ...) + def = this->add("inherits", coStrings); def->label = L("Inherits profile"); def->tooltip = L("Name of the profile, from which this profile inherits."); def->full_width = true; def->height = 50; - def->default_value = new ConfigOptionString(""); + def->default_value = new ConfigOptionStrings { "" }; def = this->add("interface_shells", coBool); def->label = L("Interface shells"); -- cgit v1.2.3