MaterialGroup.py 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import List, TYPE_CHECKING
  4. if TYPE_CHECKING:
  5. from cura.Machines.MaterialNode import MaterialNode
  6. ## A MaterialGroup represents a group of material InstanceContainers that are derived from a single material profile.
  7. # The main InstanceContainer which has the ID of the material profile file name is called the "root_material". For
  8. # example: "generic_abs" is the root material (ID) of "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4",
  9. # and "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4" are derived materials of "generic_abs".
  10. #
  11. # Using "generic_abs" as an example, the MaterialGroup for "generic_abs" will contain the following information:
  12. # - name: "generic_abs", root_material_id
  13. # - root_material_node: MaterialNode of "generic_abs"
  14. # - derived_material_node_list: A list of MaterialNodes that are derived from "generic_abs",
  15. # so "generic_abs_ultimaker3", "generic_abs_ultimaker3_AA_0.4", etc.
  16. #
  17. class MaterialGroup:
  18. __slots__ = ("name", "is_read_only", "root_material_node", "derived_material_node_list")
  19. def __init__(self, name: str, root_material_node: "MaterialNode") -> None:
  20. self.name = name
  21. self.is_read_only = False
  22. self.root_material_node = root_material_node # type: MaterialNode
  23. self.derived_material_node_list = [] # type: List[MaterialNode]
  24. def __str__(self) -> str:
  25. return "%s[%s]" % (self.__class__.__name__, self.name)