From 42b15b4d41a099c5f1aca9dd59ac592aafba0b43 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Fri, 23 May 2025 17:53:16 +0800 Subject: [PATCH] FIX: the encoding of filament check_ams_filament_valid jira: [STUDIO-12251] Change-Id: Idc3d23dce67d3e835f15c47984fdd68041371d61 --- src/slic3r/GUI/AMSMaterialsSetting.cpp | 58 +++++++++---------- .../GUI/CalibrationWizardPresetPage.cpp | 4 +- src/slic3r/GUI/DeviceManager.cpp | 12 ++-- src/slic3r/GUI/DeviceManager.hpp | 2 +- src/slic3r/GUI/SelectMachine.cpp | 18 +++--- 5 files changed, 46 insertions(+), 48 deletions(-) diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index cf627c5e8..0a905a81f 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -555,7 +555,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event) if (wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") { bool in_blacklist = false; std::string action; - std::string info; + wxString info; std::string filamnt_type; std::string filamnt_name; it->get_filament_type(filamnt_type); @@ -1455,7 +1455,7 @@ void ColorPicker::doRender(wxDC& dc) } if (m_show_full) { - dc.SetPen(wxPen(wxColour(0x6B6B6B))); + dc.SetPen(wxPen(wxColour("#6B6B6B"))); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawCircle(size.x / 2, size.y / 2, radius); @@ -1518,30 +1518,30 @@ ColorPickerPopup::ColorPickerPopup(wxWindow* parent) :PopupWindow(parent, wxBORDER_NONE) { m_def_colors.clear(); - m_def_colors.push_back(wxColour(0xFFFFFF)); - m_def_colors.push_back(wxColour(0xfff144)); - m_def_colors.push_back(wxColour(0xDCF478)); - m_def_colors.push_back(wxColour(0x0ACC38)); - m_def_colors.push_back(wxColour(0x057748)); - m_def_colors.push_back(wxColour(0x0d6284)); - m_def_colors.push_back(wxColour(0x0EE2A0)); - m_def_colors.push_back(wxColour(0x76D9F4)); - m_def_colors.push_back(wxColour(0x46a8f9)); - m_def_colors.push_back(wxColour(0x2850E0)); - m_def_colors.push_back(wxColour(0x443089)); - m_def_colors.push_back(wxColour(0xA03CF7)); - m_def_colors.push_back(wxColour(0xF330F9)); - m_def_colors.push_back(wxColour(0xD4B1DD)); - m_def_colors.push_back(wxColour(0xf95d73)); - m_def_colors.push_back(wxColour(0xf72323)); - m_def_colors.push_back(wxColour(0x7c4b00)); - m_def_colors.push_back(wxColour(0xf98c36)); - m_def_colors.push_back(wxColour(0xfcecd6)); - m_def_colors.push_back(wxColour(0xD3C5A3)); - m_def_colors.push_back(wxColour(0xAF7933)); - m_def_colors.push_back(wxColour(0x898989)); - m_def_colors.push_back(wxColour(0xBCBCBC)); - m_def_colors.push_back(wxColour(0x161616)); + m_def_colors.push_back(wxColour("#FFFFFF")); + m_def_colors.push_back(wxColour("#fff144")); + m_def_colors.push_back(wxColour("#DCF478")); + m_def_colors.push_back(wxColour("#0ACC38")); + m_def_colors.push_back(wxColour("#057748")); + m_def_colors.push_back(wxColour("#0d6284")); + m_def_colors.push_back(wxColour("#0EE2A0")); + m_def_colors.push_back(wxColour("#76D9F4")); + m_def_colors.push_back(wxColour("#46a8f9")); + m_def_colors.push_back(wxColour("#2850E0")); + m_def_colors.push_back(wxColour("#443089")); + m_def_colors.push_back(wxColour("#A03CF7")); + m_def_colors.push_back(wxColour("#F330F9")); + m_def_colors.push_back(wxColour("#D4B1DD")); + m_def_colors.push_back(wxColour("#f95d73")); + m_def_colors.push_back(wxColour("#f72323")); + m_def_colors.push_back(wxColour("#7c4b00")); + m_def_colors.push_back(wxColour("#f98c36")); + m_def_colors.push_back(wxColour("#fcecd6")); + m_def_colors.push_back(wxColour("#D3C5A3")); + m_def_colors.push_back(wxColour("#AF7933")); + m_def_colors.push_back(wxColour("#898989")); + m_def_colors.push_back(wxColour("#BCBCBC")); + m_def_colors.push_back(wxColour("#161616")); SetBackgroundColour(wxColour(*wxWHITE)); @@ -1556,7 +1556,7 @@ ColorPickerPopup::ColorPickerPopup(wxWindow* parent) m_title_ams->SetBackgroundColour(wxColour(238, 238, 238)); m_sizer_ams->Add(m_title_ams, 0, wxALL, 5); auto ams_line = new wxPanel(m_def_color_box, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); - ams_line->SetBackgroundColour(wxColour(0xCECECE)); + ams_line->SetBackgroundColour(wxColour("#CECECE")); ams_line->SetMinSize(wxSize(-1, 1)); ams_line->SetMaxSize(wxSize(-1, 1)); m_sizer_ams->Add(ams_line, 1, wxALIGN_CENTER, 0); @@ -1603,7 +1603,7 @@ ColorPickerPopup::ColorPickerPopup(wxWindow* parent) auto other_line = new wxPanel(m_def_color_box, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); other_line->SetMinSize(wxSize(-1, 1)); other_line->SetMaxSize(wxSize(-1, 1)); - other_line->SetBackgroundColour(wxColour(0xCECECE)); + other_line->SetBackgroundColour(wxColour("#CECECE")); m_sizer_other->Add(other_line, 1, wxALIGN_CENTER, 0); //custom color @@ -1612,7 +1612,7 @@ ColorPickerPopup::ColorPickerPopup(wxWindow* parent) m_title_custom->SetFont(::Label::Body_14); m_title_custom->SetBackgroundColour(wxColour(238, 238, 238)); auto custom_line = new wxPanel(m_def_color_box, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL); - custom_line->SetBackgroundColour(wxColour(0xCECECE)); + custom_line->SetBackgroundColour(wxColour("#CECECE")); custom_line->SetMinSize(wxSize(-1, 1)); custom_line->SetMaxSize(wxSize(-1, 1)); m_sizer_custom->Add(m_title_custom, 0, wxALL, 5); diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp index 8b4ac8f26..8cb159839 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp @@ -1485,7 +1485,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset if (wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") { bool in_blacklist = false; std::string action; - std::string info; + wxString info; std::string filamnt_type; preset->get_filament_type(filamnt_type); @@ -1496,7 +1496,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset } if (in_blacklist) { - error_tips = info; + error_tips = info.ToUTF8().data(); if (action == "prohibition") { return false; } diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index d84d3e3c7..4ad61f90e 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -281,7 +281,7 @@ PrinterArch get_printer_arch_by_str(std::string arch_str) return PrinterArch::ARCH_CORE_XY; } -void check_filaments_for_vt_slot(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info) +void check_filaments_for_vt_slot(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, wxString &info) { DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (!dev) @@ -299,12 +299,12 @@ void check_filaments_for_vt_slot(const std::string &tag_vendor, const std::strin wxString info_str = wxString::Format(_L("TPU is not supported by %s extruder for this printer."), extruder_name); ac = "prohibition"; - info = info_str.ToUTF8().data(); + info = info_str; in_blacklist = true; } } -bool check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, const std::string& filament_id, int ams_id, bool &in_blacklist, std::string &ac, std::string &info) +bool check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, const std::string& filament_id, int ams_id, bool &in_blacklist, std::string &ac, wxString &info) { DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (!dev) { @@ -7931,7 +7931,7 @@ void check_filaments_for_ams_slot(std::string model_id, std::string tag_name, bool& in_blacklist, std::string& ac, - std::string& info) + wxString& info) { if (tag_name.empty()) { @@ -7994,7 +7994,7 @@ void check_filaments_for_ams_slot(std::string model_id, in_blacklist = true; ac = action; - info = blacklist_prompt[description].ToStdString(); + info = blacklist_prompt[description]; return; } } @@ -8011,7 +8011,7 @@ void DeviceManager::check_filaments_in_blacklist(std::string model_id, std::string tag_name, bool &in_blacklist, std::string &ac, - std::string &info) + wxString &info) { if (ams_id < 0 || slot_id < 0) { return; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index b1803f2ca..aa7f9869e 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1507,7 +1507,7 @@ public: static std::vector get_resolution_supported(std::string type_str); static std::vector get_compatible_machine(std::string type_str); static std::vector get_unsupport_auto_cali_filaments(std::string type_str); - static void check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool &in_blacklist, std::string &ac, std::string &info); + static void check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool &in_blacklist, std::string &ac, wxString &info); static boost::bimaps::bimap get_all_model_id_with_name(); static std::string load_gcode(std::string type_str, std::string gcode_file); static bool is_virtual_slot(int ams_id); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index e3ac162f7..7cb8dda36 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -354,7 +354,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) /*filament area*/ /*1 extruder*/ m_filament_panel = new StaticBox(m_scroll_area); - m_filament_panel->SetBackgroundColour(wxColour(0xF8F8F8)); + m_filament_panel->SetBackgroundColour(wxColour("#F8F8F8")); m_filament_panel->SetBorderWidth(0); m_filament_panel->SetMinSize(wxSize(FromDIP(637), -1)); m_filament_panel->SetMaxSize(wxSize(FromDIP(637), -1)); @@ -370,7 +370,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_sizer_filament_2extruder = new wxBoxSizer(wxHORIZONTAL); m_filament_left_panel = new StaticBox(m_scroll_area); - m_filament_left_panel->SetBackgroundColour(wxColour(0xF8F8F8)); + m_filament_left_panel->SetBackgroundColour(wxColour("#F8F8F8")); m_filament_left_panel->SetBorderWidth(0); m_filament_left_panel->SetMinSize(wxSize(FromDIP(315), -1)); m_filament_left_panel->SetMaxSize(wxSize(FromDIP(315), -1)); @@ -379,7 +379,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) auto left_recommend_title_sizer = new wxBoxSizer(wxHORIZONTAL); auto left_recommend_title1 = new Label(m_filament_left_panel, _L("Left Nozzle")); left_recommend_title1->SetFont(::Label::Head_13); - left_recommend_title1->SetBackgroundColour(wxColour(0xF8F8F8)); + left_recommend_title1->SetBackgroundColour(wxColour("#F8F8F8")); left_recommend_title_sizer->Add(left_recommend_title1, 0, wxALIGN_CENTER, 0); m_sizer_ams_mapping_left = new wxGridSizer(0, 5, FromDIP(7), FromDIP(7)); @@ -390,7 +390,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) m_filament_right_panel = new StaticBox(m_scroll_area); m_filament_right_panel->SetBorderWidth(0); - m_filament_right_panel->SetBackgroundColour(wxColour(0xf8f8f8)); + m_filament_right_panel->SetBackgroundColour(wxColour("#F8F8F8")); m_filament_right_panel->SetMinSize(wxSize(FromDIP(315), -1)); m_filament_right_panel->SetMaxSize(wxSize(FromDIP(315), -1)); @@ -398,7 +398,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater) auto right_recommend_title_sizer = new wxBoxSizer(wxHORIZONTAL); auto right_recommend_title1 = new Label(m_filament_right_panel, _L("Right Nozzle")); right_recommend_title1->SetFont(::Label::Head_13); - right_recommend_title1->SetBackgroundColour(wxColour(0xF8F8F8)); + right_recommend_title1->SetBackgroundColour(wxColour("#F8F8F8")); right_recommend_title_sizer->Add(right_recommend_title1, 0, wxALIGN_CENTER, 0); m_sizer_ams_mapping_right = new wxGridSizer(0, 5, FromDIP(7), FromDIP(7)); @@ -2049,8 +2049,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) bool in_blacklist = false; std::string action; - std::string info; - + wxString info; DeviceManager::check_filaments_in_blacklist(obj_->printer_type, filament_brand, filament_type, m_ams_mapping_result[i].filament_id, ams_id, slot_id, "", in_blacklist, action, info); @@ -3500,8 +3499,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_) bool in_blacklist = false; std::string action; - std::string info; - + wxString info; DeviceManager::check_filaments_in_blacklist(obj_->printer_type, filament_brand, filament_type, m_ams_mapping_result[i].filament_id, ams_id, slot_id, "", in_blacklist, action, info); if (in_blacklist) { @@ -5249,7 +5247,7 @@ void PrinterInfoBox::Create() auto printer_staticbox = new StaticBox(this); printer_staticbox->SetMinSize(wxSize(FromDIP(338), FromDIP(68))); printer_staticbox->SetMaxSize(wxSize(FromDIP(338), FromDIP(68))); - printer_staticbox->SetBorderColor(wxColour(0xCECECE)); + printer_staticbox->SetBorderColor(wxColour("#CECECE")); m_comboBox_printer = new ComboBox(printer_staticbox, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0, nullptr, wxCB_READONLY); m_comboBox_printer->SetBorderWidth(0);