@@ -1,93 +1,97 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 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 "boxplotanimation_p.h" |
|
22 | 22 | #include "boxplotchartitem_p.h" |
|
23 | 23 | #include "boxwhiskersdata_p.h" |
|
24 | 24 | #include "boxwhiskersanimation_p.h" |
|
25 | 25 | |
|
26 | 26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 27 | |
|
28 | 28 | BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item) |
|
29 | 29 | : QObject(item), |
|
30 | 30 | m_item(item) |
|
31 | 31 | { |
|
32 | 32 | } |
|
33 | 33 | |
|
34 | 34 | BoxPlotAnimation::~BoxPlotAnimation() |
|
35 | 35 | { |
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | void BoxPlotAnimation::addBox(BoxWhiskers *box) |
|
39 | 39 | { |
|
40 | 40 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
41 | 41 | if (!animation) { |
|
42 | 42 | animation = new BoxWhiskersAnimation(box, this); |
|
43 | 43 | m_animations.insert(box, animation); |
|
44 | 44 | BoxWhiskersData start; |
|
45 | start.m_lowerExtreme = box->m_data.m_median; | |
|
46 | start.m_lowerQuartile = box->m_data.m_median; | |
|
45 | 47 | start.m_median = box->m_data.m_median; |
|
48 | start.m_upperQuartile = box->m_data.m_median; | |
|
49 | start.m_upperExtreme = box->m_data.m_median; | |
|
46 | 50 | animation->setup(start, box->m_data); |
|
47 | 51 | } else { |
|
48 | 52 | animation->stop(); |
|
49 | 53 | animation->setEndData(box->m_data); |
|
50 | 54 | } |
|
51 | 55 | } |
|
52 | 56 | |
|
53 | 57 | ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box) |
|
54 | 58 | { |
|
55 | 59 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
56 | 60 | if (animation) |
|
57 |
animation->m_ |
|
|
61 | animation->m_changeAnimation = false; | |
|
58 | 62 | |
|
59 | 63 | return animation; |
|
60 | 64 | } |
|
61 | 65 | |
|
62 | 66 | ChartAnimation *BoxPlotAnimation::boxChangeAnimation(BoxWhiskers *box) |
|
63 | 67 | { |
|
64 | 68 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
65 |
animation->m_ |
|
|
69 | animation->m_changeAnimation = true; | |
|
66 | 70 | animation->setEndData(box->m_data); |
|
67 | 71 | |
|
68 | 72 | return animation; |
|
69 | 73 | } |
|
70 | 74 | |
|
71 | 75 | void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box) |
|
72 | 76 | { |
|
73 | 77 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
74 | 78 | animation->setStartData(box->m_data); |
|
75 | 79 | } |
|
76 | 80 | |
|
77 | 81 | void BoxPlotAnimation::stopAll() |
|
78 | 82 | { |
|
79 | 83 | foreach (BoxWhiskers *box, m_animations.keys()) { |
|
80 | 84 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
81 | 85 | animation->stopAndDestroyLater(); |
|
82 | 86 | m_animations.remove(box); |
|
83 | 87 | } |
|
84 | 88 | } |
|
85 | 89 | |
|
86 | 90 | void BoxPlotAnimation::removeBoxAnimation(BoxWhiskers *box) |
|
87 | 91 | { |
|
88 | 92 | m_animations.remove(box); |
|
89 | 93 | } |
|
90 | 94 | |
|
91 | 95 | #include "moc_boxplotanimation_p.cpp" |
|
92 | 96 | |
|
93 | 97 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,110 +1,110 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 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 "boxwhiskersanimation_p.h" |
|
22 | 22 | #include "boxplotanimation_p.h" |
|
23 | 23 | #include "boxplotchartitem_p.h" |
|
24 | 24 | #include "boxwhiskersdata_p.h" |
|
25 | 25 | |
|
26 | 26 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
27 | 27 | Q_DECLARE_METATYPE(QTCOMMERCIALCHART_NAMESPACE::BoxWhiskersData) |
|
28 | 28 | Q_DECLARE_METATYPE(qreal) |
|
29 | 29 | |
|
30 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | 31 | |
|
32 | 32 | BoxWhiskersAnimation::BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation) |
|
33 | 33 | : ChartAnimation(box), |
|
34 | 34 | m_box(box), |
|
35 | 35 | m_boxPlotAnimation(boxPlotAnimation) |
|
36 | 36 | { |
|
37 | 37 | setDuration(ChartAnimationDuration); |
|
38 | 38 | setEasingCurve(QEasingCurve::OutQuart); |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | BoxWhiskersAnimation::~BoxWhiskersAnimation() |
|
42 | 42 | { |
|
43 | 43 | if (m_boxPlotAnimation) |
|
44 | 44 | m_boxPlotAnimation->removeBoxAnimation(m_box); |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | QVariant BoxWhiskersAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const |
|
48 | 48 | { |
|
49 | 49 | BoxWhiskersData startData = qvariant_cast<BoxWhiskersData>(from); |
|
50 | 50 | BoxWhiskersData endData = qvariant_cast<BoxWhiskersData>(to); |
|
51 | 51 | BoxWhiskersData result; |
|
52 | 52 | |
|
53 |
if (m_ |
|
|
53 | if (m_changeAnimation) { | |
|
54 | 54 | result.m_lowerExtreme = startData.m_lowerExtreme + progress * (endData.m_lowerExtreme - startData.m_lowerExtreme); |
|
55 | 55 | result.m_lowerQuartile = startData.m_lowerQuartile + progress * (endData.m_lowerQuartile - startData.m_lowerQuartile); |
|
56 | 56 | result.m_median = startData.m_median + progress * (endData.m_median - startData.m_median); |
|
57 | 57 | result.m_upperQuartile = startData.m_upperQuartile + progress * (endData.m_upperQuartile - startData.m_upperQuartile); |
|
58 | 58 | result.m_upperExtreme = startData.m_upperExtreme + progress * (endData.m_upperExtreme - startData.m_upperExtreme); |
|
59 | 59 | } else { |
|
60 | 60 | result.m_lowerExtreme = endData.m_median + progress * (endData.m_lowerExtreme - endData.m_median); |
|
61 | 61 | result.m_lowerQuartile = endData.m_median + progress * (endData.m_lowerQuartile - endData.m_median); |
|
62 | 62 | result.m_median = endData.m_median; |
|
63 | 63 | result.m_upperQuartile = endData.m_median + progress * (endData.m_upperQuartile - endData.m_median); |
|
64 | 64 | result.m_upperExtreme = endData.m_median + progress * (endData.m_upperExtreme - endData.m_median); |
|
65 | 65 | } |
|
66 | 66 | result.m_index = endData.m_index; |
|
67 | 67 | result.m_boxItems = endData.m_boxItems; |
|
68 | 68 | |
|
69 | 69 | result.m_maxX = endData.m_maxX; |
|
70 | 70 | result.m_minX = endData.m_minX; |
|
71 | 71 | result.m_maxY = endData.m_maxY; |
|
72 | 72 | result.m_minY = endData.m_minY; |
|
73 | 73 | result.m_seriesIndex = endData.m_seriesIndex; |
|
74 | 74 | result.m_seriesCount = endData.m_seriesCount; |
|
75 | 75 | |
|
76 | 76 | return qVariantFromValue(result); |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | 79 | void BoxWhiskersAnimation::updateCurrentValue(const QVariant &value) |
|
80 | 80 | { |
|
81 | 81 | BoxWhiskersData data = qvariant_cast<BoxWhiskersData>(value); |
|
82 | 82 | m_box->setLayout(data); |
|
83 | 83 | } |
|
84 | 84 | |
|
85 | 85 | void BoxWhiskersAnimation::setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData) |
|
86 | 86 | { |
|
87 | 87 | setKeyValueAt(0.0, qVariantFromValue(startData)); |
|
88 | 88 | setKeyValueAt(1.0, qVariantFromValue(endData)); |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | void BoxWhiskersAnimation::setEndData(const BoxWhiskersData &endData) |
|
92 | 92 | { |
|
93 | 93 | if (state() != QAbstractAnimation::Stopped) |
|
94 | 94 | stop(); |
|
95 | 95 | |
|
96 | 96 | setEndValue(qVariantFromValue(endData)); |
|
97 | 97 | } |
|
98 | 98 | |
|
99 | 99 | void BoxWhiskersAnimation::setStartData(const BoxWhiskersData &endData) |
|
100 | 100 | { |
|
101 | 101 | if (state() != QAbstractAnimation::Stopped) |
|
102 | 102 | stop(); |
|
103 | 103 | |
|
104 | 104 | setStartValue(qVariantFromValue(endData)); |
|
105 | 105 | } |
|
106 | 106 | |
|
107 | 107 | #include "moc_boxwhiskersanimation_p.cpp" |
|
108 | 108 | |
|
109 | 109 | QTCOMMERCIALCHART_END_NAMESPACE |
|
110 | 110 |
@@ -1,69 +1,69 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 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 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef BOXWHISKERSANIMATION_P_H |
|
31 | 31 | #define BOXWHISKERSANIMATION_P_H |
|
32 | 32 | |
|
33 | 33 | #include "chartanimation_p.h" |
|
34 | 34 | #include "boxwhiskers_p.h" |
|
35 | 35 | #include "boxwhiskersdata_p.h" |
|
36 | 36 | |
|
37 | 37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
38 | 38 | |
|
39 | 39 | class BoxPlotChartItem; |
|
40 | 40 | class BoxPlotAnimation; |
|
41 | 41 | |
|
42 | 42 | class BoxWhiskersAnimation : public ChartAnimation |
|
43 | 43 | { |
|
44 | 44 | Q_OBJECT |
|
45 | 45 | |
|
46 | 46 | public: |
|
47 | 47 | BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation); |
|
48 | 48 | ~BoxWhiskersAnimation(); |
|
49 | 49 | |
|
50 | 50 | public: // from QVariantAnimation |
|
51 | 51 | virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; |
|
52 | 52 | virtual void updateCurrentValue(const QVariant &value); |
|
53 | 53 | |
|
54 | 54 | void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData); |
|
55 | 55 | void setEndData(const BoxWhiskersData &endData); |
|
56 | 56 | void setStartData(const BoxWhiskersData &endData); |
|
57 | 57 | |
|
58 | 58 | void moveMedianLine(bool move); |
|
59 | 59 | |
|
60 | 60 | protected: |
|
61 | 61 | friend class BoxPlotAnimation; |
|
62 | 62 | BoxWhiskers *m_box; |
|
63 |
bool m_ |
|
|
63 | bool m_changeAnimation; | |
|
64 | 64 | BoxPlotAnimation *m_boxPlotAnimation; |
|
65 | 65 | }; |
|
66 | 66 | |
|
67 | 67 | QTCOMMERCIALCHART_END_NAMESPACE |
|
68 | 68 | |
|
69 | 69 | #endif // BOXWHISKERSANIMATION_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now