cura_empty_instance_containers.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 quality
  23. EMPTY_QUALITY_CONTAINER_ID = "empty_quality"
  24. empty_quality_container = copy.deepcopy(empty_container)
  25. empty_quality_container.setMetaDataEntry("id", EMPTY_QUALITY_CONTAINER_ID)
  26. empty_quality_container.setName(catalog.i18nc("@info:not supported profile", "Not supported"))
  27. empty_quality_container.setMetaDataEntry("quality_type", "not_supported")
  28. empty_quality_container.setMetaDataEntry("type", "quality")
  29. empty_quality_container.setMetaDataEntry("supported", False)
  30. # Empty quality changes
  31. EMPTY_QUALITY_CHANGES_CONTAINER_ID = "empty_quality_changes"
  32. empty_quality_changes_container = copy.deepcopy(empty_container)
  33. empty_quality_changes_container.setMetaDataEntry("id", EMPTY_QUALITY_CHANGES_CONTAINER_ID)
  34. empty_quality_changes_container.setMetaDataEntry("type", "quality_changes")
  35. empty_quality_changes_container.setMetaDataEntry("quality_type", "not_supported")
  36. # Empty intent
  37. EMPTY_INTENT_CONTAINER_ID = "empty_intent"
  38. empty_intent_container = copy.deepcopy(empty_container)
  39. empty_intent_container.setMetaDataEntry("id", EMPTY_INTENT_CONTAINER_ID)
  40. empty_intent_container.setMetaDataEntry("type", "intent")
  41. empty_intent_container.setMetaDataEntry("intent_category", "default")
  42. empty_intent_container.setName(catalog.i18nc("@info:No intent profile selected", "Default"))
  43. # All empty container IDs set
  44. ALL_EMPTY_CONTAINER_ID_SET = {
  45. EMPTY_CONTAINER_ID,
  46. EMPTY_DEFINITION_CHANGES_CONTAINER_ID,
  47. EMPTY_VARIANT_CONTAINER_ID,
  48. EMPTY_MATERIAL_CONTAINER_ID,
  49. EMPTY_QUALITY_CONTAINER_ID,
  50. EMPTY_QUALITY_CHANGES_CONTAINER_ID,
  51. EMPTY_INTENT_CONTAINER_ID
  52. }
  53. # Convenience function to check if a container ID represents an empty container.
  54. def isEmptyContainer(container_id: str) -> bool:
  55. return container_id in ALL_EMPTY_CONTAINER_ID_SET
  56. __all__ = ["EMPTY_CONTAINER_ID",
  57. "empty_container", # For convenience
  58. "EMPTY_DEFINITION_CHANGES_CONTAINER_ID",
  59. "empty_definition_changes_container",
  60. "EMPTY_VARIANT_CONTAINER_ID",
  61. "empty_variant_container",
  62. "EMPTY_MATERIAL_CONTAINER_ID",
  63. "empty_material_container",
  64. "EMPTY_QUALITY_CHANGES_CONTAINER_ID",
  65. "empty_quality_changes_container",
  66. "EMPTY_QUALITY_CONTAINER_ID",
  67. "empty_quality_container",
  68. "ALL_EMPTY_CONTAINER_ID_SET",
  69. "isEmptyContainer",
  70. "EMPTY_INTENT_CONTAINER_ID",
  71. "empty_intent_container"
  72. ]