FIX: some filament group issues

1. Add filament_is_support field. Format the filament type
2. Optimize machine filament info logic

jira:STUDIO-10326

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Ia8bfc37095339e73c98209b4e3f1e0804e511e88
(cherry picked from commit 001144400b841629439a890d46fa40a7296689ba)
This commit is contained in:
xun.zhang
2025-02-12 18:28:28 +08:00
committed by Noisyfox
parent 2db3c63b7b
commit 58c877976d
8 changed files with 142 additions and 70 deletions

View File

@@ -392,6 +392,38 @@ bool PresetBundle::backup_user_folder() const
}
}
std::optional<FilamentBaseInfo> PresetBundle::get_filament_by_filament_id(const std::string& filament_id) const
{
if (filament_id.empty())
return {};
// basic filament info should be same in the parent preset and child preset
// so just match the filament id is enough
for (auto iter = filaments.begin(); iter != filaments.end(); ++iter) {
const Preset& filament_preset = *iter;
const auto& config = filament_preset.config;
if (filament_preset.filament_id == filament_id) {
FilamentBaseInfo info;
info.filament_id = filament_id;
info.is_system = filament_preset.is_system;
info.filament_name = filament_preset.alias;
if (config.has("filament_is_support"))
info.is_support = config.option<ConfigOptionBools>("filament_is_support")->values[0];
if (config.has("filament_type"))
info.filament_type = config.option<ConfigOptionStrings>("filament_type")->values[0];
if (config.has("filament_vendor"))
info.vendor = config.option<ConfigOptionStrings>("filament_vendor")->values[0];
if (config.has("nozzle_temperature_range_high"))
info.nozzle_temp_range_high = config.option<ConfigOptionInts>("nozzle_temperature_range_high")->values[0];
if (config.has("nozzle_temperature_range_low"))
info.nozzle_temp_range_low = config.option<ConfigOptionInts>("nozzle_temperature_range_low")->values[0];
return info;
}
}
return {};
}
//BBS: load project embedded presets
PresetsConfigSubstitutions PresetBundle::load_project_embedded_presets(std::vector<Preset*> project_presets, ForwardCompatibilitySubstitutionRule substitution_rule)
{