FIX: 1. add auto sync on connect printer

2. remove printer list in prepare page
jira: none

Change-Id: Iab4009c5249663f309221d3fcc02e0bd676e554b
This commit is contained in:
zhimin.zeng 2025-01-16 12:11:13 +08:00 committed by lane.wei
parent 13355ca669
commit 19e8ab2648
4 changed files with 24 additions and 24 deletions

View File

@ -314,6 +314,7 @@ void MonitorPanel::select_machine(std::string machine_sn)
obj_->reset_pa_cali_history_result();
obj_->reset_pa_cali_result();
GUI::wxGetApp().sidebar().load_ams_list(obj_->dev_id, obj_);
GUI::wxGetApp().sidebar().auto_sync_extruder_list_on_connect_priner(obj_);
}
Layout();

View File

@ -1128,7 +1128,7 @@ bool Sidebar::priv::switch_diameter(bool single)
bool Sidebar::priv::sync_extruder_list()
{
MachineObject *obj = wxGetApp().getDeviceManager()->get_selected_machine();
if (obj == nullptr || !obj->is_info_ready(false)) {
if (obj == nullptr) {
MessageDialog dlg(this->plater, _L("Please select a printer in 'Device' page first."), _L("Sync extruder infomation"), wxOK | wxICON_WARNING);
dlg.ShowModal();
return false;
@ -1165,10 +1165,7 @@ bool Sidebar::priv::sync_extruder_list()
});
}
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
printer_tab->select_preset(machine_preset->name);
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);
@ -1190,6 +1187,7 @@ bool Sidebar::priv::sync_extruder_list()
dlg.ShowModal();
continue;
}
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
printer_tab->set_extruder_volume_type(index, NozzleVolumeType(obj->m_extder_data.extders[extruder_id].current_nozzle_flow_type - 1));
}
@ -2750,30 +2748,31 @@ bool Sidebar::sync_extruder_list()
return p->sync_extruder_list();
}
bool Sidebar::auto_sync_extruder_list_on_connect_priner(const MachineObject *obj)
{
if(!obj)
return false;
std::string machine_print_name = obj->printer_type;
PresetBundle *preset_bundle = wxGetApp().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) {
return false;
}
if (preset_bundle->get_printer_extruder_count() <= 1)
return false;
return p->sync_extruder_list();
}
void Sidebar::update_sync_status(const MachineObject *obj)
{
p->update_sync_status(obj);
}
bool Sidebar::should_sync_extruder_list(MachineObject *obj)
{
if (obj && obj->is_connected() && obj->is_multi_extruders() && wxGetApp().plater()->is_multi_extruder_ams_empty()) {
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);
if (machine_print_name == target_model_id) {
return true;
}
}
return false;
}
void Sidebar::load_ams_list(std::string const &device, MachineObject* obj)
{
// Remove auto sync
//if (should_sync_extruder_list(obj))
// sync_extruder_list();
std::map<int, DynamicPrintConfig> filament_ams_list = build_filament_ams_list(obj);
p->ams_list_device = device;

View File

@ -158,7 +158,7 @@ public:
std::map<int, DynamicPrintConfig> build_filament_ams_list(MachineObject* obj);
void sync_ams_list();
bool sync_extruder_list();
bool should_sync_extruder_list(MachineObject* obj);
bool auto_sync_extruder_list_on_connect_priner(const MachineObject* obj);
void update_sync_status(const MachineObject* obj);
PlaterPresetComboBox * printer_combox();

View File

@ -1203,8 +1203,8 @@ void PlaterPresetComboBox::update()
//if (i + 1 == m_collection->num_default_presets())
// set_label_marker(Append(separator(L("System presets")), wxNullBitmap));
}
if (m_type == Preset::TYPE_PRINTER)
add_connected_printers("", true);
//if (m_type == Preset::TYPE_PRINTER)
// add_connected_printers("", true);
if (m_type == Preset::TYPE_FILAMENT) {
set_replace_text("Bambu", "BambuStudioBlack");