@@ -1,314 +1,315 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include "chartdataset_p.h" |
|
21 | #include "chartdataset_p.h" | |
22 | #include "qchart.h" |
|
22 | #include "qchart.h" | |
23 | #include "qvaluesaxis.h" |
|
23 | #include "qvaluesaxis.h" | |
24 | #include "qvaluesaxis_p.h" |
|
24 | #include "qvaluesaxis_p.h" | |
25 | #include "qabstractseries_p.h" |
|
25 | #include "qabstractseries_p.h" | |
26 | #include "qbarseries.h" |
|
26 | #include "qbarseries.h" | |
27 | #include "qstackedbarseries.h" |
|
27 | #include "qstackedbarseries.h" | |
28 | #include "qpercentbarseries.h" |
|
28 | #include "qpercentbarseries.h" | |
29 | #include "qpieseries.h" |
|
29 | #include "qpieseries.h" | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent), |
|
33 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent), | |
34 | m_domainIndex(0) |
|
34 | m_domainIndex(0) | |
35 | { |
|
35 | { | |
36 |
|
36 | |||
37 | } |
|
37 | } | |
38 |
|
38 | |||
39 | ChartDataSet::~ChartDataSet() |
|
39 | ChartDataSet::~ChartDataSet() | |
40 | { |
|
40 | { | |
41 | removeAllSeries(); |
|
41 | removeAllSeries(); | |
42 | } |
|
42 | } | |
43 |
|
43 | |||
44 | void ChartDataSet::addSeries(QAbstractSeries* series) |
|
44 | void ChartDataSet::addSeries(QAbstractSeries* series) | |
45 | { |
|
45 | { | |
46 | QAbstractAxis* axis = m_seriesAxisXMap.value(series); |
|
46 | QAbstractAxis* axis = m_seriesAxisXMap.value(series); | |
47 |
|
47 | |||
48 | if(axis) { |
|
48 | if(axis) { | |
49 | qWarning() << "Can not add series. Series already on the chart"; |
|
49 | qWarning() << "Can not add series. Series already on the chart"; | |
50 | return; |
|
50 | return; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | QAbstractAxis* axisX = series->d_ptr->createAxisX(this); |
|
53 | QAbstractAxis* axisX = series->d_ptr->createAxisX(this); | |
54 | QAbstractAxis* axisY = series->d_ptr->createAxisY(this); |
|
54 | QAbstractAxis* axisY = series->d_ptr->createAxisY(this); | |
55 |
|
55 | |||
56 | series->setParent(this); // take ownership |
|
56 | series->setParent(this); // take ownership | |
57 |
|
57 | |||
58 | Domain* domain = new Domain(series); |
|
58 | Domain* domain = new Domain(series); | |
59 |
|
59 | |||
60 | if(axisX){ |
|
60 | if(axisX){ | |
61 | QObject::connect(axisX->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); |
|
61 | QObject::connect(axisX->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); | |
62 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
62 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
63 | axisX->d_ptr->m_orientation=Qt::Horizontal; |
|
63 | axisX->d_ptr->m_orientation=Qt::Horizontal; | |
64 | emit axisAdded(axisX,domain); |
|
64 | emit axisAdded(axisX,domain); | |
65 | m_seriesAxisXMap.insert(series,axisX); |
|
65 | m_seriesAxisXMap.insert(series,axisX); | |
66 | } |
|
66 | } | |
67 |
|
67 | |||
68 | if(axisY){ |
|
68 | if(axisY){ | |
69 | QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); |
|
69 | QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); | |
70 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
70 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
71 | axisY->d_ptr->m_orientation=Qt::Vertical; |
|
71 | axisY->d_ptr->m_orientation=Qt::Vertical; | |
72 | emit axisAdded(axisY,domain); |
|
72 | emit axisAdded(axisY,domain); | |
73 | m_seriesAxisYMap.insert(series,axisY); |
|
73 | m_seriesAxisYMap.insert(series,axisY); | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | m_seriesDomainMap.insert(series,domain); |
|
76 | m_seriesDomainMap.insert(series,domain); | |
77 |
|
77 | |||
78 | series->d_ptr->scaleDomain(*domain); |
|
78 | series->d_ptr->scaleDomain(*domain); | |
79 |
|
79 | |||
80 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); |
|
80 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
81 |
|
81 | |||
82 | int key=0; |
|
82 | int key=0; | |
83 | while (i.hasNext()) { |
|
83 | while (i.hasNext()) { | |
84 | i.next(); |
|
84 | i.next(); | |
85 | if(i.key()!=key) { |
|
85 | if(i.key()!=key) { | |
86 | break; |
|
86 | break; | |
87 | } |
|
87 | } | |
88 | key++; |
|
88 | key++; | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
91 | m_indexSeriesMap.insert(key,series); |
|
91 | m_indexSeriesMap.insert(key,series); | |
92 |
|
92 | |||
93 | series->d_ptr->m_chart = qobject_cast<QChart*>(parent()); |
|
93 | series->d_ptr->m_chart = qobject_cast<QChart*>(parent()); | |
94 | series->d_ptr->m_dataset = this; |
|
94 | series->d_ptr->m_dataset = this; | |
95 |
|
95 | |||
96 | emit seriesAdded(series,domain); |
|
96 | emit seriesAdded(series,domain); | |
97 |
|
97 | |||
98 | } |
|
98 | } | |
99 |
|
99 | |||
100 | void ChartDataSet::removeSeries(QAbstractSeries* series) |
|
100 | void ChartDataSet::removeSeries(QAbstractSeries* series) | |
101 | { |
|
101 | { | |
102 | Domain* domain = m_seriesDomainMap.take(series); |
|
102 | Domain* domain = m_seriesDomainMap.take(series); | |
103 |
|
103 | |||
104 | if(!domain) { |
|
104 | if(!domain) { | |
105 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
105 | qWarning()<<"Can not remove series. Series not found on the chart."; | |
106 | } |
|
106 | } | |
107 |
|
107 | |||
108 | emit seriesRemoved(series); |
|
108 | emit seriesRemoved(series); | |
109 |
|
109 | |||
110 | delete domain; |
|
110 | delete domain; | |
111 | domain = 0; |
|
111 | domain = 0; | |
112 |
|
112 | |||
113 | int key = seriesIndex(series); |
|
113 | int key = seriesIndex(series); | |
114 | Q_ASSERT(key!=-1); |
|
114 | Q_ASSERT(key!=-1); | |
115 |
|
115 | |||
116 | m_indexSeriesMap.remove(key); |
|
116 | m_indexSeriesMap.remove(key); | |
117 |
|
117 | |||
118 | series->setParent(0); |
|
118 | series->setParent(0); | |
119 | series->d_ptr->m_chart = 0; |
|
119 | series->d_ptr->m_chart = 0; | |
120 | series->d_ptr->m_dataset = 0; |
|
120 | series->d_ptr->m_dataset = 0; | |
121 |
|
121 | |||
122 | QAbstractAxis* axisX = m_seriesAxisXMap.take(series); |
|
122 | QAbstractAxis* axisX = m_seriesAxisXMap.take(series); | |
123 |
|
123 | |||
124 | if(axisX) { |
|
124 | if(axisX) { | |
125 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); |
|
125 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); | |
126 | int x = axesX.indexOf(axisX); |
|
126 | int x = axesX.indexOf(axisX); | |
127 |
|
127 | |||
128 | if(x==-1) { |
|
128 | if(x==-1) { | |
129 | emit axisRemoved(axisX); |
|
129 | emit axisRemoved(axisX); | |
130 |
|
|
130 | axisX->deleteLater(); | |
131 | } |
|
131 | } | |
132 | } |
|
132 | } | |
133 |
|
133 | |||
134 | QAbstractAxis* axisY = m_seriesAxisYMap.take(series); |
|
134 | QAbstractAxis* axisY = m_seriesAxisYMap.take(series); | |
135 |
|
135 | |||
136 | if(axisY) { |
|
136 | if(axisY) { | |
137 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); |
|
137 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); | |
138 |
|
138 | |||
139 | int y = axesY.indexOf(axisY); |
|
139 | int y = axesY.indexOf(axisY); | |
140 |
|
140 | |||
141 | if(y==-1) { |
|
141 | if(y==-1) { | |
142 | emit axisRemoved(axisY); |
|
142 | emit axisRemoved(axisY); | |
143 |
|
|
143 | axisY->deleteLater(); | |
144 | } |
|
144 | } | |
145 | } |
|
145 | } | |
146 | } |
|
146 | } | |
147 |
|
147 | |||
148 | void ChartDataSet::removeAllSeries() |
|
148 | void ChartDataSet::removeAllSeries() | |
149 | { |
|
149 | { | |
150 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); |
|
150 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); | |
151 | foreach(QAbstractSeries *s , series) { |
|
151 | foreach(QAbstractSeries *s , series) { | |
152 | removeSeries(s); |
|
152 | removeSeries(s); | |
153 | } |
|
153 | } | |
154 |
|
154 | |||
155 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
155 | Q_ASSERT(m_seriesAxisXMap.count()==0); | |
156 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
156 | Q_ASSERT(m_seriesAxisXMap.count()==0); | |
157 | Q_ASSERT(m_seriesDomainMap.count()==0); |
|
157 | Q_ASSERT(m_seriesDomainMap.count()==0); | |
158 |
|
158 | |||
159 | qDeleteAll(series); |
|
159 | qDeleteAll(series); | |
160 | } |
|
160 | } | |
161 |
|
161 | |||
162 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
162 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) | |
163 | { |
|
163 | { | |
164 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
164 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
165 | while (i.hasNext()) { |
|
165 | while (i.hasNext()) { | |
166 | i.next(); |
|
166 | i.next(); | |
167 | i.value()->zoomIn(rect,size); |
|
167 | i.value()->zoomIn(rect,size); | |
168 | } |
|
168 | } | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
171 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) | |
172 | { |
|
172 | { | |
173 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
173 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
174 | while (i.hasNext()) { |
|
174 | while (i.hasNext()) { | |
175 | i.next(); |
|
175 | i.next(); | |
176 | i.value()->zoomOut(rect,size); |
|
176 | i.value()->zoomOut(rect,size); | |
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) |
|
180 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) | |
181 | { |
|
181 | { | |
182 | int count=0; |
|
182 | int count=0; | |
183 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(m_seriesAxisXMap); |
|
183 | QMapIterator<QAbstractSeries*, QAbstractAxis*> i(m_seriesAxisXMap); | |
184 | while (i.hasNext()) { |
|
184 | while (i.hasNext()) { | |
185 | i.next(); |
|
185 | i.next(); | |
186 | if(i.key()->type()==type) count++; |
|
186 | if(i.key()->type()==type) count++; | |
187 | } |
|
187 | } | |
188 | return count; |
|
188 | return count; | |
189 | } |
|
189 | } | |
190 |
|
190 | |||
191 | int ChartDataSet::seriesIndex(QAbstractSeries *series) |
|
191 | int ChartDataSet::seriesIndex(QAbstractSeries *series) | |
192 | { |
|
192 | { | |
193 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); |
|
193 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); | |
194 | while (i.hasNext()) { |
|
194 | while (i.hasNext()) { | |
195 | i.next(); |
|
195 | i.next(); | |
196 | if (i.value() == series) |
|
196 | if (i.value() == series) | |
197 | return i.key(); |
|
197 | return i.key(); | |
198 | } |
|
198 | } | |
199 | return -1; |
|
199 | return -1; | |
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const |
|
202 | QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const | |
203 | { |
|
203 | { | |
204 | if(series == 0) return m_seriesAxisXMap.begin().value(); |
|
204 | if(series == 0) return m_seriesAxisXMap.begin().value(); | |
205 | return m_seriesAxisXMap.value(series); |
|
205 | return m_seriesAxisXMap.value(series); | |
206 | } |
|
206 | } | |
207 |
|
207 | |||
208 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const |
|
208 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const | |
209 | { |
|
209 | { | |
210 | if(series == 0) return m_seriesAxisYMap.begin().value(); |
|
210 | if(series == 0) return m_seriesAxisYMap.begin().value(); | |
211 | return m_seriesAxisYMap.value(series); |
|
211 | return m_seriesAxisYMap.value(series); | |
212 | } |
|
212 | } | |
213 |
|
213 | |||
214 | void ChartDataSet::setAxisX(QAbstractSeries *series, QAbstractAxis *axis) |
|
214 | void ChartDataSet::setAxisX(QAbstractSeries *series, QAbstractAxis *axis) | |
215 | { |
|
215 | { | |
|
216 | ||||
216 | Q_ASSERT(axis); |
|
217 | Q_ASSERT(axis); | |
217 | QAbstractAxis *oldAxis = m_seriesAxisXMap.take(series); |
|
218 | QAbstractAxis *oldAxis = m_seriesAxisXMap.take(series); | |
218 |
|
219 | |||
219 | if(!oldAxis) { |
|
220 | if(!oldAxis) { | |
220 | qWarning()<<"Series not found on the chart."; |
|
221 | qWarning()<<"Series not found on the chart."; | |
221 | return; |
|
222 | return; | |
222 | } |
|
223 | } | |
223 |
|
224 | |||
224 | if(axis->d_ptr->m_orientation==Qt::Vertical) { |
|
225 | if(axis->d_ptr->m_orientation==Qt::Vertical) { | |
225 | qWarning()<<"Axis already defined as axis Y"; |
|
226 | qWarning()<<"Axis already defined as axis Y"; | |
226 | return; |
|
227 | return; | |
227 | } |
|
228 | } | |
228 |
|
229 | |||
229 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); |
|
230 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); | |
230 | int x = axesX.indexOf(oldAxis); |
|
231 | int x = axesX.indexOf(oldAxis); | |
231 | if(x==-1) { |
|
232 | if(x==-1) { | |
232 | emit axisRemoved(oldAxis); |
|
233 | emit axisRemoved(oldAxis); | |
233 | delete oldAxis; |
|
234 | oldAxis->deleteLater(); | |
234 | } |
|
235 | } | |
235 |
|
236 | |||
236 | Domain* domain = m_seriesDomainMap.value(series); |
|
237 | Domain* domain = m_seriesDomainMap.value(series); | |
237 | Q_ASSERT(domain); |
|
238 | Q_ASSERT(domain); | |
238 |
|
239 | |||
239 | QObject::connect(axis->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); |
|
240 | QObject::connect(axis->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); | |
240 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axis->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
241 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axis->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
241 |
|
242 | |||
242 | x = axesX.indexOf(axis); |
|
243 | x = axesX.indexOf(axis); | |
243 | if(x==-1) { |
|
244 | if(x==-1) { | |
244 | axis->d_ptr->m_orientation=Qt::Horizontal; |
|
245 | axis->d_ptr->m_orientation=Qt::Horizontal; | |
245 | emit axisAdded(axis,domain); |
|
246 | emit axisAdded(axis,domain); | |
246 | } |
|
247 | } | |
247 |
|
248 | |||
248 | m_seriesAxisXMap.insert(series,axis); |
|
249 | m_seriesAxisXMap.insert(series,axis); | |
249 | } |
|
250 | } | |
250 |
|
251 | |||
251 | void ChartDataSet::setAxisY(QAbstractSeries *series, QAbstractAxis *axis) |
|
252 | void ChartDataSet::setAxisY(QAbstractSeries *series, QAbstractAxis *axis) | |
252 | { |
|
253 | { | |
253 | Q_ASSERT(axis); |
|
254 | Q_ASSERT(axis); | |
254 | QAbstractAxis *oldAxis = m_seriesAxisYMap.take(series); |
|
255 | QAbstractAxis *oldAxis = m_seriesAxisYMap.take(series); | |
255 |
|
256 | |||
256 | if(!oldAxis) { |
|
257 | if(!oldAxis) { | |
257 | qWarning()<<"Series not found on the chart or axis is unsupported for given series type"; |
|
258 | qWarning()<<"Series not found on the chart or axis is unsupported for given series type"; | |
258 | return; |
|
259 | return; | |
259 | } |
|
260 | } | |
260 |
|
261 | |||
261 | if(axis->d_ptr->m_orientation==Qt::Horizontal) { |
|
262 | if(axis->d_ptr->m_orientation==Qt::Horizontal) { | |
262 | qWarning()<<"Axis already defined as axis X"; |
|
263 | qWarning()<<"Axis already defined as axis X"; | |
263 | return; |
|
264 | return; | |
264 | } |
|
265 | } | |
265 |
|
266 | |||
266 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); |
|
267 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); | |
267 | int y = axesY.indexOf(oldAxis); |
|
268 | int y = axesY.indexOf(oldAxis); | |
268 | if(y==-1) { |
|
269 | if(y==-1) { | |
269 | emit axisRemoved(oldAxis); |
|
270 | emit axisRemoved(oldAxis); | |
270 | delete oldAxis; |
|
271 | oldAxis->deleteLater(); | |
271 | } |
|
272 | } | |
272 |
|
273 | |||
273 | Domain* domain = m_seriesDomainMap.value(series); |
|
274 | Domain* domain = m_seriesDomainMap.value(series); | |
274 | Q_ASSERT(domain); |
|
275 | Q_ASSERT(domain); | |
275 |
|
276 | |||
276 | QObject::connect(axis->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); |
|
277 | QObject::connect(axis->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); | |
277 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axis->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
278 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axis->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
278 |
|
279 | |||
279 | y = axesY.indexOf(axis); |
|
280 | y = axesY.indexOf(axis); | |
280 | if(y==-1) { |
|
281 | if(y==-1) { | |
281 | axis->d_ptr->m_orientation=Qt::Vertical; |
|
282 | axis->d_ptr->m_orientation=Qt::Vertical; | |
282 | emit axisAdded(axis,domain); |
|
283 | emit axisAdded(axis,domain); | |
283 | } |
|
284 | } | |
284 |
|
285 | |||
285 | m_seriesAxisYMap.insert(series,axis); |
|
286 | m_seriesAxisYMap.insert(series,axis); | |
286 | } |
|
287 | } | |
287 |
|
288 | |||
288 | Domain* ChartDataSet::domain(QAbstractSeries *series) const |
|
289 | Domain* ChartDataSet::domain(QAbstractSeries *series) const | |
289 | { |
|
290 | { | |
290 | return m_seriesDomainMap.value(series); |
|
291 | return m_seriesDomainMap.value(series); | |
291 | } |
|
292 | } | |
292 |
|
293 | |||
293 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) |
|
294 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) | |
294 | { |
|
295 | { | |
295 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); |
|
296 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
296 | while (i.hasNext()) { |
|
297 | while (i.hasNext()) { | |
297 | i.next(); |
|
298 | i.next(); | |
298 | i.value()->move(dx,dy,size); |
|
299 | i.value()->move(dx,dy,size); | |
299 | } |
|
300 | } | |
300 | } |
|
301 | } | |
301 |
|
302 | |||
302 | QList<QAbstractSeries*> ChartDataSet::series() const |
|
303 | QList<QAbstractSeries*> ChartDataSet::series() const | |
303 | { |
|
304 | { | |
304 | return m_seriesAxisXMap.keys(); |
|
305 | return m_seriesAxisXMap.keys(); | |
305 | } |
|
306 | } | |
306 |
|
307 | |||
307 | void ChartDataSet::updateSeries(QAbstractSeries *series) |
|
308 | void ChartDataSet::updateSeries(QAbstractSeries *series) | |
308 | { |
|
309 | { | |
309 | emit seriesUpdated(series); |
|
310 | emit seriesUpdated(series); | |
310 | } |
|
311 | } | |
311 |
|
312 | |||
312 | #include "moc_chartdataset_p.cpp" |
|
313 | #include "moc_chartdataset_p.cpp" | |
313 |
|
314 | |||
314 | QTCOMMERCIALCHART_END_NAMESPACE |
|
315 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now