CameraAnimation.py 857 B

12345678910111213141516171819202122232425262728
  1. # Copyright (c) 2015 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from PyQt6.QtCore import QVariantAnimation, QEasingCurve
  4. from PyQt6.QtGui import QVector3D
  5. from UM.Math.Vector import Vector
  6. class CameraAnimation(QVariantAnimation):
  7. def __init__(self, parent = None):
  8. super().__init__(parent)
  9. self._camera_tool = None
  10. self.setDuration(300)
  11. self.setEasingCurve(QEasingCurve.Type.OutQuad)
  12. def setCameraTool(self, camera_tool):
  13. self._camera_tool = camera_tool
  14. def setStart(self, start):
  15. self.setStartValue(QVector3D(start.x, start.y, start.z))
  16. def setTarget(self, target):
  17. self.setEndValue(QVector3D(target.x, target.y, target.z))
  18. def updateCurrentValue(self, value):
  19. self._camera_tool.setOrigin(Vector(value.x(), value.y(), value.z()))