From fa2fc22f3e648c0f0f485d1a7e701658693da457 Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 17 Feb 2025 19:43:28 +0800 Subject: [PATCH] NEW:added inspection of pla-glow material jira:[none] Change-Id: I1a62992e24665b83f54981e59edc1ba1fcda9a8a --- resources/printers/filaments_blacklist.json | 7 + src/slic3r/GUI/AMSMaterialsSetting.cpp | 7 +- .../GUI/CalibrationWizardPresetPage.cpp | 6 +- src/slic3r/GUI/DeviceManager.cpp | 14 +- src/slic3r/GUI/DeviceManager.hpp | 2 +- src/slic3r/GUI/GUI_App.hpp | 1 - src/slic3r/GUI/SelectMachine.cpp | 16 +- src/slic3r/GUI/SyncAmsInfoDialog.cpp | 150 ------------------ src/slic3r/GUI/SyncAmsInfoDialog.hpp | 1 - 9 files changed, 43 insertions(+), 161 deletions(-) diff --git a/resources/printers/filaments_blacklist.json b/resources/printers/filaments_blacklist.json index 87dafbddc..de335ee8b 100644 --- a/resources/printers/filaments_blacklist.json +++ b/resources/printers/filaments_blacklist.json @@ -74,6 +74,13 @@ "action": "warning", "description": "CF/GF: hard and brittle" }, + { + "vendor": "Bambu Lab", + "type": "PLA", + "name": "Bambu PLA Glow", + "action": "warning", + "description": "PLA-Glow" + }, { "vendor": "Bambu Lab", "type": "PET-CF", diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 92ba54557..a8b4108de 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -564,9 +564,14 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event) it->get_filament_type(filamnt_type); auto vendor = dynamic_cast(it->config.option("filament_vendor")); + + PresetBundle *preset_bundle = GUI::wxGetApp().preset_bundle; + auto option = preset_bundle->get_filament_by_filament_id(filament_id); + auto tag_name = option ? option->filament_name : ""; + if (vendor && (vendor->values.size() > 0)) { std::string vendor_name = vendor->values[0]; - DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, ams_id, in_blacklist, action, info); + DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, tag_name, ams_id, in_blacklist, action, info); } if (in_blacklist) { diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp index 4f79f718f..cba3a4c59 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp @@ -1486,10 +1486,14 @@ bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset std::string filamnt_type; preset->get_filament_type(filamnt_type); + PresetBundle *preset_bundle = GUI::wxGetApp().preset_bundle; + auto option = preset_bundle->get_filament_by_filament_id(preset->filament_id); + auto tag_name = option ? option->filament_name : ""; + auto vendor = dynamic_cast (preset->config.option("filament_vendor")); if (vendor && (vendor->values.size() > 0)) { std::string vendor_name = vendor->values[0]; - DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, ams_id, in_blacklist, action, info); + DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, tag_name, ams_id, in_blacklist, action, info); } if (in_blacklist) { diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index f5242255c..24d2c4b74 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -7395,7 +7395,7 @@ bool DeviceManager::check_filaments_printable(const std::string &tag_vendor, con return true; } -void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, int ams_id, bool& in_blacklist, std::string& ac, std::string& info) +void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, std::string tag_name, int ams_id, bool& in_blacklist, std::string& ac, std::string& info) { if (!check_filaments_printable(tag_vendor, tag_type, ams_id, in_blacklist, ac, info)) { return; @@ -7411,7 +7411,8 @@ void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::st {"TPU: not supported", _L("TPU is not supported by AMS.")}, {"Bambu CF: not supported", _L("Bambu PET-CF/PA6-CF/PPA-CF/PPS-CF is not supported by AMS.")}, {"PVA: flexible", _L("Damp PVA will become flexible and get stuck inside AMS,please take care to dry it before use.")}, - {"CF/GF: hard and brittle", _L("CF/GF filaments are hard and brittle, It's easy to break or get stuck in AMS, please use with caution.")} + {"CF/GF: hard and brittle", _L("CF/GF filaments are hard and brittle, It's easy to break or get stuck in AMS, please use with caution.")}, + {"PLA-Glow", _L("The rough surface of PLA Glow can accelerate wear on the AMS system, particularly on the internal components of the AMS Lite.")} }; in_blacklist = false; @@ -7423,6 +7424,7 @@ void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::st std::string type; std::string action; std::string description; + std::string name = "undefine"; if (prohibited_filament.contains("vendor") && prohibited_filament.contains("type") && @@ -7440,6 +7442,10 @@ void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::st return; } + if (prohibited_filament.contains("name")) { + name = prohibited_filament["name"].get(); + } + std::transform(vendor.begin(), vendor.end(), vendor.begin(), ::tolower); std::transform(tag_vendor.begin(), tag_vendor.end(), tag_vendor.begin(), ::tolower); std::transform(tag_type.begin(), tag_type.end(), tag_type.begin(), ::tolower); @@ -7447,7 +7453,7 @@ void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::st //third party if (vendor == "third party") { - if ("bambu lab" != tag_vendor && tag_type == type) { + if ("bambu lab" != tag_vendor && (tag_type == type || tag_name == name)) { in_blacklist = true; ac = action; info = description; @@ -7455,7 +7461,7 @@ void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::st } } else { - if (vendor == tag_vendor && tag_type == type) { + if (vendor == tag_vendor && (tag_type == type || tag_name == name)) { in_blacklist = true; ac = action; info = description; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 76baa0709..58867b1c4 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1359,7 +1359,7 @@ public: static bool load_filaments_blacklist_config(); static std::vector get_resolution_supported(std::string type_str); static std::vector get_compatible_machine(std::string type_str); - static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info); + static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, std::string tag_name, int ams_id, bool &in_blacklist, std::string &ac, std::string &info); static bool check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info); static boost::bimaps::bimap get_all_model_id_with_name(); static std::string load_gcode(std::string type_str, std::string gcode_file); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 79adabd32..e35d703f7 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -314,7 +314,6 @@ private: public: //try again when subscription fails void on_start_subscribe_again(std::string dev_id); - void check_filaments_in_blacklist(std::string tag_supplier, std::string tag_material, bool& in_blacklist, std::string& action, std::string& info); std::string get_local_models_path(); bool OnInit() override; int OnExit() override; diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index c6d8e75bc..d353a8ebe 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -2119,18 +2119,24 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) std::string filament_type = boost::to_upper_copy(m_ams_mapping_result[i].type); std::string filament_brand; + std::string filament_id; for (auto fs : m_filaments) { if (fs.id == m_ams_mapping_result[i].id) { filament_brand = m_filaments[i].brand; + filament_id = m_filaments[i].filament_id; } } + PresetBundle *preset_bundle = GUI::wxGetApp().preset_bundle; + auto option = preset_bundle->get_filament_by_filament_id(filament_id); + auto tag_name = option ? option->filament_name : ""; + bool in_blacklist = false; std::string action; std::string info; - DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, ams_id, in_blacklist, action, info); + DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, tag_name, ams_id, in_blacklist, action, info); if (in_blacklist && action == "warning") { wxString prohibited_error = wxString::FromUTF8(info); @@ -2194,17 +2200,23 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) std::string filament_type = boost::to_upper_copy(m_ams_mapping_result[i].type); std::string filament_brand; + std::string filament_id; for (auto fs : m_filaments) { if (fs.id == m_ams_mapping_result[i].id) { filament_brand = m_filaments[i].brand; + filament_id = m_filaments[i].filament_id; } } + PresetBundle *preset_bundle = GUI::wxGetApp().preset_bundle; + auto option = preset_bundle->get_filament_by_filament_id(filament_id); + auto tag_name = option ? option->filament_name : ""; + bool in_blacklist = false; std::string action; std::string info; - DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, ams_id, in_blacklist, action, info); + DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, tag_name, ams_id, in_blacklist, action, info); if (in_blacklist && action == "prohibition") { has_prohibited_filament = true; diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index 5a8f64436..e85e88cea 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -2193,156 +2193,6 @@ void SyncAmsInfoDialog::show_errors(wxString &info) confirm_dlg.on_show(); } -void SyncAmsInfoDialog::on_ok_btn(wxCommandEvent &event) -{ - bool has_slice_warnings = false; - bool is_printing_block = false; - - DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - if (!dev) return; - MachineObject *obj_ = dev->get_selected_machine(); - if (!obj_) return; - - std::vector confirm_text; - confirm_text.push_back(ConfirmBeforeSendInfo(_L("Please check the following:"))); - - // Check Printer Model Id - bool is_same_printer_type = is_same_printer_model(); - if (!is_same_printer_type && (m_print_type == PrintFromType::FROM_NORMAL)) { - confirm_text.push_back(ConfirmBeforeSendInfo(_L("The printer type selected when generating G-Code is not consistent with the currently selected printer. It is " - "recommended that you use the same printer type for slicing."))); - has_slice_warnings = true; - } - - // check blacklist - for (auto i = 0; i < m_ams_mapping_result.size(); i++) { - auto tid = m_ams_mapping_result[i].tray_id; - - std::string filament_type = boost::to_upper_copy(m_ams_mapping_result[i].type); - std::string filament_brand; - - for (auto fs : m_filaments) { - if (fs.id == m_ams_mapping_result[i].id) { filament_brand = m_filaments[i].brand; } - } - - bool in_blacklist = false; - std::string action; - std::string info; - DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, tid, in_blacklist, action, info); - - if (in_blacklist && action == "warning") { - wxString prohibited_error = wxString::FromUTF8(info); - - confirm_text.push_back(ConfirmBeforeSendInfo(prohibited_error)); - has_slice_warnings = true; - } - } - - PartPlate *plate = m_plater->get_partplate_list().get_curr_plate(); - - for (auto warning : plate->get_slice_result()->warnings) { - if (warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) { - if ((obj_->get_printer_is_enclosed())) { - // confirm_text.push_back(Plater::get_slice_warning_string(warning) + "\n"); - // has_slice_warnings = true; - } - } else if (warning.msg == NOT_SUPPORT_TRADITIONAL_TIMELAPSE) { - if (obj_->get_printer_arch() == PrinterArch::ARCH_I3 && (m_checkbox_list["timelapse"]->getValue() == "on")) { - confirm_text.push_back(ConfirmBeforeSendInfo(Plater::get_slice_warning_string(warning))); - has_slice_warnings = true; - } - } else if (warning.msg == NOT_GENERATE_TIMELAPSE) { - continue; - } else if (warning.msg == NOZZLE_HRC_CHECKER) { - wxString error_info = Plater::get_slice_warning_string(warning); - if (error_info.IsEmpty()) { error_info = wxString::Format("%s\n", warning.msg); } - - confirm_text.push_back(ConfirmBeforeSendInfo(error_info)); - has_slice_warnings = true; - } - } - - // check for unidentified material - auto mapping_result = m_mapping_popup.parse_ams_mapping(obj_->amsList); - auto has_unknown_filament = false; - - // check if ams mapping is has errors, tpu - bool has_prohibited_filament = false; - wxString prohibited_error = wxEmptyString; - - for (auto i = 0; i < m_ams_mapping_result.size(); i++) { - auto tid = m_ams_mapping_result[i].tray_id; - - std::string filament_type = boost::to_upper_copy(m_ams_mapping_result[i].type); - std::string filament_brand; - - for (auto fs : m_filaments) { - if (fs.id == m_ams_mapping_result[i].id) { filament_brand = m_filaments[i].brand; } - } - - bool in_blacklist = false; - std::string action; - std::string info; - DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, tid, in_blacklist, action, info); - - if (in_blacklist && action == "prohibition") { - has_prohibited_filament = true; - prohibited_error = wxString::FromUTF8(info); - } - - for (auto miter : mapping_result) { - // matching - if (miter.id == tid) { - if (miter.type == TrayType::THIRD || miter.type == TrayType::EMPTY) { - has_unknown_filament = true; - break; - } - } - } - } - - if (has_prohibited_filament && obj_->has_ams() && (m_checkbox_list["use_ams"]->getValue() == "on")) { - wxString tpu_tips = prohibited_error; - BOOST_LOG_TRIVIAL(info)<<__FUNCTION__ << "print_job: on_ok to send"; - return; - } - - if (has_unknown_filament) { - has_slice_warnings = true; - confirm_text.push_back(ConfirmBeforeSendInfo(_L("There are some unknown filaments in the AMS mappings. Please check whether they are the required filaments. If they are " - "okay, press \"Confirm\" to start printing."))); - } - - float nozzle_diameter; - std::string filament_type; - NozzleType tag_nozzle_type; - - if (!obj_->m_extder_data.extders[0].current_nozzle_type == NozzleType::ntUndefine && (m_print_type == PrintFromType::FROM_NORMAL)) { - if (!is_same_nozzle_diameters(tag_nozzle_type, nozzle_diameter)) { - has_slice_warnings = true; - is_printing_block = true; - - wxString nozzle_in_preset = wxString::Format(_L("nozzle in preset: %.1f %s"), nozzle_diameter, ""); - wxString nozzle_in_printer = wxString::Format(_L("nozzle memorized: %.1f %s"), obj_->m_extder_data.extders[0].current_nozzle_diameter, ""); - - confirm_text.push_back(ConfirmBeforeSendInfo(_L("Your nozzle diameter in sliced file is not consistent with memorized nozzle. If you changed your nozzle lately, " - "please go to Device > Printer Parts to change settings.") + - "\n " + nozzle_in_preset + "\n " + nozzle_in_printer + "\n", - ConfirmBeforeSendInfo::InfoLevel::Warning)); - } - - if (!is_same_nozzle_type(filament_type, tag_nozzle_type)) { - has_slice_warnings = true; - is_printing_block = true; - nozzle_diameter = obj_->m_extder_data.extders[0].current_nozzle_diameter; - - wxString nozzle_in_preset = wxString::Format(_L("Printing %1s material with %2s nozzle may cause nozzle damage."), filament_type, - format_steel_name(obj_->m_extder_data.extders[0].current_nozzle_type)); - confirm_text.push_back(ConfirmBeforeSendInfo(nozzle_in_preset, ConfirmBeforeSendInfo::InfoLevel::Warning)); - } - } -} - wxString SyncAmsInfoDialog::format_steel_name(NozzleType type) { if (type == NozzleType::ntHardenedSteel) { diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.hpp b/src/slic3r/GUI/SyncAmsInfoDialog.hpp index 77ef27a1b..08545650b 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.hpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.hpp @@ -174,7 +174,6 @@ public: void update_printer_combobox(wxCommandEvent &event); void on_cancel(wxCloseEvent &event); void show_errors(wxString &info); - void on_ok_btn(wxCommandEvent &event); void Enable_Auto_Refill(bool enable); void connect_printer_mqtt(); void clear_ip_address_config(wxCommandEvent &e);