##// END OF EJS Templates
Doc: Remove the additional "Getting Started" page...
Doc: Remove the additional "Getting Started" page Now that the addon is available under opensource license, there are less hurdles to install and use it. Change-Id: Ia8de9ca0f4034e4b5397a9f1a5ed218f068b193a Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>

File last commit:

r2854:46147b040d06
r2880:023f3b1edeaa
Show More
splineanimation.cpp
219 lines | 7.8 KiB | text/x-c | CppLexer
Miikka Heikkinen
Updated license...
r2854 /****************************************************************************
Titta Heikkala
Updated license headers...
r2845 **
Miikka Heikkinen
Updated license...
r2854 ** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
Titta Heikkala
Updated license headers...
r2845 **
Miikka Heikkinen
Updated license...
r2854 ** This file is part of the Qt Charts module of the Qt Toolkit.
Titta Heikkala
Updated license headers...
r2845 **
Miikka Heikkinen
Updated license...
r2854 ** $QT_BEGIN_LICENSE:GPL$
Titta Heikkala
Updated license headers...
r2845 ** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
Miikka Heikkinen
Updated license...
r2854 ** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 or (at your option) any later version
** approved by the KDE Free Qt Foundation. The licenses are as published by
** the Free Software Foundation and appearing in the file LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
Titta Heikkala
Updated license headers...
r2845 **
** $QT_END_LICENSE$
**
Miikka Heikkinen
Updated license...
r2854 ****************************************************************************/
Jani Honkonen
Add license headers
r794
Titta Heikkala
Fix include syntax...
r2714 #include <private/splineanimation_p.h>
#include <private/splinechartitem_p.h>
#include <QtCore/QDebug>
Michal Klocek
Improves spline interpolation...
r622
Q_DECLARE_METATYPE(QVector<QPointF>)
Q_DECLARE_METATYPE(SplineVector)
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_BEGIN_NAMESPACE
Michal Klocek
Improves spline interpolation...
r622
Titta Heikkala
Added possibility to set duration and easing curve for chart animation...
r2804 SplineAnimation::SplineAnimation(SplineChartItem *item, int duration, QEasingCurve &curve)
: XYAnimation(item, duration, curve),
Jani Honkonen
more coding style fixes for src-folder...
r2104 m_item(item),
m_valid(false)
Michal Klocek
Improves spline interpolation...
r622 {
}
SplineAnimation::~SplineAnimation()
{
}
Michal Klocek
adds QLineAnimation fixes
r1271 void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldControlPoints, QVector<QPointF> &newControlPoints, int index)
Michal Klocek
Improves spline interpolation...
r622 {
Tero Ahola
Minor: extra colons, commented out code
r1782 if (newPoints.count() * 2 - 2 != newControlPoints.count() || newControlPoints.count() < 2) {
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 m_valid = false;
m_dirty = false;
Tero Ahola
Minor: extra colons, commented out code
r1782 m_item->setGeometryPoints(newPoints);
m_item->setControlGeometryPoints(newControlPoints);
m_item->setDirty(false);
m_item->updateGeometry();
return;
Michal Klocek
Refactor spline animation handling...
r1770 }
Michal Klocek
Improves spline interpolation...
r622
Michal Klocek
Refactors spline animations:...
r1288 m_type = NewAnimation;
if (state() != QAbstractAnimation::Stopped) {
stop();
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 m_dirty = false;
Michal Klocek
Improves spline interpolation...
r622 }
Michal Klocek
Refactors spline animations:...
r1288
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (!m_dirty) {
Michal Klocek
Refactors spline animations:...
r1288 m_dirty = true;
m_oldSpline.first = oldPoints;
m_oldSpline.second = oldControlPoints;
}
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 m_newSpline.first = newPoints;
m_newSpline.second = newControlPoints;
Michal Klocek
Refactors spline animations:...
r1288
Michal Klocek
Refactor spline animation handling...
r1770
Michal Klocek
Refactors spline animations:...
r1288 int x = m_oldSpline.first.count();
int y = m_newSpline.first.count();
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (x - y == 1 && index >= 0 && y > 0) {
Michal Klocek
Refactors spline animations:...
r1288 //remove point
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (index > 0) {
m_newSpline.first.insert(index, newPoints[index - 1]);
m_newSpline.second.insert((index - 1) * 2, newPoints[index - 1]);
m_newSpline.second.insert((index - 1) * 2 + 1, newPoints[index - 1]);
} else {
Miikka Heikkinen
Further animation fixes...
r2492 m_newSpline.first.insert(0, newPoints[index]);
m_newSpline.second.insert(0, newPoints[index]);
m_newSpline.second.insert(1, newPoints[index]);
Michal Klocek
Improves spline interpolation...
r622 }
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 m_index = index;
Michal Klocek
Refactors spline animations:...
r1288 m_type = RemovePointAnimation;
}
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (x - y == -1 && index >= 0) {
Michal Klocek
Refactors spline animations:...
r1288 //add point
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (index > 0) {
m_oldSpline.first.insert(index, newPoints[index - 1]);
m_oldSpline.second.insert((index - 1) * 2, newPoints[index - 1]);
m_oldSpline.second.insert((index - 1) * 2 + 1, newPoints[index - 1]);
} else {
Miikka Heikkinen
Further animation fixes...
r2492 m_oldSpline.first.insert(0, newPoints[index]);
m_oldSpline.second.insert(0, newPoints[index]);
m_oldSpline.second.insert(1, newPoints[index]);
Michal Klocek
Improves spline interpolation...
r622 }
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 m_index = index;
Michal Klocek
Refactors spline animations:...
r1288 m_type = AddPointAnimation;
}
x = m_oldSpline.first.count();
y = m_newSpline.first.count();
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (x != y) {
Michal Klocek
Refactors spline animations:...
r1288 m_type = NewAnimation;
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 } else if (m_type == NewAnimation) {
Michal Klocek
Refactors spline animations:...
r1288 m_type = ReplacePointAnimation;
Michal Klocek
Improves spline interpolation...
r622 }
Michal Klocek
Refactors spline animations:...
r1288
setKeyValueAt(0.0, qVariantFromValue(m_oldSpline));
setKeyValueAt(1.0, qVariantFromValue(m_newSpline));
Michal Klocek
Refactor spline animation handling...
r1770
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 m_valid = true;
Michal Klocek
Refactors spline animations:...
r1288
Michal Klocek
Improves spline interpolation...
r622 }
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const
Michal Klocek
Improves spline interpolation...
r622 {
Jani Honkonen
Fix deprecation errors from Qt5
r2241 SplineVector startPair = qvariant_cast< SplineVector >(start);
SplineVector endPair = qvariant_cast< SplineVector >(end);
Michal Klocek
Improves spline interpolation...
r622 SplineVector result;
Michal Klocek
Refactors animation handling for xyseries
r1217 switch (animationType()) {
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 case RemovePointAnimation:
case AddPointAnimation:
case ReplacePointAnimation: {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 if (startPair.first.count() != endPair.first.count())
break;
Q_ASSERT(startPair.first.count() * 2 - 2 == startPair.second.count());
Q_ASSERT(endPair.first.count() * 2 - 2 == endPair.second.count());
for (int i = 0; i < endPair.first.count(); i++) {
qreal x = startPair.first[i].x() + ((endPair.first[i].x() - startPair.first[i].x()) * progress);
qreal y = startPair.first[i].y() + ((endPair.first[i].y() - startPair.first[i].y()) * progress);
result.first << QPointF(x, y);
if (i + 1 >= endPair.first.count())
continue;
x = startPair.second[i * 2].x() + ((endPair.second[i * 2].x() - startPair.second[i * 2].x()) * progress);
y = startPair.second[i * 2].y() + ((endPair.second[i * 2].y() - startPair.second[i * 2].y()) * progress);
result.second << QPointF(x, y);
x = startPair.second[i * 2 + 1].x() + ((endPair.second[i * 2 + 1].x() - startPair.second[i * 2 + 1].x()) * progress);
y = startPair.second[i * 2 + 1].y() + ((endPair.second[i * 2 + 1].y() - startPair.second[i * 2 + 1].y()) * progress);
result.second << QPointF(x, y);
Michal Klocek
Refactors spline animations:...
r1288 }
Jani Honkonen
src folder: another massive victory for coding style police
r2131 }
break;
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 case NewAnimation: {
Jani Honkonen
src folder: another massive victory for coding style police
r2131 Q_ASSERT(endPair.first.count() * 2 - 2 == endPair.second.count());
int count = endPair.first.count() * qBound(qreal(0), progress, qreal(1));
for (int i = 0; i < count; i++) {
result.first << endPair.first[i];
if (i + 1 == count)
break;
result.second << endPair.second[2 * i];
result.second << endPair.second[2 * i + 1];
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738 }
Jani Honkonen
src folder: another massive victory for coding style police
r2131 }
break;
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 default:
Michal Klocek
Refactors animation handling for xyseries
r1217 qWarning() << "Unknown type of animation";
Marek Rosa
Animation folder formating: white spaces, brackets, etc fixed
r738 break;
Michal Klocek
Improves spline interpolation...
r622 }
return qVariantFromValue(result);
}
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 void SplineAnimation::updateCurrentValue(const QVariant &value)
Michal Klocek
Improves spline interpolation...
r622 {
Michal Klocek
Refactor spline animation handling...
r1770 if (state() != QAbstractAnimation::Stopped && m_valid) { //workaround
Jani Honkonen
Fix deprecation errors from Qt5
r2241 QPair<QVector<QPointF >, QVector<QPointF > > pair = qvariant_cast< QPair< QVector<QPointF>, QVector<QPointF> > >(value);
Michal Klocek
Refactors animation handling for xyseries
r1217 m_item->setGeometryPoints(pair.first);
m_item->setControlGeometryPoints(pair.second);
m_item->updateGeometry();
Michal Klocek
Refactors spline animations:...
r1288 m_item->setDirty(true);
m_dirty = false;
Michal Klocek
Improves spline interpolation...
r622 }
}
Michal Klocek
Refactors spline animations:...
r1288 void SplineAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
Michal Klocek
Refactor spline animation handling...
r1770 XYAnimation::updateState(newState, oldState);
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped) {
if (m_item->isDirty() && m_type == RemovePointAnimation) {
if (!m_newSpline.first.isEmpty()) {
Miikka Heikkinen
Further animation fixes...
r2492 if (m_index) {
m_newSpline.first.remove(m_index);
m_newSpline.second.remove((m_index - 1) * 2);
m_newSpline.second.remove((m_index - 1) * 2);
} else {
m_newSpline.first.remove(0);
m_newSpline.second.remove(0);
m_newSpline.second.remove(0);
}
Michal Klocek
Refactors spline animations:...
r1288 }
m_item->setGeometryPoints(m_newSpline.first);
m_item->setControlGeometryPoints(m_newSpline.second);
}
}
Michal Klocek
Refactor spline animation handling...
r1770
Jani Honkonen
astyle and manual coding style fixes for src-folder
r2097 if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) {
if (!m_valid)
stop();
Michal Klocek
Refactor spline animation handling...
r1770 }
Michal Klocek
Refactors spline animations:...
r1288 }
Michal Klocek
Improves spline interpolation...
r622
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_END_NAMESPACE