QualityChangesGroup.py 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import TYPE_CHECKING
  4. from UM.Application import Application
  5. from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
  6. from .QualityGroup import QualityGroup
  7. if TYPE_CHECKING:
  8. from cura.Machines.QualityNode import QualityNode
  9. class QualityChangesGroup(QualityGroup):
  10. def __init__(self, name: str, quality_type: str, parent = None) -> None:
  11. super().__init__(name, quality_type, parent)
  12. self._container_registry = Application.getInstance().getContainerRegistry()
  13. def addNode(self, node: "QualityNode") -> None:
  14. extruder_position = node.getMetaDataEntry("position")
  15. if extruder_position is None and self.node_for_global is not None or extruder_position in self.nodes_for_extruders: #We would be overwriting another node.
  16. ConfigurationErrorMessage.getInstance().addFaultyContainers(node.getMetaDataEntry("id"))
  17. return
  18. if extruder_position is None: # Then we're a global quality changes profile.
  19. self.node_for_global = node
  20. else: # This is an extruder's quality changes profile.
  21. self.nodes_for_extruders[extruder_position] = node
  22. def __str__(self) -> str:
  23. return "%s[<%s>, available = %s]" % (self.__class__.__name__, self.name, self.is_available)