diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 98dd5cd1e..a742614bf 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -458,8 +458,6 @@ std::string AppConfig::load() } else if (it.key() == "presets") { for (auto iter = it.value().begin(); iter != it.value().end(); iter++) { if (iter.key() == "filaments") { - // BBS: filament presets is now considered as project config instead of app config -#if 0 int idx = 0; for(auto& element: iter.value()) { if (idx == 0) @@ -468,7 +466,6 @@ std::string AppConfig::load() m_storage[it.key()]["filament_" + std::to_string(idx)] = element; idx++; } -#endif } else { m_storage[it.key()][iter.key()] = iter.value().get(); } @@ -598,7 +595,7 @@ void AppConfig::save() } else if (category.first == "presets") { json j_filament_array; for(const auto& kvp : category.second) { - if (boost::starts_with(kvp.first, "filament")) { + if (boost::starts_with(kvp.first, "filament") && kvp.first != "filament_colors") { j_filament_array.push_back(kvp.second); } else { j[category.first][kvp.first] = kvp.second; diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 94faebd2a..46e57bd20 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -13,7 +13,7 @@ #include #include #include - +#include #include #include #include @@ -1288,8 +1288,6 @@ void PresetBundle::load_selections(AppConfig &config, const PresetPreferences& p sla_prints.select_preset_by_name_strict(initial_sla_print_profile_name); sla_materials.select_preset_by_name_strict(initial_sla_material_profile_name); - // BBS: filament_presets are now considered as project config instead of app config -#if 0 // Load the names of the other filament profiles selected for a multi-material printer. // Load it even if the current printer technology is SLA. // The possibly excessive filament names will be later removed with this->update_multi_material_filament_presets() @@ -1302,7 +1300,22 @@ void PresetBundle::load_selections(AppConfig &config, const PresetPreferences& p break; this->filament_presets.emplace_back(remove_ini_suffix(config.get("presets", name))); } -#endif + std::vector filament_colors; + if (config.has("presets", "filament_colors")) { + boost::algorithm::split(filament_colors, config.get("presets", "filament_colors"), boost::algorithm::is_any_of(",")); + project_config.option("filament_colour")->values = filament_colors; + } + std::vector matrix; + if (config.has("presets", "flush_volumes_matrix")) { + boost::algorithm::split(matrix, config.get("presets", "flush_volumes_matrix"), boost::algorithm::is_any_of("|")); + auto flush_volumes_matrix = matrix | boost::adaptors::transformed(boost::lexical_cast); + project_config.option("flush_volumes_matrix")->values = std::vector(flush_volumes_matrix.begin(), flush_volumes_matrix.end()); + } + if (config.has("presets", "flush_volumes_vector")) { + boost::algorithm::split(matrix, config.get("presets", "flush_volumes_vector"), boost::algorithm::is_any_of("|")); + auto flush_volumes_vector = matrix | boost::adaptors::transformed(boost::lexical_cast); + project_config.option("flush_volumes_vector")->values = std::vector(flush_volumes_vector.begin(), flush_volumes_vector.end()); + } // Update visibility of presets based on their compatibility with the active printer. // Always try to select a compatible print and filament preset to the current printer preset, @@ -1354,6 +1367,16 @@ void PresetBundle::export_selections(AppConfig &config) sprintf(name, "filament_%u", i); config.set("presets", name, filament_presets[i]); } + std::string filament_colors = boost::algorithm::join(project_config.option("filament_colour")->values, ","); + config.set("presets", "filament_colors", filament_colors); + std::string flush_volumes_matrix = boost::algorithm::join(project_config.option("flush_volumes_matrix")->values | + boost::adaptors::transformed(static_cast(std::to_string)), + "|"); + config.set("presets", "flush_volumes_matrix", flush_volumes_matrix); + std::string flush_volumes_vector = boost::algorithm::join(project_config.option("flush_volumes_vector")->values | + boost::adaptors::transformed(static_cast(std::to_string)), + "|"); + config.set("presets", "flush_volumes_vector", flush_volumes_vector); config.set("presets", PRESET_PRINTER_NAME, printers.get_selected_preset_name()); // BBS