From 3697ff05a4a6935422792b64fe1be4b6cc5be09d 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 --- src/slic3r/GUI/SelectMachine.cpp | 120 +++++++++++++------------------ src/slic3r/GUI/SelectMachine.hpp | 3 +- 2 files changed, 53 insertions(+), 70 deletions(-) diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index e711b0a9e..781d0f58b 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -72,25 +72,7 @@ void SelectMachineDialog::stripWhiteSpace(std::string& str) } } -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() @@ -1587,8 +1569,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); @@ -1620,8 +1600,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); @@ -1779,7 +1757,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]); @@ -2220,52 +2207,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 (m_print_type == PrintFromType::FROM_NORMAL) - { - /*check nozzle diameter*/ - float nozzle_diameter = 0; - if (!is_same_nozzle_diameters(nozzle_diameter)) - { - has_slice_warnings = true; - is_printing_block = true; - - 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); - confirm_text.push_back(ConfirmBeforeSendInfo(nozzle_config + "\n\n" + tips, ConfirmBeforeSendInfo::InfoLevel::Warning)); - } - 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); - confirm_text.push_back(ConfirmBeforeSendInfo(nozzle_config + "\n\n" + tips, 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")); @@ -3343,6 +3284,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 eb108e6b7..29fcbc4ba 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -80,6 +80,8 @@ enum PrintDialogStatus { PrintStatusAmsMappingMixInvalid, PrintStatusNozzleMatchInvalid, PrintStatusNozzleDataInvalid, + PrintStatusNozzleDiameterMismatch, + PrintStatusNozzleTypeMismatch, PrintStatusAmsMappingValid, PrintStatusAmsMappingByOrder, PrintStatusRefreshingMachineList, @@ -488,7 +490,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; } };