cura_empty_instance_containers.py 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # Copyright (c) 2019 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. import copy
  4. from UM.Settings.constant_instance_containers import EMPTY_CONTAINER_ID, empty_container
  5. from UM.i18n import i18nCatalog
  6. catalog = i18nCatalog("cura")
  7. # Empty definition changes
  8. EMPTY_DEFINITION_CHANGES_CONTAINER_ID = "empty_definition_changes"
  9. empty_definition_changes_container = copy.deepcopy(empty_container)
  10. empty_definition_changes_container.setMetaDataEntry("id", EMPTY_DEFINITION_CHANGES_CONTAINER_ID)
  11. empty_definition_changes_container.setMetaDataEntry("type", "definition_changes")
  12. # Empty variant
  13. EMPTY_VARIANT_CONTAINER_ID = "empty_variant"
  14. empty_variant_container = copy.deepcopy(empty_container)
  15. empty_variant_container.setMetaDataEntry("id", EMPTY_VARIANT_CONTAINER_ID)
  16. empty_variant_container.setMetaDataEntry("type", "variant")
  17. # Empty material
  18. EMPTY_MATERIAL_CONTAINER_ID = "empty_material"
  19. empty_material_container = copy.deepcopy(empty_container)
  20. empty_material_container.setMetaDataEntry("id", EMPTY_MATERIAL_CONTAINER_ID)
  21. empty_material_container.setMetaDataEntry("type", "material")
  22. empty_material_container.setMetaDataEntry("base_file", "empty_material")
  23. empty_material_container.setMetaDataEntry("GUID", "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF")
  24. empty_material_container.setMetaDataEntry("material", "empty")
  25. # Empty quality
  26. EMPTY_QUALITY_CONTAINER_ID = "empty_quality"
  27. empty_quality_container = copy.deepcopy(empty_container)
  28. empty_quality_container.setMetaDataEntry("id", EMPTY_QUALITY_CONTAINER_ID)
  29. empty_quality_container.setName(catalog.i18nc("@info:not supported profile", "Not supported"))
  30. empty_quality_container.setMetaDataEntry("quality_type", "not_supported")
  31. empty_quality_container.setMetaDataEntry("type", "quality")
  32. empty_quality_container.setMetaDataEntry("supported", False)
  33. # Empty quality changes
  34. EMPTY_QUALITY_CHANGES_CONTAINER_ID = "empty_quality_changes"
  35. empty_quality_changes_container = copy.deepcopy(empty_container)
  36. empty_quality_changes_container.setMetaDataEntry("id", EMPTY_QUALITY_CHANGES_CONTAINER_ID)
  37. empty_quality_changes_container.setMetaDataEntry("type", "quality_changes")
  38. empty_quality_changes_container.setMetaDataEntry("quality_type", "not_supported")
  39. empty_quality_changes_container.setMetaDataEntry("intent_category", "not_supported")
  40. # Empty intent
  41. EMPTY_INTENT_CONTAINER_ID = "empty_intent"
  42. empty_intent_container = copy.deepcopy(empty_container)
  43. empty_intent_container.setMetaDataEntry("id", EMPTY_INTENT_CONTAINER_ID)
  44. empty_intent_container.setMetaDataEntry("type", "intent")
  45. empty_intent_container.setMetaDataEntry("intent_category", "default")
  46. empty_intent_container.setName(catalog.i18nc("@info:No intent profile selected", "Default"))
  47. # All empty container IDs set
  48. ALL_EMPTY_CONTAINER_ID_SET = {
  49. EMPTY_CONTAINER_ID,
  50. EMPTY_DEFINITION_CHANGES_CONTAINER_ID,
  51. EMPTY_VARIANT_CONTAINER_ID,
  52. EMPTY_MATERIAL_CONTAINER_ID,
  53. EMPTY_QUALITY_CONTAINER_ID,
  54. EMPTY_QUALITY_CHANGES_CONTAINER_ID,
  55. EMPTY_INTENT_CONTAINER_ID
  56. }
  57. # Convenience function to check if a container ID represents an empty container.
  58. def isEmptyContainer(container_id: str) -> bool:
  59. return container_id in ALL_EMPTY_CONTAINER_ID_SET
  60. __all__ = ["EMPTY_CONTAINER_ID",
  61. "empty_container", # For convenience
  62. "EMPTY_DEFINITION_CHANGES_CONTAINER_ID",
  63. "empty_definition_changes_container",
  64. "EMPTY_VARIANT_CONTAINER_ID",
  65. "empty_variant_container",
  66. "EMPTY_MATERIAL_CONTAINER_ID",
  67. "empty_material_container",
  68. "EMPTY_QUALITY_CHANGES_CONTAINER_ID",
  69. "empty_quality_changes_container",
  70. "EMPTY_QUALITY_CONTAINER_ID",
  71. "empty_quality_container",
  72. "ALL_EMPTY_CONTAINER_ID_SET",
  73. "isEmptyContainer",
  74. "EMPTY_INTENT_CONTAINER_ID",
  75. "empty_intent_container"
  76. ]