OpenCoverage

qgraphicsitemanimation.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9