##// END OF EJS Templates
Remove unused member variable in chartview
Remove unused member variable in chartview

File last commit:

r1288:77f0ec765102
r2057:f6a6fb4a2c5f
Show More
xyanimation.cpp
154 lines | 4.0 KiB | text/x-c | CppLexer
Jani Honkonen
Add license headers
r794 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the Qt Commercial Charts Add-on.
**
** $QT_BEGIN_LICENSE$
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
** $QT_END_LICENSE$
**
****************************************************************************/
Michal Klocek
Animation refactor...
r530 #include "xyanimation_p.h"
Michal Klocek
Refactor xychartitem -> xychart
r1218 #include "xychart_p.h"
Michal Klocek
Improves build configuration...
r996 #include <QDebug>
Michal Klocek
Animation refactor...
r530
Q_DECLARE_METATYPE(QVector<QPointF>)
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor xychartitem -> xychart
r1218 XYAnimation::XYAnimation(XYChart *item):ChartAnimation(item),
Michal Klocek
Refactors spline animations:...
r1288 m_type(NewAnimation),
Michal Klocek
Refactors animation handling for xyseries
r1217 m_dirty(false),
Michal Klocek
Refactors spline animations:...
r1288 m_index(-1),
m_item(item)
Michal Klocek
Animation refactor...
r530 {
Michal Klocek
Refactors axis animation, line animations
r1241 setDuration(ChartAnimationDuration);
setEasingCurve(QEasingCurve::OutQuart);
Michal Klocek
Animation refactor...
r530 }
XYAnimation::~XYAnimation()
{
}
Michal Klocek
adds QLineAnimation fixes
r1271 void XYAnimation::setup(const QVector<QPointF> &oldPoints, const QVector<QPointF> &newPoints, int index)
Michal Klocek
Refactors animation handling for xyseries
r1217 {
Michal Klocek
adds QLineAnimation fixes
r1271 m_type = NewAnimation;
Michal Klocek
Refactors animation handling for xyseries
r1217
Michal Klocek
adds QLineAnimation fixes
r1271 if (state() != QAbstractAnimation::Stopped){
stop();
m_dirty=false;
}
Michal Klocek
prevents flipping in xyseries animation
r1220
Michal Klocek
adds QLineAnimation fixes
r1271 if(!m_dirty){
m_dirty = true;
m_oldPoints = oldPoints;
}
Michal Klocek
Refactors axis animation, line animations
r1241
Michal Klocek
adds QLineAnimation fixes
r1271 m_newPoints = newPoints;
Michal Klocek
Refactors axis animation, line animations
r1241
Michal Klocek
adds QLineAnimation fixes
r1271 int x = m_oldPoints.count();
int y = m_newPoints.count();
Michal Klocek
Refactors spline animations:...
r1288 if(x - y == 1 && index >= 0 && y > 0){
Michal Klocek
adds QLineAnimation fixes
r1271 //remove point
Michal Klocek
Refactors spline animations:...
r1288 m_newPoints.insert(index, index > 0 ? newPoints[index-1] : newPoints[index]);
Michal Klocek
adds QLineAnimation fixes
r1271 m_index=index;
m_type = RemovePointAnimation;
}
if(x - y == -1 && index >= 0){
//add point
Michal Klocek
Refactors spline animations:...
r1288 m_oldPoints.insert(index, index > 0 ? newPoints[index-1] : newPoints[index]);
Michal Klocek
adds QLineAnimation fixes
r1271 m_index=index;
m_type = AddPointAnimation;
}
x = m_oldPoints.count();
y = m_newPoints.count();
if(x != y)
{
m_type = NewAnimation;
}
else if(m_type == NewAnimation)
{
m_type = ReplacePointAnimation;
}
Michal Klocek
Refactors axis animation, line animations
r1241
setKeyValueAt(0.0, qVariantFromValue(m_oldPoints));
setKeyValueAt(1.0, qVariantFromValue(m_newPoints));
Michal Klocek
Animation refactor...
r530 }
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738 QVariant XYAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress ) const
Michal Klocek
Animation refactor...
r530 {
QVector<QPointF> startVector = qVariantValue<QVector<QPointF> >(start);
QVector<QPointF> endVector = qVariantValue<QVector<QPointF> >(end);
QVector<QPointF> result;
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738 switch (m_type) {
Michal Klocek
Bugfix wrong index when points added to xychart
r602
Michal Klocek
Refactors axis animation, line animations
r1241 case ReplacePointAnimation:
case AddPointAnimation:
case RemovePointAnimation:
{
Michal Klocek
adds QLineAnimation fixes
r1271 if (startVector.count() != endVector.count()){
Michal Klocek
Animation refactor...
r530 break;
Michal Klocek
adds QLineAnimation fixes
r1271 }
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738
for(int i = 0; i < startVector.count(); i++) {
qreal x = startVector[i].x() + ((endVector[i].x() - startVector[i].x()) * progress);
qreal y = startVector[i].y() + ((endVector[i].y() - startVector[i].y()) * progress);
result << QPointF(x, y);
Michal Klocek
Animation refactor...
r530 }
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738
}
break;
Michal Klocek
Refactors axis animation, line animations
r1241 case NewAnimation: {
Michal Klocek
Krazy reported errors...
r974 for(int i = 0; i < endVector.count() * qBound(qreal(0), progress, qreal(1)); i++)
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738 result << endVector[i];
}
break;
default:
qWarning() << "Unknown type of animation";
break;
Michal Klocek
Animation refactor...
r530 }
return qVariantFromValue(result);
}
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738 void XYAnimation::updateCurrentValue (const QVariant &value)
Michal Klocek
Animation refactor...
r530 {
if(state()!=QAbstractAnimation::Stopped){ //workaround
Michal Klocek
adds QLineAnimation fixes
r1271
Michal Klocek
Animation refactor...
r530 QVector<QPointF> vector = qVariantValue<QVector<QPointF> >(value);
Michal Klocek
Refactors animation handling for xyseries
r1217 m_item->setGeometryPoints(vector);
m_item->updateGeometry();
Michal Klocek
Refactors axis animation, line animations
r1241 m_item->setDirty(true);
Michal Klocek
adds QLineAnimation fixes
r1271 m_dirty=false;
Michal Klocek
Animation refactor...
r530 }
}
Michal Klocek
Refactors axis animation, line animations
r1241 void XYAnimation::updateState( QAbstractAnimation::State newState, QAbstractAnimation::State oldState )
{
if(oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped)
{
if(m_item->isDirty() && m_type==RemovePointAnimation){
if(!m_newPoints.isEmpty()) m_newPoints.remove(m_index);
m_item->setGeometryPoints(m_newPoints);
}
}
}
#include "moc_chartanimation_p.cpp"
Michal Klocek
Animation refactor...
r530 QTCOMMERCIALCHART_END_NAMESPACE