##// END OF EJS Templates
Further crash fixes to boxplot...
Miikka Heikkinen -
r2561:3dd93906f007
parent child
Show More
@@ -39,7 +39,7 void BoxPlotAnimation::addBox(BoxWhiskers *box)
39 39 {
40 40 BoxWhiskersAnimation *animation = m_animations.value(box);
41 41 if (!animation) {
42 animation = new BoxWhiskersAnimation(box);
42 animation = new BoxWhiskersAnimation(box, this);
43 43 m_animations.insert(box, animation);
44 44 BoxWhiskersData start;
45 45 start.m_median = box->m_data.m_median;
@@ -76,10 +76,16 void BoxPlotAnimation::setAnimationStart(BoxWhiskers *box)
76 76
77 77 void BoxPlotAnimation::stopAll()
78 78 {
79 foreach (BoxWhiskersAnimation *animation, m_animations.values())
79 foreach (BoxWhiskers *box, m_animations.keys()) {
80 BoxWhiskersAnimation *animation = m_animations.value(box);
80 81 animation->stopAndDestroyLater();
82 m_animations.remove(box);
83 }
81 84 }
82 85
83 //#include "moc_boxplotanimation_p.cpp"
86 void BoxPlotAnimation::removeBoxAnimation(BoxWhiskers *box)
87 {
88 m_animations.remove(box);
89 }
84 90
85 91 QTCOMMERCIALCHART_END_NAMESPACE
@@ -52,6 +52,7 public:
52 52
53 53 void setAnimationStart(BoxWhiskers *box);
54 54 void stopAll();
55 void removeBoxAnimation(BoxWhiskers *box);
55 56
56 57 protected:
57 58 BoxPlotChartItem *m_item;
@@ -29,9 +29,10 Q_DECLARE_METATYPE(qreal)
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 BoxWhiskersAnimation::BoxWhiskersAnimation(BoxWhiskers *box)
32 BoxWhiskersAnimation::BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation)
33 33 : ChartAnimation(box),
34 m_box(box)
34 m_box(box),
35 m_boxPlotAnimation(boxPlotAnimation)
35 36 {
36 37 setDuration(ChartAnimationDuration);
37 38 setEasingCurve(QEasingCurve::OutQuart);
@@ -39,6 +40,8 BoxWhiskersAnimation::BoxWhiskersAnimation(BoxWhiskers *box)
39 40
40 41 BoxWhiskersAnimation::~BoxWhiskersAnimation()
41 42 {
43 if (m_boxPlotAnimation)
44 m_boxPlotAnimation->removeBoxAnimation(m_box);
42 45 }
43 46
44 47 QVariant BoxWhiskersAnimation::interpolated(const QVariant &from, const QVariant &to, qreal progress) const
@@ -43,7 +43,7 class BoxWhiskersAnimation : public ChartAnimation
43 43 Q_OBJECT
44 44
45 45 public:
46 BoxWhiskersAnimation(BoxWhiskers *box);
46 BoxWhiskersAnimation(BoxWhiskers *box, BoxPlotAnimation *boxPlotAnimation);
47 47 ~BoxWhiskersAnimation();
48 48
49 49 public: // from QVariantAnimation
@@ -60,6 +60,7 protected:
60 60 friend class BoxPlotAnimation;
61 61 BoxWhiskers *m_box;
62 62 bool m_moveMedianLine;
63 BoxPlotAnimation *m_boxPlotAnimation;
63 64 };
64 65
65 66 QTCOMMERCIALCHART_END_NAMESPACE
@@ -559,13 +559,14 void QBoxPlotSeriesPrivate::handleSeriesChange(QAbstractSeries *series)
559 559
560 560 bool QBoxPlotSeriesPrivate::append(QBoxSet *set)
561 561 {
562 if ((m_boxSets.contains(set)) || (set == 0))
562 if (m_boxSets.contains(set) || (set == 0) || set->d_ptr->m_series)
563 563 return false; // Fail if set is already in list or set is null.
564 564
565 565 m_boxSets.append(set);
566 566 QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
567 567 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes()));
568 568 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes()));
569 set->d_ptr->m_series = this;
569 570
570 571 emit restructuredBoxes(); // this notifies boxplotchartitem
571 572 return true;
@@ -576,6 +577,7 bool QBoxPlotSeriesPrivate::remove(QBoxSet *set)
576 577 if (!m_boxSets.contains(set))
577 578 return false; // Fail if set is not in list
578 579
580 set->d_ptr->m_series = 0;
579 581 m_boxSets.removeOne(set);
580 582 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
581 583 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes()));
@@ -588,7 +590,7 bool QBoxPlotSeriesPrivate::remove(QBoxSet *set)
588 590 bool QBoxPlotSeriesPrivate::append(QList<QBoxSet *> sets)
589 591 {
590 592 foreach (QBoxSet *set, sets) {
591 if ((set == 0) || (m_boxSets.contains(set)))
593 if ((set == 0) || m_boxSets.contains(set) || set->d_ptr->m_series)
592 594 return false; // Fail if any of the sets is null or is already appended.
593 595 if (sets.count(set) != 1)
594 596 return false; // Also fail if same set is more than once in given list.
@@ -599,6 +601,7 bool QBoxPlotSeriesPrivate::append(QList<QBoxSet *> sets)
599 601 QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
600 602 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes()));
601 603 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes()));
604 set->d_ptr->m_series = this;
602 605 }
603 606
604 607 emit restructuredBoxes(); // this notifies boxplotchartitem
@@ -618,6 +621,7 bool QBoxPlotSeriesPrivate::remove(QList<QBoxSet *> sets)
618 621 }
619 622
620 623 foreach (QBoxSet *set, sets) {
624 set->d_ptr->m_series = 0;
621 625 m_boxSets.removeOne(set);
622 626 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
623 627 QObject::disconnect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes()));
@@ -631,10 +635,11 bool QBoxPlotSeriesPrivate::remove(QList<QBoxSet *> sets)
631 635
632 636 bool QBoxPlotSeriesPrivate::insert(int index, QBoxSet *set)
633 637 {
634 if ((m_boxSets.contains(set)) || (set == 0))
638 if ((m_boxSets.contains(set)) || (set == 0) || set->d_ptr->m_series)
635 639 return false; // Fail if set is already in list or set is null.
636 640
637 641 m_boxSets.insert(index, set);
642 set->d_ptr->m_series = this;
638 643 QObject::connect(set->d_ptr.data(), SIGNAL(updatedLayout()), this, SIGNAL(updatedLayout()));
639 644 QObject::connect(set->d_ptr.data(), SIGNAL(updatedBox()), this, SIGNAL(updatedBoxes()));
640 645 QObject::connect(set->d_ptr.data(), SIGNAL(restructuredBox()), this, SIGNAL(restructuredBoxes()));
@@ -325,7 +325,8 QBoxSetPrivate::QBoxSetPrivate(const QString label, QBoxSet *parent) : QObject(p
325 325 m_valuesCount(5),
326 326 m_appendCount(0),
327 327 m_pen(QPen(Qt::NoPen)),
328 m_brush(QBrush(Qt::NoBrush))
328 m_brush(QBrush(Qt::NoBrush)),
329 m_series(0)
329 330 {
330 331 m_values = new qreal[m_valuesCount];
331 332 }
@@ -38,6 +38,8
38 38
39 39 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 40
41 class QBoxPlotSeriesPrivate;
42
41 43 class QBoxSetPrivate : public QObject
42 44 {
43 45 Q_OBJECT
@@ -71,6 +73,7 private:
71 73 QBrush m_brush;
72 74 QBrush m_labelBrush;
73 75 QFont m_labelFont;
76 QBoxPlotSeriesPrivate *m_series;
74 77
75 78 friend class QBoxSet;
76 79 friend class QBoxPlotSeriesPrivate;
General Comments 0
You need to be logged in to leave comments. Login now