From ed7658ae9f37f6253fbc0efebca73cd8b6e6d6a8 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Wed, 9 Apr 2025 20:59:41 +0800 Subject: [PATCH] FIX: use old wipe tower params for old version 3mf file jira: STUDIO-11309 Change-Id: I598236646b4de5094d1e9d10ace59c14f1643b44 --- src/slic3r/GUI/Plater.cpp | 66 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 65c39f9ba..b6caaad8a 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5175,12 +5175,12 @@ std::vector Plater::priv::load_files(const std::vector& input_ if (type_3mf) { DynamicPrintConfig config; Semver file_version; + En3mfType en_3mf_file_type = En3mfType::From_BBS; { DynamicPrintConfig config_loaded; // BBS: add part plate related logic PlateDataPtrs plate_data; - En3mfType en_3mf_file_type = En3mfType::From_BBS; ConfigSubstitutionContext config_substitutions{ForwardCompatibilitySubstitutionRule::Enable}; std::vector project_presets; // BBS: backup & restore @@ -5435,6 +5435,70 @@ std::vector Plater::priv::load_files(const std::vector& input_ Preset::normalize(config); PresetBundle *preset_bundle = wxGetApp().preset_bundle; + { + // BBS: modify the prime tower params for old version file + Semver old_version3(2, 0, 0); + if (en_3mf_file_type == En3mfType::From_BBS && file_version < old_version3) { + double old_filament_prime_volume = 0.; + int filament_count = 0; + { + ConfigOptionFloats *filament_prime_volume_option = config.option("filament_prime_volume"); + ConfigOptionStrings *filament_colors_option = config.option("filament_colour", true); + filament_count = filament_colors_option->values.size(); + if (filament_prime_volume_option) { + std::vector &filament_prime_volume_values = filament_prime_volume_option->values; + if (!filament_prime_volume_values.empty()) { + old_filament_prime_volume = filament_prime_volume_values[0]; + if (filament_count > 1) filament_prime_volume_values.resize(filament_count, old_filament_prime_volume); + } + } + } + ConfigOptionBool *prime_tower_rib_wall_option = config.option("prime_tower_rib_wall", true); + prime_tower_rib_wall_option->value = false; + + ConfigOptionPercent *prime_tower_infill_gap_option = config.option("prime_tower_infill_gap", true); + prime_tower_infill_gap_option->value = 100; + + ConfigOptionInts *filament_adhesiveness_category_option = config.option("filament_adhesiveness_category", true); + std::vector &filament_adhesiveness_category_values = filament_adhesiveness_category_option->values; + filament_adhesiveness_category_values.resize(filament_count); + for (int index = 0; index < filament_count; index++) + filament_adhesiveness_category_values[index] = 100; + + ConfigOptionFloats *filament_prime_volume_option = config.option("filament_prime_volume", true); + + std::vector &filament_prime_volume_values = filament_prime_volume_option->values; + filament_prime_volume_values.resize(filament_count); + for (int index = 0; index < filament_count; index++) { + if (old_filament_prime_volume != 0.) + filament_prime_volume_values[index] = old_filament_prime_volume; + else + filament_prime_volume_values[index] = filament_prime_volume_values[0]; + } + + std::vector &diff_settings = config.option("different_settings_to_system", true)->values; + diff_settings.resize(filament_count + 2); + + std::vector diff_process_keys; + std::string diff_process_settings = diff_settings[0]; + Slic3r::unescape_strings_cstyle(diff_process_settings, diff_process_keys); + diff_process_keys.emplace_back("prime_tower_rib_wall"); + diff_process_keys.emplace_back("prime_tower_infill_gap"); + diff_process_settings = Slic3r::escape_strings_cstyle(diff_process_keys); + diff_settings[0] = diff_process_settings; + + for (int index = 0; index < filament_count; index++) { + std::vector diff_filament_keys; + std::string diff_filament_settings = diff_settings[index + 1]; + Slic3r::unescape_strings_cstyle(diff_filament_settings, diff_filament_keys); + diff_filament_keys.emplace_back("filament_prime_volume"); + diff_filament_keys.emplace_back("filament_adhesiveness_category"); + diff_filament_settings = Slic3r::escape_strings_cstyle(diff_filament_keys); + diff_settings[index + 1] = diff_filament_settings; + } + } + } + auto choise = wxGetApp().app_config->get("no_warn_when_modified_gcodes"); if (choise.empty() || choise != "true") { // BBS: first validate the printer