@@ -1,79 +1,78 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "percentbaranimation_p.h" |
|
22 | 22 | #include "percentbarchartitem_p.h" |
|
23 | 23 | #include <QTimer> |
|
24 | 24 | |
|
25 | 25 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | PercentBarAnimation::PercentBarAnimation(BarChartItem *item) |
|
30 | 30 | :ChartAnimation(item), |
|
31 | 31 | m_item(item) |
|
32 | 32 | { |
|
33 | 33 | setEasingCurve(QEasingCurve::OutQuart); |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | PercentBarAnimation::~PercentBarAnimation() |
|
37 | 37 | { |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | QVariant PercentBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const |
|
41 | 41 | { |
|
42 | 42 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from); |
|
43 | 43 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to); |
|
44 | 44 | QVector<QRectF> result; |
|
45 | 45 | |
|
46 | 46 | Q_ASSERT(startVector.count() == endVector.count()); |
|
47 | 47 | |
|
48 |
qreal |
|
|
48 | qreal yAxis = m_item->geometry().height() + m_item->geometry().y(); | |
|
49 | 49 | |
|
50 | 50 | for(int i = 0; i < startVector.count(); i++) { |
|
51 | 51 | qreal w = endVector[i].width(); |
|
52 | 52 | qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); |
|
53 | 53 | qreal x = endVector[i].topLeft().x(); |
|
54 |
qreal y = |
|
|
55 | + zeroPos; | |
|
54 | qreal y = yAxis + ((endVector[i].topLeft().y() - yAxis) * progress); | |
|
56 | 55 | |
|
57 | 56 | QRectF value(x,y,w,h); |
|
58 | 57 | result << value; |
|
59 | 58 | } |
|
60 | 59 | return qVariantFromValue(result); |
|
61 | 60 | } |
|
62 | 61 | |
|
63 | 62 | void PercentBarAnimation::updateCurrentValue(const QVariant &value) |
|
64 | 63 | { |
|
65 | 64 | QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value); |
|
66 | 65 | m_item->setLayout(layout); |
|
67 | 66 | } |
|
68 | 67 | |
|
69 | 68 | void PercentBarAnimation::updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout) |
|
70 | 69 | { |
|
71 | 70 | setDuration(ChartAnimationDuration); |
|
72 | 71 | setKeyValueAt(0.0, qVariantFromValue(oldLayout)); |
|
73 | 72 | setKeyValueAt(1.0, qVariantFromValue(newLayout)); |
|
74 | 73 | QTimer::singleShot(0, this, SLOT(start())); |
|
75 | 74 | } |
|
76 | 75 | |
|
77 | 76 | #include "moc_percentbaranimation_p.cpp" |
|
78 | 77 | |
|
79 | 78 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,79 +1,78 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2012 Digia Plc |
|
4 | 4 | ** All rights reserved. |
|
5 | 5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
6 | 6 | ** |
|
7 | 7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
12 | 12 | ** Software or, alternatively, in accordance with the terms contained in |
|
13 | 13 | ** a written agreement between you and Digia. |
|
14 | 14 | ** |
|
15 | 15 | ** If you have questions regarding the use of this file, please use |
|
16 | 16 | ** contact form at http://qt.digia.com |
|
17 | 17 | ** $QT_END_LICENSE$ |
|
18 | 18 | ** |
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "stackedbaranimation_p.h" |
|
22 | 22 | #include "stackedbarchartitem_p.h" |
|
23 | 23 | #include <QTimer> |
|
24 | 24 | |
|
25 | 25 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | 29 | StackedBarAnimation::StackedBarAnimation(BarChartItem *item) |
|
30 | 30 | :ChartAnimation(item), |
|
31 | 31 | m_item(item) |
|
32 | 32 | { |
|
33 | 33 | setEasingCurve(QEasingCurve::OutQuart); |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | StackedBarAnimation::~StackedBarAnimation() |
|
37 | 37 | { |
|
38 | 38 | } |
|
39 | 39 | |
|
40 | 40 | QVariant StackedBarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const |
|
41 | 41 | { |
|
42 | 42 | QVector<QRectF> startVector = qVariantValue<QVector<QRectF> >(from); |
|
43 | 43 | QVector<QRectF> endVector = qVariantValue<QVector<QRectF> >(to); |
|
44 | 44 | QVector<QRectF> result; |
|
45 | 45 | |
|
46 | 46 | Q_ASSERT(startVector.count() == endVector.count()); |
|
47 | 47 | |
|
48 |
qreal |
|
|
48 | qreal yAxis = m_item->geometry().height() + m_item->geometry().y(); | |
|
49 | 49 | |
|
50 | 50 | for(int i = 0; i < startVector.count(); i++) { |
|
51 | 51 | qreal w = endVector[i].width(); |
|
52 | 52 | qreal h = startVector[i].height() + ((endVector[i].height() - startVector[i].height()) * progress); |
|
53 | 53 | qreal x = endVector[i].topLeft().x(); |
|
54 |
qreal y = |
|
|
55 | + zeroPos; | |
|
54 | qreal y = yAxis + ((endVector[i].topLeft().y() - yAxis) * progress); | |
|
56 | 55 | |
|
57 | 56 | QRectF value(x,y,w,h); |
|
58 | 57 | result << value; |
|
59 | 58 | } |
|
60 | 59 | return qVariantFromValue(result); |
|
61 | 60 | } |
|
62 | 61 | |
|
63 | 62 | void StackedBarAnimation::updateCurrentValue(const QVariant &value) |
|
64 | 63 | { |
|
65 | 64 | QVector<QRectF> layout = qVariantValue<QVector<QRectF> >(value); |
|
66 | 65 | m_item->setLayout(layout); |
|
67 | 66 | } |
|
68 | 67 | |
|
69 | 68 | |
|
70 | 69 | void StackedBarAnimation::updateLayout(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout) |
|
71 | 70 | { |
|
72 | 71 | setDuration(ChartAnimationDuration); |
|
73 | 72 | setKeyValueAt(0.0, qVariantFromValue(oldLayout)); |
|
74 | 73 | setKeyValueAt(1.0, qVariantFromValue(newLayout)); |
|
75 | 74 | QTimer::singleShot(0, this, SLOT(start())); |
|
76 | 75 | } |
|
77 | 76 | #include "moc_stackedbaranimation_p.cpp" |
|
78 | 77 | |
|
79 | 78 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now