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