From 1dfd5cfdfb44b7ad4418633a3e00f5c451856fe7 Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Thu, 3 Apr 2025 11:49:36 +0800 Subject: [PATCH] FIX: modify style; optimize ext image loading time jira: [none] Change-Id: Ia4bd69cc4ae6ae115c22a5c0b6c6a517773ec3f4 --- resources/images/ams_ext_image_default.svg | 5 - resources/images/ams_ext_image_n1.svg | 739 --------------------- resources/images/ams_ext_image_n2s.svg | 46 -- resources/images/ams_ext_image_o_left.svg | 360 ---------- resources/images/ams_ext_image_o_right.svg | 361 ---------- resources/images/ams_ext_image_xp.svg | 322 --------- resources/printers/BL-P001.json | 1 + resources/printers/BL-P002.json | 1 + resources/printers/C11.json | 1 + resources/printers/C12.json | 1 + resources/printers/C13.json | 1 + resources/printers/N1.json | 1 + resources/printers/N2S.json | 1 + resources/printers/O1D.json | 1 + resources/printers/version.txt | 2 +- src/slic3r/GUI/DeviceManager.cpp | 7 +- src/slic3r/GUI/DeviceManager.hpp | 3 +- src/slic3r/GUI/Widgets/AMSItem.cpp | 64 +- src/slic3r/GUI/Widgets/AMSItem.hpp | 17 +- 19 files changed, 31 insertions(+), 1903 deletions(-) delete mode 100644 resources/images/ams_ext_image_default.svg delete mode 100644 resources/images/ams_ext_image_n1.svg delete mode 100644 resources/images/ams_ext_image_n2s.svg delete mode 100644 resources/images/ams_ext_image_o_left.svg delete mode 100644 resources/images/ams_ext_image_o_right.svg delete mode 100644 resources/images/ams_ext_image_xp.svg diff --git a/resources/images/ams_ext_image_default.svg b/resources/images/ams_ext_image_default.svg deleted file mode 100644 index 299f4cb94..000000000 --- a/resources/images/ams_ext_image_default.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/resources/images/ams_ext_image_n1.svg b/resources/images/ams_ext_image_n1.svg deleted file mode 100644 index 9ab20d8e1..000000000 --- a/resources/images/ams_ext_image_n1.svg +++ /dev/null @@ -1,739 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/ams_ext_image_n2s.svg b/resources/images/ams_ext_image_n2s.svg deleted file mode 100644 index eca8ee07b..000000000 --- a/resources/images/ams_ext_image_n2s.svg +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/ams_ext_image_o_left.svg b/resources/images/ams_ext_image_o_left.svg deleted file mode 100644 index 9912aaa6d..000000000 --- a/resources/images/ams_ext_image_o_left.svg +++ /dev/null @@ -1,360 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/ams_ext_image_o_right.svg b/resources/images/ams_ext_image_o_right.svg deleted file mode 100644 index 4b7fa88ff..000000000 --- a/resources/images/ams_ext_image_o_right.svg +++ /dev/null @@ -1,361 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/images/ams_ext_image_xp.svg b/resources/images/ams_ext_image_xp.svg deleted file mode 100644 index c81f8fcb2..000000000 --- a/resources/images/ams_ext_image_xp.svg +++ /dev/null @@ -1,322 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/printers/BL-P001.json b/resources/printers/BL-P001.json index c4024e21d..40f1bf161 100644 --- a/resources/printers/BL-P001.json +++ b/resources/printers/BL-P001.json @@ -50,6 +50,7 @@ "printer_thumbnail_image": "printer_thumbnail", "printer_connect_help_image": "input_access_code_x1", "printer_use_ams_image": "ams_icon", + "printer_ext_image": ["ext_image_xp"], "use_ams_type": "generic", "printer_arch": "core_xy", "printer_series": "series_x1", diff --git a/resources/printers/BL-P002.json b/resources/printers/BL-P002.json index a6a971beb..77f990e96 100644 --- a/resources/printers/BL-P002.json +++ b/resources/printers/BL-P002.json @@ -50,6 +50,7 @@ "printer_thumbnail_image": "printer_thumbnail", "printer_connect_help_image": "input_access_code_x1", "printer_use_ams_image": "ams_icon", + "printer_ext_image": ["ext_image_xp"], "use_ams_type": "generic", "printer_arch": "core_xy", "printer_series": "series_x1", diff --git a/resources/printers/C11.json b/resources/printers/C11.json index 0a214fcfb..0aabc36ac 100644 --- a/resources/printers/C11.json +++ b/resources/printers/C11.json @@ -46,6 +46,7 @@ "printer_thumbnail_image": "printer_thumbnail_p1p", "printer_connect_help_image": "input_access_code_p1p", "printer_use_ams_image": "ams_icon", + "printer_ext_image": ["ext_image_xp"], "use_ams_type": "generic", "printer_arch": "core_xy", "printer_series": "series_p1p", diff --git a/resources/printers/C12.json b/resources/printers/C12.json index 9689d33ae..090b8f638 100644 --- a/resources/printers/C12.json +++ b/resources/printers/C12.json @@ -46,6 +46,7 @@ "printer_thumbnail_image": "printer_thumbnail_p1s", "printer_connect_help_image": "input_access_code_p1p", "printer_use_ams_image": "ams_icon", + "printer_ext_image": ["ext_image_xp"], "use_ams_type": "generic", "printer_arch": "core_xy", "printer_series": "series_p1p", diff --git a/resources/printers/C13.json b/resources/printers/C13.json index eeef29f26..b9f67823c 100644 --- a/resources/printers/C13.json +++ b/resources/printers/C13.json @@ -54,6 +54,7 @@ "printer_thumbnail_image": "printer_thumbnail", "printer_connect_help_image": "input_access_code_x1", "printer_use_ams_image": "ams_icon", + "printer_ext_image": ["ext_image_xp"], "use_ams_type": "generic", "printer_arch": "core_xy", "printer_series": "series_x1", diff --git a/resources/printers/N1.json b/resources/printers/N1.json index 654ebc3b6..842150c42 100644 --- a/resources/printers/N1.json +++ b/resources/printers/N1.json @@ -46,6 +46,7 @@ "printer_thumbnail_image": "printer_thumbnail_n1", "printer_connect_help_image": "input_access_code_n1", "printer_use_ams_image": "extra_icon", + "printer_ext_image": ["ext_image_n1"], "use_ams_type": "f1", "printer_arch": "i3", "printer_series": "series_n", diff --git a/resources/printers/N2S.json b/resources/printers/N2S.json index 73fbd90cd..f8f3248e1 100644 --- a/resources/printers/N2S.json +++ b/resources/printers/N2S.json @@ -46,6 +46,7 @@ "printer_thumbnail_image": "printer_thumbnail_n2s", "printer_connect_help_image": "input_access_code_n1", "printer_use_ams_image": "extra_icon", + "printer_ext_image": ["ext_image_n2s"], "use_ams_type": "f1", "printer_arch": "i3", "printer_series": "series_n", diff --git a/resources/printers/O1D.json b/resources/printers/O1D.json index 0db1b00ff..ed702d55c 100644 --- a/resources/printers/O1D.json +++ b/resources/printers/O1D.json @@ -63,6 +63,7 @@ "printer_thumbnail_image": "printer_thumbnail_h2d", "printer_connect_help_image": "input_access_code_h2d", "printer_use_ams_image": "ams_icon", + "printer_ext_image": ["ext_image_o_right", "ext_image_o_left"], "use_ams_type": "generic", "printer_arch": "core_xy", "printer_series": "series_o", diff --git a/resources/printers/version.txt b/resources/printers/version.txt index 37be97115..71c8fec3c 100644 --- a/resources/printers/version.txt +++ b/resources/printers/version.txt @@ -1 +1 @@ -02.00.00.10 \ No newline at end of file +02.00.00.11 \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 3b8302216..5bf40f9fa 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -7510,7 +7510,12 @@ std::string DeviceManager::get_printer_diagram_img(std::string type_str) } std::string DeviceManager::get_printer_ams_img(std::string type_str) { - return get_value_from_config(type_str, "printer_use_ams_image"); + return get_value_from_config(type_str, "printer_use_ams_image"); } + +std::string DeviceManager::get_printer_ext_img(std::string type_str, int pos) { + const auto& vec = get_value_from_config>(type_str, "printer_ext_image"); + if (vec.size() > pos) { return vec[pos];} + return std::string(); } bool DeviceManager::get_printer_is_enclosed(std::string type_str) { diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 6684730a8..47ed7c6de 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -1459,7 +1459,7 @@ public: } } catch (...) {} - return ""; + return T(); } static std::string parse_printer_type(std::string type_str); @@ -1469,6 +1469,7 @@ public: static std::string get_printer_series(std::string type_str); static std::string get_printer_diagram_img(std::string type_str); static std::string get_printer_ams_img(std::string type_str); + static std::string get_printer_ext_img(std::string type_str, int pos); static PrinterArch get_printer_arch(std::string type_str); static std::string get_ftp_folder(std::string type_str); static bool get_printer_is_enclosed(std::string type_str); diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index bbad3c795..ee764698d 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -581,7 +581,6 @@ AMSExtImage::AMSExtImage(wxWindow* parent, AMSPanelPos ext_pos, ExtderData *data } m_ext_pos = ext_pos; - createImages(); SetBackgroundColour(StateColor::darkModeColorFor(AMS_CONTROL_DEF_LIB_BK_COLOUR)); Bind(wxEVT_PAINT, &AMSExtImage::paintEvent, this); @@ -589,63 +588,24 @@ AMSExtImage::AMSExtImage(wxWindow* parent, AMSPanelPos ext_pos, ExtderData *data AMSExtImage::~AMSExtImage() {} -void AMSExtImage::createImages() +const wxBitmap &AMSExtImage::get_bmp(const std::string &printer_type, bool is_ams_ext, AMSPanelPos pos) { - m_ams_ext_o_left = ScalableBitmap(this, "ams_ext_image_o_left", 25); - m_ams_ext_o_right = ScalableBitmap(this, "ams_ext_image_o_right", 25); - m_ams_ext_xp = ScalableBitmap(this, "ams_ext_image_xp", 25); - m_ams_ext_n1 = ScalableBitmap(this, "ams_ext_image_n1", 25); - m_ams_ext_n2s = ScalableBitmap(this, "ams_ext_image_n2s", 25); - m_ams_ext_default = ScalableBitmap(this, "ams_ext_image_default", 25); + int pos_id = 0; + if (pos == AMSPanelPos::LEFT_PANEL) { pos_id = 1;} + const std::string &image_name = DeviceManager::get_printer_ext_img(printer_type, pos_id); + if (image_name.empty()) { return wxNullBitmap; } - m_ext_o_left = ScalableBitmap(this, "ext_image_o_left", 98); - m_ext_o_right = ScalableBitmap(this, "ext_image_o_right", 98); - m_ext_xp = ScalableBitmap(this, "ext_image_xp", 98); - m_ext_n1 = ScalableBitmap(this, "ext_image_n1", 98); - m_ext_n2s = ScalableBitmap(this, "ext_image_n2s", 98); - m_ext_default = ScalableBitmap(this, "ext_image_default", 98); -} - -const wxBitmap &AMSExtImage::get_bmp(const std::string &series_name, const std::string &printer_type, bool is_ams_ext, AMSPanelPos pos) const -{ - if (MachineObject::is_series_o(series_name)) { - if (pos == AMSPanelPos::LEFT_PANEL) { - return is_ams_ext ? m_ams_ext_o_left.bmp() : m_ext_o_left.bmp(); - } else if (pos == AMSPanelPos::RIGHT_PANEL) { - return is_ams_ext ? m_ams_ext_o_right.bmp() : m_ext_o_right.bmp(); - } - } else if (MachineObject::is_series_x(series_name) || MachineObject::is_series_p(series_name)) { - return is_ams_ext ? m_ams_ext_xp.bmp() : m_ext_xp.bmp(); - } else if (MachineObject::is_series_n(series_name)) { - if (printer_type == "N1") { - return is_ams_ext ? m_ams_ext_n1.bmp() : m_ext_n1.bmp(); - } else if (printer_type == "N2S") { - return is_ams_ext ? m_ams_ext_n2s.bmp() : m_ext_n2s.bmp(); - } + int image_size = is_ams_ext ? 25 : 98; + if ((m_ext_image.name() != image_name) || (m_ext_image.GetBmpWidth() != image_size)) { + m_ext_image = ScalableBitmap(this, image_name, image_size); } - return is_ams_ext ? m_ams_ext_default.bmp() : m_ext_default.bmp(); + return m_ext_image.bmp(); } void AMSExtImage::msw_rescale() { - //m_ams_extruder.SetSize(AMS_EXTRUDER_BITMAP_SIZE); - //auto image = m_ams_extruder.ConvertToImage(); - m_ams_ext_o_left.msw_rescale(); - m_ams_ext_o_right.msw_rescale(); - m_ams_ext_xp.msw_rescale(); - m_ams_ext_n1.msw_rescale(); - m_ams_ext_n2s.msw_rescale(); - m_ams_ext_default.msw_rescale(); - - m_ext_o_left.msw_rescale(); - m_ext_o_right.msw_rescale(); - m_ext_xp.msw_rescale(); - m_ext_n1.msw_rescale(); - m_ext_n2s.msw_rescale(); - m_ext_default.msw_rescale(); - - m_ext_default.bmp(); + m_ext_image.msw_rescale(); Layout(); Fit(); @@ -706,7 +666,7 @@ void AMSExtImage::doRender(wxDC& dc) if (m_show_ams_ext) { - const wxBitmap &bmp = get_bmp(m_series_name, m_printer_type_name, true, m_ext_pos); + const wxBitmap &bmp = get_bmp(m_printer_type_name, true, m_ext_pos); dc.DrawBitmap(bmp, wxPoint((size.x - ScalableBitmap::GetBmpSize(bmp).x) / 2, 0)); Layout(); @@ -715,7 +675,7 @@ void AMSExtImage::doRender(wxDC& dc) if (m_show_ext) { - const wxBitmap &bmp = get_bmp(m_series_name, m_printer_type_name, false, m_ext_pos); + const wxBitmap &bmp = get_bmp(m_printer_type_name, false, m_ext_pos); const wxSize& bmp_size = ScalableBitmap::GetBmpSize(bmp); dc.DrawBitmap(bmp, wxPoint((size.x - bmp_size.x) / 2, (size.y - bmp_size.GetHeight()))); diff --git a/src/slic3r/GUI/Widgets/AMSItem.hpp b/src/slic3r/GUI/Widgets/AMSItem.hpp index 0383a6e86..94daf20fa 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.hpp +++ b/src/slic3r/GUI/Widgets/AMSItem.hpp @@ -377,19 +377,7 @@ private: AMSPanelPos m_ext_pos; int total_ext_num = 1; - ScalableBitmap m_ams_ext_o_left; - ScalableBitmap m_ams_ext_o_right; - ScalableBitmap m_ams_ext_xp; - ScalableBitmap m_ams_ext_n1; - ScalableBitmap m_ams_ext_n2s; - ScalableBitmap m_ams_ext_default; - - ScalableBitmap m_ext_o_left; - ScalableBitmap m_ext_o_right; - ScalableBitmap m_ext_xp; - ScalableBitmap m_ext_n1; - ScalableBitmap m_ext_n2s; - ScalableBitmap m_ext_default; + ScalableBitmap m_ext_image; public: AMSExtImage(wxWindow *parent, AMSPanelPos ext_pos = AMSPanelPos::RIGHT_PANEL, ExtderData *data = nullptr, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition); @@ -404,8 +392,7 @@ private: void render(wxDC &dc); void doRender(wxDC &dc); - void createImages(); - const wxBitmap &get_bmp(const std::string &series_name, const std::string &printer_type, bool is_ams_ext, AMSPanelPos pos) const; + const wxBitmap &get_bmp(const std::string &printer_type, bool is_ams_ext, AMSPanelPos pos); };