summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2013-04-09 16:40:02 +0300
committerMika Salmela <mika.salmela@digia.com>2013-04-10 13:32:29 +0300
commit5245fa8e4b1600944d3968db7fb0df06aab94b86 (patch)
tree50e0b5c373faa5e7201d4cda1d2b1265ef6b2062
parent3080953542fceb7e8bea1bfbd3ad9405304764b7 (diff)
Fixed animation to work when adding a new series.
Change-Id: I698e4143213e49d07ef69c802eed051912af7532 Reviewed-by: Mika Salmela <mika.salmela@digia.com>
-rw-r--r--src/animations/boxplotanimation.cpp26
-rw-r--r--src/animations/boxwhiskersanimation.cpp15
-rw-r--r--src/animations/boxwhiskersanimation_p.h1
-rw-r--r--src/boxplotchart/boxwhiskers.cpp4
4 files changed, 24 insertions, 22 deletions
diff --git a/src/animations/boxplotanimation.cpp b/src/animations/boxplotanimation.cpp
index 57add4de..f645f678 100644
--- a/src/animations/boxplotanimation.cpp
+++ b/src/animations/boxplotanimation.cpp
@@ -22,33 +22,32 @@
#include "boxplotchartitem_p.h"
#include "boxwhiskersdata_p.h"
#include "boxwhiskersanimation_p.h"
+#include <QDebug>
QTCOMMERCIALCHART_BEGIN_NAMESPACE
BoxPlotAnimation::BoxPlotAnimation(BoxPlotChartItem *item)
- // : ChartAnimation(item),
: m_item(item)
{
}
-//BoxPlotAnimation::BoxPlotAnimation(BoxWhiskers *box)
-// : ChartAnimation(box),
-// m_box(box)
-//{
-//}
-
BoxPlotAnimation::~BoxPlotAnimation()
{
}
void BoxPlotAnimation::addBox(BoxWhiskers *box)
{
- BoxWhiskersAnimation *animation = new BoxWhiskersAnimation(box);
- m_animations.insert(box, animation);
-
- BoxWhiskersData start;
- start.m_median = box->m_data.m_median;
- animation->setup(start, box->m_data);
+ BoxWhiskersAnimation *animation = m_animations.value(box);
+ if (!animation) {
+ animation = new BoxWhiskersAnimation(box);
+ m_animations.insert(box, animation);
+ BoxWhiskersData start;
+ start.m_median = box->m_data.m_median;
+ animation->setup(start, box->m_data);
+ } else {
+ animation->stop();
+ animation->setEndData(box->m_data);
+ }
}
ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box)
@@ -57,7 +56,6 @@ ChartAnimation *BoxPlotAnimation::boxAnimation(BoxWhiskers *box)
return m_animations.value(box);
}
-
//#include "moc_boxplotanimation_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/animations/boxwhiskersanimation.cpp b/src/animations/boxwhiskersanimation.cpp
index 264f58b7..d5770829 100644
--- a/src/animations/boxwhiskersanimation.cpp
+++ b/src/animations/boxwhiskersanimation.cpp
@@ -22,6 +22,7 @@
#include "boxplotanimation_p.h"
#include "boxplotchartitem_p.h"
#include "boxwhiskersdata_p.h"
+#include <QDebug>
Q_DECLARE_METATYPE(QVector<QRectF>)
Q_DECLARE_METATYPE(QTCOMMERCIALCHART_NAMESPACE::BoxWhiskersData)
@@ -80,7 +81,8 @@ QVariant BoxWhiskersAnimation::interpolated(const QVariant &from, const QVariant
result.m_minX = endData.m_minX;
result.m_maxY = endData.m_maxY;
result.m_minY = endData.m_minY;
- //result.m_domainSize = endData.m_domainSize;
+ result.m_seriesIndex = endData.m_seriesIndex;
+ result.m_seriesCount = endData.m_seriesCount;
return qVariantFromValue(result);
}
@@ -93,13 +95,18 @@ void BoxWhiskersAnimation::updateCurrentValue(const QVariant &value)
void BoxWhiskersAnimation::setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData)
{
- if (endData.m_index == 0) {
- qDebug() << "BoxPlotAnimation::setup m_upperExtreme" << endData.m_upperExtreme;
- }
setKeyValueAt(0.0, qVariantFromValue(startData));
setKeyValueAt(1.0, qVariantFromValue(endData));
}
+void BoxWhiskersAnimation::setEndData(const BoxWhiskersData &endData)
+{
+ if (state() != QAbstractAnimation::Stopped)
+ stop();
+
+ setEndValue(qVariantFromValue(endData));
+}
+
#include "moc_boxwhiskersanimation_p.cpp"
QTCOMMERCIALCHART_END_NAMESPACE
diff --git a/src/animations/boxwhiskersanimation_p.h b/src/animations/boxwhiskersanimation_p.h
index f2dc6dc1..3b8979fb 100644
--- a/src/animations/boxwhiskersanimation_p.h
+++ b/src/animations/boxwhiskersanimation_p.h
@@ -52,6 +52,7 @@ public: // from QVariantAnimation
virtual void updateCurrentValue(const QVariant &value);
void setup(const BoxWhiskersData &startData, const BoxWhiskersData &endData);
+ void setEndData(const BoxWhiskersData &endData);
protected:
BoxPlotChartItem *m_item;
diff --git a/src/boxplotchart/boxwhiskers.cpp b/src/boxplotchart/boxwhiskers.cpp
index b975ce17..aed2fcfe 100644
--- a/src/boxplotchart/boxwhiskers.cpp
+++ b/src/boxplotchart/boxwhiskers.cpp
@@ -73,7 +73,6 @@ void BoxWhiskers::setLayout(const BoxWhiskersData &data)
// if (m_data.m_index == 1)
// qDebug() << "BoxWhiskers::setLayout";
updateGeometry();
- //update(0.0, 0.0, m_data.m_domainSize.width(), m_data.m_domainSize.height());
update();
}
@@ -130,9 +129,6 @@ void BoxWhiskers::updateGeometry()
QPainterPath path;
- // TODO: Dirty hack
- if (m_data.m_seriesCount == 0) m_data.m_seriesCount = 1;
-
qreal columnWidth = 1.0 / m_data.m_seriesCount;
qreal left = 0.25 * columnWidth + columnWidth * m_data.m_seriesIndex;
qreal right = 0.75 * columnWidth + columnWidth * m_data.m_seriesIndex;