|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -10,7 +10,7 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 | } |
@@ -19,7 +19,8 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 | |
@@ -114,16 +115,15 void ChartAnimator::updateLayout(Axis* item , QVector<qreal>& newLayout) | |||
|
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 | } |
@@ -134,46 +134,37 void ChartAnimator::updateLayout(Axis* item , QVector<qreal>& newLayout) | |||
|
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); |
@@ -191,14 +182,14 void ChartAnimator::updateLayout(SplineChartItem* item, QVector<QPointF>& oldPoi | |||
|
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) |
@@ -219,14 +210,14 void ChartAnimator::updateLayout(XYChartItem* item, QVector<QPointF>& oldPoints | |||
|
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) |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -76,15 +76,16 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant & e | |||
|
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 |
|
@@ -100,7 +101,8 QVariant SplineAnimation::interpolated(const QVariant &start, const QVariant & e | |||
|
100 | 101 |
|
|
101 | 102 |
|
|
102 | 103 |
|
|
103 |
|
|
|
104 | if(i + 1 == count) | |
|
105 | break; | |
|
104 | 106 |
|
|
105 | 107 |
|
|
106 | 108 |
|
@@ -7,7 +7,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 |
@@ -17,7 +17,6 XYAnimation::~XYAnimation() | |||
|
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 | |
@@ -34,8 +33,10 void XYAnimation::setValues(QVector<QPointF>& oldPoints,QVector<QPointF>& newPoi | |||
|
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()); |
@@ -52,7 +53,8 QVariant XYAnimation::interpolated(const QVariant &start, const QVariant & end, | |||
|
52 | 53 | |
|
53 | 54 |
|
|
54 | 55 | |
|
55 |
|
|
|
56 | if (startVector.count() != endVector.count()) | |
|
57 | break; | |
|
56 | 58 | |
|
57 | 59 |
|
|
58 | 60 |
|
@@ -63,10 +65,9 QVariant XYAnimation::interpolated(const QVariant &start, const QVariant & end, | |||
|
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 |
|
|
1 | NO CONTENT: modified file |
General Comments 0
You need to be logged in to leave comments.
Login now