From 9b1abd02ff4a497d1a0ef418e68657ca644200f2 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Thu, 16 Jan 2025 16:56:21 +0800 Subject: [PATCH] FIX: move the message to dialog jira: [STUDIO-9580] Change-Id: I95f6d8ee56767b682956ce84cc74c096984afbef (cherry picked from commit 3697ff05a4a6935422792b64fe1be4b6cc5be09d) --- src/slic3r/GUI/SelectMachine.cpp | 117 ++++++++++++++----------------- src/slic3r/GUI/SelectMachine.hpp | 3 +- 2 files changed, 53 insertions(+), 67 deletions(-) diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index e3e811d21e..d599e0bc39 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -75,33 +75,7 @@ void SelectMachineDialog::stripWhiteSpace(std::string& str) } } -static std::string MachineBedTypeString[BED_TYPE_COUNT] = { - //"auto", - "pc", - "pe", - "pei", - "pte", -}; -wxString SelectMachineDialog::format_text(wxString &m_msg) -{ - if (wxGetApp().app_config->get("language") != "zh_CN") {return m_msg; } - - wxString out_txt = m_msg; - wxString count_txt = ""; - int new_line_pos = 0; - - for (int i = 0; i < m_msg.length(); i++) { - auto text_size = m_statictext_ams_msg->GetTextExtent(count_txt); - if (text_size.x < (FromDIP(600))) { - count_txt += m_msg[i]; - } else { - out_txt.insert(i - 1, '\n'); - count_txt = ""; - } - } - return out_txt; -} std::vector SelectMachineDialog::MACHINE_BED_TYPE_STRING; std::vector SelectMachineDialog::MachineBedTypeString; void SelectMachineDialog::init_machine_bed_types() @@ -1593,8 +1567,6 @@ void SelectMachineDialog::update_ams_status_msg(wxString msg, bool is_warning) Fit(); } } else { - msg = format_text(msg); - auto str_new = msg.utf8_string(); stripWhiteSpace(str_new); @@ -1626,8 +1598,6 @@ void SelectMachineDialog::update_priner_status_msg(wxString msg, bool is_warning Fit(); } } else { - msg = format_text(msg); - auto str_new = msg.utf8_string(); stripWhiteSpace(str_new); @@ -1785,7 +1755,16 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector 1) msg_text = wxString::Format(_L("Filament %s does not match the filament in AMS slot %s. Please update the printer firmware to support AMS slot assignment."), params[0], params[1]); @@ -2223,41 +2202,6 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) 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."))); } - if (!obj_->m_extder_data.extders[0].current_nozzle_type != ntUndefine && (m_print_type == PrintFromType::FROM_NORMAL)) - { - float nozzle_diameter = 0; - if (!is_same_nozzle_diameters(nozzle_diameter)) - { - has_slice_warnings = true; - // is_printing_block = true; # Removed to allow nozzle overrides (to support non-standard nozzles) - - 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)); - } - - /*check nozzle type*/ - DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); - MachineObject* obj = dev ? dev->get_selected_machine() : nullptr; - const std::vector& extders = obj ? obj->m_extder_data.extders : std::vector(); - for (const auto& extder : extders) - { - std::string filament_type; - if (!is_same_nozzle_type(extder, filament_type)) - { - has_slice_warnings = true; - is_printing_block = true; - wxString nozzle_in_preset = wxString::Format(_L("Printing high temperature material(%s material) with %s 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)); - } - } - } - if (has_slice_warnings) { ConfirmBeforeSendDialog confirm_dlg(this, wxID_ANY, _L("Warning")); @@ -3328,6 +3272,47 @@ void SelectMachineDialog::update_show_status() } } + // check nozzle type and diameter + if (m_print_type == PrintFromType::FROM_NORMAL) + { + float nozzle_diameter = 0; + if (!is_same_nozzle_diameters(nozzle_diameter)) + { + std::vector error_msg; + const wxString& tips = _L("Tips: If you changed your nozzle of your printer lately, Please go to 'Device -> Printer parts' to change your nozzle setting."); + if (obj_->m_extder_data.total_extder_count == 2) + { + const wxString& nozzle_config = wxString::Format(_L("The nozzle diameter (%.1fmm) in slice file is unconsistent with" + "the left nozzle diameter (%.1fmm) or right nozzle diameter (%.1fmm)" + "set on your print."), nozzle_diameter, + obj_->m_extder_data.extders[0].current_nozzle_diameter, + obj_->m_extder_data.extders[1].current_nozzle_diameter); + error_msg.emplace_back(nozzle_config + "\n\n" + tips); + } + else + { + const wxString& nozzle_config = wxString::Format(_L("The nozzle diameter (%.1fmm) in slice file is unconsistent with the nozzle diameter (%.1fmm) set on your print." + "You can't send to print until they are consistent."), nozzle_diameter, + obj_->m_extder_data.extders[0].current_nozzle_diameter); + error_msg.emplace_back(nozzle_config + "\n\n" + tips); + } + + return show_status(PrintDialogStatus::PrintStatusNozzleDiameterMismatch, error_msg); + } + + for (const auto& extder : obj_->m_extder_data.extders) + { + std::string filament_type; + if (!is_same_nozzle_type(extder, filament_type)) + { + std::vector error_msg; + error_msg.emplace_back(wxString::Format(_L("Printing high temperature material(%s material) with %s may cause nozzle damage"), + filament_type, format_steel_name(extder.current_nozzle_type))); + return show_status(PrintDialogStatus::PrintStatusNozzleTypeMismatch, error_msg); + } + } + } + if (!m_mapping_popup.m_supporting_mix_print && nozzle_nums == 1) { bool useAms = false; diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index e3ae28736e..dbfea834b2 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -82,6 +82,8 @@ enum PrintDialogStatus { PrintStatusAmsMappingMixInvalid, PrintStatusNozzleMatchInvalid, PrintStatusNozzleDataInvalid, + PrintStatusNozzleDiameterMismatch, + PrintStatusNozzleTypeMismatch, PrintStatusAmsMappingValid, PrintStatusAmsMappingByOrder, PrintStatusRefreshingMachineList, @@ -491,7 +493,6 @@ public: PrintFromType get_print_type() {return m_print_type;}; wxString format_bed_name(std::string plate_name); wxString format_steel_name(NozzleType type); - wxString format_text(wxString &m_msg); PrintDialogStatus get_status() { return m_print_status; } };