From c41eb657818bb29abb3a2e7c6df7b7d489c80592 Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 5 Nov 2024 20:35:31 +0800 Subject: [PATCH] FIX:Fixed printer name display error jira:[STUDIO-8619] Change-Id: Ie9ce0cb39623eefa3973a342b447ab2f2a765d28 --- src/slic3r/GUI/DeviceManager.cpp | 14 ++++++++++---- src/slic3r/GUI/DeviceManager.hpp | 9 +++++---- src/slic3r/GUI/ReleaseNote.cpp | 13 +++++++++---- src/slic3r/GUI/ReleaseNote.hpp | 1 + 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 88cbab478..ca78bc0f5 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -6068,9 +6068,9 @@ std::vector DeviceManager::get_compatible_machine(std::string type_ return compatible_machine; } -std::vector DeviceManager::get_all_model_id() +boost::bimaps::bimap DeviceManager::get_all_model_id_with_name() { - std::vector models; + boost::bimaps::bimap models; std::vector m_files; wxDir dir(Slic3r::resources_dir() + "/printers/"); @@ -6095,8 +6095,14 @@ std::vector DeviceManager::get_all_model_id() json_file >> jj; if (jj.contains("00.00.00.00")) { json const &printer = jj["00.00.00.00"]; - if (printer.contains("model_id")) { - for (auto res : printer["model_id"]) models.emplace_back(res.get()); + + std::string model_id; + std::string display_name; + if (printer.contains("model_id")) {model_id = printer["model_id"].get();} + if (printer.contains("display_name")) {display_name = printer["display_name"].get();} + + if (!model_id.empty() && !display_name.empty()) { + models.left.insert(make_pair(model_id, display_name)); } } } diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index a3bc6ac87..a127ca68d 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -13,6 +13,7 @@ #include "libslic3r/ProjectTask.hpp" #include "slic3r/Utils/json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" +#include "boost/bimap/bimap.hpp" #include "CameraPopup.hpp" #include "libslic3r/Calib.hpp" #include "libslic3r/Utils.hpp" @@ -1077,12 +1078,12 @@ public: static std::string get_printer_ams_img(std::string type_str); 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); + static bool get_printer_is_enclosed(std::string type_str); + static bool load_filaments_blacklist_config(); + static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info); static std::vector get_resolution_supported(std::string type_str); static std::vector get_compatible_machine(std::string type_str); - static std::vector get_all_model_id(); - static bool load_filaments_blacklist_config(); - static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, 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/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 888ba35f6..503e7d8a3 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1545,9 +1545,9 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) m_input_modelID->SetMinSize(wxSize(FromDIP(168), FromDIP(28))); m_input_modelID->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); - auto models = DeviceManager::get_all_model_id(); - for (int i = 0; i < models.size(); i++) { - m_input_modelID->Append(models[i]); + m_models_map = DeviceManager::get_all_model_id_with_name(); + for (auto it = m_models_map.begin(); it != m_models_map.end(); ++it) { + m_input_modelID->Append(it->right); m_input_modelID->SetSelection(0); } @@ -1865,7 +1865,12 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) std::string str_ip = m_input_ip->GetTextCtrl()->GetValue().ToStdString(); std::string str_access_code = m_input_access_code->GetTextCtrl()->GetValue().ToStdString(); std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().ToStdString(); - std::string str_model_id = m_input_modelID->GetStringSelection().ToStdString(); + std::string str_model_id = ""; + + auto it = m_models_map.right.find(m_input_modelID->GetStringSelection().ToStdString()); + if (it != m_models_map.right.end()) { + str_model_id = it->get_left(); + } m_button_ok->Enable(false); m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 95c547a63..b87db5bee 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -315,6 +315,7 @@ public: int current_input_index {0}; std::shared_ptr m_send_job{nullptr}; std::shared_ptr m_status_bar; + boost::bimaps::bimap m_models_map; void switch_input_panel(int index); void on_cancel();