@@ -0,0 +1,63 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2013 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "boxplotanimation_p.h" | |
|
22 | #include "boxplotchartitem_p.h" | |
|
23 | #include "boxwhiskersdata_p.h" | |
|
24 | #include "boxwhiskersanimation_p.h" | |
|
25 | ||
|
26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
27 | ||
|
28 | BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item) | |
|
29 | // : ChartAnimation(item), | |
|
30 | : m_item(item) | |
|
31 | { | |
|
32 | } | |
|
33 | ||
|
34 | //BoxPlotAnimation::BoxPlotAnimation(BoxWhiskers *box) | |
|
35 | // : ChartAnimation(box), | |
|
36 | // m_box(box) | |
|
37 | //{ | |
|
38 | //} | |
|
39 | ||
|
40 | BoxPlotAnimation::~BoxPlotAnimation() | |
|
41 | { | |
|
42 | } | |
|
43 | ||
|
44 | void BoxPlotAnimation::addBox(BoxWhiskers *box) | |
|
45 | { | |
|
46 | BoxWhiskersAnimation *animation = new BoxWhiskersAnimation(box); | |
|
47 | m_animations.insert(box, animation); | |
|
48 | ||
|
49 | BoxWhiskersData start; | |
|
50 | start.m_median = box->m_data.m_median; | |
|
51 | animation->setup(start, box->m_data); | |
|
52 | } | |
|
53 | ||
|
54 | ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box) | |
|
55 | { | |
|
56 | // TODO: Check for missing animation | |
|
57 | return m_animations.value(box); | |
|
58 | } | |
|
59 | ||
|
60 | ||
|
61 | //#include "moc_boxplotanimation_p.cpp" | |
|
62 | ||
|
63 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -0,0 +1,59 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2013 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | #ifndef BOXPLOTANIMATION_P_H | |
|
31 | #define BOXPLOTANIMATION_P_H | |
|
32 | ||
|
33 | #include "chartanimation_p.h" | |
|
34 | #include "boxwhiskers_p.h" | |
|
35 | #include "boxwhiskersdata_p.h" | |
|
36 | #include "boxwhiskersanimation_p.h" | |
|
37 | ||
|
38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
39 | ||
|
40 | class BoxPlotChartItem; | |
|
41 | ||
|
42 | class BoxPlotAnimation /*: public ChartAnimation*/ | |
|
43 | { | |
|
44 | //Q_OBJECT | |
|
45 | public: | |
|
46 | BoxPlotAnimation(BoxPlotChartItem *item); | |
|
47 | ~BoxPlotAnimation(); | |
|
48 | ||
|
49 | void addBox(BoxWhiskers *box); | |
|
50 | ChartAnimation *boxAnimation(BoxWhiskers *box); | |
|
51 | ||
|
52 | protected: | |
|
53 | BoxPlotChartItem *m_item; | |
|
54 | QHash<BoxWhiskers *, BoxWhiskersAnimation *> m_animations; | |
|
55 | }; | |
|
56 | ||
|
57 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
58 | ||
|
59 | #endif // BOXPLOTANIMATION_P_H |
@@ -0,0 +1,106 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2013 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | #include "boxwhiskersanimation_p.h" | |
|
22 | #include "boxplotanimation_p.h" | |
|
23 | #include "boxplotchartitem_p.h" | |
|
24 | #include "boxwhiskersdata_p.h" | |
|
25 | ||
|
26 | Q_DECLARE_METATYPE(QVector<QRectF>) | |
|
27 | Q_DECLARE_METATYPE(QTCOMMERCIALCHART_NAMESPACE::BoxWhiskersData) | |
|
28 | Q_DECLARE_METATYPE(qreal) | |
|
29 | ||
|
30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
31 | ||
|
32 | BoxWhiskersAnimation::BoxWhiskersAnimation(BoxPlotChartItem *item) | |
|
33 | : ChartAnimation(item), | |
|
34 | m_item(item) | |
|
35 | { | |
|
36 | setDuration(ChartAnimationDuration); | |
|
37 | setEasingCurve(QEasingCurve::OutQuart); | |
|
38 | } | |
|
39 | ||
|
40 | BoxWhiskersAnimation::BoxWhiskersAnimation(BoxWhiskers *box) | |
|
41 | : ChartAnimation(box), | |
|
42 | m_box(box) | |
|
43 | { | |
|
44 | setDuration(ChartAnimationDuration); | |
|
45 | setEasingCurve(QEasingCurve::OutQuart); | |
|
46 | } | |
|
47 | ||
|
48 | BoxWhiskersAnimation::~BoxWhiskersAnimation() | |
|
49 | { | |
|
50 | } | |
|
51 | ||
|
52 | QVariant BoxWhiskersAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const | |
|
53 | { | |
|
54 | BoxWhiskersData startData = qvariant_cast<BoxWhiskersData>(from); | |
|
55 | BoxWhiskersData endData = qvariant_cast<BoxWhiskersData>(to); | |
|
56 | BoxWhiskersData result; | |
|
57 | ||
|
58 | if (endData.m_index == 1) { | |
|
59 | //qDebug() << "endData.m_lowerExtreme = " << endData.m_lowerExtreme; | |
|
60 | //qDebug() << "endData.m_median = " << endData.m_median; | |
|
61 | } | |
|
62 | ||
|
63 | result.m_lowerExtreme = endData.m_median + progress * (endData.m_lowerExtreme - endData.m_median); | |
|
64 | result.m_lowerQuartile = endData.m_median + progress * (endData.m_lowerQuartile - endData.m_median); | |
|
65 | result.m_median = endData.m_median; | |
|
66 | result.m_upperQuartile = endData.m_median + progress * (endData.m_upperQuartile - endData.m_median); | |
|
67 | result.m_upperExtreme = endData.m_median + progress * (endData.m_upperExtreme - endData.m_median); | |
|
68 | result.m_index = endData.m_index; | |
|
69 | result.m_boxItems = endData.m_boxItems; | |
|
70 | ||
|
71 | // result.m_lowerExtreme = endData.m_lowerExtreme; | |
|
72 | // result.m_lowerQuartile = endData.m_lowerQuartile; | |
|
73 | // result.m_median = endData.m_median; | |
|
74 | // result.m_upperQuartile = endData.m_upperQuartile; | |
|
75 | // result.m_upperExtreme = endData.m_upperExtreme; | |
|
76 | // result.m_index = endData.m_index; | |
|
77 | // result.m_boxItems = endData.m_boxItems; | |
|
78 | ||
|
79 | result.m_maxX = endData.m_maxX; | |
|
80 | result.m_minX = endData.m_minX; | |
|
81 | result.m_maxY = endData.m_maxY; | |
|
82 | result.m_minY = endData.m_minY; | |
|
83 | //result.m_domainSize = endData.m_domainSize; | |
|
84 | ||
|
85 | return qVariantFromValue(result); | |
|
86 | } | |
|
87 | ||
|
88 | void BoxWhiskersAnimation::updateCurrentValue(const QVariant &value) | |
|
89 | { | |
|
90 | BoxWhiskersData data = qvariant_cast<BoxWhiskersData>(value); | |
|
91 | m_box->setLayout(data); | |
|
92 | } | |
|
93 | ||
|
94 | void BoxWhiskersAnimation::setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData) | |
|
95 | { | |
|
96 | if (endData.m_index == 0) { | |
|
97 | qDebug() << "BoxPlotAnimation::setup m_upperExtreme" << endData.m_upperExtreme; | |
|
98 | } | |
|
99 | setKeyValueAt(0.0, qVariantFromValue(startData)); | |
|
100 | setKeyValueAt(1.0, qVariantFromValue(endData)); | |
|
101 | } | |
|
102 | ||
|
103 | #include "moc_boxwhiskersanimation_p.cpp" | |
|
104 | ||
|
105 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
106 |
@@ -0,0 +1,64 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2013 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
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 | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | #ifndef BOXWHISKERSANIMATION_P_H | |
|
31 | #define BOXWHISKERSANIMATION_P_H | |
|
32 | ||
|
33 | #include "chartanimation_p.h" | |
|
34 | #include "boxwhiskers_p.h" | |
|
35 | #include "boxwhiskersdata_p.h" | |
|
36 | ||
|
37 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
38 | ||
|
39 | class BoxPlotChartItem; | |
|
40 | ||
|
41 | class BoxWhiskersAnimation : public ChartAnimation | |
|
42 | { | |
|
43 | Q_OBJECT | |
|
44 | ||
|
45 | public: | |
|
46 | BoxWhiskersAnimation(BoxPlotChartItem *item); | |
|
47 | BoxWhiskersAnimation(BoxWhiskers *box); | |
|
48 | ~BoxWhiskersAnimation(); | |
|
49 | ||
|
50 | public: // from QVariantAnimation | |
|
51 | virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const; | |
|
52 | virtual void updateCurrentValue(const QVariant &value); | |
|
53 | ||
|
54 | void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData); | |
|
55 | ||
|
56 | protected: | |
|
57 | BoxPlotChartItem *m_item; | |
|
58 | BoxWhiskers *m_box; | |
|
59 | BoxWhiskersData *m_boxData; | |
|
60 | }; | |
|
61 | ||
|
62 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
63 | ||
|
64 | #endif // BOXWHISKERSANIMATION_P_H |
@@ -7,7 +7,9 SOURCES += \ | |||
|
7 | 7 | $$PWD/pieanimation.cpp \ |
|
8 | 8 | $$PWD/piesliceanimation.cpp \ |
|
9 | 9 | $$PWD/splineanimation.cpp \ |
|
10 | $$PWD/baranimation.cpp | |
|
10 | $$PWD/baranimation.cpp \ | |
|
11 | $$PWD/boxplotanimation.cpp \ | |
|
12 | animations/boxwhiskersanimation.cpp | |
|
11 | 13 | |
|
12 | 14 | PRIVATE_HEADERS += \ |
|
13 | 15 | $$PWD/axisanimation_p.h \ |
@@ -16,4 +18,6 PRIVATE_HEADERS += \ | |||
|
16 | 18 | $$PWD/pieanimation_p.h \ |
|
17 | 19 | $$PWD/piesliceanimation_p.h \ |
|
18 | 20 | $$PWD/splineanimation_p.h \ |
|
19 | $$PWD/baranimation_p.h | |
|
21 | $$PWD/baranimation_p.h \ | |
|
22 | $$PWD/boxplotanimation_p.h \ | |
|
23 | $$PWD/boxwhiskersanimation_p.h |
General Comments 0
You need to be logged in to leave comments.
Login now