@@ -1,91 +1,93 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "boxplotanimation_p.h" |
|
21 | #include "boxplotanimation_p.h" | |
22 | #include "boxplotchartitem_p.h" |
|
22 | #include "boxplotchartitem_p.h" | |
23 | #include "boxwhiskersdata_p.h" |
|
23 | #include "boxwhiskersdata_p.h" | |
24 | #include "boxwhiskersanimation_p.h" |
|
24 | #include "boxwhiskersanimation_p.h" | |
25 |
|
25 | |||
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
27 |
|
27 | |||
28 | BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item) |
|
28 | BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item) | |
29 | : QObject(item), |
|
29 | : QObject(item), | |
30 | m_item(item) |
|
30 | m_item(item) | |
31 | { |
|
31 | { | |
32 | } |
|
32 | } | |
33 |
|
33 | |||
34 | BoxPlotAnimation::~BoxPlotAnimation() |
|
34 | BoxPlotAnimation::~BoxPlotAnimation() | |
35 | { |
|
35 | { | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | void BoxPlotAnimation::addBox(BoxWhiskers *box) |
|
38 | void BoxPlotAnimation::addBox(BoxWhiskers *box) | |
39 | { |
|
39 | { | |
40 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
40 | BoxWhiskersAnimation *animation = m_animations.value(box); | |
41 | if (!animation) { |
|
41 | if (!animation) { | |
42 | animation = new BoxWhiskersAnimation(box, this); |
|
42 | animation = new BoxWhiskersAnimation(box, this); | |
43 | m_animations.insert(box, animation); |
|
43 | m_animations.insert(box, animation); | |
44 | BoxWhiskersData start; |
|
44 | BoxWhiskersData start; | |
45 | start.m_median = box->m_data.m_median; |
|
45 | start.m_median = box->m_data.m_median; | |
46 | animation->setup(start, box->m_data); |
|
46 | animation->setup(start, box->m_data); | |
47 | } else { |
|
47 | } else { | |
48 | animation->stop(); |
|
48 | animation->stop(); | |
49 | animation->setEndData(box->m_data); |
|
49 | animation->setEndData(box->m_data); | |
50 | } |
|
50 | } | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box) |
|
53 | ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box) | |
54 | { |
|
54 | { | |
55 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
55 | BoxWhiskersAnimation *animation = m_animations.value(box); | |
56 | if (animation) |
|
56 | if (animation) | |
57 | animation->m_moveMedianLine = false; |
|
57 | animation->m_moveMedianLine = false; | |
58 |
|
58 | |||
59 | return animation; |
|
59 | return animation; | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | ChartAnimation *BoxPlotAnimation::boxChangeAnimation(BoxWhiskers *box) |
|
62 | ChartAnimation *BoxPlotAnimation::boxChangeAnimation(BoxWhiskers *box) | |
63 | { |
|
63 | { | |
64 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
64 | BoxWhiskersAnimation *animation = m_animations.value(box); | |
65 | animation->m_moveMedianLine = true; |
|
65 | animation->m_moveMedianLine = true; | |
66 | animation->setEndData(box->m_data); |
|
66 | animation->setEndData(box->m_data); | |
67 |
|
67 | |||
68 | return animation; |
|
68 | return animation; | |
69 | } |
|
69 | } | |
70 |
|
70 | |||
71 | void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box) |
|
71 | void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box) | |
72 | { |
|
72 | { | |
73 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
73 | BoxWhiskersAnimation *animation = m_animations.value(box); | |
74 | animation->setStartData(box->m_data); |
|
74 | animation->setStartData(box->m_data); | |
75 | } |
|
75 | } | |
76 |
|
76 | |||
77 | void BoxPlotAnimation::stopAll() |
|
77 | void BoxPlotAnimation::stopAll() | |
78 | { |
|
78 | { | |
79 | foreach (BoxWhiskers *box, m_animations.keys()) { |
|
79 | foreach (BoxWhiskers *box, m_animations.keys()) { | |
80 | BoxWhiskersAnimation *animation = m_animations.value(box); |
|
80 | BoxWhiskersAnimation *animation = m_animations.value(box); | |
81 | animation->stopAndDestroyLater(); |
|
81 | animation->stopAndDestroyLater(); | |
82 | m_animations.remove(box); |
|
82 | m_animations.remove(box); | |
83 | } |
|
83 | } | |
84 | } |
|
84 | } | |
85 |
|
85 | |||
86 | void BoxPlotAnimation::removeBoxAnimation(BoxWhiskers *box) |
|
86 | void BoxPlotAnimation::removeBoxAnimation(BoxWhiskers *box) | |
87 | { |
|
87 | { | |
88 | m_animations.remove(box); |
|
88 | m_animations.remove(box); | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
|
91 | #include "moc_boxplotanimation_p.cpp" | |||
|
92 | ||||
91 | QTCOMMERCIALCHART_END_NAMESPACE |
|
93 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,68 +1,69 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2013 Digia Plc |
|
3 | ** Copyright (C) 2013 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | // W A R N I N G |
|
21 | // W A R N I N G | |
22 | // ------------- |
|
22 | // ------------- | |
23 | // |
|
23 | // | |
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
25 | // implementation detail. This header file may change from version to |
|
25 | // implementation detail. This header file may change from version to | |
26 | // version without notice, or even be removed. |
|
26 | // version without notice, or even be removed. | |
27 | // |
|
27 | // | |
28 | // We mean it. |
|
28 | // We mean it. | |
29 |
|
29 | |||
30 | #ifndef BOXWHISKERSANIMATION_P_H |
|
30 | #ifndef BOXWHISKERSANIMATION_P_H | |
31 | #define BOXWHISKERSANIMATION_P_H |
|
31 | #define BOXWHISKERSANIMATION_P_H | |
32 |
|
32 | |||
33 | #include "chartanimation_p.h" |
|
33 | #include "chartanimation_p.h" | |
34 | #include "boxwhiskers_p.h" |
|
34 | #include "boxwhiskers_p.h" | |
35 | #include "boxwhiskersdata_p.h" |
|
35 | #include "boxwhiskersdata_p.h" | |
36 |
|
36 | |||
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
38 |
|
38 | |||
39 | class BoxPlotChartItem; |
|
39 | class BoxPlotChartItem; | |
|
40 | class BoxPlotAnimation; | |||
40 |
|
41 | |||
41 | class BoxWhiskersAnimation : public ChartAnimation |
|
42 | class BoxWhiskersAnimation : public ChartAnimation | |
42 | { |
|
43 | { | |
43 | Q_OBJECT |
|
44 | Q_OBJECT | |
44 |
|
45 | |||
45 | public: |
|
46 | public: | |
46 | BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation); |
|
47 | BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation); | |
47 | ~BoxWhiskersAnimation(); |
|
48 | ~BoxWhiskersAnimation(); | |
48 |
|
49 | |||
49 | public: // from QVariantAnimation |
|
50 | public: // from QVariantAnimation | |
50 | virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; |
|
51 | virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; | |
51 | virtual void updateCurrentValue(const QVariant &value); |
|
52 | virtual void updateCurrentValue(const QVariant &value); | |
52 |
|
53 | |||
53 | void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData); |
|
54 | void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData); | |
54 | void setEndData(const BoxWhiskersData &endData); |
|
55 | void setEndData(const BoxWhiskersData &endData); | |
55 | void setStartData(const BoxWhiskersData &endData); |
|
56 | void setStartData(const BoxWhiskersData &endData); | |
56 |
|
57 | |||
57 | void moveMedianLine(bool move); |
|
58 | void moveMedianLine(bool move); | |
58 |
|
59 | |||
59 | protected: |
|
60 | protected: | |
60 | friend class BoxPlotAnimation; |
|
61 | friend class BoxPlotAnimation; | |
61 | BoxWhiskers *m_box; |
|
62 | BoxWhiskers *m_box; | |
62 | bool m_moveMedianLine; |
|
63 | bool m_moveMedianLine; | |
63 | BoxPlotAnimation *m_boxPlotAnimation; |
|
64 | BoxPlotAnimation *m_boxPlotAnimation; | |
64 | }; |
|
65 | }; | |
65 |
|
66 | |||
66 | QTCOMMERCIALCHART_END_NAMESPACE |
|
67 | QTCOMMERCIALCHART_END_NAMESPACE | |
67 |
|
68 | |||
68 | #endif // BOXWHISKERSANIMATION_P_H |
|
69 | #endif // BOXWHISKERSANIMATION_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now