FIX: crash when sync extruder ams info
jira: none Change-Id: I48f098499e4cc3f1b2b7926443bce94bd7c06dda
This commit is contained in:
parent
f08d40b42a
commit
8fdc2ec622
|
@ -719,7 +719,7 @@ void Sidebar::priv::sync_extruder_list()
|
|||
|
||||
std::string machine_print_name = obj->printer_type;
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
std::string target_model_id = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
|
||||
std::string target_model_id = preset_bundle->printers.get_selected_preset().get_printer_type(preset_bundle);
|
||||
if (machine_print_name != target_model_id) {
|
||||
MessageDialog dlg(this->plater, _L("The currently selected machine preset is inconsistent with the connected printer type.\n"
|
||||
"Are you sure to continue syncing?"), _L("Sync extruder infomation"), wxICON_WARNING | wxYES | wxNO);
|
||||
|
@ -729,25 +729,49 @@ void Sidebar::priv::sync_extruder_list()
|
|||
}
|
||||
|
||||
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
|
||||
printer_tab->set_extruder_volume_type(0, NozzleVolumeType(obj->m_extder_data.extders[1].current_nozzle_flow_type));
|
||||
printer_tab->set_extruder_volume_type(1, NozzleVolumeType(obj->m_extder_data.extders[0].current_nozzle_flow_type));
|
||||
int left_4 = 0, right_4 = 0, left_1 = 0, right_1 = 0;
|
||||
const Preset &cur_preset = preset_bundle->printers.get_selected_preset();
|
||||
|
||||
int extruder_nums = preset_bundle->get_printer_extruder_count();
|
||||
std::vector<int> extruder_map(extruder_nums);
|
||||
std::iota(extruder_map.begin(), extruder_map.end(), 0);
|
||||
const ConfigOptionInts *physical_extruder_map = cur_preset.config.option<ConfigOptionInts>("physical_extruder_map");
|
||||
if (physical_extruder_map != nullptr) {
|
||||
assert(physical_extruder_map->values.size() == extruder_nums);
|
||||
extruder_map = physical_extruder_map->values;
|
||||
}
|
||||
assert(obj->m_extder_data.extders.size() == extruder_nums);
|
||||
|
||||
for (size_t index = 0; index < extruder_nums; ++index) {
|
||||
int extruder_id = extruder_map[index];
|
||||
if (obj->m_extder_data.extders[index].current_nozzle_flow_type == NozzleFlowType::NONE_FLOWTYPE) {
|
||||
MessageDialog dlg(this->plater, _L("There are unset nozzle types. Please set the nozzle types of all extruders before synchronizing."),
|
||||
_L("Sync extruder infomation"), wxICON_WARNING | wxOK);
|
||||
dlg.ShowModal();
|
||||
continue;
|
||||
}
|
||||
printer_tab->set_extruder_volume_type(index, NozzleVolumeType(obj->m_extder_data.extders[extruder_id].current_nozzle_flow_type - 1));
|
||||
}
|
||||
|
||||
int deputy_4 = 0, main_4 = 0, deputy_1 = 0, main_1 = 0;
|
||||
for (auto ams : obj->amsList) {
|
||||
// Main (first) extruder at right
|
||||
if (ams.second->nozzle == 0) {
|
||||
if (ams.second->type == 4) // N3S
|
||||
++right_1;
|
||||
++main_1;
|
||||
else
|
||||
++right_4;
|
||||
++main_4;
|
||||
} else if (ams.second->nozzle == 1) {
|
||||
if (ams.second->type == 4) // N3S
|
||||
++left_1;
|
||||
++deputy_1;
|
||||
else
|
||||
++left_4;
|
||||
++deputy_4;
|
||||
}
|
||||
}
|
||||
AMSCountPopupWindow::SetAMSCount(0, left_4, left_1);
|
||||
AMSCountPopupWindow::SetAMSCount(1, right_4, right_1);
|
||||
|
||||
int main_index = obj->is_main_extruder_on_left() ? 0 : 1;
|
||||
int deputy_index = obj->is_main_extruder_on_left() ? 1 : 0;
|
||||
AMSCountPopupWindow::SetAMSCount(deputy_index, deputy_4, deputy_1);
|
||||
AMSCountPopupWindow::SetAMSCount(main_index, main_4, main_1);
|
||||
AMSCountPopupWindow::UpdateAMSCount(0, m_left_ams_count);
|
||||
AMSCountPopupWindow::UpdateAMSCount(1, m_right_ams_count);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue