ENH: Enhance ams synchronization prompts

jira: none
Change-Id: Ide3141f980dc8de0284f3301414eca5c58a24204
This commit is contained in:
zhimin.zeng 2024-09-25 17:26:38 +08:00 committed by lane.wei
parent b34395358b
commit f30c7d3355
2 changed files with 35 additions and 0 deletions

View File

@ -706,6 +706,18 @@ void Sidebar::priv::sync_extruder_list()
dlg.ShowModal();
return;
}
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) {
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);
if (dlg.ShowModal() == wxID_NO) {
return;
}
}
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
printer_tab->set_extruder_volume_type(0, NozzleVolumeType(obj->m_nozzle_data.nozzles[1].flow_type));
printer_tab->set_extruder_volume_type(1, NozzleVolumeType(obj->m_nozzle_data.nozzles[0].flow_type));
@ -2031,8 +2043,16 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
return filament_ams_list;
}
void Sidebar::sync_extruder_list()
{
p->sync_extruder_list();
}
void Sidebar::load_ams_list(std::string const &device, MachineObject* obj)
{
if (obj && obj->is_connected() && obj->is_multi_extruders() && wxGetApp().plater()->is_multi_extruder_ams_empty())
sync_extruder_list();
std::map<int, DynamicPrintConfig> filament_ams_list = build_filament_ams_list(obj);
p->ams_list_device = device;
@ -12689,6 +12709,19 @@ void Plater::export_toolpaths_to_obj() const
p->preview->get_canvas3d()->export_toolpaths_to_obj(into_u8(path).c_str());
}
bool Plater::is_multi_extruder_ams_empty()
{
std::vector<std::string> extruder_ams_count_str = p->config->option<ConfigOptionStrings>("extruder_ams_count", true)->values;
std::vector<std::map<int, int>> extruder_ams_counts = get_extruder_ams_count(extruder_ams_count_str);
for (auto extruder_ams_count : extruder_ams_counts) {
for (auto iter = extruder_ams_count.begin(); iter != extruder_ams_count.end(); ++iter) {
if (iter->second != 0)
return false;
}
}
return true;
}
//BBS: add multiple plate reslice logic
void Plater::reslice()
{

View File

@ -150,6 +150,7 @@ public:
void load_ams_list(std::string const & device, MachineObject* obj);
std::map<int, DynamicPrintConfig> build_filament_ams_list(MachineObject* obj);
void sync_ams_list();
void sync_extruder_list();
ObjectList* obj_list();
ObjectSettings* obj_settings();
@ -279,6 +280,7 @@ public:
m_exported_file = exported_file;
}
bool is_multi_extruder_ams_empty();
// BBS
wxString get_project_name();
void update_all_plate_thumbnails(bool force_update = false);