##// END OF EJS Templates
Removed few unnecessary include from animation classes
Marek Rosa -
r2317:e05e191bbd8a
parent child
Show More
@@ -1,141 +1,138
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 "axisanimation_p.h"
21 #include "axisanimation_p.h"
22 #include "chartaxis_p.h"
22 #include "chartaxis_p.h"
23 #include "chartpresenter_p.h"
24 #include <QTimer>
25 #include <QDebug>
26
23
27 Q_DECLARE_METATYPE(QVector<qreal>)
24 Q_DECLARE_METATYPE(QVector<qreal>)
28
25
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
27
31
28
32 AxisAnimation::AxisAnimation(ChartAxis *axis)
29 AxisAnimation::AxisAnimation(ChartAxis *axis)
33 : ChartAnimation(axis),
30 : ChartAnimation(axis),
34 m_axis(axis),
31 m_axis(axis),
35 m_type(DefaultAnimation)
32 m_type(DefaultAnimation)
36 {
33 {
37 setDuration(ChartAnimationDuration);
34 setDuration(ChartAnimationDuration);
38 setEasingCurve(QEasingCurve::OutQuart);
35 setEasingCurve(QEasingCurve::OutQuart);
39 }
36 }
40
37
41 AxisAnimation::~AxisAnimation()
38 AxisAnimation::~AxisAnimation()
42 {
39 {
43 }
40 }
44
41
45 void AxisAnimation::setAnimationType(Animation type)
42 void AxisAnimation::setAnimationType(Animation type)
46 {
43 {
47 if (state() != QAbstractAnimation::Stopped)
44 if (state() != QAbstractAnimation::Stopped)
48 stop();
45 stop();
49 m_type = type;
46 m_type = type;
50 }
47 }
51
48
52 void AxisAnimation::setAnimationPoint(const QPointF &point)
49 void AxisAnimation::setAnimationPoint(const QPointF &point)
53 {
50 {
54 if (state() != QAbstractAnimation::Stopped)
51 if (state() != QAbstractAnimation::Stopped)
55 stop();
52 stop();
56 m_point = point;
53 m_point = point;
57 }
54 }
58
55
59 void AxisAnimation::setValues(QVector<qreal> &oldLayout, QVector<qreal> &newLayout)
56 void AxisAnimation::setValues(QVector<qreal> &oldLayout, QVector<qreal> &newLayout)
60 {
57 {
61 if (state() != QAbstractAnimation::Stopped) stop();
58 if (state() != QAbstractAnimation::Stopped) stop();
62
59
63 if (newLayout.count() == 0)
60 if (newLayout.count() == 0)
64 return;
61 return;
65
62
66 switch (m_type) {
63 switch (m_type) {
67 case ZoomOutAnimation: {
64 case ZoomOutAnimation: {
68 QRectF rect = m_axis->gridGeometry();
65 QRectF rect = m_axis->gridGeometry();
69 oldLayout.resize(newLayout.count());
66 oldLayout.resize(newLayout.count());
70
67
71 for (int i = 0, j = oldLayout.count() - 1; i < (oldLayout.count() + 1) / 2; ++i, --j) {
68 for (int i = 0, j = oldLayout.count() - 1; i < (oldLayout.count() + 1) / 2; ++i, --j) {
72 oldLayout[i] = m_axis->orientation() == Qt::Horizontal ? rect.left() : rect.bottom();
69 oldLayout[i] = m_axis->orientation() == Qt::Horizontal ? rect.left() : rect.bottom();
73 oldLayout[j] = m_axis->orientation() == Qt::Horizontal ? rect.right() : rect.top();
70 oldLayout[j] = m_axis->orientation() == Qt::Horizontal ? rect.right() : rect.top();
74 }
71 }
75 }
72 }
76 break;
73 break;
77 case ZoomInAnimation: {
74 case ZoomInAnimation: {
78 int index = qMin(oldLayout.count() * (m_axis->orientation() == Qt::Horizontal ? m_point.x() : (1 - m_point.y())), newLayout.count() - (qreal)1.0);
75 int index = qMin(oldLayout.count() * (m_axis->orientation() == Qt::Horizontal ? m_point.x() : (1 - m_point.y())), newLayout.count() - (qreal)1.0);
79 oldLayout.resize(newLayout.count());
76 oldLayout.resize(newLayout.count());
80
77
81 for (int i = 0; i < oldLayout.count(); i++)
78 for (int i = 0; i < oldLayout.count(); i++)
82 oldLayout[i] = oldLayout[index];
79 oldLayout[i] = oldLayout[index];
83 }
80 }
84 break;
81 break;
85 case MoveForwardAnimation: {
82 case MoveForwardAnimation: {
86 oldLayout.resize(newLayout.count());
83 oldLayout.resize(newLayout.count());
87
84
88 for (int i = 0, j = i + 1; i < oldLayout.count() - 1; ++i, ++j)
85 for (int i = 0, j = i + 1; i < oldLayout.count() - 1; ++i, ++j)
89 oldLayout[i] = oldLayout[j];
86 oldLayout[i] = oldLayout[j];
90 }
87 }
91 break;
88 break;
92 case MoveBackwordAnimation: {
89 case MoveBackwordAnimation: {
93 oldLayout.resize(newLayout.count());
90 oldLayout.resize(newLayout.count());
94
91
95 for (int i = oldLayout.count() - 1, j = i - 1; i > 0; --i, --j)
92 for (int i = oldLayout.count() - 1, j = i - 1; i > 0; --i, --j)
96 oldLayout[i] = oldLayout[j];
93 oldLayout[i] = oldLayout[j];
97 }
94 }
98 break;
95 break;
99 default: {
96 default: {
100 oldLayout.resize(newLayout.count());
97 oldLayout.resize(newLayout.count());
101 QRectF rect = m_axis->gridGeometry();
98 QRectF rect = m_axis->gridGeometry();
102 for (int i = 0, j = oldLayout.count() - 1; i < oldLayout.count(); ++i, --j)
99 for (int i = 0, j = oldLayout.count() - 1; i < oldLayout.count(); ++i, --j)
103 oldLayout[i] = m_axis->orientation() == Qt::Horizontal ? rect.left() : rect.top();
100 oldLayout[i] = m_axis->orientation() == Qt::Horizontal ? rect.left() : rect.top();
104 }
101 }
105 break;
102 break;
106 }
103 }
107
104
108 QVariantAnimation::KeyValues value;
105 QVariantAnimation::KeyValues value;
109 setKeyValues(value); //workaround for wrong interpolation call
106 setKeyValues(value); //workaround for wrong interpolation call
110 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
107 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
111 setKeyValueAt(1.0, qVariantFromValue(newLayout));
108 setKeyValueAt(1.0, qVariantFromValue(newLayout));
112 }
109 }
113
110
114 QVariant AxisAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
111 QVariant AxisAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
115 {
112 {
116 QVector<qreal> startVector = qvariant_cast<QVector<qreal> >(start);
113 QVector<qreal> startVector = qvariant_cast<QVector<qreal> >(start);
117 QVector<qreal> endVecotr = qvariant_cast<QVector<qreal> >(end);
114 QVector<qreal> endVecotr = qvariant_cast<QVector<qreal> >(end);
118 QVector<qreal> result;
115 QVector<qreal> result;
119
116
120 Q_ASSERT(startVector.count() == endVecotr.count()) ;
117 Q_ASSERT(startVector.count() == endVecotr.count()) ;
121
118
122 for (int i = 0; i < startVector.count(); i++) {
119 for (int i = 0; i < startVector.count(); i++) {
123 qreal value = startVector[i] + ((endVecotr[i] - startVector[i]) * progress); //qBound(0.0, progress, 1.0));
120 qreal value = startVector[i] + ((endVecotr[i] - startVector[i]) * progress); //qBound(0.0, progress, 1.0));
124 result << value;
121 result << value;
125 }
122 }
126 return qVariantFromValue(result);
123 return qVariantFromValue(result);
127 }
124 }
128
125
129
126
130 void AxisAnimation::updateCurrentValue(const QVariant &value)
127 void AxisAnimation::updateCurrentValue(const QVariant &value)
131 {
128 {
132 if (state() != QAbstractAnimation::Stopped) { //workaround
129 if (state() != QAbstractAnimation::Stopped) { //workaround
133 QVector<qreal> vector = qvariant_cast<QVector<qreal> >(value);
130 QVector<qreal> vector = qvariant_cast<QVector<qreal> >(value);
134 Q_ASSERT(vector.count() != 0);
131 Q_ASSERT(vector.count() != 0);
135 m_axis->setLayout(vector);
132 m_axis->setLayout(vector);
136 m_axis->updateGeometry();
133 m_axis->updateGeometry();
137 }
134 }
138
135
139 }
136 }
140
137
141 QTCOMMERCIALCHART_END_NAMESPACE
138 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,80 +1,79
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 "baranimation_p.h"
21 #include "baranimation_p.h"
22 #include "abstractbarchartitem_p.h"
22 #include "abstractbarchartitem_p.h"
23 #include <QTimer>
24
23
25 Q_DECLARE_METATYPE(QVector<QRectF>)
24 Q_DECLARE_METATYPE(QVector<QRectF>)
26
25
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
27
29 BarAnimation::BarAnimation(AbstractBarChartItem *item)
28 BarAnimation::BarAnimation(AbstractBarChartItem *item)
30 : ChartAnimation(item),
29 : ChartAnimation(item),
31 m_item(item)
30 m_item(item)
32 {
31 {
33 setDuration(ChartAnimationDuration);
32 setDuration(ChartAnimationDuration);
34 setEasingCurve(QEasingCurve::OutQuart);
33 setEasingCurve(QEasingCurve::OutQuart);
35 }
34 }
36
35
37 BarAnimation::~BarAnimation()
36 BarAnimation::~BarAnimation()
38 {
37 {
39 }
38 }
40
39
41 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
40 QVariant BarAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
42 {
41 {
43 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
42 QVector<QRectF> startVector = qvariant_cast<QVector<QRectF> >(from);
44 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
43 QVector<QRectF> endVector = qvariant_cast<QVector<QRectF> >(to);
45 QVector<QRectF> result;
44 QVector<QRectF> result;
46
45
47 Q_ASSERT(startVector.count() == endVector.count());
46 Q_ASSERT(startVector.count() == endVector.count());
48
47
49 for (int i = 0; i < startVector.count(); i++) {
48 for (int i = 0; i < startVector.count(); i++) {
50 QRectF start = startVector[i].normalized();
49 QRectF start = startVector[i].normalized();
51 QRectF end = endVector[i].normalized();
50 QRectF end = endVector[i].normalized();
52 qreal x1 = start.left() + progress * (end.left() - start.left());
51 qreal x1 = start.left() + progress * (end.left() - start.left());
53 qreal x2 = start.right() + progress * (end.right() - start.right());
52 qreal x2 = start.right() + progress * (end.right() - start.right());
54 qreal y1 = start.top() + progress * (end.top() - start.top());
53 qreal y1 = start.top() + progress * (end.top() - start.top());
55 qreal y2 = start.bottom() + progress * (end.bottom() - start.bottom());
54 qreal y2 = start.bottom() + progress * (end.bottom() - start.bottom());
56
55
57 QRectF value(QPointF(x1, y1), QPointF(x2, y2));
56 QRectF value(QPointF(x1, y1), QPointF(x2, y2));
58 result << value.normalized();
57 result << value.normalized();
59 }
58 }
60 return qVariantFromValue(result);
59 return qVariantFromValue(result);
61 }
60 }
62
61
63 void BarAnimation::updateCurrentValue(const QVariant &value)
62 void BarAnimation::updateCurrentValue(const QVariant &value)
64 {
63 {
65 QVector<QRectF> layout = qvariant_cast<QVector<QRectF> >(value);
64 QVector<QRectF> layout = qvariant_cast<QVector<QRectF> >(value);
66 m_item->setLayout(layout);
65 m_item->setLayout(layout);
67 }
66 }
68
67
69 void BarAnimation::setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
68 void BarAnimation::setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout)
70 {
69 {
71 QVariantAnimation::KeyValues value;
70 QVariantAnimation::KeyValues value;
72 setKeyValues(value); //workaround for wrong interpolation call
71 setKeyValues(value); //workaround for wrong interpolation call
73 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
72 setKeyValueAt(0.0, qVariantFromValue(oldLayout));
74 setKeyValueAt(1.0, qVariantFromValue(newLayout));
73 setKeyValueAt(1.0, qVariantFromValue(newLayout));
75 }
74 }
76
75
77 #include "moc_baranimation_p.cpp"
76 #include "moc_baranimation_p.cpp"
78
77
79 QTCOMMERCIALCHART_END_NAMESPACE
78 QTCOMMERCIALCHART_END_NAMESPACE
80
79
@@ -1,59 +1,59
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 ABSTRACTBARANIMATION_P_H
30 #ifndef BARANIMATION_P_H
31 #define ABSTRACTBARANIMATION_P_H
31 #define BARANIMATION_P_H
32
32
33 #include "chartanimation_p.h"
33 #include "chartanimation_p.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class AbstractBarChartItem;
37 class AbstractBarChartItem;
38
38
39 class BarAnimation : public ChartAnimation
39 class BarAnimation : public ChartAnimation
40 {
40 {
41 Q_OBJECT
41 Q_OBJECT
42
42
43 public:
43 public:
44 BarAnimation(AbstractBarChartItem *item);
44 BarAnimation(AbstractBarChartItem *item);
45 ~BarAnimation();
45 ~BarAnimation();
46
46
47 public: // from QVariantAnimation
47 public: // from QVariantAnimation
48 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
48 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
49 virtual void updateCurrentValue(const QVariant &value);
49 virtual void updateCurrentValue(const QVariant &value);
50
50
51 void setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
51 void setup(const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
52
52
53 protected:
53 protected:
54 AbstractBarChartItem *m_item;
54 AbstractBarChartItem *m_item;
55 };
55 };
56
56
57 QTCOMMERCIALCHART_END_NAMESPACE
57 QTCOMMERCIALCHART_END_NAMESPACE
58
58
59 #endif // ABSTRACTBARANIMATION_P_H
59 #endif // BARANIMATION_P_H
@@ -1,107 +1,106
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 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 "pieanimation_p.h"
21 #include "pieanimation_p.h"
22 #include "piesliceanimation_p.h"
22 #include "piesliceanimation_p.h"
23 #include "piechartitem_p.h"
23 #include "piechartitem_p.h"
24 #include <QTimer>
25
24
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
26
28 PieAnimation::PieAnimation(PieChartItem *item)
27 PieAnimation::PieAnimation(PieChartItem *item)
29 : ChartAnimation(item),
28 : ChartAnimation(item),
30 m_item(item)
29 m_item(item)
31 {
30 {
32 }
31 }
33
32
34 PieAnimation::~PieAnimation()
33 PieAnimation::~PieAnimation()
35 {
34 {
36 }
35 }
37
36
38 ChartAnimation *PieAnimation::updateValue(PieSliceItem *sliceItem, const PieSliceData &sliceData)
37 ChartAnimation *PieAnimation::updateValue(PieSliceItem *sliceItem, const PieSliceData &sliceData)
39 {
38 {
40 PieSliceAnimation *animation = m_animations.value(sliceItem);
39 PieSliceAnimation *animation = m_animations.value(sliceItem);
41 Q_ASSERT(animation);
40 Q_ASSERT(animation);
42 animation->stop();
41 animation->stop();
43
42
44 animation->updateValue(sliceData);
43 animation->updateValue(sliceData);
45 animation->setDuration(ChartAnimationDuration);
44 animation->setDuration(ChartAnimationDuration);
46 animation->setEasingCurve(QEasingCurve::OutQuart);
45 animation->setEasingCurve(QEasingCurve::OutQuart);
47
46
48 return animation;
47 return animation;
49 }
48 }
50
49
51 ChartAnimation *PieAnimation::addSlice(PieSliceItem *sliceItem, const PieSliceData &sliceData, bool startupAnimation)
50 ChartAnimation *PieAnimation::addSlice(PieSliceItem *sliceItem, const PieSliceData &sliceData, bool startupAnimation)
52 {
51 {
53 PieSliceAnimation *animation = new PieSliceAnimation(sliceItem);
52 PieSliceAnimation *animation = new PieSliceAnimation(sliceItem);
54 m_animations.insert(sliceItem, animation);
53 m_animations.insert(sliceItem, animation);
55
54
56 PieSliceData startValue = sliceData;
55 PieSliceData startValue = sliceData;
57 startValue.m_radius = 0;
56 startValue.m_radius = 0;
58 if (startupAnimation)
57 if (startupAnimation)
59 startValue.m_startAngle = 0;
58 startValue.m_startAngle = 0;
60 else
59 else
61 startValue.m_startAngle = sliceData.m_startAngle + (sliceData.m_angleSpan / 2);
60 startValue.m_startAngle = sliceData.m_startAngle + (sliceData.m_angleSpan / 2);
62 startValue.m_angleSpan = 0;
61 startValue.m_angleSpan = 0;
63
62
64 if (sliceData.m_holeRadius > 0)
63 if (sliceData.m_holeRadius > 0)
65 startValue.m_radius = sliceData.m_holeRadius;
64 startValue.m_radius = sliceData.m_holeRadius;
66
65
67 animation->setValue(startValue, sliceData);
66 animation->setValue(startValue, sliceData);
68 animation->setDuration(ChartAnimationDuration);
67 animation->setDuration(ChartAnimationDuration);
69 animation->setEasingCurve(QEasingCurve::OutQuart);
68 animation->setEasingCurve(QEasingCurve::OutQuart);
70
69
71 return animation;
70 return animation;
72 }
71 }
73
72
74 ChartAnimation *PieAnimation::removeSlice(PieSliceItem *sliceItem)
73 ChartAnimation *PieAnimation::removeSlice(PieSliceItem *sliceItem)
75 {
74 {
76 PieSliceAnimation *animation = m_animations.value(sliceItem);
75 PieSliceAnimation *animation = m_animations.value(sliceItem);
77 Q_ASSERT(animation);
76 Q_ASSERT(animation);
78 animation->stop();
77 animation->stop();
79
78
80 PieSliceData endValue = animation->currentSliceValue();
79 PieSliceData endValue = animation->currentSliceValue();
81 if (endValue.m_holeRadius > 0)
80 if (endValue.m_holeRadius > 0)
82 endValue.m_radius = endValue.m_holeRadius;
81 endValue.m_radius = endValue.m_holeRadius;
83 else
82 else
84 endValue.m_radius = 0;
83 endValue.m_radius = 0;
85 endValue.m_startAngle = endValue.m_startAngle + endValue.m_angleSpan;
84 endValue.m_startAngle = endValue.m_startAngle + endValue.m_angleSpan;
86 endValue.m_angleSpan = 0;
85 endValue.m_angleSpan = 0;
87 endValue.m_isLabelVisible = false;
86 endValue.m_isLabelVisible = false;
88
87
89 animation->updateValue(endValue);
88 animation->updateValue(endValue);
90 animation->setDuration(ChartAnimationDuration);
89 animation->setDuration(ChartAnimationDuration);
91 animation->setEasingCurve(QEasingCurve::OutQuart);
90 animation->setEasingCurve(QEasingCurve::OutQuart);
92
91
93 // PieSliceItem is the parent of PieSliceAnimation so the animation will be deleted as well..
92 // PieSliceItem is the parent of PieSliceAnimation so the animation will be deleted as well..
94 connect(animation, SIGNAL(finished()), sliceItem, SLOT(deleteLater()));
93 connect(animation, SIGNAL(finished()), sliceItem, SLOT(deleteLater()));
95 m_animations.remove(sliceItem);
94 m_animations.remove(sliceItem);
96
95
97 return animation;
96 return animation;
98 }
97 }
99
98
100 void PieAnimation::updateCurrentValue(const QVariant &)
99 void PieAnimation::updateCurrentValue(const QVariant &)
101 {
100 {
102 // nothing to do...
101 // nothing to do...
103 }
102 }
104
103
105 #include "moc_pieanimation_p.cpp"
104 #include "moc_pieanimation_p.cpp"
106
105
107 QTCOMMERCIALCHART_END_NAMESPACE
106 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now