##// END OF EJS Templates
mingw compiler fix for pie animations
Jani Honkonen -
r619:f477d377754b
parent child
Show More
@@ -1,77 +1,78
1 #include "PieSliceAnimation_p.h"
1 #include "PieSliceAnimation_p.h"
2 #include "piechartitem_p.h"
2 #include "piechartitem_p.h"
3 #include "qpieslice.h"
3 #include "qpieslice.h"
4
4
5 Q_DECLARE_METATYPE(QtCommercialChart::PieSliceLayout)
5 Q_DECLARE_METATYPE(QtCommercialChart::PieSliceLayout)
6
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
8
9 qreal linearPos(qreal start, qreal end, qreal pos)
9 qreal linearPos(qreal start, qreal end, qreal pos)
10 {
10 {
11 return start + ((end - start) * pos);
11 return start + ((end - start) * pos);
12 }
12 }
13
13
14 QPointF linearPos(QPointF start, QPointF end, qreal pos)
14 QPointF linearPos(QPointF start, QPointF end, qreal pos)
15 {
15 {
16 qreal x = linearPos(start.x(), end.x(), pos);
16 qreal x = linearPos(start.x(), end.x(), pos);
17 qreal y = linearPos(start.y(), end.y(), pos);
17 qreal y = linearPos(start.y(), end.y(), pos);
18 return QPointF(x, y);
18 return QPointF(x, y);
19 }
19 }
20
20
21 PieSliceAnimation::PieSliceAnimation(PieChartItem *item)
21 PieSliceAnimation::PieSliceAnimation(PieChartItem *item)
22 :QVariantAnimation(item),
22 :QVariantAnimation(item),
23 m_item(item)
23 m_item(item)
24 {
24 {
25 }
25 }
26
26
27 PieSliceAnimation::~PieSliceAnimation()
27 PieSliceAnimation::~PieSliceAnimation()
28 {
28 {
29 }
29 }
30
30
31 void PieSliceAnimation::setValue(PieSliceLayout& startValue, PieSliceLayout& endValue)
31 void PieSliceAnimation::setValue(PieSliceLayout& startValue, PieSliceLayout& endValue)
32 {
32 {
33 if (state() != QAbstractAnimation::Stopped)
33 if (state() != QAbstractAnimation::Stopped)
34 stop();
34 stop();
35
35
36 setKeyValueAt(0.0, qVariantFromValue(startValue));
36 setKeyValueAt(0.0, qVariantFromValue(startValue));
37 setKeyValueAt(1.0, qVariantFromValue(endValue));
37 setKeyValueAt(1.0, qVariantFromValue(endValue));
38 }
38 }
39
39
40 void PieSliceAnimation::updateValue(PieSliceLayout& endValue)
40 void PieSliceAnimation::updateValue(PieSliceLayout& endValue)
41 {
41 {
42 if (state() != QAbstractAnimation::Stopped)
42 if (state() != QAbstractAnimation::Stopped)
43 stop();
43 stop();
44
44
45 //qDebug() << "PieSliceAnimation::updateValue()" << endValue.m_data->label() << currentSliceValue().m_startAngle << endValue.m_startAngle;
45 //qDebug() << "PieSliceAnimation::updateValue()" << endValue.m_data->label() << currentSliceValue().m_startAngle << endValue.m_startAngle;
46
46
47 setKeyValueAt(0.0, qVariantFromValue(currentSliceValue()));
47 setKeyValueAt(0.0, qVariantFromValue(currentSliceValue()));
48 setKeyValueAt(1.0, qVariantFromValue(endValue));
48 setKeyValueAt(1.0, qVariantFromValue(endValue));
49 }
49 }
50
50
51 PieSliceLayout PieSliceAnimation::currentSliceValue()
51 PieSliceLayout PieSliceAnimation::currentSliceValue()
52 {
52 {
53 return qVariantValue<PieSliceLayout>(currentValue());
53 return qVariantValue<PieSliceLayout>(currentValue());
54 }
54 }
55
55
56 QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
56 QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
57 {
57 {
58 PieSliceLayout startValue = qVariantValue<PieSliceLayout>(start);
58 PieSliceLayout startValue = qVariantValue<PieSliceLayout>(start);
59 PieSliceLayout endValue = qVariantValue<PieSliceLayout>(end);
59 PieSliceLayout endValue = qVariantValue<PieSliceLayout>(end);
60
60
61 PieSliceLayout result;
61 PieSliceLayout result;
62 result = endValue;
62 result = endValue;
63 result.m_center = linearPos(startValue.m_center, endValue.m_center, progress);
63 result.m_center = linearPos(startValue.m_center, endValue.m_center, progress);
64 result.m_radius = linearPos(startValue.m_radius, endValue.m_radius, progress);
64 result.m_radius = linearPos(startValue.m_radius, endValue.m_radius, progress);
65 result.m_startAngle = linearPos(startValue.m_startAngle, endValue.m_startAngle, progress);
65 result.m_startAngle = linearPos(startValue.m_startAngle, endValue.m_startAngle, progress);
66 result.m_angleSpan = linearPos(startValue.m_angleSpan, endValue.m_angleSpan, progress);
66 result.m_angleSpan = linearPos(startValue.m_angleSpan, endValue.m_angleSpan, progress);
67
67
68 return qVariantFromValue(result);
68 return qVariantFromValue(result);
69 }
69 }
70
70
71 void PieSliceAnimation::updateCurrentValue(const QVariant &value)
71 void PieSliceAnimation::updateCurrentValue(const QVariant &value)
72 {
72 {
73 PieSliceLayout layout = qVariantValue<PieSliceLayout>(value);
73 if (state() != QAbstractAnimation::Stopped) //workaround
74 if (state() != QAbstractAnimation::Stopped) //workaround
74 m_item->setLayout(qVariantValue<PieSliceLayout>(value));
75 m_item->setLayout(layout);
75 }
76 }
76
77
77 QTCOMMERCIALCHART_END_NAMESPACE
78 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now