FIX: support sync N3S ams

jira: 9008
Change-Id: Icd63670f312562e0260277eb47e01e5d13789f31
This commit is contained in:
zhimin.zeng 2024-12-06 18:01:23 +08:00 committed by lane.wei
parent 96197d8abd
commit ee99497fd7
2 changed files with 26 additions and 5 deletions

View File

@ -2316,14 +2316,26 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
}
}
auto get_ams_name = [](int ams_id, int slot_id)->std::string {
if (ams_id >= 0 && ams_id < 26) {
char slot_name = slot_id + '1';
return std::string(1, 'A' + ams_id) + std::string(1, slot_name);
} else if (ams_id >= 128 && ams_id < 153) {
return "HT-" + std::string(1, 'A' + (ams_id - 128));
} else {
assert(false);
}
return std::string();
};
auto list = obj->amsList;
for (auto ams : list) {
char n = ams.first.front() - '0' + 'A';
int ams_id = std::stoi(ams.first);
int extruder = ams.second->nozzle ? 0 : 0x10000; // Main (first) extruder at right
for (auto tray : ams.second->trayList) {
char t = tray.first.front() - '0' + '1';
filament_ams_list.emplace(extruder + ((n - 'A') * 4 + t - '1'),
build_tray_config(*tray.second, std::string(1, n) + std::string(1, t)));
int slot_id = std::stoi(tray.first);
filament_ams_list.emplace(extruder + (ams_id * 4 + slot_id),
build_tray_config(*tray.second, get_ams_name(ams_id, slot_id)));
}
}
return filament_ams_list;

View File

@ -437,6 +437,15 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
set_label_marker(Append(separator(dual_extruder ? L("Left filaments") : L("AMS filaments")), wxNullBitmap));
m_first_ams_filament = GetCount();
auto &filaments = m_collection->get_presets();
int icon_width = 24;
for (auto &entry : m_preset_bundle->filament_ams_list) {
auto & tray = entry.second;
auto name = tray.opt_string("tray_name", 0u);
if (name.size() > 3)
icon_width = 32;
}
for (auto &entry : m_preset_bundle->filament_ams_list) {
if (dual_extruder && (entry.first & 0x10000)) {
dual_extruder = false;
@ -462,7 +471,7 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
const_cast<Preset&>(*iter).is_visible = true;
auto color = tray.opt_string("filament_colour", 0u);
auto name = tray.opt_string("tray_name", 0u);
wxBitmap bmp(*get_extruder_color_icon(color, name, 24, 16));
wxBitmap bmp(*get_extruder_color_icon(color, name, icon_width, 16));
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
//validate_selection(id->value == selected); // can not select
}