Browse Source

Centralize all of these mappings.

done as part of CURA-12005
Remco Burema 7 months ago
parent
commit
f81a3f0e11

+ 40 - 0
cura/PrinterOutput/FormatMaps.py

@@ -0,0 +1,40 @@
+# Copyright (c) 2024 UltiMaker
+# Cura is released under the terms of the LGPLv3 or higher.
+
+class FormatMaps:
+
+    PRINTER_TYPE_NAME = {
+        "fire_e": "ultimaker_method",
+        "lava_f": "ultimaker_methodx",
+        "magma_10": "ultimaker_methodxl",
+        "sketch": "ultimaker_sketch"
+    }
+
+    EXTRUDER_NAME_MAP = {
+        "mk14_hot": "1XA",
+        "mk14_hot_s": "2XA",
+        "mk14_c": "1C",
+        "mk14": "1A",
+        "mk14_s": "2A",
+        "mk14_e": "LABS"
+    }
+
+    MATERIAL_MAP = {
+        "abs": {"name": "ABS", "guid": "2780b345-577b-4a24-a2c5-12e6aad3e690"},
+         "abs-cf10": {"name": "ABS-CF", "guid": "495a0ce5-9daf-4a16-b7b2-06856d82394d"},
+         "abs-wss1": {"name": "ABS-R", "guid": "88c8919c-6a09-471a-b7b6-e801263d862d"},
+         "asa": {"name": "ASA", "guid": "f79bc612-21eb-482e-ad6c-87d75bdde066"},
+         "nylon12-cf": {"name": "Nylon 12 CF", "guid": "3c6f2877-71cc-4760-84e6-4b89ab243e3b"},
+         "nylon": {"name": "Nylon", "guid": "283d439a-3490-4481-920c-c51d8cdecf9c"},
+         "pc": {"name": "PC", "guid": "62414577-94d1-490d-b1e4-7ef3ec40db02"},
+         "petg": {"name": "PETG", "guid": "69386c85-5b6c-421a-bec5-aeb1fb33f060"},
+         "pla": {"name": "PLA", "guid": "abb9c58e-1f56-48d1-bd8f-055fde3a5b56"},
+         "pva": {"name": "PVA", "guid": "add51ef2-86eb-4c39-afd5-5586564f0715"},
+         "wss1": {"name": "RapidRinse", "guid": "a140ef8f-4f26-4e73-abe0-cfc29d6d1024"},
+         "sr30": {"name": "SR-30", "guid": "77873465-83a9-4283-bc44-4e542b8eb3eb"},
+         "bvoh": {"name": "BVOH", "guid": "923e604c-8432-4b09-96aa-9bbbd42207f4"},
+         "cpe": {"name": "CPE", "guid": "da1872c1-b991-4795-80ad-bdac0f131726"},
+         "hips": {"name": "HIPS", "guid": "a468d86a-220c-47eb-99a5-bbb47e514eb0"},
+         "tpu": {"name": "TPU 95A", "guid": "19baa6a9-94ff-478b-b4a1-8157b74358d2"},
+         "im-pla": {"name": "Tough", "guid": "de031137-a8ca-4a72-bd1b-17bb964033ad"}
+    }

+ 4 - 11
cura/PrinterOutput/Models/ExtruderConfigurationModel.py

@@ -1,9 +1,10 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2024 UltiMaker
 # Cura is released under the terms of the LGPLv3 or higher.
 from typing import Optional
 
 from PyQt6.QtCore import pyqtProperty, QObject, pyqtSignal
 
+from cura.PrinterOutput.FormatMaps import FormatMaps
 from .MaterialOutputModel import MaterialOutputModel
 
 
@@ -45,16 +46,8 @@ class ExtruderConfigurationModel(QObject):
 
     @staticmethod
     def applyNameMappingHotend(hotendId) -> str:
-        _EXTRUDER_NAME_MAP = {
-            "mk14_hot":"1XA",
-            "mk14_hot_s":"2XA",
-            "mk14_c":"1C",
-            "mk14":"1A",
-            "mk14_s":"2A",
-            "mk14_e": "LABS"
-        }
-        if hotendId in _EXTRUDER_NAME_MAP:
-            return _EXTRUDER_NAME_MAP[hotendId]
+        if hotendId in FormatMaps.EXTRUDER_NAME_MAP:
+            return FormatMaps.EXTRUDER_NAME_MAP[hotendId]
         return hotendId
 
     @pyqtProperty(str, fset = setHotendID, notify = extruderConfigurationChanged)

+ 5 - 25
cura/PrinterOutput/Models/MaterialOutputModel.py

@@ -1,9 +1,10 @@
-# Copyright (c) 2017 Ultimaker B.V.
+# Copyright (c) 2024 UltiMaker
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from typing import Optional
 
 from PyQt6.QtCore import pyqtProperty, QObject
+from cura.PrinterOutput.FormatMaps import FormatMaps
 
 
 class MaterialOutputModel(QObject):
@@ -23,30 +24,9 @@ class MaterialOutputModel(QObject):
 
     @staticmethod
     def getMaterialFromDefinition(guid, type, brand, name):
-
-        _MATERIAL_MAP = {	"abs"       :{"name" :"ABS"           ,"guid": "2780b345-577b-4a24-a2c5-12e6aad3e690"},
-                            "abs-cf10"  :{"name": "ABS-CF"        ,"guid": "495a0ce5-9daf-4a16-b7b2-06856d82394d"},
-                            "abs-wss1"  :{"name" :"ABS-R"         ,"guid": "88c8919c-6a09-471a-b7b6-e801263d862d"},
-                            "asa"       :{"name" :"ASA"           ,"guid": "f79bc612-21eb-482e-ad6c-87d75bdde066"},
-                            "nylon12-cf":{"name": "Nylon 12 CF"   ,"guid": "3c6f2877-71cc-4760-84e6-4b89ab243e3b"},
-                            "nylon"     :{"name" :"Nylon"         ,"guid": "283d439a-3490-4481-920c-c51d8cdecf9c"},
-                            "pc"        :{"name" :"PC"            ,"guid": "62414577-94d1-490d-b1e4-7ef3ec40db02"},
-                            "petg"      :{"name" :"PETG"          ,"guid": "69386c85-5b6c-421a-bec5-aeb1fb33f060"},
-                            "pla"       :{"name" :"PLA"           ,"guid": "abb9c58e-1f56-48d1-bd8f-055fde3a5b56"},
-                            "pva"       :{"name" :"PVA"           ,"guid": "add51ef2-86eb-4c39-afd5-5586564f0715"},
-                            "wss1"      :{"name" :"RapidRinse"    ,"guid": "a140ef8f-4f26-4e73-abe0-cfc29d6d1024"},
-                            "sr30"      :{"name" :"SR-30"         ,"guid": "77873465-83a9-4283-bc44-4e542b8eb3eb"},
-                            "bvoh"      :{"name" :"BVOH"          ,"guid": "923e604c-8432-4b09-96aa-9bbbd42207f4"},
-                            "cpe"       :{"name" :"CPE"           ,"guid": "da1872c1-b991-4795-80ad-bdac0f131726"},
-                            "hips"      :{"name" :"HIPS"          ,"guid": "a468d86a-220c-47eb-99a5-bbb47e514eb0"},
-                            "tpu"       :{"name" :"TPU 95A"       ,"guid": "19baa6a9-94ff-478b-b4a1-8157b74358d2"},
-                            "im-pla"    :{"name": "Tough"         ,"guid": "de031137-a8ca-4a72-bd1b-17bb964033ad"}
-                        }
-
-
-        if guid is None and brand != "empty" and type in _MATERIAL_MAP:
-            name = _MATERIAL_MAP[type]["name"]
-            guid = _MATERIAL_MAP[type]["guid"]
+        if guid is None and brand != "empty" and type in FormatMaps.MATERIAL_MAP:
+            name = FormatMaps.MATERIAL_MAP[type]["name"]
+            guid = FormatMaps.MATERIAL_MAP[type]["guid"]
         return name, guid
 
 

+ 4 - 9
cura/PrinterOutput/NetworkedPrinterOutputDevice.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2021 Ultimaker B.V.
+# Copyright (c) 2024 UltiMaker
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from UM.FileHandler.FileHandler import FileHandler #For typing.
@@ -6,6 +6,7 @@ from UM.Logger import Logger
 from UM.Scene.SceneNode import SceneNode #For typing.
 from cura.API import Account
 from cura.CuraApplication import CuraApplication
+from cura.PrinterOutput.FormatMaps import FormatMaps
 
 from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionState, ConnectionType
 
@@ -419,14 +420,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
 
     @staticmethod
     def applyPrinterTypeMapping(printer_type):
-        _PRINTER_TYPE_NAME = {
-            "fire_e": "ultimaker_method",
-            "lava_f": "ultimaker_methodx",
-            "magma_10": "ultimaker_methodxl",
-            "sketch": "ultimaker_sketch"
-        }
-        if printer_type in _PRINTER_TYPE_NAME:
-            return _PRINTER_TYPE_NAME[printer_type]
+        if printer_type in FormatMaps.PRINTER_TYPE_NAME:
+            return FormatMaps.PRINTER_TYPE_NAME[printer_type]
         return printer_type
 
     @pyqtProperty(str, constant = True)