graphicsview/qgraphicsitemanimation.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 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 -
42/*! -
43 \class QGraphicsItemAnimation -
44 \brief The QGraphicsItemAnimation class provides simple animation -
45 support for QGraphicsItem. -
46 \since 4.2 -
47 \ingroup graphicsview-api -
48 \inmodule QtWidgets -
49 \deprecated -
50 -
51 The QGraphicsItemAnimation class animates a QGraphicsItem. You can -
52 schedule changes to the item's transformation matrix at -
53 specified steps. The QGraphicsItemAnimation class has a -
54 current step value. When this value changes the transformations -
55 scheduled at that step are performed. The current step of the -
56 animation is set with the \c setStep() function. -
57 -
58 QGraphicsItemAnimation will do a simple linear interpolation -
59 between the nearest adjacent scheduled changes to calculate the -
60 matrix. For instance, if you set the position of an item at values -
61 0.0 and 1.0, the animation will show the item moving in a straight -
62 line between these positions. The same is true for scaling and -
63 rotation. -
64 -
65 It is usual to use the class with a QTimeLine. The timeline's -
66 \l{QTimeLine::}{valueChanged()} signal is then connected to the -
67 \c setStep() slot. For example, you can set up an item for rotation -
68 by calling \c setRotationAt() for different step values. -
69 The animations timeline is set with the setTimeLine() function. -
70 -
71 An example animation with a timeline follows: -
72 -
73 \snippet timeline/main.cpp 0 -
74 -
75 Note that steps lie between 0.0 and 1.0. It may be necessary to use -
76 \l{QTimeLine::}{setUpdateInterval()}. The default update interval -
77 is 40 ms. A scheduled transformation cannot be removed when set, -
78 so scheduling several transformations of the same kind (e.g., -
79 rotations) at the same step is not recommended. -
80 -
81 \sa QTimeLine, {Graphics View Framework} -
82*/ -
83 -
84#include "qgraphicsitemanimation.h" -
85 -
86#ifndef QT_NO_GRAPHICSVIEW -
87 -
88#include "qgraphicsitem.h" -
89 -
90#include <QtCore/qtimeline.h> -
91#include <QtCore/qpoint.h> -
92#include <QtCore/qpointer.h> -
93#include <QtCore/qpair.h> -
94#include <QtGui/qmatrix.h> -
95 -
96QT_BEGIN_NAMESPACE -
97 -
98class QGraphicsItemAnimationPrivate -
99{ -
100public: -
101 inline QGraphicsItemAnimationPrivate() -
102 : q(0), timeLine(0), item(0), step(0) -
103 { }
executed: }
Execution Count:6
6
104 -
105 QGraphicsItemAnimation *q; -
106 -
107 QPointer<QTimeLine> timeLine; -
108 QGraphicsItem *item; -
109 -
110 QPointF startPos; -
111 QMatrix startMatrix; -
112 -
113 qreal step; -
114 -
115 struct Pair { -
116 Pair(qreal a, qreal b) : step(a), value(b) {}
executed: }
Execution Count:41
41
117 bool operator <(const Pair &other) const -
118 { return step < other.step; }
executed: return step < other.step;
Execution Count:42
42
119 bool operator==(const Pair &other) const -
120 { return step == other.step; }
never executed: return step == other.step;
0
121 qreal step; -
122 qreal value; -
123 }; -
124 QList<Pair> xPosition; -
125 QList<Pair> yPosition; -
126 QList<Pair> rotation; -
127 QList<Pair> verticalScale; -
128 QList<Pair> horizontalScale; -
129 QList<Pair> verticalShear; -
130 QList<Pair> horizontalShear; -
131 QList<Pair> xTranslation; -
132 QList<Pair> yTranslation; -
133 -
134 qreal linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue = 0); -
135 void insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method); -
136}; -
137 -
138qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, QList<Pair> *source, qreal defaultValue) -
139{ -
140 if (source->isEmpty())
evaluated: source->isEmpty()
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:57
57-63
141 return defaultValue;
executed: return defaultValue;
Execution Count:63
63
142 step = qMin<qreal>(qMax<qreal>(step, 0), 1);
executed (the execution status of this line is deduced): step = qMin<qreal>(qMax<qreal>(step, 0), 1);
-
143 -
144 if (step == 1)
evaluated: step == 1
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:50
7-50
145 return source->last().value;
executed: return source->last().value;
Execution Count:7
7
146 -
147 qreal stepBefore = 0;
executed (the execution status of this line is deduced): qreal stepBefore = 0;
-
148 qreal stepAfter = 1;
executed (the execution status of this line is deduced): qreal stepAfter = 1;
-
149 qreal valueBefore = source->first().step == 0 ? source->first().value : defaultValue;
partially evaluated: source->first().step == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
150 qreal valueAfter = source->last().value;
executed (the execution status of this line is deduced): qreal valueAfter = source->last().value;
-
151 -
152 // Find the closest step and value before the given step. -
153 for (int i = 0; i < source->size() && step >= source->at(i).step; ++i) {
partially evaluated: i < source->size()
TRUEFALSE
yes
Evaluation Count:50
no
Evaluation Count:0
partially evaluated: step >= source->at(i).step
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:50
0-50
154 stepBefore = source->at(i).step;
never executed (the execution status of this line is deduced): stepBefore = source->at(i).step;
-
155 valueBefore = source->at(i).value;
never executed (the execution status of this line is deduced): valueBefore = source->at(i).value;
-
156 }
never executed: }
0
157 -
158 // Find the closest step and value after the given step. -
159 for (int j = source->size() - 1; j >= 0 && step < source->at(j).step; --j) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:50
partially evaluated: step < source->at(j).step
TRUEFALSE
yes
Evaluation Count:50
no
Evaluation Count:0
0-50
160 stepAfter = source->at(j).step;
executed (the execution status of this line is deduced): stepAfter = source->at(j).step;
-
161 valueAfter = source->at(j).value;
executed (the execution status of this line is deduced): valueAfter = source->at(j).value;
-
162 }
executed: }
Execution Count:50
50
163 -
164 // Do a simple linear interpolation. -
165 return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore));
executed: return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore));
Execution Count:50
50
166} -
167 -
168void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QList<Pair> *binList, const char* method) -
169{ -
170 if (step < 0.0 || step > 1.0) {
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
evaluated: step > 1.0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:41
0-43
171 qWarning("QGraphicsItemAnimation::%s: invalid step = %f", method, step);
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 171, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::%s: invalid step = %f", method, step);
-
172 return;
executed: return;
Execution Count:2
2
173 } -
174 -
175 Pair pair(step, value);
executed (the execution status of this line is deduced): Pair pair(step, value);
-
176 -
177 QList<Pair>::iterator result = qBinaryFind(binList->begin(), binList->end(), pair);
executed (the execution status of this line is deduced): QList<Pair>::iterator result = qBinaryFind(binList->begin(), binList->end(), pair);
-
178 if (result != binList->end())
evaluated: result != binList->end()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:23
18-23
179 result->value = value;
executed: result->value = value;
Execution Count:18
18
180 else { -
181 *binList << pair;
executed (the execution status of this line is deduced): *binList << pair;
-
182 qSort(binList->begin(), binList->end());
executed (the execution status of this line is deduced): qSort(binList->begin(), binList->end());
-
183 }
executed: }
Execution Count:23
23
184} -
185 -
186/*! -
187 Constructs an animation object with the given \a parent. -
188*/ -
189QGraphicsItemAnimation::QGraphicsItemAnimation(QObject *parent) -
190 : QObject(parent), d(new QGraphicsItemAnimationPrivate) -
191{ -
192 d->q = this;
executed (the execution status of this line is deduced): d->q = this;
-
193}
executed: }
Execution Count:6
6
194 -
195/*! -
196 Destroys the animation object. -
197*/ -
198QGraphicsItemAnimation::~QGraphicsItemAnimation() -
199{ -
200 delete d;
executed (the execution status of this line is deduced): delete d;
-
201}
executed: }
Execution Count:6
6
202 -
203/*! -
204 Returns the item on which the animation object operates. -
205 -
206 \sa setItem() -
207*/ -
208QGraphicsItem *QGraphicsItemAnimation::item() const -
209{ -
210 return d->item;
executed: return d->item;
Execution Count:1
1
211} -
212 -
213/*! -
214 Sets the specified \a item to be used in the animation. -
215 -
216 \sa item() -
217*/ -
218void QGraphicsItemAnimation::setItem(QGraphicsItem *item) -
219{ -
220 d->item = item;
never executed (the execution status of this line is deduced): d->item = item;
-
221 d->startPos = d->item->pos();
never executed (the execution status of this line is deduced): d->startPos = d->item->pos();
-
222}
never executed: }
0
223 -
224/*! -
225 Returns the timeline object used to control the rate at which the animation -
226 occurs. -
227 -
228 \sa setTimeLine() -
229*/ -
230QTimeLine *QGraphicsItemAnimation::timeLine() const -
231{ -
232 return d->timeLine;
executed: return d->timeLine;
Execution Count:7
7
233} -
234 -
235/*! -
236 Sets the timeline object used to control the rate of animation to the \a timeLine -
237 specified. -
238 -
239 \sa timeLine() -
240*/ -
241void QGraphicsItemAnimation::setTimeLine(QTimeLine *timeLine) -
242{ -
243 if (d->timeLine == timeLine)
evaluated: d->timeLine == timeLine
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
244 return;
executed: return;
Execution Count:1
1
245 if (d->timeLine)
evaluated: d->timeLine
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
246 delete d->timeLine;
executed: delete d->timeLine;
Execution Count:1
1
247 if (!timeLine)
evaluated: !timeLine
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
248 return;
executed: return;
Execution Count:1
1
249 d->timeLine = timeLine;
executed (the execution status of this line is deduced): d->timeLine = timeLine;
-
250 connect(timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(setStep(qreal)));
executed (the execution status of this line is deduced): connect(timeLine, "2""valueChanged(qreal)", this, "1""setStep(qreal)");
-
251}
executed: }
Execution Count:2
2
252 -
253/*! -
254 Returns the position of the item at the given \a step value. -
255 -
256 \sa setPosAt() -
257*/ -
258QPointF QGraphicsItemAnimation::posAt(qreal step) const -
259{ -
260 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
evaluated: step > 1.0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:47
0-48
261 qWarning("QGraphicsItemAnimation::posAt: invalid step = %f", step);
executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 261, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::posAt: invalid step = %f", step);
Execution Count:1
1
262 -
263 return QPointF(d->linearValueForStep(step, &d->xPosition, d->startPos.x()),
executed: return QPointF(d->linearValueForStep(step, &d->xPosition, d->startPos.x()), d->linearValueForStep(step, &d->yPosition, d->startPos.y()));
Execution Count:48
48
264 d->linearValueForStep(step, &d->yPosition, d->startPos.y()));
executed: return QPointF(d->linearValueForStep(step, &d->xPosition, d->startPos.x()), d->linearValueForStep(step, &d->yPosition, d->startPos.y()));
Execution Count:48
48
265} -
266 -
267/*! -
268 \fn void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &point) -
269 -
270 Sets the position of the item at the given \a step value to the \a point specified. -
271 -
272 \sa posAt() -
273*/ -
274void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &pos) -
275{ -
276 d->insertUniquePair(step, pos.x(), &d->xPosition, "setPosAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, pos.x(), &d->xPosition, "setPosAt");
-
277 d->insertUniquePair(step, pos.y(), &d->yPosition, "setPosAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, pos.y(), &d->yPosition, "setPosAt");
-
278}
executed: }
Execution Count:7
7
279 -
280/*! -
281 Returns all explicitly inserted positions. -
282 -
283 \sa posAt(), setPosAt() -
284*/ -
285QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const -
286{ -
287 QList<QPair<qreal, QPointF> > list;
executed (the execution status of this line is deduced): QList<QPair<qreal, QPointF> > list;
-
288 for (int i = 0; i < d->xPosition.size(); ++i)
evaluated: i < d->xPosition.size()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:6
6-9
289 list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value));
executed: list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value));
Execution Count:9
9
290 -
291 return list;
executed: return list;
Execution Count:6
6
292} -
293 -
294/*! -
295 Returns the matrix used to transform the item at the specified \a step value. -
296*/ -
297QMatrix QGraphicsItemAnimation::matrixAt(qreal step) const -
298{ -
299 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
300 qWarning("QGraphicsItemAnimation::matrixAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 300, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::matrixAt: invalid step = %f", step);
0
301 -
302 QMatrix matrix;
executed (the execution status of this line is deduced): QMatrix matrix;
-
303 if (!d->rotation.isEmpty())
partially evaluated: !d->rotation.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
304 matrix.rotate(rotationAt(step));
never executed: matrix.rotate(rotationAt(step));
0
305 if (!d->verticalScale.isEmpty())
partially evaluated: !d->verticalScale.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
306 matrix.scale(horizontalScaleAt(step), verticalScaleAt(step));
never executed: matrix.scale(horizontalScaleAt(step), verticalScaleAt(step));
0
307 if (!d->verticalShear.isEmpty())
partially evaluated: !d->verticalShear.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
308 matrix.shear(horizontalShearAt(step), verticalShearAt(step));
never executed: matrix.shear(horizontalShearAt(step), verticalShearAt(step));
0
309 if (!d->xTranslation.isEmpty())
partially evaluated: !d->xTranslation.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
310 matrix.translate(xTranslationAt(step), yTranslationAt(step));
never executed: matrix.translate(xTranslationAt(step), yTranslationAt(step));
0
311 return matrix;
executed: return matrix;
Execution Count:3
3
312} -
313 -
314/*! -
315 Returns the angle at which the item is rotated at the specified \a step value. -
316 -
317 \sa setRotationAt() -
318*/ -
319qreal QGraphicsItemAnimation::rotationAt(qreal step) const -
320{ -
321 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
322 qWarning("QGraphicsItemAnimation::rotationAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 322, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::rotationAt: invalid step = %f", step);
0
323 -
324 return d->linearValueForStep(step, &d->rotation);
executed: return d->linearValueForStep(step, &d->rotation);
Execution Count:14
14
325} -
326 -
327/*! -
328 Sets the rotation of the item at the given \a step value to the \a angle specified. -
329 -
330 \sa rotationAt() -
331*/ -
332void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle) -
333{ -
334 d->insertUniquePair(step, angle, &d->rotation, "setRotationAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, angle, &d->rotation, "setRotationAt");
-
335}
executed: }
Execution Count:5
5
336 -
337/*! -
338 Returns all explicitly inserted rotations. -
339 -
340 \sa rotationAt(), setRotationAt() -
341*/ -
342QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const -
343{ -
344 QList<QPair<qreal, qreal> > list;
executed (the execution status of this line is deduced): QList<QPair<qreal, qreal> > list;
-
345 for (int i = 0; i < d->rotation.size(); ++i)
evaluated: i < d->rotation.size()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
346 list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value);
executed: list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value);
Execution Count:5
5
347 -
348 return list;
executed: return list;
Execution Count:5
5
349} -
350 -
351/*! -
352 Returns the horizontal translation of the item at the specified \a step value. -
353 -
354 \sa setTranslationAt() -
355*/ -
356qreal QGraphicsItemAnimation::xTranslationAt(qreal step) const -
357{ -
358 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
359 qWarning("QGraphicsItemAnimation::xTranslationAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 359, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::xTranslationAt: invalid step = %f", step);
0
360 -
361 return d->linearValueForStep(step, &d->xTranslation);
executed: return d->linearValueForStep(step, &d->xTranslation);
Execution Count:3
3
362} -
363 -
364/*! -
365 Returns the vertical translation of the item at the specified \a step value. -
366 -
367 \sa setTranslationAt() -
368*/ -
369qreal QGraphicsItemAnimation::yTranslationAt(qreal step) const -
370{ -
371 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
372 qWarning("QGraphicsItemAnimation::yTranslationAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 372, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::yTranslationAt: invalid step = %f", step);
0
373 -
374 return d->linearValueForStep(step, &d->yTranslation);
executed: return d->linearValueForStep(step, &d->yTranslation);
Execution Count:3
3
375} -
376 -
377/*! -
378 Sets the translation of the item at the given \a step value using the horizontal -
379 and vertical coordinates specified by \a dx and \a dy. -
380 -
381 \sa xTranslationAt(), yTranslationAt() -
382*/ -
383void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy) -
384{ -
385 d->insertUniquePair(step, dx, &d->xTranslation, "setTranslationAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, dx, &d->xTranslation, "setTranslationAt");
-
386 d->insertUniquePair(step, dy, &d->yTranslation, "setTranslationAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, dy, &d->yTranslation, "setTranslationAt");
-
387}
executed: }
Execution Count:4
4
388 -
389/*! -
390 Returns all explicitly inserted translations. -
391 -
392 \sa xTranslationAt(), yTranslationAt(), setTranslationAt() -
393*/ -
394QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const -
395{ -
396 QList<QPair<qreal, QPointF> > list;
executed (the execution status of this line is deduced): QList<QPair<qreal, QPointF> > list;
-
397 for (int i = 0; i < d->xTranslation.size(); ++i)
evaluated: i < d->xTranslation.size()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
398 list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));
executed: list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value));
Execution Count:5
5
399 -
400 return list;
executed: return list;
Execution Count:5
5
401} -
402 -
403/*! -
404 Returns the vertical scale for the item at the specified \a step value. -
405 -
406 \sa setScaleAt() -
407*/ -
408qreal QGraphicsItemAnimation::verticalScaleAt(qreal step) const -
409{ -
410 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
411 qWarning("QGraphicsItemAnimation::verticalScaleAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 411, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::verticalScaleAt: invalid step = %f", step);
0
412 -
413 return d->linearValueForStep(step, &d->verticalScale, 1);
executed: return d->linearValueForStep(step, &d->verticalScale, 1);
Execution Count:1
1
414} -
415 -
416/*! -
417 Returns the horizontal scale for the item at the specified \a step value. -
418 -
419 \sa setScaleAt() -
420*/ -
421qreal QGraphicsItemAnimation::horizontalScaleAt(qreal step) const -
422{ -
423 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
424 qWarning("QGraphicsItemAnimation::horizontalScaleAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 424, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::horizontalScaleAt: invalid step = %f", step);
0
425 -
426 return d->linearValueForStep(step, &d->horizontalScale, 1);
executed: return d->linearValueForStep(step, &d->horizontalScale, 1);
Execution Count:1
1
427} -
428 -
429/*! -
430 Sets the scale of the item at the given \a step value using the horizontal and -
431 vertical scale factors specified by \a sx and \a sy. -
432 -
433 \sa verticalScaleAt(), horizontalScaleAt() -
434*/ -
435void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy) -
436{ -
437 d->insertUniquePair(step, sx, &d->horizontalScale, "setScaleAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, sx, &d->horizontalScale, "setScaleAt");
-
438 d->insertUniquePair(step, sy, &d->verticalScale, "setScaleAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, sy, &d->verticalScale, "setScaleAt");
-
439}
executed: }
Execution Count:4
4
440 -
441/*! -
442 Returns all explicitly inserted scales. -
443 -
444 \sa verticalScaleAt(), horizontalScaleAt(), setScaleAt() -
445*/ -
446QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const -
447{ -
448 QList<QPair<qreal, QPointF> > list;
executed (the execution status of this line is deduced): QList<QPair<qreal, QPointF> > list;
-
449 for (int i = 0; i < d->horizontalScale.size(); ++i)
evaluated: i < d->horizontalScale.size()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
450 list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value));
executed: list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value));
Execution Count:5
5
451 -
452 return list;
executed: return list;
Execution Count:5
5
453} -
454 -
455/*! -
456 Returns the vertical shear for the item at the specified \a step value. -
457 -
458 \sa setShearAt() -
459*/ -
460qreal QGraphicsItemAnimation::verticalShearAt(qreal step) const -
461{ -
462 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
463 qWarning("QGraphicsItemAnimation::verticalShearAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 463, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::verticalShearAt: invalid step = %f", step);
0
464 -
465 return d->linearValueForStep(step, &d->verticalShear, 0);
executed: return d->linearValueForStep(step, &d->verticalShear, 0);
Execution Count:1
1
466} -
467 -
468/*! -
469 Returns the horizontal shear for the item at the specified \a step value. -
470 -
471 \sa setShearAt() -
472*/ -
473qreal QGraphicsItemAnimation::horizontalShearAt(qreal step) const -
474{ -
475 if (step < 0.0 || step > 1.0)
partially evaluated: step < 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: step > 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
476 qWarning("QGraphicsItemAnimation::horizontalShearAt: invalid step = %f", step);
never executed: QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 476, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::horizontalShearAt: invalid step = %f", step);
0
477 -
478 return d->linearValueForStep(step, &d->horizontalShear, 0);
executed: return d->linearValueForStep(step, &d->horizontalShear, 0);
Execution Count:1
1
479} -
480 -
481/*! -
482 Sets the shear of the item at the given \a step value using the horizontal and -
483 vertical shear factors specified by \a sh and \a sv. -
484 -
485 \sa verticalShearAt(), horizontalShearAt() -
486*/ -
487void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv) -
488{ -
489 d->insertUniquePair(step, sh, &d->horizontalShear, "setShearAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, sh, &d->horizontalShear, "setShearAt");
-
490 d->insertUniquePair(step, sv, &d->verticalShear, "setShearAt");
executed (the execution status of this line is deduced): d->insertUniquePair(step, sv, &d->verticalShear, "setShearAt");
-
491}
executed: }
Execution Count:4
4
492 -
493/*! -
494 Returns all explicitly inserted shears. -
495 -
496 \sa verticalShearAt(), horizontalShearAt(), setShearAt() -
497*/ -
498QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const -
499{ -
500 QList<QPair<qreal, QPointF> > list;
executed (the execution status of this line is deduced): QList<QPair<qreal, QPointF> > list;
-
501 for (int i = 0; i < d->horizontalShear.size(); ++i)
evaluated: i < d->horizontalShear.size()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
502 list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value));
executed: list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value));
Execution Count:5
5
503 -
504 return list;
executed: return list;
Execution Count:5
5
505} -
506 -
507/*! -
508 Clears the scheduled transformations used for the animation, but -
509 retains the item and timeline. -
510*/ -
511void QGraphicsItemAnimation::clear() -
512{ -
513 d->xPosition.clear();
executed (the execution status of this line is deduced): d->xPosition.clear();
-
514 d->yPosition.clear();
executed (the execution status of this line is deduced): d->yPosition.clear();
-
515 d->rotation.clear();
executed (the execution status of this line is deduced): d->rotation.clear();
-
516 d->verticalScale.clear();
executed (the execution status of this line is deduced): d->verticalScale.clear();
-
517 d->horizontalScale.clear();
executed (the execution status of this line is deduced): d->horizontalScale.clear();
-
518 d->verticalShear.clear();
executed (the execution status of this line is deduced): d->verticalShear.clear();
-
519 d->horizontalShear.clear();
executed (the execution status of this line is deduced): d->horizontalShear.clear();
-
520 d->xTranslation.clear();
executed (the execution status of this line is deduced): d->xTranslation.clear();
-
521 d->yTranslation.clear();
executed (the execution status of this line is deduced): d->yTranslation.clear();
-
522}
executed: }
Execution Count:1
1
523 -
524/*! -
525 \fn void QGraphicsItemAnimation::setStep(qreal step) -
526 -
527 Sets the current \a step value for the animation, causing the -
528 transformations scheduled at this step to be performed. -
529*/ -
530void QGraphicsItemAnimation::setStep(qreal x) -
531{ -
532 if (x < 0.0 || x > 1.0) {
never evaluated: x < 0.0
never evaluated: x > 1.0
0
533 qWarning("QGraphicsItemAnimation::setStep: invalid step = %f", x);
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitemanimation.cpp", 533, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::setStep: invalid step = %f", x);
-
534 return;
never executed: return;
0
535 } -
536 -
537 beforeAnimationStep(x);
never executed (the execution status of this line is deduced): beforeAnimationStep(x);
-
538 -
539 d->step = x;
never executed (the execution status of this line is deduced): d->step = x;
-
540 if (d->item) {
never evaluated: d->item
0
541 if (!d->xPosition.isEmpty() || !d->yPosition.isEmpty())
never evaluated: !d->xPosition.isEmpty()
never evaluated: !d->yPosition.isEmpty()
0
542 d->item->setPos(posAt(x));
never executed: d->item->setPos(posAt(x));
0
543 if (!d->rotation.isEmpty()
never evaluated: !d->rotation.isEmpty()
0
544 || !d->verticalScale.isEmpty()
never evaluated: !d->verticalScale.isEmpty()
0
545 || !d->horizontalScale.isEmpty()
never evaluated: !d->horizontalScale.isEmpty()
0
546 || !d->verticalShear.isEmpty()
never evaluated: !d->verticalShear.isEmpty()
0
547 || !d->horizontalShear.isEmpty()
never evaluated: !d->horizontalShear.isEmpty()
0
548 || !d->xTranslation.isEmpty()
never evaluated: !d->xTranslation.isEmpty()
0
549 || !d->yTranslation.isEmpty()) {
never evaluated: !d->yTranslation.isEmpty()
0
550 d->item->setMatrix(d->startMatrix * matrixAt(x));
never executed (the execution status of this line is deduced): d->item->setMatrix(d->startMatrix * matrixAt(x));
-
551 }
never executed: }
0
552 }
never executed: }
0
553 -
554 afterAnimationStep(x);
never executed (the execution status of this line is deduced): afterAnimationStep(x);
-
555}
never executed: }
0
556 -
557/*! -
558 Resets the item to its starting position and transformation. -
559 -
560 \obsolete -
561 -
562 You can call setStep(0) instead. -
563*/ -
564void QGraphicsItemAnimation::reset() -
565{ -
566 if (!d->item)
never evaluated: !d->item
0
567 return;
never executed: return;
0
568 d->startPos = d->item->pos();
never executed (the execution status of this line is deduced): d->startPos = d->item->pos();
-
569 d->startMatrix = d->item->matrix();
never executed (the execution status of this line is deduced): d->startMatrix = d->item->matrix();
-
570}
never executed: }
0
571 -
572/*! -
573 \fn void QGraphicsItemAnimation::beforeAnimationStep(qreal step) -
574 -
575 This method is meant to be overridden by subclassed that needs to -
576 execute additional code before a new step takes place. The -
577 animation \a step is provided for use in cases where the action -
578 depends on its value. -
579*/ -
580void QGraphicsItemAnimation::beforeAnimationStep(qreal step) -
581{ -
582 Q_UNUSED(step);
never executed (the execution status of this line is deduced): (void)step;;
-
583}
never executed: }
0
584 -
585/*! -
586 \fn void QGraphicsItemAnimation::afterAnimationStep(qreal step) -
587 -
588 This method is meant to be overridden in subclasses that need to -
589 execute additional code after a new step has taken place. The -
590 animation \a step is provided for use in cases where the action -
591 depends on its value. -
592*/ -
593void QGraphicsItemAnimation::afterAnimationStep(qreal step) -
594{ -
595 Q_UNUSED(step);
never executed (the execution status of this line is deduced): (void)step;;
-
596}
never executed: }
0
597 -
598QT_END_NAMESPACE -
599 -
600#endif // QT_NO_GRAPHICSVIEW -
601 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial