mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Animate camera origin changes
This commit is contained in:
parent
43d8d31a63
commit
97dd82e107
2 changed files with 32 additions and 1 deletions
24
CameraAnimation.py
Normal file
24
CameraAnimation.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
from PyQt5.QtCore import QVariantAnimation, QEasingCurve
|
||||||
|
from PyQt5.QtGui import QVector3D
|
||||||
|
|
||||||
|
from UM.Math.Vector import Vector
|
||||||
|
|
||||||
|
class CameraAnimation(QVariantAnimation):
|
||||||
|
def __init__(self, parent = None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self._camera_tool = None
|
||||||
|
self.setDuration(500)
|
||||||
|
self.setEasingCurve(QEasingCurve.InOutQuad)
|
||||||
|
|
||||||
|
def setCameraTool(self, cameraTool):
|
||||||
|
self._camera_tool = cameraTool
|
||||||
|
|
||||||
|
def setStart(self, start):
|
||||||
|
self.setStartValue(QVector3D(start.x, start.y, start.z))
|
||||||
|
|
||||||
|
def setTarget(self, target):
|
||||||
|
self.setEndValue(QVector3D(target.x, target.y, target.z))
|
||||||
|
|
||||||
|
def updateCurrentValue(self, value):
|
||||||
|
self._camera_tool.setOrigin(Vector(value.x(), value.y(), value.z()))
|
|
@ -11,6 +11,7 @@ from UM.Scene.Selection import Selection
|
||||||
|
|
||||||
from PlatformPhysics import PlatformPhysics
|
from PlatformPhysics import PlatformPhysics
|
||||||
from BuildVolume import BuildVolume
|
from BuildVolume import BuildVolume
|
||||||
|
from CameraAnimation import CameraAnimation
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal
|
from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal
|
||||||
from PyQt5.QtGui import QColor
|
from PyQt5.QtGui import QColor
|
||||||
|
@ -64,6 +65,9 @@ class PrinterApplication(QtApplication):
|
||||||
camera.setPerspective(True)
|
camera.setPerspective(True)
|
||||||
camera.lookAt(Vector(0, 0, 0), Vector(0, 1, 0))
|
camera.lookAt(Vector(0, 0, 0), Vector(0, 1, 0))
|
||||||
|
|
||||||
|
self._camera_animation = CameraAnimation()
|
||||||
|
self._camera_animation.setCameraTool(self.getController().getTool('CameraTool'))
|
||||||
|
|
||||||
controller.getScene().setActiveCamera('3d')
|
controller.getScene().setActiveCamera('3d')
|
||||||
|
|
||||||
self.showSplashMessage('Loading interface...')
|
self.showSplashMessage('Loading interface...')
|
||||||
|
@ -79,6 +83,7 @@ class PrinterApplication(QtApplication):
|
||||||
|
|
||||||
if self._engine.rootObjects:
|
if self._engine.rootObjects:
|
||||||
self.closeSplash()
|
self.closeSplash()
|
||||||
|
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
self.saveMachines()
|
self.saveMachines()
|
||||||
|
@ -91,7 +96,9 @@ class PrinterApplication(QtApplication):
|
||||||
if not self.getController().getActiveTool():
|
if not self.getController().getActiveTool():
|
||||||
self.getController().setActiveTool('TranslateTool')
|
self.getController().setActiveTool('TranslateTool')
|
||||||
|
|
||||||
self.getController().getTool('CameraTool').setOrigin(Selection.getSelectedObject(0).getGlobalPosition())
|
self._camera_animation.setStart(self.getController().getTool('CameraTool').getOrigin())
|
||||||
|
self._camera_animation.setTarget(Selection.getSelectedObject(0).getGlobalPosition())
|
||||||
|
self._camera_animation.start()
|
||||||
else:
|
else:
|
||||||
if self.getController().getActiveTool():
|
if self.getController().getActiveTool():
|
||||||
self.getController().setActiveTool(None)
|
self.getController().setActiveTool(None)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue