FIX: [STUDIO-1574] not switch filament preset after wizard

Change-Id: Ica703553a6994456f12b509564443902697ed374
This commit is contained in:
chunmao.guo 2022-12-05 11:24:12 +08:00 committed by Lane.Wei
parent f49c4c7e4c
commit 8cee81b5ef
5 changed files with 16 additions and 43 deletions

View file

@ -807,36 +807,6 @@ void PresetBundle::update_system_preset_setting_ids(std::map<std::string, std::m
return;
}
void PresetBundle::load_default_setting_from_app_config(const AppConfig &config) {
auto config_filament_presets = config.get_filament_presets();
if (!config_filament_presets.empty())
this->filament_presets = config_filament_presets;
auto config_filament_colors = config.get_filament_colors();
if (!config_filament_colors.empty()) {
ConfigOptionStrings *filament_color = project_config.option<ConfigOptionStrings>("filament_colour");
filament_color->resize(config_filament_colors.size());
filament_color->values = config_filament_colors;
}
auto config_flush_volumes_matrix = config.get_flush_volumes_matrix();
if (!config_flush_volumes_matrix.empty()) {
ConfigOptionFloats *flush_volumes_matrix = project_config.option<ConfigOptionFloats>("flush_volumes_matrix");
flush_volumes_matrix->values = std::vector<double>(config_flush_volumes_matrix.begin(), config_flush_volumes_matrix.end());
}
}
void PresetBundle::update_filament_info_to_app_config(AppConfig &config)
{
config.set_filament_presets(this->filament_presets);
ConfigOptionStrings *filament_color = project_config.option<ConfigOptionStrings>("filament_colour");
config.set_filament_colors(filament_color->values);
ConfigOptionFloats *flush_volumes_matrix = project_config.option<ConfigOptionFloats>("flush_volumes_matrix");
config.set_flush_volumes_matrix(std::vector<float>(flush_volumes_matrix->values.begin(), flush_volumes_matrix->values.end()));
}
//BBS: validate printers from previous project
bool PresetBundle::validate_printers(const std::string &name, DynamicPrintConfig& config)
{
@ -1346,6 +1316,15 @@ void PresetBundle::load_selections(AppConfig &config, const PresetPreferences& p
}
}
std::string first_visible_filament_name;
for (auto & fp : filament_presets) {
if (auto it = filaments.find_preset_internal(fp); it == filaments.end() || !it->is_visible || !it->is_compatible) {
if (first_visible_filament_name.empty())
first_visible_filament_name = filaments.first_compatible().name;
fp = first_visible_filament_name;
}
}
// Parse the initial physical printer name.
std::string initial_physical_printer_name = remove_ini_suffix(config.get("presets", "physical_printer"));