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