mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-04 02:38:05 -05:00
Fix garbled filament names in AMS and flow dynamics calibration (#18033)
The AMS material dropdown and the filament list in the New Flow Dynamic Calibration dialog converted UTF-8 preset names with the Windows code page, so on a CP936 system 天瑞 PETG showed as 澶╃憺 PETG. Decode the preset alias with from_u8() and use the decoded name for the dropdown rows, the selection lookup and sorting, along with the vendor and material type used to sort. The calibration dialog converts the selected name back to UTF-8 to look up its filament and setting IDs. Linux and macOS are unchanged.
This commit is contained in:
1 parent
79172a26b8
commit
cb660ecfa5
2 files changed
+10
-14
No files matched your search
@@ -1162,8 +1162,8 @@ static void _collect_filament_info(const wxString& shown_name,
|
||||
std::unordered_map<wxString, wxString>& query_filament_vendors,
|
||||
std::unordered_map<wxString, wxString>& query_filament_types)
|
||||
{
|
||||
query_filament_vendors[shown_name] = filament.config.get_filament_vendor();
|
||||
query_filament_types[shown_name] = filament.config.get_filament_type();
|
||||
query_filament_vendors[shown_name] = from_u8(filament.config.get_filament_vendor());
|
||||
query_filament_types[shown_name] = from_u8(filament.config.get_filament_type());
|
||||
}
|
||||
|
||||
static const char* AMS_FAVORITE_FILAMENT_IDS_KEY = "ams_favorite_filament_ids";
|
||||
@@ -1337,7 +1337,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
||||
DevPrinterConfigUtil::get_printer_display_name(obj->printer_type), nozzle_diameter_str, obj->is_support_user_preset)) {
|
||||
if (!filament_id_set.insert(filament_it->filament_id).second)
|
||||
continue;
|
||||
const std::string alias = preset_bundle->filaments.get_preset_alias(*filament_it, true);
|
||||
const wxString alias = from_u8(preset_bundle->filaments.get_preset_alias(*filament_it, true));
|
||||
if (alias.empty())
|
||||
continue;
|
||||
|
||||
@@ -1350,7 +1350,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
||||
map_filament_items[alias] = filament_infos;
|
||||
|
||||
if (filament_it->filament_id == ams_filament_id) {
|
||||
bambu_filament_name = from_u8(alias);
|
||||
bambu_filament_name = alias;
|
||||
|
||||
|
||||
// update if nozzle_temperature_range is found
|
||||
@@ -1467,7 +1467,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " Update filament rank to " + std::to_string(sort_rank) + " for preset Name: "
|
||||
<< match->name << " - Alias: " << match->alias;
|
||||
selected_filament_ranks.insert_or_assign(match->alias, sort_rank);
|
||||
selected_filament_ranks.insert_or_assign(from_u8(match->alias), sort_rank);
|
||||
}
|
||||
|
||||
static const std::vector<wxString> sorted_vendors { "Generic" };
|
||||
|
||||
@@ -754,7 +754,7 @@ wxArrayString NewCalibrationHistoryDialog::get_all_filaments(const MachineObject
|
||||
if (alias.empty())
|
||||
continue;
|
||||
|
||||
filament_items.push_back(alias);
|
||||
filament_items.push_back(from_u8(alias));
|
||||
FilamentInfos filament_infos;
|
||||
filament_infos.filament_id = filament_it->filament_id;
|
||||
filament_infos.setting_id = filament_it->setting_id;
|
||||
@@ -960,8 +960,8 @@ void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
||||
wxString nozzle_value_str = m_comboBox_nozzle_diameter->GetValue();
|
||||
nozzle_value_str.ToDouble(&nozzle_value);
|
||||
|
||||
std::string filament_name = m_comboBox_filament->GetValue().ToStdString();
|
||||
if (filament_name.empty()) {
|
||||
const auto filament_item = map_filament_items.find(into_u8(m_comboBox_filament->GetValue()));
|
||||
if (filament_item == map_filament_items.end()) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The filament must be selected."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
@@ -987,18 +987,14 @@ void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
||||
m_new_result.nozzle_volume_type = NozzleVolumeType(intptr_t(m_comboBox_nozzle_type->GetClientData(m_comboBox_nozzle_type->GetSelection())));
|
||||
}
|
||||
|
||||
auto filament_item = map_filament_items[m_comboBox_filament->GetValue().ToStdString()];
|
||||
std::string filament_id = filament_item.filament_id;
|
||||
std::string setting_id = filament_item.setting_id;
|
||||
|
||||
m_new_result.name = name.ToUTF8().data();
|
||||
m_new_result.k_value = k;
|
||||
m_new_result.tray_id = -1;
|
||||
m_new_result.cali_idx = -1;
|
||||
|
||||
m_new_result.nozzle_diameter = nozzle_value;
|
||||
m_new_result.filament_id = filament_id;
|
||||
m_new_result.setting_id = setting_id;
|
||||
m_new_result.filament_id = filament_item->second.filament_id;
|
||||
m_new_result.setting_id = filament_item->second.setting_id;
|
||||
m_new_result.nozzle_pos_id = get_nozzle_combo_id_code();
|
||||
|
||||
// Check for duplicate names from history
|
||||
|
||||
Reference in new issue
Block a user