QualityChangesGroup.py 1.4 KB

123456789101112131415161718192021222324252627
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from UM.Application import Application
  4. from .QualityGroup import QualityGroup
  5. class QualityChangesGroup(QualityGroup):
  6. def __init__(self, name: str, quality_type: str, parent = None):
  7. super().__init__(name, quality_type, parent)
  8. self._container_registry = Application.getInstance().getContainerRegistry()
  9. def addNode(self, node: "QualityNode"):
  10. extruder_position = node.metadata.get("position")
  11. if extruder_position is None: #Then we're a global quality changes profile.
  12. if self.node_for_global is not None:
  13. raise RuntimeError("{group} tries to overwrite the existing node_for_global {original_global} with {new_global}".format(group = self, original_global = self.node_for_global, new_global = node))
  14. self.node_for_global = node
  15. else: #This is an extruder's quality changes profile.
  16. if extruder_position in self.nodes_for_extruders:
  17. raise RuntimeError("%s tries to overwrite the existing nodes_for_extruders position [%s] %s with %s" %
  18. (self, extruder_position, self.node_for_global, node))
  19. self.nodes_for_extruders[extruder_position] = node
  20. def __str__(self) -> str:
  21. return "%s[<%s>, available = %s]" % (self.__class__.__name__, self.name, self.is_available)