1 /*************************************************************************** 2 qgs3danimationsettings.h 3 -------------------------------------- 4 Date : July 2018 5 Copyright : (C) 2018 by Martin Dobias 6 Email : wonder dot sk at gmail dot com 7 *************************************************************************** 8 * * 9 * This program is free software; you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation; either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 ***************************************************************************/ 15 16 #ifndef QGS3DANIMATIONSETTINGS_H 17 #define QGS3DANIMATIONSETTINGS_H 18 19 #include "qgsvector3d.h" 20 #include "qgis_3d.h" 21 22 #include <QEasingCurve> 23 #include <QVector> 24 25 class QDomDocument; 26 class QDomElement; 27 class QgsReadWriteContext; 28 29 #define SIP_NO_FILE 30 31 /** 32 * \ingroup 3d 33 * \brief Class that holds information about animation in 3D view. The animation is defined 34 * as a series of keyframes 35 * \note Not available in Python bindings 36 * \since QGIS 3.8 37 */ 38 class _3D_EXPORT Qgs3DAnimationSettings 39 { 40 public: 41 //! ctor 42 Qgs3DAnimationSettings(); 43 44 //! keyframe definition 45 struct Keyframe 46 { 47 float time = 0; //!< Relative time of the keyframe in seconds 48 QgsVector3D point; //!< Point towards which the camera is looking in 3D world coords 49 float dist = 0; //!< Distance of the camera from the focal point 50 float pitch = 0; //!< Tilt of the camera in degrees (0 = looking from the top, 90 = looking from the side, 180 = looking from the bottom) 51 float yaw = 0; //!< Horizontal rotation around the focal point in degrees 52 }; 53 54 typedef QVector<Keyframe> Keyframes; 55 56 //! Configures keyframes of the animation. It is expected that the keyframes are ordered according to their time. setKeyframes(const Keyframes & keyframes)57 void setKeyframes( const Keyframes &keyframes ) { mKeyframes = keyframes; } 58 //! Returns keyframes of the animation keyFrames()59 Keyframes keyFrames() const { return mKeyframes; } 60 61 //! Sets the interpolation method for transitions of the camera setEasingCurve(const QEasingCurve & curve)62 void setEasingCurve( const QEasingCurve &curve ) { mEasingCurve = curve; } 63 //! Returns the interpolation method for transitions of the camera easingCurve()64 QEasingCurve easingCurve() const { return mEasingCurve; } 65 66 //! Returns duration of the whole animation in seconds 67 float duration() const; 68 69 //! Interpolates camera position and rotation at the given point in time 70 Keyframe interpolate( float time ) const; 71 72 //! Reads configuration from a DOM element previously written by writeXml() 73 void readXml( const QDomElement &elem ); 74 //! Writes configuration to a DOM element, to be used later with readXml() 75 QDomElement writeXml( QDomDocument &doc ) const; 76 77 private: 78 Keyframes mKeyframes; 79 QEasingCurve mEasingCurve; 80 }; 81 82 Q_DECLARE_METATYPE( Qgs3DAnimationSettings::Keyframe ) 83 84 #endif // QGS3DANIMATIONSETTINGS_H 85