##// END OF EJS Templates
Fix box-and-whiskers animations...
Miikka Heikkinen -
r2560:a2f72685ff33
parent child
Show More
@@ -26,7 +26,8
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item)
28 BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item)
29 : m_item(item)
29 : QObject(item),
30 m_item(item)
30 {
31 {
31 }
32 }
32
33
@@ -73,6 +74,12 void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box)
73 animation->setStartData(box->m_data);
74 animation->setStartData(box->m_data);
74 }
75 }
75
76
77 void BoxPlotAnimation::stopAll()
78 {
79 foreach (BoxWhiskersAnimation *animation, m_animations.values())
80 animation->stopAndDestroyLater();
81 }
82
76 //#include "moc_boxplotanimation_p.cpp"
83 //#include "moc_boxplotanimation_p.cpp"
77
84
78 QTCOMMERCIALCHART_END_NAMESPACE
85 QTCOMMERCIALCHART_END_NAMESPACE
@@ -39,8 +39,9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39
39
40 class BoxPlotChartItem;
40 class BoxPlotChartItem;
41
41
42 class BoxPlotAnimation
42 class BoxPlotAnimation : public QObject
43 {
43 {
44 Q_OBJECT
44 public:
45 public:
45 BoxPlotAnimation(BoxPlotChartItem *item);
46 BoxPlotAnimation(BoxPlotChartItem *item);
46 ~BoxPlotAnimation();
47 ~BoxPlotAnimation();
@@ -50,6 +51,7 public:
50 ChartAnimation *boxChangeAnimation(BoxWhiskers *box);
51 ChartAnimation *boxChangeAnimation(BoxWhiskers *box);
51
52
52 void setAnimationStart(BoxWhiskers *box);
53 void setAnimationStart(BoxWhiskers *box);
54 void stopAll();
53
55
54 protected:
56 protected:
55 BoxPlotChartItem *m_item;
57 BoxPlotChartItem *m_item;
@@ -58,9 +58,7 public: // from QVariantAnimation
58
58
59 protected:
59 protected:
60 friend class BoxPlotAnimation;
60 friend class BoxPlotAnimation;
61 BoxPlotChartItem *m_item;
62 BoxWhiskers *m_box;
61 BoxWhiskers *m_box;
63 BoxWhiskersData *m_boxData;
64 bool m_moveMedianLine;
62 bool m_moveMedianLine;
65 };
63 };
66
64
@@ -32,8 +32,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 BoxPlotChartItem::BoxPlotChartItem(QBoxPlotSeries *series, QGraphicsItem *item) :
32 BoxPlotChartItem::BoxPlotChartItem(QBoxPlotSeries *series, QGraphicsItem *item) :
33 ChartItem(series->d_func(), item),
33 ChartItem(series->d_func(), item),
34 m_series(series),
34 m_series(series),
35 m_animation(0),
35 m_animation(0)
36 m_animate(0)
37 {
36 {
38 connect(series, SIGNAL(boxsetsRemoved(QList<QBoxSet *>)), this, SLOT(handleBoxsetRemove(QList<QBoxSet *>)));
37 connect(series, SIGNAL(boxsetsRemoved(QList<QBoxSet *>)), this, SLOT(handleBoxsetRemove(QList<QBoxSet *>)));
39 connect(series->d_func(), SIGNAL(restructuredBoxes()), this, SLOT(handleDataStructureChanged()));
38 connect(series->d_func(), SIGNAL(restructuredBoxes()), this, SLOT(handleDataStructureChanged()));
@@ -75,7 +75,6 protected:
75 int m_seriesCount;
75 int m_seriesCount;
76
76
77 BoxPlotAnimation *m_animation;
77 BoxPlotAnimation *m_animation;
78 bool m_animate;
79
78
80 QRectF m_boundingRect;
79 QRectF m_boundingRect;
81 };
80 };
@@ -488,9 +488,11 void QBoxPlotSeriesPrivate::initializeAnimations(QChart::AnimationOptions option
488 item->animation()->stopAndDestroyLater();
488 item->animation()->stopAndDestroyLater();
489
489
490 if (options.testFlag(QChart::SeriesAnimations))
490 if (options.testFlag(QChart::SeriesAnimations))
491 item->setAnimation(new BoxPlotAnimation(item));
491 m_animation = new BoxPlotAnimation(item);
492 else
492 else
493 item->setAnimation(0);
493 m_animation = 0;
494 item->setAnimation(m_animation);
495
494 QAbstractSeriesPrivate::initializeAnimations(options);
496 QAbstractSeriesPrivate::initializeAnimations(options);
495 }
497 }
496
498
@@ -506,7 +508,11 void QBoxPlotSeriesPrivate::handleSeriesRemove(QAbstractSeries *series)
506 Q_Q(QBoxPlotSeries);
508 Q_Q(QBoxPlotSeries);
507
509
508 QBoxPlotSeries *removedSeries = static_cast<QBoxPlotSeries *>(series);
510 QBoxPlotSeries *removedSeries = static_cast<QBoxPlotSeries *>(series);
509 QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0);
511
512 if (q == removedSeries && m_animation) {
513 m_animation->stopAll();
514 QObject::disconnect(m_chart->d_ptr->m_dataset, 0, removedSeries->d_func(), 0);
515 }
510
516
511 // Test if series removed is me, then don't do anything
517 // Test if series removed is me, then don't do anything
512 if (q != removedSeries) {
518 if (q != removedSeries) {
@@ -37,6 +37,8
37
37
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
39
39
40 class BoxPlotAnimation;
41
40 class QBoxPlotSeriesPrivate : public QAbstractSeriesPrivate
42 class QBoxPlotSeriesPrivate : public QAbstractSeriesPrivate
41 {
43 {
42 Q_OBJECT
44 Q_OBJECT
@@ -85,6 +87,7 protected:
85 QPen m_pen;
87 QPen m_pen;
86 QBrush m_brush;
88 QBrush m_brush;
87 int m_index;
89 int m_index;
90 BoxPlotAnimation *m_animation;
88
91
89 private:
92 private:
90 Q_DECLARE_PUBLIC(QBoxPlotSeries)
93 Q_DECLARE_PUBLIC(QBoxPlotSeries)
General Comments 0
You need to be logged in to leave comments. Login now