Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicsitemanimation.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | - | |||||||||||||||||||
5 | - | |||||||||||||||||||
6 | - | |||||||||||||||||||
7 | - | |||||||||||||||||||
8 | - | |||||||||||||||||||
9 | - | |||||||||||||||||||
10 | static inline bool check_step_valid(qreal step, const char *method) | - | ||||||||||||||||||
11 | { | - | ||||||||||||||||||
12 | if (!(step >= 0 && step <= 1)) { | - | ||||||||||||||||||
13 | QMessageLogger(__FILE__, 95101, __PRETTY_FUNCTION__).warning("QGraphicsItemAnimation::%s: invalid step = %f", method, step); | - | ||||||||||||||||||
14 | return false; | - | ||||||||||||||||||
15 | } | - | ||||||||||||||||||
16 | return true; | - | ||||||||||||||||||
17 | } | - | ||||||||||||||||||
18 | - | |||||||||||||||||||
19 | class QGraphicsItemAnimationPrivate | - | ||||||||||||||||||
20 | { | - | ||||||||||||||||||
21 | public: | - | ||||||||||||||||||
22 | inline QGraphicsItemAnimationPrivate() | - | ||||||||||||||||||
23 | : q(0), timeLine(0), item(0), step(0) | - | ||||||||||||||||||
24 | { } | - | ||||||||||||||||||
25 | - | |||||||||||||||||||
26 | QGraphicsItemAnimation *q; | - | ||||||||||||||||||
27 | - | |||||||||||||||||||
28 | QPointer<QTimeLine> timeLine; | - | ||||||||||||||||||
29 | QGraphicsItem *item; | - | ||||||||||||||||||
30 | - | |||||||||||||||||||
31 | QPointF startPos; | - | ||||||||||||||||||
32 | QMatrix startMatrix; | - | ||||||||||||||||||
33 | - | |||||||||||||||||||
34 | qreal step; | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | struct Pair { | - | ||||||||||||||||||
37 | bool operator <(const Pair &other) const | - | ||||||||||||||||||
38 | { return step < other.step; } | - | ||||||||||||||||||
39 | bool operator==(const Pair &other) const | - | ||||||||||||||||||
40 | { return step == other.step; } | - | ||||||||||||||||||
41 | qreal step; | - | ||||||||||||||||||
42 | qreal value; | - | ||||||||||||||||||
43 | }; | - | ||||||||||||||||||
44 | QVector<Pair> xPosition; | - | ||||||||||||||||||
45 | QVector<Pair> yPosition; | - | ||||||||||||||||||
46 | QVector<Pair> rotation; | - | ||||||||||||||||||
47 | QVector<Pair> verticalScale; | - | ||||||||||||||||||
48 | QVector<Pair> horizontalScale; | - | ||||||||||||||||||
49 | QVector<Pair> verticalShear; | - | ||||||||||||||||||
50 | QVector<Pair> horizontalShear; | - | ||||||||||||||||||
51 | QVector<Pair> xTranslation; | - | ||||||||||||||||||
52 | QVector<Pair> yTranslation; | - | ||||||||||||||||||
53 | - | |||||||||||||||||||
54 | qreal linearValueForStep(qreal step, const QVector<Pair> *source&source, qreal defaultValue = 0); | - | ||||||||||||||||||
55 | void insertUniquePair(qreal step, qreal value, QVector<Pair> *binList, const char* method); | - | ||||||||||||||||||
56 | }; | - | ||||||||||||||||||
57 | template<> class QTypeInfo<QGraphicsItemAnimationPrivate::Pair > { public: enum { isComplex = (((Q_PRIMITIVE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_PRIMITIVE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_PRIMITIVE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QGraphicsItemAnimationPrivate::Pair)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QGraphicsItemAnimationPrivate::Pair >::value, isDummy = (((Q_PRIMITIVE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QGraphicsItemAnimationPrivate::Pair) }; static inline const char *name() { return "QGraphicsItemAnimationPrivate::Pair"; } }; | - | ||||||||||||||||||
58 | - | |||||||||||||||||||
59 | qreal QGraphicsItemAnimationPrivate::linearValueForStep(qreal step, const QVector<Pair> *source&source, qreal defaultValue) | - | ||||||||||||||||||
60 | { | - | ||||||||||||||||||
61 | if (source->.isEmpty()
| 0 | ||||||||||||||||||
62 | return never executed: defaultValue;return defaultValue; never executed: return defaultValue; | 0 | ||||||||||||||||||
63 | step = qMin<qreal>(qMax<qreal>(step, 0), 1); | - | ||||||||||||||||||
64 | - | |||||||||||||||||||
65 | if (step == 1
| 0 | ||||||||||||||||||
66 | return never executed: source->last.back().value;return source.back().value; never executed: return source.back().value; | 0 | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | qreal stepBefore = 0; | - | ||||||||||||||||||
69 | qreal stepAfter = 1; | - | ||||||||||||||||||
70 | qreal valueBefore = source->first.front().step == 0
| 0 | ||||||||||||||||||
71 | qreal valueAfter = source->last.back().value; | - | ||||||||||||||||||
72 | - | |||||||||||||||||||
73 | - | |||||||||||||||||||
74 | for (int i = 0; i < source->.size()
| 0 | ||||||||||||||||||
75 | stepBefore = source->at([i).].step; | - | ||||||||||||||||||
76 | valueBefore = source->at([i).].value; | - | ||||||||||||||||||
77 | } never executed: end of block | 0 | ||||||||||||||||||
78 | - | |||||||||||||||||||
79 | - | |||||||||||||||||||
80 | for (int ji = source->.size() - 1; ji
| 0 | ||||||||||||||||||
81 | stepAfter = source->at(j).[i].step; | - | ||||||||||||||||||
82 | valueAfter = source->at(j).[i].value; | - | ||||||||||||||||||
83 | } never executed: end of block | 0 | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | - | |||||||||||||||||||
86 | return never executed: valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore));return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore)); never executed: return valueBefore + (valueAfter - valueBefore) * ((step - stepBefore) / (stepAfter - stepBefore)); | 0 | ||||||||||||||||||
87 | } | - | ||||||||||||||||||
88 | - | |||||||||||||||||||
89 | void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QVector<Pair> *binList, const char* method) | - | ||||||||||||||||||
90 | { | - | ||||||||||||||||||
91 | if (!check_step_valid(step, method)) | - | ||||||||||||||||||
92 | return; | - | ||||||||||||||||||
93 | - | |||||||||||||||||||
94 | const Pair pair = { step, value }; | - | ||||||||||||||||||
95 | - | |||||||||||||||||||
96 | const QVector<Pair>::iterator result = std::lower_bound(binList->begin(), binList->end(), pair); | - | ||||||||||||||||||
97 | if (result == binList->end() || pair < *result) | - | ||||||||||||||||||
98 | binList->insert(result, pair); | - | ||||||||||||||||||
99 | else | - | ||||||||||||||||||
100 | result->value = value; | - | ||||||||||||||||||
101 | } | - | ||||||||||||||||||
102 | - | |||||||||||||||||||
103 | - | |||||||||||||||||||
104 | - | |||||||||||||||||||
105 | - | |||||||||||||||||||
106 | QGraphicsItemAnimation::QGraphicsItemAnimation(QObject *parent) | - | ||||||||||||||||||
107 | : QObject(parent), d(new QGraphicsItemAnimationPrivate) | - | ||||||||||||||||||
108 | { | - | ||||||||||||||||||
109 | d->q = this; | - | ||||||||||||||||||
110 | } | - | ||||||||||||||||||
111 | - | |||||||||||||||||||
112 | - | |||||||||||||||||||
113 | - | |||||||||||||||||||
114 | - | |||||||||||||||||||
115 | QGraphicsItemAnimation::~QGraphicsItemAnimation() | - | ||||||||||||||||||
116 | { | - | ||||||||||||||||||
117 | delete d; | - | ||||||||||||||||||
118 | } | - | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | - | |||||||||||||||||||
121 | - | |||||||||||||||||||
122 | - | |||||||||||||||||||
123 | - | |||||||||||||||||||
124 | - | |||||||||||||||||||
125 | QGraphicsItem *QGraphicsItemAnimation::item() const | - | ||||||||||||||||||
126 | { | - | ||||||||||||||||||
127 | return d->item; | - | ||||||||||||||||||
128 | } | - | ||||||||||||||||||
129 | - | |||||||||||||||||||
130 | - | |||||||||||||||||||
131 | - | |||||||||||||||||||
132 | - | |||||||||||||||||||
133 | - | |||||||||||||||||||
134 | - | |||||||||||||||||||
135 | void QGraphicsItemAnimation::setItem(QGraphicsItem *item) | - | ||||||||||||||||||
136 | { | - | ||||||||||||||||||
137 | d->item = item; | - | ||||||||||||||||||
138 | d->startPos = d->item->pos(); | - | ||||||||||||||||||
139 | } | - | ||||||||||||||||||
140 | - | |||||||||||||||||||
141 | - | |||||||||||||||||||
142 | - | |||||||||||||||||||
143 | - | |||||||||||||||||||
144 | - | |||||||||||||||||||
145 | - | |||||||||||||||||||
146 | - | |||||||||||||||||||
147 | QTimeLine *QGraphicsItemAnimation::timeLine() const | - | ||||||||||||||||||
148 | { | - | ||||||||||||||||||
149 | return d->timeLine; | - | ||||||||||||||||||
150 | } | - | ||||||||||||||||||
151 | - | |||||||||||||||||||
152 | - | |||||||||||||||||||
153 | - | |||||||||||||||||||
154 | - | |||||||||||||||||||
155 | - | |||||||||||||||||||
156 | - | |||||||||||||||||||
157 | - | |||||||||||||||||||
158 | void QGraphicsItemAnimation::setTimeLine(QTimeLine *timeLine) | - | ||||||||||||||||||
159 | { | - | ||||||||||||||||||
160 | if (d->timeLine == timeLine) | - | ||||||||||||||||||
161 | return; | - | ||||||||||||||||||
162 | if (d->timeLine) | - | ||||||||||||||||||
163 | delete d->timeLine; | - | ||||||||||||||||||
164 | if (!timeLine) | - | ||||||||||||||||||
165 | return; | - | ||||||||||||||||||
166 | d->timeLine = timeLine; | - | ||||||||||||||||||
167 | connect(timeLine, qFlagLocation("2""valueChanged(qreal)" "\0" __FILE__ ":" "249""255"), this, qFlagLocation("1""setStep(qreal)" "\0" __FILE__ ":" "249""255")); | - | ||||||||||||||||||
168 | } | - | ||||||||||||||||||
169 | - | |||||||||||||||||||
170 | - | |||||||||||||||||||
171 | - | |||||||||||||||||||
172 | - | |||||||||||||||||||
173 | - | |||||||||||||||||||
174 | - | |||||||||||||||||||
175 | QPointF QGraphicsItemAnimation::posAt(qreal step) const | - | ||||||||||||||||||
176 | { | - | ||||||||||||||||||
177 | check_step_valid(step, "posAt"); | - | ||||||||||||||||||
178 | return never executed: QPointF(d->linearValueForStep(step, &dd->xPosition, d->startPos.x()),return QPointF(d->linearValueForStep(step, d->xPosition, d->startPos.x()), 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 | ||||||||||||||||||
179 | d->linearValueForStep(step, &dd->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 | ||||||||||||||||||
180 | } | - | ||||||||||||||||||
181 | void QGraphicsItemAnimation::setPosAt(qreal step, const QPointF &pos) | - | ||||||||||||||||||
182 | { | - | ||||||||||||||||||
183 | d->insertUniquePair(step, pos.x(), &d->xPosition, "setPosAt"); | - | ||||||||||||||||||
184 | d->insertUniquePair(step, pos.y(), &d->yPosition, "setPosAt"); | - | ||||||||||||||||||
185 | } | - | ||||||||||||||||||
186 | - | |||||||||||||||||||
187 | - | |||||||||||||||||||
188 | - | |||||||||||||||||||
189 | - | |||||||||||||||||||
190 | - | |||||||||||||||||||
191 | - | |||||||||||||||||||
192 | QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::posList() const | - | ||||||||||||||||||
193 | { | - | ||||||||||||||||||
194 | QList<QPair<qreal, QPointF> > list; | - | ||||||||||||||||||
195 | const int xPosCount = d->xPosition.size(); | - | ||||||||||||||||||
196 | list.reserve(xPosCount); | - | ||||||||||||||||||
197 | for (int i = 0; i < xPosCount; ++i) | - | ||||||||||||||||||
198 | list << QPair<qreal, QPointF>(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value)); | - | ||||||||||||||||||
199 | - | |||||||||||||||||||
200 | return list; | - | ||||||||||||||||||
201 | } | - | ||||||||||||||||||
202 | - | |||||||||||||||||||
203 | - | |||||||||||||||||||
204 | - | |||||||||||||||||||
205 | - | |||||||||||||||||||
206 | QMatrix QGraphicsItemAnimation::matrixAt(qreal step) const | - | ||||||||||||||||||
207 | { | - | ||||||||||||||||||
208 | check_step_valid(step, "matrixAt"); | - | ||||||||||||||||||
209 | - | |||||||||||||||||||
210 | QMatrix matrix; | - | ||||||||||||||||||
211 | if (!d->rotation.isEmpty()) | - | ||||||||||||||||||
212 | matrix.rotate(rotationAt(step)); | - | ||||||||||||||||||
213 | if (!d->verticalScale.isEmpty()) | - | ||||||||||||||||||
214 | matrix.scale(horizontalScaleAt(step), verticalScaleAt(step)); | - | ||||||||||||||||||
215 | if (!d->verticalShear.isEmpty()) | - | ||||||||||||||||||
216 | matrix.shear(horizontalShearAt(step), verticalShearAt(step)); | - | ||||||||||||||||||
217 | if (!d->xTranslation.isEmpty()) | - | ||||||||||||||||||
218 | matrix.translate(xTranslationAt(step), yTranslationAt(step)); | - | ||||||||||||||||||
219 | return matrix; | - | ||||||||||||||||||
220 | } | - | ||||||||||||||||||
221 | - | |||||||||||||||||||
222 | - | |||||||||||||||||||
223 | - | |||||||||||||||||||
224 | - | |||||||||||||||||||
225 | - | |||||||||||||||||||
226 | - | |||||||||||||||||||
227 | qreal QGraphicsItemAnimation::rotationAt(qreal step) const | - | ||||||||||||||||||
228 | { | - | ||||||||||||||||||
229 | check_step_valid(step, "rotationAt"); | - | ||||||||||||||||||
230 | return never executed: d->linearValueForStep(step, &dd->rotation);return d->linearValueForStep(step, d->rotation); never executed: return d->linearValueForStep(step, d->rotation); | 0 | ||||||||||||||||||
231 | } | - | ||||||||||||||||||
232 | - | |||||||||||||||||||
233 | - | |||||||||||||||||||
234 | - | |||||||||||||||||||
235 | - | |||||||||||||||||||
236 | - | |||||||||||||||||||
237 | - | |||||||||||||||||||
238 | void QGraphicsItemAnimation::setRotationAt(qreal step, qreal angle) | - | ||||||||||||||||||
239 | { | - | ||||||||||||||||||
240 | d->insertUniquePair(step, angle, &d->rotation, "setRotationAt"); | - | ||||||||||||||||||
241 | } | - | ||||||||||||||||||
242 | - | |||||||||||||||||||
243 | - | |||||||||||||||||||
244 | - | |||||||||||||||||||
245 | - | |||||||||||||||||||
246 | - | |||||||||||||||||||
247 | - | |||||||||||||||||||
248 | QList<QPair<qreal, qreal> > QGraphicsItemAnimation::rotationList() const | - | ||||||||||||||||||
249 | { | - | ||||||||||||||||||
250 | QList<QPair<qreal, qreal> > list; | - | ||||||||||||||||||
251 | const int numRotations = d->rotation.size(); | - | ||||||||||||||||||
252 | list.reserve(numRotations); | - | ||||||||||||||||||
253 | for (int i = 0; i < numRotations; ++i) | - | ||||||||||||||||||
254 | list << QPair<qreal, qreal>(d->rotation.at(i).step, d->rotation.at(i).value); | - | ||||||||||||||||||
255 | - | |||||||||||||||||||
256 | return list; | - | ||||||||||||||||||
257 | } | - | ||||||||||||||||||
258 | - | |||||||||||||||||||
259 | - | |||||||||||||||||||
260 | - | |||||||||||||||||||
261 | - | |||||||||||||||||||
262 | - | |||||||||||||||||||
263 | - | |||||||||||||||||||
264 | qreal QGraphicsItemAnimation::xTranslationAt(qreal step) const | - | ||||||||||||||||||
265 | { | - | ||||||||||||||||||
266 | check_step_valid(step, "xTranslationAt"); | - | ||||||||||||||||||
267 | return never executed: d->linearValueForStep(step, &dd->xTranslation);return d->linearValueForStep(step, d->xTranslation); never executed: return d->linearValueForStep(step, d->xTranslation); | 0 | ||||||||||||||||||
268 | } | - | ||||||||||||||||||
269 | - | |||||||||||||||||||
270 | - | |||||||||||||||||||
271 | - | |||||||||||||||||||
272 | - | |||||||||||||||||||
273 | - | |||||||||||||||||||
274 | - | |||||||||||||||||||
275 | qreal QGraphicsItemAnimation::yTranslationAt(qreal step) const | - | ||||||||||||||||||
276 | { | - | ||||||||||||||||||
277 | check_step_valid(step, "yTranslationAt"); | - | ||||||||||||||||||
278 | return never executed: d->linearValueForStep(step, &dd->yTranslation);return d->linearValueForStep(step, d->yTranslation); never executed: return d->linearValueForStep(step, d->yTranslation); | 0 | ||||||||||||||||||
279 | } | - | ||||||||||||||||||
280 | - | |||||||||||||||||||
281 | - | |||||||||||||||||||
282 | - | |||||||||||||||||||
283 | - | |||||||||||||||||||
284 | - | |||||||||||||||||||
285 | - | |||||||||||||||||||
286 | - | |||||||||||||||||||
287 | void QGraphicsItemAnimation::setTranslationAt(qreal step, qreal dx, qreal dy) | - | ||||||||||||||||||
288 | { | - | ||||||||||||||||||
289 | d->insertUniquePair(step, dx, &d->xTranslation, "setTranslationAt"); | - | ||||||||||||||||||
290 | d->insertUniquePair(step, dy, &d->yTranslation, "setTranslationAt"); | - | ||||||||||||||||||
291 | } | - | ||||||||||||||||||
292 | - | |||||||||||||||||||
293 | - | |||||||||||||||||||
294 | - | |||||||||||||||||||
295 | - | |||||||||||||||||||
296 | - | |||||||||||||||||||
297 | - | |||||||||||||||||||
298 | QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::translationList() const | - | ||||||||||||||||||
299 | { | - | ||||||||||||||||||
300 | QList<QPair<qreal, QPointF> > list; | - | ||||||||||||||||||
301 | const int numTranslations = d->xTranslation.size(); | - | ||||||||||||||||||
302 | list.reserve(numTranslations); | - | ||||||||||||||||||
303 | for (int i = 0; i < numTranslations; ++i) | - | ||||||||||||||||||
304 | list << QPair<qreal, QPointF>(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value)); | - | ||||||||||||||||||
305 | - | |||||||||||||||||||
306 | return list; | - | ||||||||||||||||||
307 | } | - | ||||||||||||||||||
308 | - | |||||||||||||||||||
309 | - | |||||||||||||||||||
310 | - | |||||||||||||||||||
311 | - | |||||||||||||||||||
312 | - | |||||||||||||||||||
313 | - | |||||||||||||||||||
314 | qreal QGraphicsItemAnimation::verticalScaleAt(qreal step) const | - | ||||||||||||||||||
315 | { | - | ||||||||||||||||||
316 | check_step_valid(step, "verticalScaleAt"); | - | ||||||||||||||||||
317 | - | |||||||||||||||||||
318 | return never executed: d->linearValueForStep(step, &dd->verticalScale, 1);return d->linearValueForStep(step, d->verticalScale, 1); never executed: return d->linearValueForStep(step, d->verticalScale, 1); | 0 | ||||||||||||||||||
319 | } | - | ||||||||||||||||||
320 | - | |||||||||||||||||||
321 | - | |||||||||||||||||||
322 | - | |||||||||||||||||||
323 | - | |||||||||||||||||||
324 | - | |||||||||||||||||||
325 | - | |||||||||||||||||||
326 | qreal QGraphicsItemAnimation::horizontalScaleAt(qreal step) const | - | ||||||||||||||||||
327 | { | - | ||||||||||||||||||
328 | check_step_valid(step, "horizontalScaleAt"); | - | ||||||||||||||||||
329 | return never executed: d->linearValueForStep(step, &dd->horizontalScale, 1);return d->linearValueForStep(step, d->horizontalScale, 1); never executed: return d->linearValueForStep(step, d->horizontalScale, 1); | 0 | ||||||||||||||||||
330 | } | - | ||||||||||||||||||
331 | - | |||||||||||||||||||
332 | - | |||||||||||||||||||
333 | - | |||||||||||||||||||
334 | - | |||||||||||||||||||
335 | - | |||||||||||||||||||
336 | - | |||||||||||||||||||
337 | - | |||||||||||||||||||
338 | void QGraphicsItemAnimation::setScaleAt(qreal step, qreal sx, qreal sy) | - | ||||||||||||||||||
339 | { | - | ||||||||||||||||||
340 | d->insertUniquePair(step, sx, &d->horizontalScale, "setScaleAt"); | - | ||||||||||||||||||
341 | d->insertUniquePair(step, sy, &d->verticalScale, "setScaleAt"); | - | ||||||||||||||||||
342 | } | - | ||||||||||||||||||
343 | - | |||||||||||||||||||
344 | - | |||||||||||||||||||
345 | - | |||||||||||||||||||
346 | - | |||||||||||||||||||
347 | - | |||||||||||||||||||
348 | - | |||||||||||||||||||
349 | QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::scaleList() const | - | ||||||||||||||||||
350 | { | - | ||||||||||||||||||
351 | QList<QPair<qreal, QPointF> > list; | - | ||||||||||||||||||
352 | const int numScales = d->horizontalScale.size(); | - | ||||||||||||||||||
353 | list.reserve(numScales); | - | ||||||||||||||||||
354 | for (int i = 0; i < numScales; ++i) | - | ||||||||||||||||||
355 | list << QPair<qreal, QPointF>(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value)); | - | ||||||||||||||||||
356 | - | |||||||||||||||||||
357 | return list; | - | ||||||||||||||||||
358 | } | - | ||||||||||||||||||
359 | - | |||||||||||||||||||
360 | - | |||||||||||||||||||
361 | - | |||||||||||||||||||
362 | - | |||||||||||||||||||
363 | - | |||||||||||||||||||
364 | - | |||||||||||||||||||
365 | qreal QGraphicsItemAnimation::verticalShearAt(qreal step) const | - | ||||||||||||||||||
366 | { | - | ||||||||||||||||||
367 | check_step_valid(step, "verticalShearAt"); | - | ||||||||||||||||||
368 | return never executed: d->linearValueForStep(step, &dd->verticalShear, 0);return d->linearValueForStep(step, d->verticalShear, 0); never executed: return d->linearValueForStep(step, d->verticalShear, 0); | 0 | ||||||||||||||||||
369 | } | - | ||||||||||||||||||
370 | - | |||||||||||||||||||
371 | - | |||||||||||||||||||
372 | - | |||||||||||||||||||
373 | - | |||||||||||||||||||
374 | - | |||||||||||||||||||
375 | - | |||||||||||||||||||
376 | qreal QGraphicsItemAnimation::horizontalShearAt(qreal step) const | - | ||||||||||||||||||
377 | { | - | ||||||||||||||||||
378 | check_step_valid(step, "horizontalShearAt"); | - | ||||||||||||||||||
379 | return never executed: d->linearValueForStep(step, &dd->horizontalShear, 0);return d->linearValueForStep(step, d->horizontalShear, 0); never executed: return d->linearValueForStep(step, d->horizontalShear, 0); | 0 | ||||||||||||||||||
380 | } | - | ||||||||||||||||||
381 | - | |||||||||||||||||||
382 | - | |||||||||||||||||||
383 | - | |||||||||||||||||||
384 | - | |||||||||||||||||||
385 | - | |||||||||||||||||||
386 | - | |||||||||||||||||||
387 | - | |||||||||||||||||||
388 | void QGraphicsItemAnimation::setShearAt(qreal step, qreal sh, qreal sv) | - | ||||||||||||||||||
389 | { | - | ||||||||||||||||||
390 | d->insertUniquePair(step, sh, &d->horizontalShear, "setShearAt"); | - | ||||||||||||||||||
391 | d->insertUniquePair(step, sv, &d->verticalShear, "setShearAt"); | - | ||||||||||||||||||
392 | } | - | ||||||||||||||||||
393 | - | |||||||||||||||||||
394 | - | |||||||||||||||||||
395 | - | |||||||||||||||||||
396 | - | |||||||||||||||||||
397 | - | |||||||||||||||||||
398 | - | |||||||||||||||||||
399 | QList<QPair<qreal, QPointF> > QGraphicsItemAnimation::shearList() const | - | ||||||||||||||||||
400 | { | - | ||||||||||||||||||
401 | QList<QPair<qreal, QPointF> > list; | - | ||||||||||||||||||
402 | const int numShears = d->horizontalShear.size(); | - | ||||||||||||||||||
403 | list.reserve(numShears); | - | ||||||||||||||||||
404 | for (int i = 0; i < numShears; ++i) | - | ||||||||||||||||||
405 | list << QPair<qreal, QPointF>(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value)); | - | ||||||||||||||||||
406 | - | |||||||||||||||||||
407 | return list; | - | ||||||||||||||||||
408 | } | - | ||||||||||||||||||
409 | - | |||||||||||||||||||
410 | - | |||||||||||||||||||
411 | - | |||||||||||||||||||
412 | - | |||||||||||||||||||
413 | - | |||||||||||||||||||
414 | void QGraphicsItemAnimation::clear() | - | ||||||||||||||||||
415 | { | - | ||||||||||||||||||
416 | d->xPosition.clear(); | - | ||||||||||||||||||
417 | d->yPosition.clear(); | - | ||||||||||||||||||
418 | d->rotation.clear(); | - | ||||||||||||||||||
419 | d->verticalScale.clear(); | - | ||||||||||||||||||
420 | d->horizontalScale.clear(); | - | ||||||||||||||||||
421 | d->verticalShear.clear(); | - | ||||||||||||||||||
422 | d->horizontalShear.clear(); | - | ||||||||||||||||||
423 | d->xTranslation.clear(); | - | ||||||||||||||||||
424 | d->yTranslation.clear(); | - | ||||||||||||||||||
425 | } | - | ||||||||||||||||||
426 | - | |||||||||||||||||||
427 | - | |||||||||||||||||||
428 | - | |||||||||||||||||||
429 | - | |||||||||||||||||||
430 | - | |||||||||||||||||||
431 | - | |||||||||||||||||||
432 | - | |||||||||||||||||||
433 | void QGraphicsItemAnimation::setStep(qreal step) | - | ||||||||||||||||||
434 | { | - | ||||||||||||||||||
435 | if (!check_step_valid(step, "setStep")) | - | ||||||||||||||||||
436 | return; | - | ||||||||||||||||||
437 | - | |||||||||||||||||||
438 | beforeAnimationStep(step); | - | ||||||||||||||||||
439 | - | |||||||||||||||||||
440 | d->step = step; | - | ||||||||||||||||||
441 | if (d->item) { | - | ||||||||||||||||||
442 | if (!d->xPosition.isEmpty() || !d->yPosition.isEmpty()) | - | ||||||||||||||||||
443 | d->item->setPos(posAt(step)); | - | ||||||||||||||||||
444 | if (!d->rotation.isEmpty() | - | ||||||||||||||||||
445 | || !d->verticalScale.isEmpty() | - | ||||||||||||||||||
446 | || !d->horizontalScale.isEmpty() | - | ||||||||||||||||||
447 | || !d->verticalShear.isEmpty() | - | ||||||||||||||||||
448 | || !d->horizontalShear.isEmpty() | - | ||||||||||||||||||
449 | || !d->xTranslation.isEmpty() | - | ||||||||||||||||||
450 | || !d->yTranslation.isEmpty()) { | - | ||||||||||||||||||
451 | d->item->setMatrix(d->startMatrix * matrixAt(step)); | - | ||||||||||||||||||
452 | } | - | ||||||||||||||||||
453 | } | - | ||||||||||||||||||
454 | - | |||||||||||||||||||
455 | afterAnimationStep(step); | - | ||||||||||||||||||
456 | } | - | ||||||||||||||||||
457 | void QGraphicsItemAnimation::reset() | - | ||||||||||||||||||
458 | { | - | ||||||||||||||||||
459 | if (!d->item) | - | ||||||||||||||||||
460 | return; | - | ||||||||||||||||||
461 | d->startPos = d->item->pos(); | - | ||||||||||||||||||
462 | d->startMatrix = d->item->matrix(); | - | ||||||||||||||||||
463 | } | - | ||||||||||||||||||
464 | void QGraphicsItemAnimation::beforeAnimationStep(qreal step) | - | ||||||||||||||||||
465 | { | - | ||||||||||||||||||
466 | (void)step;; | - | ||||||||||||||||||
467 | } | - | ||||||||||||||||||
468 | void QGraphicsItemAnimation::afterAnimationStep(qreal step) | - | ||||||||||||||||||
469 | { | - | ||||||||||||||||||
470 | (void)step;; | - | ||||||||||||||||||
471 | } | - | ||||||||||||||||||
472 | - | |||||||||||||||||||
473 | - | |||||||||||||||||||
474 | - | |||||||||||||||||||
Switch to Source code | Preprocessed file |