From 104cbb7b9b9a3f03a2c28aa0385514e25c0808f1 Mon Sep 17 00:00:00 2001 From: hemai Date: Thu, 9 Oct 2025 10:31:14 +0800 Subject: [PATCH] ENH: support E3D print parts display Jira: [STUDIO-14908] Change-Id: Ie8273eb6f74a3e7508f440d2092bb48f2e1dbb10 (cherry picked from commit a4218e991e6367e3f1ee3802e785802df2ad6d41) --- resources/info/nozzle_info.json | 1 + src/libslic3r/CommonDefs.hpp | 1 + src/libslic3r/PrintConfig.hpp | 6 ++++-- src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp | 10 ++++++---- src/slic3r/GUI/DeviceCore/DevNozzleSystem.h | 2 +- src/slic3r/GUI/DeviceManager.cpp | 13 +++++++------ src/slic3r/GUI/DeviceManager.hpp | 5 ++++- src/slic3r/GUI/PrintOptionsDialog.cpp | 6 ++++-- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/resources/info/nozzle_info.json b/resources/info/nozzle_info.json index 3a4bba977a..1a93bb09ff 100644 --- a/resources/info/nozzle_info.json +++ b/resources/info/nozzle_info.json @@ -5,6 +5,7 @@ "stainless_steel": 20, "tungsten_carbide": 85, "brass": 2, + "E3D": 55, "undefine": 0 } } \ No newline at end of file diff --git a/src/libslic3r/CommonDefs.hpp b/src/libslic3r/CommonDefs.hpp index 0c909bcc9e..dea53e7400 100644 --- a/src/libslic3r/CommonDefs.hpp +++ b/src/libslic3r/CommonDefs.hpp @@ -16,6 +16,7 @@ namespace Slic3r ntStainlessSteel, ntTungstenCarbide, ntBrass, + ntE3D, ntCount }; } \ No newline at end of file diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index e70ff7fdf0..3125e654c7 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -315,7 +315,8 @@ static std::unordered_mapNozzleTypeEumnToStr = { {NozzleType::ntHardenedSteel, "hardened_steel"}, {NozzleType::ntStainlessSteel, "stainless_steel"}, {NozzleType::ntTungstenCarbide, "tungsten_carbide"}, - {NozzleType::ntBrass, "brass"} + {NozzleType::ntBrass, "brass"}, + {NozzleType::ntE3D, "E3D"} }; static std::unordered_mapNozzleTypeStrToEumn = { @@ -323,7 +324,8 @@ static std::unordered_mapNozzleTypeStrToEumn = { {"hardened_steel", NozzleType::ntHardenedSteel}, {"stainless_steel", NozzleType::ntStainlessSteel}, {"tungsten_carbide", NozzleType::ntTungstenCarbide}, - {"brass", NozzleType::ntBrass} + {"brass", NozzleType::ntBrass}, + {"E3D", NozzleType::ntE3D} }; // BBS diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp index 53e1455aef..d6c35d06b1 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp @@ -62,8 +62,8 @@ static void s_parse_nozzle_type(const std::string& nozzle_type_str, DevNozzle& n void DevNozzleSystemParser::ParseV1_0(const nlohmann::json& nozzletype_json, const nlohmann::json& diameter_json, - const int& nozzle_flow_type, - DevNozzleSystem* system) + DevNozzleSystem* system, + std::optional flag_e3d) { //Since both the old and new protocols push data. // assert(system->m_nozzles.size() < 2); @@ -100,10 +100,12 @@ void DevNozzleSystemParser::ParseV1_0(const nlohmann::json& nozzletype_json, } { - if (nozzle_flow_type != -1) { + if (flag_e3d.has_value()) { // 0: BBL S_FLOW; 1:E3D H_FLOW (only P) - if (nozzle_flow_type == 1) { + if (flag_e3d.value() == 1) { + // note: E3D = E3D nozzle type + High Flow nozzle.m_nozzle_flow = NozzleFlowType::H_FLOW; + nozzle.m_nozzle_type = NozzleType::ntE3D; } else { nozzle.m_nozzle_flow = NozzleFlowType::S_FLOW; } diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h index 1ffbff8a93..7b68ef551b 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h @@ -45,7 +45,7 @@ namespace Slic3r class DevNozzleSystemParser { public: - static void ParseV1_0(const nlohmann::json& nozzletype_json, const nlohmann::json& diameter_json, const int& nozzle_flow_type, DevNozzleSystem* system); + static void ParseV1_0(const nlohmann::json& nozzletype_json, const nlohmann::json& diameter_json, DevNozzleSystem* system, std::optional flag_e3d); static void ParseV2_0(const json& nozzle_json, DevNozzleSystem* system); }; }; \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 8eae555588..a0663166e8 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2361,6 +2361,7 @@ void MachineObject::reset() } } subtask_ = nullptr; + has_extra_flow_type = false; m_partskip_ids.clear(); } @@ -3377,14 +3378,14 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_ if (jj.contains("nozzle_diameter") && jj.contains("nozzle_type")) { - int nozzle_flow_type = -1; - - if(jj.contains("flag3")){ - int flag3 = jj["flag3"].get(); - nozzle_flow_type = get_flag_bits(flag3, 10, 3); + std::optional flag_e3d; + if (jj.contains("flag3")) { + int flag3 = jj["flag3"].get(); + flag_e3d = std::make_optional(get_flag_bits(flag3, 10, 3)); + has_extra_flow_type = true; } - DevNozzleSystemParser::ParseV1_0(jj["nozzle_type"], jj["nozzle_diameter"], nozzle_flow_type, m_nozzle_system); + DevNozzleSystemParser::ParseV1_0(jj["nozzle_type"], jj["nozzle_diameter"], m_nozzle_system, flag_e3d); } } diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 8a1e34d0bf..68cfe7ce1c 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -292,7 +292,10 @@ public: bool is_multi_extruders() const; int get_extruder_id_by_ams_id(const std::string& ams_id); - [[nodiscard]] bool is_nozzle_flow_type_supported() const { return is_enable_np; }; + /* E3D has extra nozzle flow type info */ + bool has_extra_flow_type{false}; + + [[nodiscard]] bool is_nozzle_flow_type_supported() const { return is_enable_np | has_extra_flow_type; }; [[nodiscard]] wxString get_nozzle_replace_url() const; /*online*/ diff --git a/src/slic3r/GUI/PrintOptionsDialog.cpp b/src/slic3r/GUI/PrintOptionsDialog.cpp index 48800920fa..6b2e9f694e 100644 --- a/src/slic3r/GUI/PrintOptionsDialog.cpp +++ b/src/slic3r/GUI/PrintOptionsDialog.cpp @@ -1421,9 +1421,11 @@ void PrinterPartsDialog::EnableEditing(bool enable) { wxString PrinterPartsDialog::GetString(NozzleType nozzle_type) const { switch (nozzle_type) { - case Slic3r::ntHardenedSteel: return _L("Hardened Steel"); - case Slic3r::ntStainlessSteel: return _L("Stainless Steel"); + case Slic3r::ntHardenedSteel: return _L("Hardened Steel"); + case Slic3r::ntStainlessSteel: return _L("Stainless Steel"); case Slic3r::ntTungstenCarbide: return _L("Tungsten Carbide"); + case Slic3r::ntBrass: return _L("Brass"); + case Slic3r::ntE3D: return "E3D"; default: break; }