mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-20 07:11:12 -06:00 
			
		
		
		
	FIX: save and restore filament colors and flush volumes
Change-Id: I04b80d95e6a3e23ef3561e512673ea39dfc3ff0c
This commit is contained in:
		
							parent
							
								
									8be11c8688
								
							
						
					
					
						commit
						711f5906b9
					
				
					 2 changed files with 28 additions and 8 deletions
				
			
		|  | @ -458,8 +458,6 @@ std::string AppConfig::load() | ||||||
|             } else if (it.key() == "presets") { |             } else if (it.key() == "presets") { | ||||||
|                 for (auto iter = it.value().begin(); iter != it.value().end(); iter++) { |                 for (auto iter = it.value().begin(); iter != it.value().end(); iter++) { | ||||||
|                     if (iter.key() == "filaments") { |                     if (iter.key() == "filaments") { | ||||||
|                         // BBS: filament presets is now considered as project config instead of app config
 |  | ||||||
| #if 0 |  | ||||||
|                         int idx = 0; |                         int idx = 0; | ||||||
|                         for(auto& element: iter.value()) { |                         for(auto& element: iter.value()) { | ||||||
|                             if (idx == 0) |                             if (idx == 0) | ||||||
|  | @ -468,7 +466,6 @@ std::string AppConfig::load() | ||||||
|                                 m_storage[it.key()]["filament_" + std::to_string(idx)] = element; |                                 m_storage[it.key()]["filament_" + std::to_string(idx)] = element; | ||||||
|                             idx++; |                             idx++; | ||||||
|                         } |                         } | ||||||
| #endif |  | ||||||
|                     } else { |                     } else { | ||||||
|                         m_storage[it.key()][iter.key()] = iter.value().get<std::string>(); |                         m_storage[it.key()][iter.key()] = iter.value().get<std::string>(); | ||||||
|                     } |                     } | ||||||
|  | @ -598,7 +595,7 @@ void AppConfig::save() | ||||||
|         } else if (category.first == "presets") { |         } else if (category.first == "presets") { | ||||||
|             json j_filament_array; |             json j_filament_array; | ||||||
|             for(const auto& kvp : category.second) { |             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); |                     j_filament_array.push_back(kvp.second); | ||||||
|                 } else { |                 } else { | ||||||
|                     j[category.first][kvp.first] = kvp.second; |                     j[category.first][kvp.first] = kvp.second; | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ | ||||||
| #include <boost/filesystem.hpp> | #include <boost/filesystem.hpp> | ||||||
| #include <boost/algorithm/clamp.hpp> | #include <boost/algorithm/clamp.hpp> | ||||||
| #include <boost/algorithm/string/predicate.hpp> | #include <boost/algorithm/string/predicate.hpp> | ||||||
| 
 | #include <boost/range/adaptor/transformed.hpp> | ||||||
| #include <boost/nowide/cenv.hpp> | #include <boost/nowide/cenv.hpp> | ||||||
| #include <boost/nowide/cstdio.hpp> | #include <boost/nowide/cstdio.hpp> | ||||||
| #include <boost/nowide/fstream.hpp> | #include <boost/nowide/fstream.hpp> | ||||||
|  | @ -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_prints.select_preset_by_name_strict(initial_sla_print_profile_name); | ||||||
|     sla_materials.select_preset_by_name_strict(initial_sla_material_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 the names of the other filament profiles selected for a multi-material printer.
 | ||||||
|     // Load it even if the current printer technology is SLA.
 |     // 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()
 |     // 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; |             break; | ||||||
|         this->filament_presets.emplace_back(remove_ini_suffix(config.get("presets", name))); |         this->filament_presets.emplace_back(remove_ini_suffix(config.get("presets", name))); | ||||||
|     } |     } | ||||||
| #endif |     std::vector<std::string> 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<ConfigOptionStrings>("filament_colour")->values = filament_colors; | ||||||
|  |     } | ||||||
|  |     std::vector<std::string> 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<double, std::string>); | ||||||
|  |         project_config.option<ConfigOptionFloats>("flush_volumes_matrix")->values = std::vector<double>(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<double, std::string>); | ||||||
|  |         project_config.option<ConfigOptionFloats>("flush_volumes_vector")->values = std::vector<double>(flush_volumes_vector.begin(), flush_volumes_vector.end()); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     // Update visibility of presets based on their compatibility with the active printer.
 |     // 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,
 |     // 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); |         sprintf(name, "filament_%u", i); | ||||||
|         config.set("presets", name, filament_presets[i]); |         config.set("presets", name, filament_presets[i]); | ||||||
|     } |     } | ||||||
|  |     std::string filament_colors = boost::algorithm::join(project_config.option<ConfigOptionStrings>("filament_colour")->values, ","); | ||||||
|  |     config.set("presets", "filament_colors", filament_colors); | ||||||
|  |     std::string flush_volumes_matrix = boost::algorithm::join(project_config.option<ConfigOptionFloats>("flush_volumes_matrix")->values | | ||||||
|  |                                                              boost::adaptors::transformed(static_cast<std::string (*)(double)>(std::to_string)), | ||||||
|  |                                                          "|"); | ||||||
|  |     config.set("presets", "flush_volumes_matrix", flush_volumes_matrix); | ||||||
|  |     std::string flush_volumes_vector = boost::algorithm::join(project_config.option<ConfigOptionFloats>("flush_volumes_vector")->values | | ||||||
|  |                                                              boost::adaptors::transformed(static_cast<std::string (*)(double)>(std::to_string)), | ||||||
|  |                                                          "|"); | ||||||
|  |     config.set("presets", "flush_volumes_vector", flush_volumes_vector); | ||||||
| 
 | 
 | ||||||
|     config.set("presets", PRESET_PRINTER_NAME, printers.get_selected_preset_name()); |     config.set("presets", PRESET_PRINTER_NAME, printers.get_selected_preset_name()); | ||||||
|     // BBS
 |     // BBS
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 chunmao.guo
						chunmao.guo