MaterialOutputModel.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Copyright (c) 2017 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import Optional
  4. from PyQt6.QtCore import pyqtProperty, QObject
  5. class MaterialOutputModel(QObject):
  6. def __init__(self, guid: Optional[str], type: str, color: str, brand: str, name: str, parent = None) -> None:
  7. super().__init__(parent)
  8. name, guid = MaterialOutputModel.getMaterialFromDefinition(guid,type, brand, name)
  9. self._guid =guid
  10. self._type = type
  11. self._color = color
  12. self._brand = brand
  13. self._name = name
  14. @pyqtProperty(str, constant = True)
  15. def guid(self) -> str:
  16. return self._guid if self._guid else ""
  17. @staticmethod
  18. def getMaterialFromDefinition(guid, type, brand, name):
  19. _MATERIAL_MAP = { "abs" :{"name" :"abs_175" ,"guid": "2780b345-577b-4a24-a2c5-12e6aad3e690"},
  20. "abs-wss1" :{"name" :"absr_175" ,"guid": "88c8919c-6a09-471a-b7b6-e801263d862d"},
  21. "asa" :{"name" :"asa_175" ,"guid": "416eead4-0d8e-4f0b-8bfc-a91a519befa5"},
  22. "nylon-cf" :{"name" :"cffpa_175" ,"guid": "85bbae0e-938d-46fb-989f-c9b3689dc4f0"},
  23. "nylon" :{"name" :"nylon_175" ,"guid": "283d439a-3490-4481-920c-c51d8cdecf9c"},
  24. "pc" :{"name" :"pc_175" ,"guid": "62414577-94d1-490d-b1e4-7ef3ec40db02"},
  25. "petg" :{"name" :"petg_175" ,"guid": "69386c85-5b6c-421a-bec5-aeb1fb33f060"},
  26. "pla" :{"name" :"pla_175" ,"guid": "0ff92885-617b-4144-a03c-9989872454bc"},
  27. "pva" :{"name" :"pva_175" ,"guid": "a4255da2-cb2a-4042-be49-4a83957a2f9a"},
  28. "wss1" :{"name" :"rapidrinse_175","guid": "a140ef8f-4f26-4e73-abe0-cfc29d6d1024"},
  29. "sr30" :{"name" :"sr30_175" ,"guid": "77873465-83a9-4283-bc44-4e542b8eb3eb"},
  30. "im-pla" :{"name" :"tough_pla_175" ,"guid": "96fca5d9-0371-4516-9e96-8e8182677f3c"},
  31. "bvoh" :{"name" :"bvoh_175" ,"guid": "923e604c-8432-4b09-96aa-9bbbd42207f4"},
  32. "cpe" :{"name" :"cpe_175" ,"guid": "da1872c1-b991-4795-80ad-bdac0f131726"},
  33. "hips" :{"name" :"hips_175" ,"guid": "a468d86a-220c-47eb-99a5-bbb47e514eb0"},
  34. "tpu" :{"name" :"tpu_175" ,"guid": "19baa6a9-94ff-478b-b4a1-8157b74358d2"}
  35. }
  36. if guid is None and brand is not "empty" and type in _MATERIAL_MAP:
  37. name = _MATERIAL_MAP[type]["name"]
  38. guid = _MATERIAL_MAP[type]["guid"]
  39. return name, guid
  40. @pyqtProperty(str, constant = True)
  41. def type(self) -> str:
  42. return self._type
  43. @pyqtProperty(str, constant = True)
  44. def brand(self) -> str:
  45. return self._brand
  46. @pyqtProperty(str, constant = True)
  47. def color(self) -> str:
  48. return self._color
  49. @pyqtProperty(str, constant = True)
  50. def name(self) -> str:
  51. return self._name
  52. def __eq__(self, other):
  53. if self is other:
  54. return True
  55. if type(other) is not MaterialOutputModel:
  56. return False
  57. return self.guid == other.guid and self.type == other.type and self.brand == other.brand and self.color == other.color and self.name == other.name