@@ -224,11 +224,11 void ChartAnimator::updateLayout(XYChartItem* item, QVector<QPointF>& oldPoints | |||||
224 | QTimer::singleShot(0,animation,SLOT(start())); |
|
224 | QTimer::singleShot(0,animation,SLOT(start())); | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | void ChartAnimator::addAnimation(PieChartItem* item, QPieSlice *slice, const PieSliceLayout &layout) |
|
227 | void ChartAnimator::addAnimation(PieChartItem* item, QPieSlice *slice, const PieSliceLayout &layout, bool isEmpty) | |
228 | { |
|
228 | { | |
229 | PieAnimation* animation = static_cast<PieAnimation*>(m_animations.value(item)); |
|
229 | PieAnimation* animation = static_cast<PieAnimation*>(m_animations.value(item)); | |
230 | Q_ASSERT(animation); |
|
230 | Q_ASSERT(animation); | |
231 | animation->addSlice(slice, layout); |
|
231 | animation->addSlice(slice, layout, isEmpty); | |
232 | } |
|
232 | } | |
233 |
|
233 | |||
234 | void ChartAnimator::removeAnimation(PieChartItem* item, QPieSlice *slice) |
|
234 | void ChartAnimator::removeAnimation(PieChartItem* item, QPieSlice *slice) |
@@ -35,7 +35,7 public: | |||||
35 | void updateLayout(SplineChartItem* item, QVector<QPointF>& oldPoints , QVector<QPointF>& newPoints, QVector<QPointF>& oldControlPoints, QVector<QPointF>& newContorlPoints,int index); |
|
35 | void updateLayout(SplineChartItem* item, QVector<QPointF>& oldPoints , QVector<QPointF>& newPoints, QVector<QPointF>& oldControlPoints, QVector<QPointF>& newContorlPoints,int index); | |
36 | void applyLayout(AxisItem* item, QVector<qreal>& layout); |
|
36 | void applyLayout(AxisItem* item, QVector<qreal>& layout); | |
37 |
|
37 | |||
38 | void addAnimation(PieChartItem* item, QPieSlice *slice, const PieSliceLayout &layout); |
|
38 | void addAnimation(PieChartItem* item, QPieSlice *slice, const PieSliceLayout &layout, bool isEmpty); | |
39 | void removeAnimation(PieChartItem* item, QPieSlice *slice); |
|
39 | void removeAnimation(PieChartItem* item, QPieSlice *slice); | |
40 | void updateLayout(PieChartItem* item, const PieLayout &layout); |
|
40 | void updateLayout(PieChartItem* item, const PieLayout &layout); | |
41 | void updateLayout(PieChartItem* item, QPieSlice *slice, const PieSliceLayout &layout); |
|
41 | void updateLayout(PieChartItem* item, QPieSlice *slice, const PieSliceLayout &layout); |
@@ -35,14 +35,17 void PieAnimation::updateValue(QPieSlice *slice, const PieSliceLayout &endLayout | |||||
35 | QTimer::singleShot(0, animation, SLOT(start())); |
|
35 | QTimer::singleShot(0, animation, SLOT(start())); | |
36 | } |
|
36 | } | |
37 |
|
37 | |||
38 | void PieAnimation::addSlice(QPieSlice *slice, const PieSliceLayout &endLayout) |
|
38 | void PieAnimation::addSlice(QPieSlice *slice, const PieSliceLayout &endLayout, bool isEmpty) | |
39 | { |
|
39 | { | |
40 | PieSliceAnimation *animation = new PieSliceAnimation(m_item, slice); |
|
40 | PieSliceAnimation *animation = new PieSliceAnimation(m_item, slice); | |
41 | m_animations.insert(slice, animation); |
|
41 | m_animations.insert(slice, animation); | |
42 |
|
42 | |||
43 | PieSliceLayout startLayout = endLayout; |
|
43 | PieSliceLayout startLayout = endLayout; | |
44 | startLayout.m_radius = 0; |
|
44 | startLayout.m_radius = 0; | |
45 | startLayout.m_startAngle = endLayout.m_startAngle + (endLayout.m_angleSpan/2); |
|
45 | if (isEmpty) | |
|
46 | startLayout.m_startAngle = 0; | |||
|
47 | else | |||
|
48 | startLayout.m_startAngle = endLayout.m_startAngle + (endLayout.m_angleSpan/2); | |||
46 | startLayout.m_angleSpan = 0; |
|
49 | startLayout.m_angleSpan = 0; | |
47 | animation->setValue(startLayout, endLayout); |
|
50 | animation->setValue(startLayout, endLayout); | |
48 |
|
51 |
@@ -18,7 +18,7 public: | |||||
18 | ~PieAnimation(); |
|
18 | ~PieAnimation(); | |
19 | void updateValues(const PieLayout &newValues); |
|
19 | void updateValues(const PieLayout &newValues); | |
20 | void updateValue(QPieSlice *slice, const PieSliceLayout &newValue); |
|
20 | void updateValue(QPieSlice *slice, const PieSliceLayout &newValue); | |
21 | void addSlice(QPieSlice *slice, const PieSliceLayout &endLayout); |
|
21 | void addSlice(QPieSlice *slice, const PieSliceLayout &endLayout, bool isEmpty); | |
22 | void removeSlice(QPieSlice *slice); |
|
22 | void removeSlice(QPieSlice *slice); | |
23 |
|
23 | |||
24 | public: // from QVariantAnimation |
|
24 | public: // from QVariantAnimation |
@@ -47,6 +47,8 void PieChartItem::initialize() | |||||
47 |
|
47 | |||
48 | void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) |
|
48 | void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) | |
49 | { |
|
49 | { | |
|
50 | bool isEmpty = m_slices.isEmpty(); | |||
|
51 | ||||
50 | foreach (QPieSlice *s, slices) { |
|
52 | foreach (QPieSlice *s, slices) { | |
51 | PieSlice* slice = new PieSlice(this); |
|
53 | PieSlice* slice = new PieSlice(this); | |
52 | m_slices.insert(s, slice); |
|
54 | m_slices.insert(s, slice); | |
@@ -58,7 +60,7 void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) | |||||
58 | PieSliceLayout layout = calculateSliceLayout(s); |
|
60 | PieSliceLayout layout = calculateSliceLayout(s); | |
59 |
|
61 | |||
60 | if (m_animator) |
|
62 | if (m_animator) | |
61 | m_animator->addAnimation(this, s, layout); |
|
63 | m_animator->addAnimation(this, s, layout, isEmpty); | |
62 | else |
|
64 | else | |
63 | setLayout(s, layout); |
|
65 | setLayout(s, layout); | |
64 | } |
|
66 | } |
General Comments 0
You need to be logged in to leave comments.
Login now