|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -1,26 +1,26 | |||
|
1 | 1 | #ifndef CHARTANIMATION_H_ |
|
2 | 2 | #define CHARTANIMATION_H_ |
|
3 | 3 | |
|
4 | 4 | #include "qchartglobal.h" |
|
5 | 5 | #include <QVariantAnimation> |
|
6 | 6 | |
|
7 | 7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | 8 | |
|
9 | 9 | class ChartAnimation: public QVariantAnimation |
|
10 | 10 | { |
|
11 | 11 | public: |
|
12 | 12 | enum Animation { LineDrawAnimation, MoveDownAnimation, MoveUpAnimation }; |
|
13 |
ChartAnimation(QObject* parent=0):QVariantAnimation(parent),m_type(MoveDownAnimation){} |
|
|
13 | ChartAnimation(QObject* parent=0):QVariantAnimation(parent), m_type(MoveDownAnimation){} | |
|
14 | 14 | void setAnimationType(Animation type){ |
|
15 | 15 | m_type=type; |
|
16 | 16 | } |
|
17 | 17 | protected: |
|
18 | 18 | Animation m_type; |
|
19 | 19 | |
|
20 | 20 | }; |
|
21 | 21 | |
|
22 | 22 | QTCOMMERCIALCHART_END_NAMESPACE |
|
23 | 23 | |
|
24 | 24 | |
|
25 | 25 | |
|
26 | 26 | #endif /* AXISITEM_H_ */ |
@@ -1,288 +1,279 | |||
|
1 | 1 | #include "chartanimator_p.h" |
|
2 | 2 | #include "axisanimation_p.h" |
|
3 | 3 | #include "xyanimation_p.h" |
|
4 | 4 | #include "splineanimation_p.h" |
|
5 | 5 | #include "xychartitem_p.h" |
|
6 | 6 | #include "pieanimation_p.h" |
|
7 | 7 | #include "baranimation_p.h" |
|
8 | 8 | #include "barchartitem_p.h" |
|
9 | 9 | #include "areachartitem_p.h" |
|
10 | 10 | #include "splinechartitem_p.h" |
|
11 | 11 | #include "scatterchartitem_p.h" |
|
12 | 12 | #include <QTimer> |
|
13 | 13 | |
|
14 | 14 | Q_DECLARE_METATYPE(QVector<QPointF>) |
|
15 | 15 | Q_DECLARE_METATYPE(QVector<qreal>) |
|
16 | 16 | Q_DECLARE_METATYPE(QVector<QRectF>) |
|
17 | 17 | |
|
18 | 18 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
19 | 19 | |
|
20 | 20 | const static int duration = 1000; |
|
21 | 21 | |
|
22 |
ChartAnimator::ChartAnimator(QObject *parent):QObject(parent), |
|
|
22 | ChartAnimator::ChartAnimator(QObject *parent):QObject(parent), | |
|
23 | m_state(ShowState) | |
|
23 | 24 | { |
|
24 | 25 | } |
|
25 | 26 | |
|
26 | 27 | ChartAnimator::~ChartAnimator() |
|
27 | 28 | { |
|
28 | 29 | } |
|
29 | 30 | |
|
30 | 31 |
void ChartAnimator::addAnimation(Axis* |
|
31 | 32 | { |
|
32 | 33 |
ChartAnimation* |
|
33 | 34 | |
|
34 | 35 | if(!animation) { |
|
35 | 36 | animation = new AxisAnimation(item); |
|
36 | 37 | m_animations.insert(item,animation); |
|
37 | 38 | } |
|
38 | 39 | |
|
39 | 40 | item->setAnimator(this); |
|
40 | 41 | } |
|
41 | 42 | |
|
42 | 43 |
void ChartAnimator::addAnimation(SplineChartItem* |
|
43 | 44 | { |
|
44 | 45 |
ChartAnimation* |
|
45 | 46 | |
|
46 | 47 | if(!animation) { |
|
47 | 48 | animation = new SplineAnimation(item); |
|
48 | 49 | m_animations.insert(item,animation); |
|
49 | 50 | } |
|
50 | 51 | |
|
51 | 52 | item->setAnimator(this); |
|
52 | 53 | } |
|
53 | 54 | |
|
54 | 55 |
void ChartAnimator::addAnimation(ScatterChartItem* |
|
55 | 56 | { |
|
56 | 57 |
ChartAnimation* |
|
57 | 58 | |
|
58 | 59 | if(!animation) { |
|
59 | 60 | animation = new XYAnimation(item); |
|
60 | 61 | m_animations.insert(item,animation); |
|
61 | 62 | } |
|
62 | 63 | |
|
63 | 64 | item->setAnimator(this); |
|
64 | 65 | } |
|
65 | 66 | |
|
66 | 67 |
void ChartAnimator::addAnimation(LineChartItem* |
|
67 | 68 | { |
|
68 | 69 |
ChartAnimation* |
|
69 | 70 | |
|
70 | 71 | if(!animation) { |
|
71 | 72 | animation = new XYAnimation(item); |
|
72 | 73 | m_animations.insert(item,animation); |
|
73 | 74 | } |
|
74 | 75 | |
|
75 | 76 | item->setAnimator(this); |
|
76 | 77 | } |
|
77 | 78 | |
|
78 | 79 |
void ChartAnimator::addAnimation(PieChartItem* |
|
79 | 80 | { |
|
80 | 81 |
ChartAnimation* |
|
81 | 82 | |
|
82 | 83 | if(!animation) { |
|
83 | 84 | animation = new PieAnimation(item); |
|
84 | 85 | m_animations.insert(item,animation); |
|
85 | 86 | } |
|
86 | 87 | |
|
87 | 88 | item->setAnimator(this); |
|
88 | 89 | } |
|
89 | 90 | |
|
90 | 91 |
void ChartAnimator::addAnimation(BarChartItem* |
|
91 | 92 | { |
|
92 | 93 |
ChartAnimation* |
|
93 | 94 | |
|
94 | 95 | if(!animation) { |
|
95 | 96 | animation = new BarAnimation(item); |
|
96 | 97 | m_animations.insert(item,animation); |
|
97 | 98 | } |
|
98 | 99 | |
|
99 | 100 | item->setAnimator(this); |
|
100 | 101 | } |
|
101 | 102 | |
|
102 | 103 | |
|
103 | 104 |
void ChartAnimator::removeAnimation(Chart* |
|
104 | 105 | { |
|
105 | 106 | item->setAnimator(0); |
|
106 | 107 | m_animations.remove(item); |
|
107 | 108 | } |
|
108 | 109 | |
|
109 | 110 |
void ChartAnimator::updateLayout(Axis* |
|
110 | 111 | { |
|
111 | 112 |
AxisAnimation* |
|
112 | 113 | |
|
113 | 114 | Q_ASSERT(animation); |
|
114 | 115 | |
|
115 | 116 | QVector<qreal> oldLayout = item->layout(); |
|
116 | 117 | |
|
117 |
if(newLayout.count()==0) |
|
|
118 | if (newLayout.count() == 0) | |
|
119 | return; | |
|
118 | 120 | |
|
119 | switch(m_state) | |
|
120 | { | |
|
121 | switch (m_state) { | |
|
121 | 122 |
|
|
122 | 123 |
|
|
123 | 124 |
|
|
124 | 125 | |
|
125 |
|
|
|
126 | { | |
|
126 | for(int i = 0, j = oldLayout.count() - 1; i < (oldLayout.count() + 1) / 2; i++, j--) { | |
|
127 | 127 |
|
|
128 | 128 |
|
|
129 | 129 | } |
|
130 | 130 |
|
|
131 | 131 |
|
|
132 | 132 |
|
|
133 | 133 |
|
|
134 | 134 |
|
|
135 | 135 | |
|
136 | 136 |
|
|
137 | { | |
|
138 | 137 |
|
|
139 | 138 | } |
|
140 | } | |
|
141 | 139 | break; |
|
142 | 140 |
|
|
143 | 141 |
|
|
144 | 142 |
|
|
145 | 143 | |
|
146 | 144 |
|
|
147 | { | |
|
148 | 145 |
|
|
149 | 146 | } |
|
150 | } | |
|
151 | 147 | break; |
|
152 | 148 |
|
|
153 | 149 |
|
|
154 | 150 |
|
|
155 | 151 | |
|
156 | 152 |
|
|
157 | { | |
|
158 | 153 |
|
|
159 | 154 | } |
|
160 | } | |
|
161 | 155 | break; |
|
162 | 156 |
|
|
163 | 157 |
|
|
164 | 158 |
|
|
165 | 159 |
|
|
166 | { | |
|
167 | 160 |
|
|
168 | 161 | } |
|
169 | } | |
|
170 | 162 | break; |
|
171 | 163 | } |
|
172 | 164 | |
|
173 | 165 | |
|
174 |
if(animation->state()!=QAbstractAnimation::Stopped) |
|
|
166 | if (animation->state() != QAbstractAnimation::Stopped) | |
|
175 | 167 | animation->stop(); |
|
176 | } | |
|
177 | 168 | |
|
178 | 169 | animation->setDuration(duration); |
|
179 | 170 | animation->setEasingCurve(QEasingCurve::OutQuart); |
|
180 | 171 | QVariantAnimation::KeyValues value; |
|
181 | 172 | animation->setKeyValues(value); //workaround for wrong interpolation call |
|
182 | 173 | animation->setKeyValueAt(0.0, qVariantFromValue(oldLayout)); |
|
183 | 174 | animation->setKeyValueAt(1.0, qVariantFromValue(newLayout)); |
|
184 | 175 | |
|
185 | 176 | QTimer::singleShot(0,animation,SLOT(start())); |
|
186 | 177 | } |
|
187 | 178 | |
|
188 | 179 |
void ChartAnimator::updateLayout(SplineChartItem* |
|
189 | 180 | { |
|
190 | 181 |
SplineAnimation* |
|
191 | 182 | |
|
192 | 183 | Q_ASSERT(animation); |
|
193 | 184 | |
|
194 |
if(newPoints.count()<2 || newControlPoints.count()<2) |
|
|
185 | if (newPoints.count() < 2 || newControlPoints.count() < 2) | |
|
186 | return; | |
|
195 | 187 | |
|
196 | 188 | bool empty = oldPoints.count()==0; |
|
197 | 189 | |
|
198 | 190 | |
|
199 |
if(animation->state()!=QAbstractAnimation::Stopped) |
|
|
191 | if (animation->state() != QAbstractAnimation::Stopped) | |
|
200 | 192 |
|
|
201 | } | |
|
202 | 193 | |
|
203 | 194 | animation->setDuration(duration); |
|
204 | 195 | if(!empty) |
|
205 | 196 | animation->setAnimationType(ChartAnimation::MoveDownAnimation); |
|
206 | 197 | else |
|
207 | 198 | animation->setAnimationType(ChartAnimation::LineDrawAnimation); |
|
208 | 199 | |
|
209 | 200 | animation->setEasingCurve(QEasingCurve::OutQuart); |
|
210 | 201 | animation->setValues(oldPoints,newPoints,oldControlPoints,newControlPoints,index); |
|
211 | 202 | |
|
212 | 203 | QTimer::singleShot(0,animation,SLOT(start())); |
|
213 | 204 | } |
|
214 | 205 | |
|
215 | 206 | |
|
216 | 207 |
void ChartAnimator::updateLayout(XYChartItem* |
|
217 | 208 | { |
|
218 | 209 |
XYAnimation* |
|
219 | 210 | |
|
220 | 211 | Q_ASSERT(animation); |
|
221 | 212 | |
|
222 |
if(newPoints.count()==0) |
|
|
213 | if (newPoints.count() == 0) | |
|
214 | return; | |
|
223 | 215 | |
|
224 | 216 | bool empty = oldPoints.count()==0; |
|
225 | 217 | |
|
226 | 218 | |
|
227 |
if(animation->state()!=QAbstractAnimation::Stopped) |
|
|
219 | if (animation->state() != QAbstractAnimation::Stopped) | |
|
228 | 220 | animation->stop(); |
|
229 | } | |
|
230 | 221 | |
|
231 | 222 | animation->setDuration(duration); |
|
232 | 223 | if(!empty) |
|
233 | 224 | animation->setAnimationType(ChartAnimation::MoveDownAnimation); |
|
234 | 225 | else |
|
235 | 226 | animation->setAnimationType(ChartAnimation::LineDrawAnimation); |
|
236 | 227 | |
|
237 | 228 | animation->setEasingCurve(QEasingCurve::OutQuart); |
|
238 | 229 | animation->setValues(oldPoints,newPoints,index); |
|
239 | 230 | |
|
240 | 231 | QTimer::singleShot(0,animation,SLOT(start())); |
|
241 | 232 | } |
|
242 | 233 | |
|
243 | 234 |
void ChartAnimator::addAnimation(PieChartItem* |
|
244 | 235 | { |
|
245 | 236 |
PieAnimation* |
|
246 | 237 | Q_ASSERT(animation); |
|
247 | 238 | animation->addSlice(slice, sliceData, isEmpty); |
|
248 | 239 | } |
|
249 | 240 | |
|
250 | 241 |
void ChartAnimator::removeAnimation(PieChartItem* |
|
251 | 242 | { |
|
252 | 243 |
PieAnimation* |
|
253 | 244 | Q_ASSERT(animation); |
|
254 | 245 | animation->removeSlice(slice); |
|
255 | 246 | } |
|
256 | 247 | |
|
257 | 248 |
void ChartAnimator::updateLayout(PieChartItem* |
|
258 | 249 | { |
|
259 | 250 |
PieAnimation* |
|
260 | 251 | Q_ASSERT(animation); |
|
261 | 252 | animation->updateValues(layout); |
|
262 | 253 | } |
|
263 | 254 | |
|
264 | 255 |
void ChartAnimator::updateLayout(PieChartItem* |
|
265 | 256 | { |
|
266 | 257 |
PieAnimation* |
|
267 | 258 | Q_ASSERT(animation); |
|
268 | 259 | animation->updateValue(slice, sliceData); |
|
269 | 260 | } |
|
270 | 261 | |
|
271 | 262 |
void ChartAnimator::updateLayout(BarChartItem* |
|
272 | 263 | { |
|
273 | 264 |
BarAnimation* |
|
274 | 265 | Q_ASSERT(animation); |
|
275 | 266 | animation->setDuration(duration); |
|
276 | 267 | animation->setKeyValueAt(0.0, qVariantFromValue(oldLayout)); |
|
277 | 268 | animation->setKeyValueAt(1.0, qVariantFromValue(newLayout)); |
|
278 | 269 | QTimer::singleShot(0,animation,SLOT(start())); |
|
279 | 270 | } |
|
280 | 271 | |
|
281 | 272 | |
|
282 | 273 |
void ChartAnimator::setState(State state,const QPointF& |
|
283 | 274 | { |
|
284 | 275 |
|
|
285 | 276 |
|
|
286 | 277 | } |
|
287 | 278 | |
|
288 | 279 | QTCOMMERCIALCHART_END_NAMESPACE |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -1,127 +1,129 | |||
|
1 | 1 | #include "splineanimation_p.h" |
|
2 | 2 | #include "splinechartitem_p.h" |
|
3 | 3 | |
|
4 | 4 | Q_DECLARE_METATYPE(QVector<QPointF>) |
|
5 | 5 | Q_DECLARE_METATYPE(SplineVector) |
|
6 | 6 | |
|
7 | 7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | 8 | |
|
9 | 9 | SplineAnimation::SplineAnimation(SplineChartItem* item):ChartAnimation(item), |
|
10 | 10 | m_item(item), |
|
11 | 11 | m_dirty(true) |
|
12 | 12 | { |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | 15 | SplineAnimation::~SplineAnimation() |
|
16 | 16 | { |
|
17 | 17 | } |
|
18 | 18 | |
|
19 | 19 |
void SplineAnimation::setValues(QVector<QPointF>& |
|
20 | 20 | { |
|
21 | 21 | int x = oldPoints.count(); |
|
22 | 22 | int y = newPoints.count(); |
|
23 | 23 | |
|
24 | 24 | Q_ASSERT(newPoints.count()*2-2 == newControlPoints.count()); |
|
25 | 25 | |
|
26 | 26 | if(x!=y && abs(x-y)!=1) { |
|
27 | 27 | m_oldSpline.first= newPoints; |
|
28 | 28 | m_oldSpline.second= newControlPoints; |
|
29 | 29 | oldPoints.resize(newPoints.size()); |
|
30 | 30 | oldControlPoints.resize(newControlPoints.size()); |
|
31 | 31 | SplineVector oldPair; |
|
32 | 32 | oldPair.first=oldPoints; |
|
33 | 33 | oldPair.second=oldControlPoints; |
|
34 | 34 | SplineVector newPair; |
|
35 | 35 | newPair.first=newPoints; |
|
36 | 36 | newPair.second=newControlPoints; |
|
37 | 37 | setKeyValueAt(0.0, qVariantFromValue(oldPair)); |
|
38 | 38 | setKeyValueAt(1.0, qVariantFromValue(newPair)); |
|
39 | 39 | m_dirty=false; |
|
40 | 40 | } |
|
41 | 41 | else { |
|
42 | 42 | if(m_dirty) { |
|
43 | 43 | m_oldSpline.first = oldPoints; |
|
44 | 44 | m_oldSpline.second = oldControlPoints; |
|
45 | 45 | m_dirty=false; |
|
46 | 46 | } |
|
47 | 47 | oldPoints = newPoints; |
|
48 | 48 | oldControlPoints = newControlPoints; |
|
49 | 49 | if (y<x) { |
|
50 | 50 | m_oldSpline.first.remove(index); //remove |
|
51 | 51 | m_oldSpline.second.remove(index*2); |
|
52 | 52 | m_oldSpline.second.remove(index*2); |
|
53 | 53 | } |
|
54 | 54 | if (y>x) { |
|
55 | 55 | m_oldSpline.first.insert(index,x>0?m_oldSpline.first[index-1]:newPoints[index]); //add |
|
56 | 56 | m_oldSpline.second.insert((index-1)*2,x>1?m_oldSpline.second[(index-2)*2]:newControlPoints[(index-1)*2]); //add |
|
57 | 57 | m_oldSpline.second.insert((index-1)*2+1,x>1?m_oldSpline.second[(index-2)*2+1]:newControlPoints[(index-1)*2+1]); //add |
|
58 | 58 | } |
|
59 | 59 | SplineVector newPair; |
|
60 | 60 | newPair.first=newPoints; |
|
61 | 61 | newPair.second=newControlPoints; |
|
62 | 62 | setKeyValueAt(0.0, qVariantFromValue(m_oldSpline)); |
|
63 | 63 | setKeyValueAt(1.0, qVariantFromValue(newPair)); |
|
64 | 64 | |
|
65 | 65 | } |
|
66 | 66 | } |
|
67 | 67 | |
|
68 | 68 |
QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant & |
|
69 | 69 | { |
|
70 | 70 | |
|
71 | 71 | SplineVector startPair = qVariantValue< SplineVector >(start); |
|
72 | 72 | SplineVector endPair = qVariantValue< SplineVector >(end); |
|
73 | 73 | SplineVector result; |
|
74 | 74 | |
|
75 | 75 | |
|
76 | 76 | switch(m_type) { |
|
77 | 77 | |
|
78 | 78 |
|
|
79 | ||
|
80 | if(startPair.first.count() != endPair.first.count()) break; | |
|
79 | if (startPair.first.count() != endPair.first.count()) | |
|
80 | break; | |
|
81 | 81 |
|
|
82 | 82 |
|
|
83 | 83 |
|
|
84 | 84 |
|
|
85 | 85 |
|
|
86 | 86 |
|
|
87 |
|
|
|
87 | if (i + 1 >= endPair.first.count()) | |
|
88 | continue; | |
|
88 | 89 |
|
|
89 | 90 |
|
|
90 | 91 |
|
|
91 | 92 |
|
|
92 | 93 |
|
|
93 | 94 |
|
|
94 | 95 |
|
|
95 | 96 | |
|
96 | 97 |
|
|
97 | 98 |
|
|
98 | 99 |
|
|
99 | 100 |
|
|
100 | 101 |
|
|
101 | 102 |
|
|
102 | 103 |
|
|
103 |
|
|
|
104 | if(i + 1 == count) | |
|
105 | break; | |
|
104 | 106 |
|
|
105 | 107 |
|
|
106 | 108 |
|
|
107 | 109 |
|
|
108 | 110 |
|
|
109 | 111 |
|
|
110 | 112 |
|
|
111 | 113 |
|
|
112 | 114 | } |
|
113 | 115 | |
|
114 | 116 | return qVariantFromValue(result); |
|
115 | 117 | } |
|
116 | 118 | |
|
117 | 119 |
void SplineAnimation::updateCurrentValue (const QVariant & |
|
118 | 120 | { |
|
119 | 121 | if(state()!=QAbstractAnimation::Stopped){ //workaround |
|
120 | 122 | m_dirty=true; |
|
121 | 123 | QPair<QVector<QPointF >, QVector<QPointF > > pair = qVariantValue< QPair< QVector<QPointF>, QVector<QPointF> > >(value); |
|
122 | 124 | m_item->setLayout(pair.first,pair.second); |
|
123 | 125 | } |
|
124 | 126 | } |
|
125 | 127 | |
|
126 | 128 | |
|
127 | 129 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,33 +1,32 | |||
|
1 | 1 | #ifndef SPLINEANIMATION_P_H_ |
|
2 | 2 | #define SPLINEANIMATION_P_H_ |
|
3 | 3 | #include "chartanimation_p.h" |
|
4 | 4 | #include <QPointF> |
|
5 | 5 | |
|
6 | 6 | typedef QPair<QVector<QPointF >, QVector<QPointF > > SplineVector; |
|
7 | 7 | |
|
8 | 8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 9 | |
|
10 | ||
|
11 | 10 | class SplineChartItem; |
|
12 | 11 | |
|
13 | 12 | class SplineAnimation : public ChartAnimation |
|
14 | 13 | { |
|
15 | 14 | public: |
|
16 | 15 | |
|
17 | 16 | SplineAnimation(SplineChartItem* item); |
|
18 | 17 | ~SplineAnimation(); |
|
19 | 18 |
void setValues(QVector<QPointF>& |
|
20 | 19 | |
|
21 | 20 | protected: |
|
22 | 21 |
QVariant interpolated(const QVariant &start, const QVariant & |
|
23 | 22 |
void updateCurrentValue |
|
24 | 23 | |
|
25 | 24 | private: |
|
26 | 25 | SplineVector m_oldSpline; |
|
27 | 26 |
SplineChartItem* |
|
28 | 27 | bool m_dirty; |
|
29 | 28 | }; |
|
30 | 29 | |
|
31 | 30 | QTCOMMERCIALCHART_END_NAMESPACE |
|
32 | 31 | |
|
33 | 32 | #endif |
@@ -1,88 +1,89 | |||
|
1 | 1 | #include "xyanimation_p.h" |
|
2 | 2 | #include "xychartitem_p.h" |
|
3 | 3 | |
|
4 | 4 | Q_DECLARE_METATYPE(QVector<QPointF>) |
|
5 | 5 | |
|
6 | 6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | 7 | |
|
8 | 8 | XYAnimation::XYAnimation(XYChartItem *item):ChartAnimation(item), |
|
9 | 9 | m_item(item), |
|
10 | 10 | m_dirty(false) |
|
11 | 11 | { |
|
12 | 12 | } |
|
13 | 13 | |
|
14 | 14 | XYAnimation::~XYAnimation() |
|
15 | 15 | { |
|
16 | 16 | } |
|
17 | 17 | |
|
18 | 18 |
void XYAnimation::setValues(QVector<QPointF>& |
|
19 | 19 | { |
|
20 | ||
|
21 | 20 | int x = oldPoints.count(); |
|
22 | 21 | int y = newPoints.count(); |
|
23 | 22 | |
|
24 | 23 | if(x!=y && abs(x-y)!=1) { |
|
25 | 24 | m_oldPoints = newPoints; |
|
26 | 25 | oldPoints.resize(newPoints.size()); |
|
27 | 26 | setKeyValueAt(0.0, qVariantFromValue(oldPoints)); |
|
28 | 27 | setKeyValueAt(1.0, qVariantFromValue(newPoints)); |
|
29 | 28 | m_dirty=false; |
|
30 | 29 | } |
|
31 | 30 | else { |
|
32 | 31 | if(m_dirty) { |
|
33 | 32 | m_oldPoints = oldPoints; |
|
34 | 33 | m_dirty=false; |
|
35 | 34 | } |
|
36 | 35 | oldPoints = newPoints; |
|
37 | if (y<x) (m_oldPoints.remove(index)); //remove | |
|
38 | if (y>x) (m_oldPoints.insert(index,x>0?m_oldPoints[index-1]:newPoints[index])); //add | |
|
36 | if (y < x) | |
|
37 | m_oldPoints.remove(index); //remove | |
|
38 | if (y > x) | |
|
39 | m_oldPoints.insert(index, x > 0 ? m_oldPoints[index-1] : newPoints[index]); //add | |
|
39 | 40 | setKeyValueAt(0.0, qVariantFromValue(m_oldPoints)); |
|
40 | 41 | setKeyValueAt(1.0, qVariantFromValue(newPoints)); |
|
41 | 42 | Q_ASSERT(m_oldPoints.count() == newPoints.count()); |
|
42 | 43 | } |
|
43 | 44 | } |
|
44 | 45 | |
|
45 | 46 |
QVariant XYAnimation::interpolated(const QVariant &start, const QVariant & |
|
46 | 47 | { |
|
47 | 48 | QVector<QPointF> startVector = qVariantValue<QVector<QPointF> >(start); |
|
48 | 49 | QVector<QPointF> endVector = qVariantValue<QVector<QPointF> >(end); |
|
49 | 50 | QVector<QPointF> result; |
|
50 | 51 | |
|
51 | 52 | switch(m_type) { |
|
52 | 53 | |
|
53 | 54 |
|
|
54 | 55 | |
|
55 |
|
|
|
56 | if (startVector.count() != endVector.count()) | |
|
57 | break; | |
|
56 | 58 | |
|
57 | 59 |
|
|
58 | 60 |
|
|
59 | 61 |
|
|
60 | 62 |
|
|
61 | 63 |
|
|
62 | 64 | |
|
63 | 65 |
|
|
64 | 66 |
|
|
65 | 67 |
|
|
66 |
|
|
|
68 | for(int i = 0; i < endVector.count() * qBound(0.0, progress, 1.0); i++) | |
|
67 | 69 |
|
|
68 | 70 | } |
|
69 | } | |
|
70 | 71 |
|
|
71 | 72 |
|
|
72 | 73 |
|
|
73 | 74 |
|
|
74 | 75 | } |
|
75 | 76 | |
|
76 | 77 | return qVariantFromValue(result); |
|
77 | 78 | } |
|
78 | 79 | |
|
79 | 80 |
void XYAnimation::updateCurrentValue (const QVariant & |
|
80 | 81 | { |
|
81 | 82 | if(state()!=QAbstractAnimation::Stopped){ //workaround |
|
82 | 83 | m_dirty=true; |
|
83 | 84 | QVector<QPointF> vector = qVariantValue<QVector<QPointF> >(value); |
|
84 | 85 | m_item->setLayout(vector); |
|
85 | 86 | } |
|
86 | 87 | } |
|
87 | 88 | |
|
88 | 89 | QTCOMMERCIALCHART_END_NAMESPACE |
|
1 | NO CONTENT: modified file |
General Comments 0
You need to be logged in to leave comments.
Login now