|
@@
-28,7
+28,8
Q_DECLARE_METATYPE(SplineVector)
|
|
28
|
QTCOMMERCIALCHART_BEGIN_NAMESPACE
|
|
28
|
QTCOMMERCIALCHART_BEGIN_NAMESPACE
|
|
29
|
|
|
29
|
|
|
30
|
SplineAnimation::SplineAnimation(SplineChartItem* item):XYAnimation(item),
|
|
30
|
SplineAnimation::SplineAnimation(SplineChartItem* item):XYAnimation(item),
|
|
31
|
m_item(item)
|
|
31
|
m_item(item),
|
|
|
|
|
32
|
m_valid(false)
|
|
32
|
{
|
|
33
|
{
|
|
33
|
}
|
|
34
|
}
|
|
34
|
|
|
35
|
|
|
@@
-38,7
+39,15
SplineAnimation::~SplineAnimation()
|
|
38
|
|
|
39
|
|
|
39
|
void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldControlPoints, QVector<QPointF> &newControlPoints, int index)
|
|
40
|
void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldControlPoints, QVector<QPointF> &newControlPoints, int index)
|
|
40
|
{
|
|
41
|
{
|
|
41
|
Q_ASSERT(newPoints.count() * 2 - 2 == newControlPoints.count());
|
|
42
|
if(newPoints.count() * 2 - 2 != newControlPoints.count() || newControlPoints.count() < 2){
|
|
|
|
|
43
|
m_valid=false;
|
|
|
|
|
44
|
m_dirty=false;
|
|
|
|
|
45
|
m_item->setGeometryPoints(newPoints);
|
|
|
|
|
46
|
m_item->setControlGeometryPoints(newControlPoints);
|
|
|
|
|
47
|
m_item->setDirty(false);
|
|
|
|
|
48
|
m_item->updateGeometry();
|
|
|
|
|
49
|
return;
|
|
|
|
|
50
|
}
|
|
42
|
|
|
51
|
|
|
43
|
m_type = NewAnimation;
|
|
52
|
m_type = NewAnimation;
|
|
44
|
|
|
53
|
|
|
@@
-56,6
+65,7
void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPo
|
|
56
|
m_newSpline.first=newPoints;
|
|
65
|
m_newSpline.first=newPoints;
|
|
57
|
m_newSpline.second=newControlPoints;
|
|
66
|
m_newSpline.second=newControlPoints;
|
|
58
|
|
|
67
|
|
|
|
|
|
68
|
|
|
59
|
int x = m_oldSpline.first.count();
|
|
69
|
int x = m_oldSpline.first.count();
|
|
60
|
int y = m_newSpline.first.count();
|
|
70
|
int y = m_newSpline.first.count();
|
|
61
|
|
|
71
|
|
|
@@
-104,52
+114,8
void SplineAnimation::setup(QVector<QPointF> &oldPoints, QVector<QPointF> &newPo
|
|
104
|
|
|
114
|
|
|
105
|
setKeyValueAt(0.0, qVariantFromValue(m_oldSpline));
|
|
115
|
setKeyValueAt(0.0, qVariantFromValue(m_oldSpline));
|
|
106
|
setKeyValueAt(1.0, qVariantFromValue(m_newSpline));
|
|
116
|
setKeyValueAt(1.0, qVariantFromValue(m_newSpline));
|
|
107
|
/*
|
|
117
|
|
|
108
|
int x = oldPoints.count();
|
|
118
|
m_valid=true;
|
|
109
|
int y = newPoints.count();
|
|
|
|
|
110
|
|
|
|
|
|
111
|
Q_ASSERT(newPoints.count() * 2 - 2 == newControlPoints.count());
|
|
|
|
|
112
|
|
|
|
|
|
113
|
if (x != y && abs(x - y) != 1) {
|
|
|
|
|
114
|
m_oldSpline.first = newPoints;
|
|
|
|
|
115
|
m_oldSpline.second = newControlPoints;
|
|
|
|
|
116
|
oldPoints.resize(newPoints.size());
|
|
|
|
|
117
|
oldControlPoints.resize(newControlPoints.size());
|
|
|
|
|
118
|
SplineVector oldPair;
|
|
|
|
|
119
|
oldPair.first = oldPoints;
|
|
|
|
|
120
|
oldPair.second = oldControlPoints;
|
|
|
|
|
121
|
SplineVector newPair;
|
|
|
|
|
122
|
newPair.first = newPoints;
|
|
|
|
|
123
|
newPair.second = newControlPoints;
|
|
|
|
|
124
|
setKeyValueAt(0.0, qVariantFromValue(oldPair));
|
|
|
|
|
125
|
setKeyValueAt(1.0, qVariantFromValue(newPair));
|
|
|
|
|
126
|
m_dirty = false;
|
|
|
|
|
127
|
}
|
|
|
|
|
128
|
else {
|
|
|
|
|
129
|
if(m_dirty) {
|
|
|
|
|
130
|
m_oldSpline.first = oldPoints;
|
|
|
|
|
131
|
m_oldSpline.second = oldControlPoints;
|
|
|
|
|
132
|
m_dirty = false;
|
|
|
|
|
133
|
}
|
|
|
|
|
134
|
oldPoints = newPoints;
|
|
|
|
|
135
|
oldControlPoints = newControlPoints;
|
|
|
|
|
136
|
if (y < x) {
|
|
|
|
|
137
|
m_oldSpline.first.remove(index); //remove
|
|
|
|
|
138
|
m_oldSpline.second.remove(index * 2);
|
|
|
|
|
139
|
m_oldSpline.second.remove(index * 2);
|
|
|
|
|
140
|
}
|
|
|
|
|
141
|
if (y > x) {
|
|
|
|
|
142
|
m_oldSpline.first.insert(index, x > 0 ? m_oldSpline.first[index-1] : newPoints[index]); //add
|
|
|
|
|
143
|
m_oldSpline.second.insert((index - 1) * 2, x > 1 ? m_oldSpline.second[(index-2)*2] : newControlPoints[(index - 1) * 2]); //add
|
|
|
|
|
144
|
m_oldSpline.second.insert((index - 1) * 2 + 1, x > 1 ? m_oldSpline.second[(index - 2) * 2 + 1] : newControlPoints[(index - 1) * 2 + 1]); //add
|
|
|
|
|
145
|
}
|
|
|
|
|
146
|
SplineVector newPair;
|
|
|
|
|
147
|
newPair.first=newPoints;
|
|
|
|
|
148
|
newPair.second=newControlPoints;
|
|
|
|
|
149
|
setKeyValueAt(0.0, qVariantFromValue(m_oldSpline));
|
|
|
|
|
150
|
setKeyValueAt(1.0, qVariantFromValue(newPair));
|
|
|
|
|
151
|
}
|
|
|
|
|
152
|
*/
|
|
|
|
|
153
|
|
|
119
|
|
|
154
|
}
|
|
120
|
}
|
|
155
|
|
|
121
|
|
|
@@
-208,7
+174,7
QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant &en
|
|
208
|
|
|
174
|
|
|
209
|
void SplineAnimation::updateCurrentValue (const QVariant &value )
|
|
175
|
void SplineAnimation::updateCurrentValue (const QVariant &value )
|
|
210
|
{
|
|
176
|
{
|
|
211
|
if (state() != QAbstractAnimation::Stopped) { //workaround
|
|
177
|
if (state() != QAbstractAnimation::Stopped && m_valid) { //workaround
|
|
212
|
QPair<QVector<QPointF >, QVector<QPointF > > pair = qVariantValue< QPair< QVector<QPointF>, QVector<QPointF> > >(value);
|
|
178
|
QPair<QVector<QPointF >, QVector<QPointF > > pair = qVariantValue< QPair< QVector<QPointF>, QVector<QPointF> > >(value);
|
|
213
|
m_item->setGeometryPoints(pair.first);
|
|
179
|
m_item->setGeometryPoints(pair.first);
|
|
214
|
m_item->setControlGeometryPoints(pair.second);
|
|
180
|
m_item->setControlGeometryPoints(pair.second);
|
|
@@
-220,6
+186,8
void SplineAnimation::updateCurrentValue (const QVariant &value )
|
|
220
|
|
|
186
|
|
|
221
|
void SplineAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
|
|
187
|
void SplineAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
|
|
222
|
{
|
|
188
|
{
|
|
|
|
|
189
|
XYAnimation::updateState(newState, oldState);
|
|
|
|
|
190
|
|
|
223
|
if(oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped)
|
|
191
|
if(oldState == QAbstractAnimation::Running && newState == QAbstractAnimation::Stopped)
|
|
224
|
{
|
|
192
|
{
|
|
225
|
if(m_item->isDirty() && m_type==RemovePointAnimation) {
|
|
193
|
if(m_item->isDirty() && m_type==RemovePointAnimation) {
|
|
@@
-232,6
+200,13
void SplineAnimation::updateState(QAbstractAnimation::State newState, QAbstractA
|
|
232
|
m_item->setControlGeometryPoints(m_newSpline.second);
|
|
200
|
m_item->setControlGeometryPoints(m_newSpline.second);
|
|
233
|
}
|
|
201
|
}
|
|
234
|
}
|
|
202
|
}
|
|
|
|
|
203
|
|
|
|
|
|
204
|
if(oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running)
|
|
|
|
|
205
|
{
|
|
|
|
|
206
|
if(!m_valid) {
|
|
|
|
|
207
|
stop();
|
|
|
|
|
208
|
}
|
|
|
|
|
209
|
}
|
|
235
|
}
|
|
210
|
}
|
|
236
|
|
|
211
|
|
|
237
|
QTCOMMERCIALCHART_END_NAMESPACE
|
|
212
|
QTCOMMERCIALCHART_END_NAMESPACE
|