PlatformPhysicsOperation.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (c) 2015 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from UM.Operations.Operation import Operation
  4. from UM.Operations.GroupedOperation import GroupedOperation
  5. from UM.Scene.SceneNode import SceneNode
  6. ## A specialised operation designed specifically to modify the previous operation.
  7. class PlatformPhysicsOperation(Operation):
  8. def __init__(self, node, translation):
  9. super().__init__()
  10. self._node = node
  11. self._old_transformation = node.getLocalTransformation()
  12. self._translation = translation
  13. self._always_merge = True
  14. def undo(self):
  15. self._node.setTransformation(self._old_transformation)
  16. def redo(self):
  17. self._node.translate(self._translation, SceneNode.TransformSpace.World)
  18. def mergeWith(self, other):
  19. group = GroupedOperation()
  20. group.addOperation(other)
  21. group.addOperation(self)
  22. return group
  23. def __repr__(self):
  24. return "PlatformPhysicsOperation(translation = {0})".format(self._translation)