FIX: [6510] set nozzle temp incorrectly when popup AMS Setting

Change-Id: I898f0b94794a3d67017b1917ce196c4019f5eb4a
This commit is contained in:
maosheng.wei 2024-03-21 15:33:46 +08:00 committed by Lane.Wei
parent f9cbb9abb4
commit eb9c334c27
2 changed files with 20 additions and 2 deletions

View File

@ -1829,7 +1829,7 @@ void PresetBundle::set_calibrate_printer(std::string name)
std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle(const std::string &printer_type, std::string nozzle_diameter_str)
{
std::set<std::string> printer_names;
if ("0.0" == nozzle_diameter_str) {
if ("0.0" == nozzle_diameter_str || nozzle_diameter_str.empty()) {
nozzle_diameter_str = "0.4";
}
std::ostringstream stream;
@ -1848,6 +1848,10 @@ std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle
}
assert(printer_names.size() == 1);
for (auto& printer_name : printer_names) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " printer name: " << printer_name;
}
return printer_names;
}

View File

@ -954,12 +954,26 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
m_filament_type = "";
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
if (preset_bundle) {
std::ostringstream stream;
if (obj)
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
std::string nozzle_diameter_str = stream.str();
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type),
nozzle_diameter_str);
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
if (!m_comboBox_filament->GetValue().IsEmpty()) {
auto filament_item = map_filament_items[m_comboBox_filament->GetValue().ToStdString()];
std::string filament_id = filament_item.filament_id;
if (it->filament_id.compare(filament_id) == 0) {
bool has_compatible_printer = false;
std::string preset_name = it->name;
for (std::string printer_name : printer_names) {
if (preset_name.find(printer_name) != std::string::npos) {
has_compatible_printer = true;
break;
}
}
if (!it->is_system && !has_compatible_printer) continue;
// ) if nozzle_temperature_range is found
ConfigOption* opt_min = it->config.option("nozzle_temperature_range_low");
if (opt_min) {