@@ -1,91 +1,93 | |||
|
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 | 45 | start.m_median = box->m_data.m_median; |
|
46 | 46 | animation->setup(start, box->m_data); |
|
47 | 47 | } else { |
|
48 | 48 | animation->stop(); |
|
49 | 49 | animation->setEndData(box->m_data); |
|
50 | 50 | } |
|
51 | 51 | } |
|
52 | 52 | |
|
53 | 53 | ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box) |
|
54 | 54 | { |
|
55 | 55 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
56 | 56 | if (animation) |
|
57 | 57 | animation->m_moveMedianLine = false; |
|
58 | 58 | |
|
59 | 59 | return animation; |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | ChartAnimation *BoxPlotAnimation::boxChangeAnimation(BoxWhiskers *box) |
|
63 | 63 | { |
|
64 | 64 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
65 | 65 | animation->m_moveMedianLine = true; |
|
66 | 66 | animation->setEndData(box->m_data); |
|
67 | 67 | |
|
68 | 68 | return animation; |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box) |
|
72 | 72 | { |
|
73 | 73 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
74 | 74 | animation->setStartData(box->m_data); |
|
75 | 75 | } |
|
76 | 76 | |
|
77 | 77 | void BoxPlotAnimation::stopAll() |
|
78 | 78 | { |
|
79 | 79 | foreach (BoxWhiskers *box, m_animations.keys()) { |
|
80 | 80 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
81 | 81 | animation->stopAndDestroyLater(); |
|
82 | 82 | m_animations.remove(box); |
|
83 | 83 | } |
|
84 | 84 | } |
|
85 | 85 | |
|
86 | 86 | void BoxPlotAnimation::removeBoxAnimation(BoxWhiskers *box) |
|
87 | 87 | { |
|
88 | 88 | m_animations.remove(box); |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | #include "moc_boxplotanimation_p.cpp" | |
|
92 | ||
|
91 | 93 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,68 +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 | class BoxPlotAnimation; | |
|
40 | 41 | |
|
41 | 42 | class BoxWhiskersAnimation : public ChartAnimation |
|
42 | 43 | { |
|
43 | 44 | Q_OBJECT |
|
44 | 45 | |
|
45 | 46 | public: |
|
46 | 47 | BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation); |
|
47 | 48 | ~BoxWhiskersAnimation(); |
|
48 | 49 | |
|
49 | 50 | public: // from QVariantAnimation |
|
50 | 51 | virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; |
|
51 | 52 | virtual void updateCurrentValue(const QVariant &value); |
|
52 | 53 | |
|
53 | 54 | void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData); |
|
54 | 55 | void setEndData(const BoxWhiskersData &endData); |
|
55 | 56 | void setStartData(const BoxWhiskersData &endData); |
|
56 | 57 | |
|
57 | 58 | void moveMedianLine(bool move); |
|
58 | 59 | |
|
59 | 60 | protected: |
|
60 | 61 | friend class BoxPlotAnimation; |
|
61 | 62 | BoxWhiskers *m_box; |
|
62 | 63 | bool m_moveMedianLine; |
|
63 | 64 | BoxPlotAnimation *m_boxPlotAnimation; |
|
64 | 65 | }; |
|
65 | 66 | |
|
66 | 67 | QTCOMMERCIALCHART_END_NAMESPACE |
|
67 | 68 | |
|
68 | 69 | #endif // BOXWHISKERSANIMATION_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now