##// END OF EJS Templates
Fixed animation to work when adding a new series....
Mika Salmela -
r2478:5245fa8e4b16
parent child
Show More
@@ -22,33 +22,32
22 #include "boxplotchartitem_p.h"
22 #include "boxplotchartitem_p.h"
23 #include "boxwhiskersdata_p.h"
23 #include "boxwhiskersdata_p.h"
24 #include "boxwhiskersanimation_p.h"
24 #include "boxwhiskersanimation_p.h"
25 #include <QDebug>
25
26
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
28
28 BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item)
29 BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item)
29 // : ChartAnimation(item),
30 : m_item(item)
30 : m_item(item)
31 {
31 {
32 }
32 }
33
33
34 //BoxPlotAnimation::BoxPlotAnimation(BoxWhiskers *box)
35 // : ChartAnimation(box),
36 // m_box(box)
37 //{
38 //}
39
40 BoxPlotAnimation::~BoxPlotAnimation()
34 BoxPlotAnimation::~BoxPlotAnimation()
41 {
35 {
42 }
36 }
43
37
44 void BoxPlotAnimation::addBox(BoxWhiskers *box)
38 void BoxPlotAnimation::addBox(BoxWhiskers *box)
45 {
39 {
46 BoxWhiskersAnimation *animation = new BoxWhiskersAnimation(box);
40 BoxWhiskersAnimation *animation = m_animations.value(box);
47 m_animations.insert(box, animation);
41 if (!animation) {
48
42 animation = new BoxWhiskersAnimation(box);
49 BoxWhiskersData start;
43 m_animations.insert(box, animation);
50 start.m_median = box->m_data.m_median;
44 BoxWhiskersData start;
51 animation->setup(start, box->m_data);
45 start.m_median = box->m_data.m_median;
46 animation->setup(start, box->m_data);
47 } else {
48 animation->stop();
49 animation->setEndData(box->m_data);
50 }
52 }
51 }
53
52
54 ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box)
53 ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box)
@@ -57,7 +56,6 ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box)
57 return m_animations.value(box);
56 return m_animations.value(box);
58 }
57 }
59
58
60
61 //#include "moc_boxplotanimation_p.cpp"
59 //#include "moc_boxplotanimation_p.cpp"
62
60
63 QTCOMMERCIALCHART_END_NAMESPACE
61 QTCOMMERCIALCHART_END_NAMESPACE
@@ -22,6 +22,7
22 #include "boxplotanimation_p.h"
22 #include "boxplotanimation_p.h"
23 #include "boxplotchartitem_p.h"
23 #include "boxplotchartitem_p.h"
24 #include "boxwhiskersdata_p.h"
24 #include "boxwhiskersdata_p.h"
25 #include <QDebug>
25
26
26 Q_DECLARE_METATYPE(QVector<QRectF>)
27 Q_DECLARE_METATYPE(QVector<QRectF>)
27 Q_DECLARE_METATYPE(QTCOMMERCIALCHART_NAMESPACE::BoxWhiskersData)
28 Q_DECLARE_METATYPE(QTCOMMERCIALCHART_NAMESPACE::BoxWhiskersData)
@@ -80,7 +81,8 QVariant BoxWhiskersAnimation::interpolated(const QVariant &from, const QVariant
80 result.m_minX = endData.m_minX;
81 result.m_minX = endData.m_minX;
81 result.m_maxY = endData.m_maxY;
82 result.m_maxY = endData.m_maxY;
82 result.m_minY = endData.m_minY;
83 result.m_minY = endData.m_minY;
83 //result.m_domainSize = endData.m_domainSize;
84 result.m_seriesIndex = endData.m_seriesIndex;
85 result.m_seriesCount = endData.m_seriesCount;
84
86
85 return qVariantFromValue(result);
87 return qVariantFromValue(result);
86 }
88 }
@@ -93,13 +95,18 void BoxWhiskersAnimation::updateCurrentValue(const QVariant &value)
93
95
94 void BoxWhiskersAnimation::setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData)
96 void BoxWhiskersAnimation::setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData)
95 {
97 {
96 if (endData.m_index == 0) {
97 qDebug() << "BoxPlotAnimation::setup m_upperExtreme" << endData.m_upperExtreme;
98 }
99 setKeyValueAt(0.0, qVariantFromValue(startData));
98 setKeyValueAt(0.0, qVariantFromValue(startData));
100 setKeyValueAt(1.0, qVariantFromValue(endData));
99 setKeyValueAt(1.0, qVariantFromValue(endData));
101 }
100 }
102
101
102 void BoxWhiskersAnimation::setEndData(const BoxWhiskersData &endData)
103 {
104 if (state() != QAbstractAnimation::Stopped)
105 stop();
106
107 setEndValue(qVariantFromValue(endData));
108 }
109
103 #include "moc_boxwhiskersanimation_p.cpp"
110 #include "moc_boxwhiskersanimation_p.cpp"
104
111
105 QTCOMMERCIALCHART_END_NAMESPACE
112 QTCOMMERCIALCHART_END_NAMESPACE
@@ -52,6 +52,7 public: // from QVariantAnimation
52 virtual void updateCurrentValue(const QVariant &value);
52 virtual void updateCurrentValue(const QVariant &value);
53
53
54 void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData);
54 void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData);
55 void setEndData(const BoxWhiskersData &endData);
55
56
56 protected:
57 protected:
57 BoxPlotChartItem *m_item;
58 BoxPlotChartItem *m_item;
@@ -73,7 +73,6 void BoxWhiskers::setLayout(const BoxWhiskersData &data)
73 // if (m_data.m_index == 1)
73 // if (m_data.m_index == 1)
74 // qDebug() << "BoxWhiskers::setLayout";
74 // qDebug() << "BoxWhiskers::setLayout";
75 updateGeometry();
75 updateGeometry();
76 //update(0.0, 0.0, m_data.m_domainSize.width(), m_data.m_domainSize.height());
77 update();
76 update();
78 }
77 }
79
78
@@ -130,9 +129,6 void BoxWhiskers::updateGeometry()
130
129
131 QPainterPath path;
130 QPainterPath path;
132
131
133 // TODO: Dirty hack
134 if (m_data.m_seriesCount == 0) m_data.m_seriesCount = 1;
135
136 qreal columnWidth = 1.0 / m_data.m_seriesCount;
132 qreal columnWidth = 1.0 / m_data.m_seriesCount;
137 qreal left = 0.25 * columnWidth + columnWidth * m_data.m_seriesIndex;
133 qreal left = 0.25 * columnWidth + columnWidth * m_data.m_seriesIndex;
138 qreal right = 0.75 * columnWidth + columnWidth * m_data.m_seriesIndex;
134 qreal right = 0.75 * columnWidth + columnWidth * m_data.m_seriesIndex;
General Comments 0
You need to be logged in to leave comments. Login now