diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 3712139d0..7da443eba 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -5999,9 +5999,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/"); @@ -6026,8 +6026,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 466b611cb..ec8f9abd2 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 619c6e25f..7af9cd5b6 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1563,9 +1563,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); } @@ -1883,7 +1883,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 e92e7064c..ba8901b26 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -314,6 +314,7 @@ public: int m_result; int current_input_index {0}; std::shared_ptr m_status_bar; + boost::bimaps::bimap m_models_map; void switch_input_panel(int index); void on_cancel();