CuraSceneNode.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from UM.Application import Application
  2. from UM.Logger import Logger
  3. from UM.Scene.SceneNode import SceneNode
  4. from copy import deepcopy
  5. ## Scene nodes that are models are only seen when selecting the corresponding build plate
  6. # Note that many other nodes can just be UM SceneNode objects.
  7. class CuraSceneNode(SceneNode):
  8. def __init__(self, *args, **kwargs):
  9. super().__init__(*args, **kwargs)
  10. self._outside_buildarea = True
  11. def setOutsideBuildArea(self, new_value):
  12. self._outside_buildarea = new_value
  13. def isOutsideBuildArea(self):
  14. return self._outside_buildarea or self.callDecoration("getBuildPlateNumber") < 0
  15. def isVisible(self):
  16. return super().isVisible() and self.callDecoration("getBuildPlateNumber") == Application.getInstance().getBuildPlateModel().activeBuildPlate
  17. def isSelectable(self) -> bool:
  18. return super().isSelectable() and self.callDecoration("getBuildPlateNumber") == Application.getInstance().getBuildPlateModel().activeBuildPlate
  19. ## Taken from SceneNode, but replaced SceneNode with CuraSceneNode
  20. def __deepcopy__(self, memo):
  21. copy = CuraSceneNode()
  22. copy.setTransformation(self.getLocalTransformation())
  23. copy.setMeshData(self._mesh_data)
  24. copy.setVisible(deepcopy(self._visible, memo))
  25. copy._selectable = deepcopy(self._selectable, memo)
  26. copy._name = deepcopy(self._name, memo)
  27. for decorator in self._decorators:
  28. copy.addDecorator(deepcopy(decorator, memo))
  29. for child in self._children:
  30. copy.addChild(deepcopy(child, memo))
  31. self.calculateBoundingBoxMesh()
  32. return copy
  33. def transformChanged(self) -> None:
  34. self._transformChanged()