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