MaterialGroup.py 1.5 KB

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