MaterialGroup.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  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. class MaterialGroup:
  7. """A MaterialGroup represents a group of material InstanceContainers that are derived from a single material profile.
  8. The main InstanceContainer which has the ID of the material profile file name is called the "root_material". For
  9. example: "generic_abs" is the root material (ID) of "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4",
  10. and "generic_abs_ultimaker3" and "generic_abs_ultimaker3_AA_0.4" are derived materials of "generic_abs".
  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", so
  15. "generic_abs_ultimaker3", "generic_abs_ultimaker3_AA_0.4", etc.
  16. """
  17. __slots__ = ("name", "is_read_only", "root_material_node", "derived_material_node_list")
  18. def __init__(self, name: str, root_material_node: "MaterialNode") -> None:
  19. self.name = name
  20. self.is_read_only = False
  21. self.root_material_node = root_material_node # type: MaterialNode
  22. self.derived_material_node_list = [] # type: List[MaterialNode]
  23. def __str__(self) -> str:
  24. return "%s[%s]" % (self.__class__.__name__, self.name)