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