diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index e4eee3da44..d7b4d4b0aa 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3683,7 +3683,7 @@ bool GUI_App::select_printer_from_connect(const std::string& msg) std::string model_name = plater()->get_user_account()->get_keyword_from_json(msg, "printer_model"); if (model_name.empty()) { std::vector compatible_printers; - plater()->get_user_account()->fill_compatible_printers_from_json(msg, compatible_printers); + plater()->get_user_account()->fill_supported_printer_models_from_json(msg, compatible_printers); if (!compatible_printers.empty()) { model_name = compatible_printers.front(); } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 172f6e0f5b..260ef99458 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -5874,7 +5874,7 @@ void Plater::connect_gcode() PresetBundle* preset_bundle = wxGetApp().preset_bundle; // Connect data std::vector compatible_printers; - p->user_account->fill_compatible_printers_from_json_old(dialog_msg, compatible_printers); + p->user_account->fill_supported_printer_models_from_json(dialog_msg, compatible_printers); std::string connect_nozzle = p->user_account->get_nozzle_from_json(dialog_msg); std::vector connect_materials; diff --git a/src/slic3r/GUI/UserAccount.cpp b/src/slic3r/GUI/UserAccount.cpp index 33099c91cb..0b06c2d5e9 100644 --- a/src/slic3r/GUI/UserAccount.cpp +++ b/src/slic3r/GUI/UserAccount.cpp @@ -365,41 +365,27 @@ std::string UserAccount::get_keyword_from_json(const std::string& json, const st return out; } -void UserAccount::fill_compatible_printers_from_json(const std::string& json, std::vector& result) const +void UserAccount::fill_supported_printer_models_from_json(const std::string& json, std::vector& result) const { try { std::stringstream ss(json); pt::ptree ptree; pt::read_json(ss, ptree); + std::string printer_model = parse_tree_for_param(ptree, "printer_model"); + if (!printer_model.empty()) { + result.emplace_back(printer_model); + } pt::ptree out = parse_tree_for_subtree(ptree, "supported_printer_models"); if (out.empty()) { BOOST_LOG_TRIVIAL(error) << "Failed to find compatible_printer_type in printer detail."; return; } for (const auto& sub : out) { - result.emplace_back(sub.second.data()); - } - } - catch (const std::exception& e) { - BOOST_LOG_TRIVIAL(error) << "Could not parse prusaconnect message. " << e.what(); - } -} - -void UserAccount::fill_compatible_printers_from_json_old(const std::string& json, std::vector& result) const -{ - try { - std::stringstream ss(json); - pt::ptree ptree; - pt::read_json(ss, ptree); - - pt::ptree out = parse_tree_for_subtree(ptree, "printer_type_compatible"); - if (out.empty()) { - BOOST_LOG_TRIVIAL(error) << "Failed to find compatible_printer_type in printer detail."; - return; - } - for (const auto& sub : out) { - result.emplace_back(sub.second.data()); + if (printer_model != sub.second.data()) { + result.emplace_back(sub.second.data()); + } + } } catch (const std::exception& e) { diff --git a/src/slic3r/GUI/UserAccount.hpp b/src/slic3r/GUI/UserAccount.hpp index a948a552a2..4d86f33b5d 100644 --- a/src/slic3r/GUI/UserAccount.hpp +++ b/src/slic3r/GUI/UserAccount.hpp @@ -68,8 +68,7 @@ public: std::string get_model_from_json(const std::string& message) const; std::string get_nozzle_from_json(const std::string& message) const; std::string get_keyword_from_json(const std::string& json, const std::string& keyword) const; - void fill_compatible_printers_from_json(const std::string& json, std::vector& result) const; - void fill_compatible_printers_from_json_old(const std::string& json, std::vector& result) const; + void fill_supported_printer_models_from_json(const std::string& json, std::vector& result) const; void fill_material_from_json(const std::string& json, std::vector& result) const; const std::map& get_printer_state_table() const { return printer_state_table; }