Fixed conversion of installed presets from PrusaSlicer 2.1.1 to 2.2.0
This commit is contained in:
parent
a3ded8fa95
commit
7f3ac39757
@ -1483,6 +1483,7 @@ void ConfigWizard::priv::load_vendors()
|
||||
for (const std::pair<std::string, std::string> &material_name_and_installed : section_old)
|
||||
if (material_name_and_installed.second == "1") {
|
||||
// Material is installed. Resolve it in bundles.
|
||||
size_t num_found = 0;
|
||||
const std::string &material_name = material_name_and_installed.first;
|
||||
for (auto &bundle : bundles) {
|
||||
const PresetCollection &materials = bundle.second.preset_bundle->materials(technology);
|
||||
@ -1491,13 +1492,19 @@ void ConfigWizard::priv::load_vendors()
|
||||
// Not found. Maybe the material preset is there, bu it was was renamed?
|
||||
const std::string *new_name = materials.get_preset_name_renamed(material_name);
|
||||
if (new_name != nullptr)
|
||||
preset = materials.find_preset(material_name);
|
||||
preset = materials.find_preset(*new_name);
|
||||
}
|
||||
if (preset != nullptr)
|
||||
// Materal preset was found, mark it as installed.
|
||||
section_new[preset->name] = "1";
|
||||
if (preset != nullptr) {
|
||||
// Materal preset was found, mark it as installed.
|
||||
section_new[preset->name] = "1";
|
||||
++ num_found;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num_found == 0)
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Profile %1% was not found in installed vendor Preset Bundles.") % material_name;
|
||||
else if (num_found > 1)
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Profile %1% was found in %2% vendor Preset Bundles.") % material_name % num_found;
|
||||
}
|
||||
}
|
||||
appconfig_new.set_section(section_name, section_new);
|
||||
};
|
||||
|
@ -289,17 +289,7 @@ std::string PresetBundle::load_system_presets()
|
||||
this->reset(false);
|
||||
}
|
||||
|
||||
this->prints .update_map_system_profile_renamed();
|
||||
this->sla_prints .update_map_system_profile_renamed();
|
||||
this->filaments .update_map_system_profile_renamed();
|
||||
this->sla_materials.update_map_system_profile_renamed();
|
||||
this->printers .update_map_system_profile_renamed();
|
||||
|
||||
this->prints .update_map_alias_to_profile_name();
|
||||
this->sla_prints .update_map_alias_to_profile_name();
|
||||
this->filaments .update_map_alias_to_profile_name();
|
||||
this->sla_materials.update_map_alias_to_profile_name();
|
||||
|
||||
this->update_system_maps();
|
||||
return errors_cummulative;
|
||||
}
|
||||
|
||||
@ -324,6 +314,20 @@ std::vector<std::string> PresetBundle::merge_presets(PresetBundle &&other)
|
||||
return duplicate_prints;
|
||||
}
|
||||
|
||||
void PresetBundle::update_system_maps()
|
||||
{
|
||||
this->prints .update_map_system_profile_renamed();
|
||||
this->sla_prints .update_map_system_profile_renamed();
|
||||
this->filaments .update_map_system_profile_renamed();
|
||||
this->sla_materials.update_map_system_profile_renamed();
|
||||
this->printers .update_map_system_profile_renamed();
|
||||
|
||||
this->prints .update_map_alias_to_profile_name();
|
||||
this->sla_prints .update_map_alias_to_profile_name();
|
||||
this->filaments .update_map_alias_to_profile_name();
|
||||
this->sla_materials.update_map_alias_to_profile_name();
|
||||
}
|
||||
|
||||
static inline std::string remove_ini_suffix(const std::string &name)
|
||||
{
|
||||
std::string out = name;
|
||||
@ -337,9 +341,9 @@ static inline std::string remove_ini_suffix(const std::string &name)
|
||||
// If the "vendor" section is missing, enable all models and variants of the particular vendor.
|
||||
void PresetBundle::load_installed_printers(const AppConfig &config)
|
||||
{
|
||||
for (auto &preset : printers) {
|
||||
this->update_system_maps();
|
||||
for (auto &preset : printers)
|
||||
preset.set_visible_from_appconfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& PresetBundle::get_preset_name_by_alias( const Preset::Type& preset_type, const std::string& alias) const
|
||||
@ -367,7 +371,7 @@ void PresetBundle::load_installed_filaments(AppConfig &config)
|
||||
if (printer.is_visible && printer.printer_technology() == ptFFF) {
|
||||
const PresetWithVendorProfile printer_with_vendor_profile = printers.get_preset_with_vendor_profile(printer);
|
||||
for (const Preset &filament : filaments)
|
||||
if (is_compatible_with_printer(filaments.get_preset_with_vendor_profile(filament), printer_with_vendor_profile))
|
||||
if (filament.is_system && is_compatible_with_printer(filaments.get_preset_with_vendor_profile(filament), printer_with_vendor_profile))
|
||||
compatible_filaments.insert(&filament);
|
||||
}
|
||||
// and mark these filaments as installed, therefore this code will not be executed at the next start of the application.
|
||||
@ -390,7 +394,7 @@ void PresetBundle::load_installed_sla_materials(AppConfig &config)
|
||||
if (printer.is_visible && printer.printer_technology() == ptSLA) {
|
||||
const PresetWithVendorProfile printer_with_vendor_profile = printers.get_preset_with_vendor_profile(printer);
|
||||
for (const Preset &material : sla_materials)
|
||||
if (is_compatible_with_printer(sla_materials.get_preset_with_vendor_profile(material), printer_with_vendor_profile))
|
||||
if (material.is_system && is_compatible_with_printer(sla_materials.get_preset_with_vendor_profile(material), printer_with_vendor_profile))
|
||||
comp_sla_materials.insert(&material);
|
||||
}
|
||||
// and mark these SLA materials as installed, therefore this code will not be executed at the next start of the application.
|
||||
|
@ -146,6 +146,8 @@ private:
|
||||
std::string load_system_presets();
|
||||
// Merge one vendor's presets with the other vendor's presets, report duplicates.
|
||||
std::vector<std::string> merge_presets(PresetBundle &&other);
|
||||
// Update renamed_from and alias maps of system profiles.
|
||||
void update_system_maps();
|
||||
|
||||
// Set the is_visible flag for filaments and sla materials,
|
||||
// apply defaults based on enabled printers when no filaments/materials are installed.
|
||||
|
Loading…
Reference in New Issue
Block a user