PlatformPhysicsOperation.py 987 B

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