diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 7bbdf93c8..de2f88a45 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -546,7 +546,7 @@ filament_cost = 0 filament_density = 0 filament_diameter = 1.75 filament_notes = "" -filament_settings_id = +filament_settings_id = "" filament_soluble = 0 min_print_speed = 15 slowdown_below_layer_time = 20 diff --git a/xs/src/libslic3r/utils.cpp b/xs/src/libslic3r/utils.cpp index 2978783a6..582488c5a 100644 --- a/xs/src/libslic3r/utils.cpp +++ b/xs/src/libslic3r/utils.cpp @@ -95,7 +95,7 @@ const std::string& var_dir() std::string var(const std::string &file_name) { - auto file = boost::filesystem::canonical(boost::filesystem::path(g_var_dir) / file_name).make_preferred(); + auto file = (boost::filesystem::path(g_var_dir) / file_name).make_preferred(); return file.string(); } diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index 1388c3510..68982185b 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -188,6 +188,14 @@ void Preset::normalize(DynamicPrintConfig &config) if (opt != nullptr && opt->is_vector()) static_cast(opt)->resize(n, defaults.option(key)); } + // The following keys are mandatory for the UI, but they are not part of FullPrintConfig, therefore they are handled separately. + for (const std::string &key : { "filament_settings_id" }) { + auto *opt = config.option(key, false); + assert(opt != nullptr); + assert(opt->type() == coStrings); + if (opt != nullptr && opt->type() == coStrings) + static_cast(opt)->values.resize(n, std::string()); + } } } diff --git a/xs/src/slic3r/GUI/PresetBundle.cpp b/xs/src/slic3r/GUI/PresetBundle.cpp index a34640da7..1427e5086 100644 --- a/xs/src/slic3r/GUI/PresetBundle.cpp +++ b/xs/src/slic3r/GUI/PresetBundle.cpp @@ -54,17 +54,15 @@ PresetBundle::PresetBundle() : // Create the ID config keys, as they are not part of the Static print config classes. this->prints.default_preset().config.opt_string("print_settings_id", true); - this->filaments.default_preset().config.opt_string("filament_settings_id", true); + this->filaments.default_preset().config.option("filament_settings_id", true)->values.assign(1, std::string()); this->printers.default_preset().config.opt_string("printer_settings_id", true); - // Create the "compatible printers" keys, as they are not part of the Static print config classes. - this->filaments.default_preset().config.optptr("compatible_printers", true); - this->filaments.default_preset().config.optptr("compatible_printers_condition", true); - this->prints.default_preset().config.optptr("compatible_printers", true); - this->prints.default_preset().config.optptr("compatible_printers_condition", true); - // Create the "inherits" keys. - this->prints.default_preset().config.optptr("inherits", true); - this->filaments.default_preset().config.optptr("inherits", true); - this->printers.default_preset().config.optptr("inherits", true); + // "compatible printers" are not mandatory yet. + //FIXME Rename "compatible_printers" and "compatible_printers_condition", as they are defined in both print and filament profiles, + // therefore they are clashing when generating a a config file, G-code or AMF/3MF. +// this->filaments.default_preset().config.optptr("compatible_printers", true); +// this->filaments.default_preset().config.optptr("compatible_printers_condition", true); +// this->prints.default_preset().config.optptr("compatible_printers", true); +// this->prints.default_preset().config.optptr("compatible_printers_condition", true); // Create the "printer_vendor", "printer_model" and "printer_variant" keys. this->printers.default_preset().config.optptr("printer_vendor", true); this->printers.default_preset().config.optptr("printer_model", true); @@ -364,7 +362,9 @@ DynamicPrintConfig PresetBundle::full_config() const DynamicPrintConfig out; out.apply(FullPrintConfig()); out.apply(this->prints.get_edited_preset().config); - out.apply(this->printers.get_edited_preset().config); + // Add the default filament preset to have the "filament_preset_id" defined. + out.apply(this->filaments.default_preset().config); + out.apply(this->printers.get_edited_preset().config); out.apply(this->project_config); auto *nozzle_diameter = dynamic_cast(out.option("nozzle_diameter")); @@ -385,7 +385,7 @@ DynamicPrintConfig PresetBundle::full_config() const std::vector filament_opts(num_extruders, nullptr); // loop through options and apply them to the resulting config. for (const t_config_option_key &key : this->filaments.default_preset().config.keys()) { - if (key == "compatible_printers") + if (key == "compatible_printers" || key == "compatible_printers_condition") continue; // Get a destination option. ConfigOption *opt_dst = out.option(key, false); @@ -403,7 +403,9 @@ DynamicPrintConfig PresetBundle::full_config() const } } + //FIXME These two value types clash between the print and filament profiles. They should be renamed. out.erase("compatible_printers"); + out.erase("compatible_printers_condition"); static const char *keys[] = { "perimeter", "infill", "solid_infill", "support_material", "support_material_interface" }; for (size_t i = 0; i < sizeof(keys) / sizeof(keys[0]); ++ i) { @@ -838,13 +840,17 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla // Load the print, filament or printer preset. const DynamicPrintConfig &default_config = presets->default_preset().config; DynamicPrintConfig config(default_config); + std::vector config_keys = config.keys(); + // The following two keys are valid, but they are not mandatory. + config_keys.emplace_back("compatible_printers"); + config_keys.emplace_back("compatible_printers_condition"); for (auto &kvp : section.second) config.set_deserialize(kvp.first, kvp.second.data()); Preset::normalize(config); // Report configuration fields, which are misplaced into a wrong group. std::string incorrect_keys; size_t n_incorrect_keys = 0; - for (const std::string &key : config.keys()) + for (const std::string &key : config_keys) if (! default_config.has(key)) { if (incorrect_keys.empty()) incorrect_keys = key;