Qt 4.8
qguivariantanimation.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 #include <QtCore/qvariantanimation.h>
42 #include <private/qvariantanimation_p.h>
43 
44 #ifndef QT_NO_ANIMATION
45 
46 #include <QtGui/qcolor.h>
47 #include <QtGui/qvector2d.h>
48 #include <QtGui/qvector3d.h>
49 #include <QtGui/qvector4d.h>
50 #include <QtGui/qquaternion.h>
51 
53 
54 template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress)
55 {
56  return QColor(qBound(0,_q_interpolate(f.red(), t.red(), progress),255),
57  qBound(0,_q_interpolate(f.green(), t.green(), progress),255),
58  qBound(0,_q_interpolate(f.blue(), t.blue(), progress),255),
59  qBound(0,_q_interpolate(f.alpha(), t.alpha(), progress),255));
60 }
61 
63 {
64  return QQuaternion::slerp(f, t, progress);
65 }
66 
68 {
69  qRegisterAnimationInterpolator<QColor>(_q_interpolateVariant<QColor>);
70  qRegisterAnimationInterpolator<QVector2D>(_q_interpolateVariant<QVector2D>);
71  qRegisterAnimationInterpolator<QVector3D>(_q_interpolateVariant<QVector3D>);
72  qRegisterAnimationInterpolator<QVector4D>(_q_interpolateVariant<QVector4D>);
73  qRegisterAnimationInterpolator<QQuaternion>(_q_interpolateVariant<QQuaternion>);
74  return 1;
75 }
77 
79 {
80  // casts required by Sun CC 5.5
81  qRegisterAnimationInterpolator<QColor>(
82  (QVariant (*)(const QColor &, const QColor &, qreal))0);
83  qRegisterAnimationInterpolator<QVector2D>(
84  (QVariant (*)(const QVector2D &, const QVector2D &, qreal))0);
85  qRegisterAnimationInterpolator<QVector3D>(
86  (QVariant (*)(const QVector3D &, const QVector3D &, qreal))0);
87  qRegisterAnimationInterpolator<QVector4D>(
88  (QVariant (*)(const QVector4D &, const QVector4D &, qreal))0);
89  qRegisterAnimationInterpolator<QQuaternion>(
90  (QVariant (*)(const QQuaternion &, const QQuaternion &, qreal))0);
91 
92  return 1;
93 }
95 
97 
98 #endif //QT_NO_ANIMATION
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QVector3D class represents a vector or vertex in 3D space.
Definition: qvector3d.h:60
double qreal
Definition: qglobal.h:1193
static int qRegisterGuiGetInterpolator()
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static QQuaternion slerp(const QQuaternion &q1, const QQuaternion &q2, qreal t)
Interpolates along the shortest spherical path between the rotational positions q1 and q2...
The QVector4D class represents a vector or vertex in 4D space.
Definition: qvector4d.h:60
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
#define Q_DESTRUCTOR_FUNCTION(AFUNC)
Definition: qglobal.h:839
Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f, const QColor &t, qreal progress)
#define Q_CONSTRUCTOR_FUNCTION(AFUNC)
Definition: qglobal.h:829
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define Q_INLINE_TEMPLATE
Definition: qglobal.h:1713
The QVector2D class represents a vector or vertex in 2D space.
Definition: qvector2d.h:60
static int qUnregisterGuiGetInterpolator()
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
Definition: qglobal.h:1219
The QQuaternion class represents a quaternion consisting of a vector and scalar.
Definition: qquaternion.h:59
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244