BuildPlateDecorator.py 1.1 KB

123456789101112131415161718192021222324252627
  1. from UM.Scene.SceneNodeDecorator import SceneNodeDecorator
  2. from cura.Scene.CuraSceneNode import CuraSceneNode
  3. class BuildPlateDecorator(SceneNodeDecorator):
  4. """Make a SceneNode build plate aware CuraSceneNode objects all have this decorator."""
  5. def __init__(self, build_plate_number: int = -1) -> None:
  6. super().__init__()
  7. self._build_plate_number = build_plate_number
  8. self.setBuildPlateNumber(build_plate_number)
  9. def setBuildPlateNumber(self, nr: int) -> None:
  10. # Make sure that groups are set correctly
  11. # setBuildPlateForSelection in CuraActions makes sure that no single childs are set.
  12. self._build_plate_number = nr
  13. if isinstance(self._node, CuraSceneNode):
  14. self._node.transformChanged() # trigger refresh node without introducing a new signal
  15. if self._node:
  16. for child in self._node.getChildren():
  17. child.callDecoration("setBuildPlateNumber", nr)
  18. def getBuildPlateNumber(self) -> int:
  19. return self._build_plate_number
  20. def __deepcopy__(self, memo):
  21. return BuildPlateDecorator()