From 562f87f550d7cff75afa581a89e0ab58ebe5ea85 Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Mon, 9 Oct 2023 16:57:50 +0800 Subject: [PATCH] ENH: add param printer_is_enclosed 1.Use printer_is_enclosed to decide whether display a pop up when bed temp is higher than softening temp jira: STUDIO-4532 Signed-off-by: xun.zhang Change-Id: I8602db8815093acded0439336f9a8fee52670261 --- resources/printers/BL-P001.json | 3 ++- resources/printers/BL-P002.json | 3 ++- resources/printers/C11.json | 3 ++- resources/printers/C12.json | 3 ++- resources/printers/C13.json | 3 ++- resources/printers/N1.json | 3 ++- src/slic3r/GUI/DeviceManager.cpp | 45 ++++++++++++-------------------- src/slic3r/GUI/DeviceManager.hpp | 26 ++++++++++++++++-- src/slic3r/GUI/SelectMachine.cpp | 2 +- 9 files changed, 54 insertions(+), 37 deletions(-) diff --git a/resources/printers/BL-P001.json b/resources/printers/BL-P001.json index 544969122..5a8653bc5 100644 --- a/resources/printers/BL-P001.json +++ b/resources/printers/BL-P001.json @@ -47,7 +47,8 @@ "use_ams_type":"generic", "printer_arch":"core_xy", "printer_series":"series_x1", - "has_cali_line":true + "has_cali_line":true, + "printer_is_enclosed":true }, "01.01.01.00": { "print": { diff --git a/resources/printers/BL-P002.json b/resources/printers/BL-P002.json index 85f00d493..1fd099499 100644 --- a/resources/printers/BL-P002.json +++ b/resources/printers/BL-P002.json @@ -47,7 +47,8 @@ "use_ams_type":"generic", "printer_arch" : "core_xy", "printer_series":"series_x1", - "has_cali_line":true + "has_cali_line":true, + "printer_is_enclosed":true }, "01.01.01.00": { "print": { diff --git a/resources/printers/C11.json b/resources/printers/C11.json index d1e656cf9..8c0567c4f 100644 --- a/resources/printers/C11.json +++ b/resources/printers/C11.json @@ -45,7 +45,8 @@ "use_ams_type":"generic", "printer_arch" : "core_xy", "printer_series":"series_p1p", - "has_cali_line":false + "has_cali_line":false, + "printer_is_enclosed":false }, "01.02.00.00": { "print": { diff --git a/resources/printers/C12.json b/resources/printers/C12.json index 835b5ac6f..03d706205 100644 --- a/resources/printers/C12.json +++ b/resources/printers/C12.json @@ -45,7 +45,8 @@ "use_ams_type":"generic", "printer_arch" : "core_xy", "printer_series":"series_p1p", - "has_cali_line":false + "has_cali_line":false, + "printer_is_enclosed":true }, "01.02.99.10" : { "print": { diff --git a/resources/printers/C13.json b/resources/printers/C13.json index 71df0fe67..330f367bc 100644 --- a/resources/printers/C13.json +++ b/resources/printers/C13.json @@ -50,7 +50,8 @@ "use_ams_type":"generic", "printer_arch" : "core_xy", "printer_series":"series_x1", - "has_cali_line":true + "has_cali_line":true, + "printer_is_enclosed":true }, "01.05.06.06": { "rv2166": "00.00.21.20" diff --git a/resources/printers/N1.json b/resources/printers/N1.json index e57a52e86..5587d7231 100644 --- a/resources/printers/N1.json +++ b/resources/printers/N1.json @@ -46,6 +46,7 @@ "use_ams_type":"f1", "printer_arch" : "i3", "printer_series":"series_p1p", - "has_cali_line":false + "has_cali_line":false, + "printer_is_enclosed":false } } \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 6b5727b38..ea8cd32f4 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -483,6 +483,11 @@ std::string MachineObject::get_printer_ams_type() const return DeviceManager::get_printer_ams_type(printer_type); } +bool MachineObject::get_printer_is_enclosed() const +{ + return DeviceManager::get_printer_is_enclosed(printer_type); +} + void MachineObject::reload_printer_settings() { print_json.load_compatible_settings("", ""); @@ -5373,63 +5378,47 @@ void DeviceManager::load_last_machine() json DeviceManager::filaments_blacklist = json::object(); -std::string DeviceManager::get_string_from_config(std::string type_str, std::string item) -{ - std::string config_file = Slic3r::resources_dir() + "/printers/" + type_str + ".json"; - boost::nowide::ifstream json_file(config_file.c_str()); - try { - json jj; - if (json_file.is_open()) { - json_file >> jj; - if (jj.contains("00.00.00.00")) { - json const& printer = jj["00.00.00.00"]; - if (printer.contains(item)) { - return printer[item].get(); - } - } - } - } - catch (...) {} - return ""; -} std::string DeviceManager::parse_printer_type(std::string type_str) { - return get_string_from_config(type_str, "printer_type"); + return get_value_from_config(type_str, "printer_type"); } std::string DeviceManager::get_printer_display_name(std::string type_str) { - return get_string_from_config(type_str, "display_name"); + return get_value_from_config(type_str, "display_name"); } std::string DeviceManager::get_ftp_folder(std::string type_str) { - return get_string_from_config(type_str, "ftp_folder"); + return get_value_from_config(type_str, "ftp_folder"); } PrinterArch DeviceManager::get_printer_arch(std::string type_str) { - return get_printer_arch_by_str(get_string_from_config(type_str, "printer_arch")); + return get_printer_arch_by_str(get_value_from_config(type_str, "printer_arch")); } std::string DeviceManager::get_printer_thumbnail_img(std::string type_str) { - return get_string_from_config(type_str, "printer_thumbnail_image"); + return get_value_from_config(type_str, "printer_thumbnail_image"); } std::string DeviceManager::get_printer_ams_type(std::string type_str) { - return get_string_from_config(type_str, "use_ams_type"); + return get_value_from_config(type_str, "use_ams_type"); } std::string DeviceManager::get_printer_series(std::string type_str) { - return get_string_from_config(type_str, "printer_series"); + return get_value_from_config(type_str, "printer_series"); } std::string DeviceManager::get_printer_diagram_img(std::string type_str) { - return get_string_from_config(type_str, "printer_connect_help_image"); + return get_value_from_config(type_str, "printer_connect_help_image"); } std::string DeviceManager::get_printer_ams_img(std::string type_str) { - return get_string_from_config(type_str, "printer_use_ams_image"); + return get_value_from_config(type_str, "printer_use_ams_image"); } +bool DeviceManager::get_printer_is_enclosed(std::string type_str) { + return get_value_from_config(type_str, "printer_is_enclosed"); +} std::vector DeviceManager::get_resolution_supported(std::string type_str) { std::vector resolution_supported; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 6da70deab..7dfea4cbc 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -7,13 +7,14 @@ #include #include #include +#include #include "nlohmann/json.hpp" #include "libslic3r/ProjectTask.hpp" #include "slic3r/Utils/json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" #include "CameraPopup.hpp" #include "libslic3r/Calib.hpp" - +#include "libslic3r/Utils.hpp" #define USE_LOCAL_SOCKET_BIND 0 #define DISCONNECT_TIMEOUT 30000.f // milliseconds @@ -424,6 +425,7 @@ public: PrinterSeries get_printer_series() const; PrinterArch get_printer_arch() const; std::string get_printer_ams_type() const; + bool get_printer_is_enclosed() const; void reload_printer_settings(); @@ -969,7 +971,26 @@ public: static json function_table; static json filaments_blacklist; - static std::string get_string_from_config(std::string type_str, std::string item); + template + static T get_value_from_config(std::string type_str, std::string item){ + std::string config_file = Slic3r::resources_dir() + "/printers/" + type_str + ".json"; + boost::nowide::ifstream json_file(config_file.c_str()); + try { + json jj; + if (json_file.is_open()) { + json_file >> jj; + if (jj.contains("00.00.00.00")) { + json const& printer = jj["00.00.00.00"]; + if (printer.contains(item)) { + return printer[item].get(); + } + } + } + } + catch (...) {} + return ""; + } + static std::string parse_printer_type(std::string type_str); static std::string get_printer_display_name(std::string type_str); static std::string get_printer_thumbnail_img(std::string type_str); @@ -979,6 +1000,7 @@ 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 std::vector get_resolution_supported(std::string type_str); static std::vector get_compatible_machine(std::string type_str); static bool load_filaments_blacklist_config(std::string config_file); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 04b7c95fa..fe91d9c18 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -2378,7 +2378,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) for (auto warning : plate->get_slice_result()->warnings) { if (warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) { - if ((obj_->get_printer_series() == PrinterSeries::SERIES_X1)) { + if ((obj_->get_printer_is_enclosed())){ confirm_text.push_back(Plater::get_slice_warning_string(warning) + "\n"); has_slice_warnings = true; }