@@ -380,16 +380,14 QList<LegendMarker*> QAreaSeriesPrivate::createLegendMarker(QLegend* legend) | |||
|
380 | 380 | } |
|
381 | 381 | |
|
382 | 382 | |
|
383 | QAbstractAxis* QAreaSeriesPrivate::createAxisX() | |
|
383 | QAbstractAxis* QAreaSeriesPrivate::createAxisX(QObject* parent) | |
|
384 | 384 | { |
|
385 | // TODO: parent? | |
|
386 | return new QValuesAxis(this); | |
|
385 | return new QValuesAxis(parent); | |
|
387 | 386 | } |
|
388 | 387 | |
|
389 | QAbstractAxis* QAreaSeriesPrivate::createAxisY() | |
|
388 | QAbstractAxis* QAreaSeriesPrivate::createAxisY(QObject* parent) | |
|
390 | 389 | { |
|
391 | // TODO: parent? | |
|
392 | return new QValuesAxis(this); | |
|
390 | return new QValuesAxis(parent); | |
|
393 | 391 | } |
|
394 | 392 | |
|
395 | 393 | #include "moc_qareaseries.cpp" |
@@ -46,8 +46,8 public: | |||
|
46 | 46 | void scaleDomain(Domain& domain); |
|
47 | 47 | Chart* createGraphics(ChartPresenter* presenter); |
|
48 | 48 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
49 | QAbstractAxis* createAxisX(); | |
|
50 | QAbstractAxis* createAxisY(); | |
|
49 | QAbstractAxis* createAxisX(QObject* parent = 0); | |
|
50 | QAbstractAxis* createAxisY(QObject* parent = 0); | |
|
51 | 51 | |
|
52 | 52 | Q_SIGNALS: |
|
53 | 53 | void updated(); |
@@ -123,6 +123,7 protected: | |||
|
123 | 123 | Q_DISABLE_COPY(QAbstractAxis); |
|
124 | 124 | friend class ChartDataSet; |
|
125 | 125 | friend class ChartAxis; |
|
126 | friend class ChartPresenter; | |
|
126 | 127 | }; |
|
127 | 128 | |
|
128 | 129 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -34,6 +34,9 | |||
|
34 | 34 | |
|
35 | 35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | 36 | |
|
37 | class ChartPresenter; | |
|
38 | class ChartAxis; | |
|
39 | ||
|
37 | 40 | class QAbstractAxisPrivate : public QObject |
|
38 | 41 | { |
|
39 | 42 | Q_OBJECT |
@@ -44,13 +47,16 public: | |||
|
44 | 47 | Q_SIGNALS: |
|
45 | 48 | void updated(); |
|
46 | 49 | |
|
50 | public: | |
|
51 | virtual ChartAxis* createGraphics(ChartPresenter* presenter) = 0; | |
|
52 | ||
|
47 | 53 | protected: |
|
48 | 54 | virtual void setMin(const QVariant& min) = 0; |
|
49 | 55 | virtual void setMax(const QVariant& max) = 0; |
|
50 | 56 | virtual void setRange(const QVariant& min, const QVariant& max) = 0; |
|
51 | 57 | virtual int ticksCount() const = 0; |
|
52 | 58 | |
|
53 | protected: | |
|
59 | public: | |
|
54 | 60 | QAbstractAxis *q_ptr; |
|
55 | 61 | |
|
56 | 62 | bool m_axisVisible; |
@@ -20,6 +20,8 | |||
|
20 | 20 | |
|
21 | 21 | #include "qcategoriesaxis.h" |
|
22 | 22 | #include "qcategoriesaxis_p.h" |
|
23 | #include "chartaxisx_p.h" | |
|
24 | #include "chartaxisy_p.h" | |
|
23 | 25 | |
|
24 | 26 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | 27 | |
@@ -203,6 +205,17 int QCategoriesAxisPrivate::ticksCount() const | |||
|
203 | 205 | return m_categories.count()+1; |
|
204 | 206 | } |
|
205 | 207 | |
|
208 | ChartAxis* QCategoriesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
|
209 | { | |
|
210 | Q_Q( QCategoriesAxis); | |
|
211 | if(m_orientation == Qt::Vertical){ | |
|
212 | return new ChartAxisY(q,presenter); | |
|
213 | }else{ | |
|
214 | return new ChartAxisX(q,presenter); | |
|
215 | } | |
|
216 | ||
|
217 | } | |
|
218 | ||
|
206 | 219 | #include "moc_qcategoriesaxis.cpp" |
|
207 | 220 | #include "moc_qcategoriesaxis_p.cpp" |
|
208 | 221 |
@@ -43,6 +43,9 public: | |||
|
43 | 43 | QCategoriesAxisPrivate(QCategoriesAxis *q); |
|
44 | 44 | ~QCategoriesAxisPrivate(); |
|
45 | 45 | |
|
46 | public: | |
|
47 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
|
48 | ||
|
46 | 49 | private: |
|
47 | 50 | //range handling |
|
48 | 51 | void setMin(const QVariant& min); |
@@ -20,6 +20,9 | |||
|
20 | 20 | |
|
21 | 21 | #include "qvaluesaxis.h" |
|
22 | 22 | #include "qvaluesaxis_p.h" |
|
23 | #include "chartaxisx_p.h" | |
|
24 | #include "chartaxisy_p.h" | |
|
25 | #include <QDebug> | |
|
23 | 26 | |
|
24 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | 28 | /*! |
@@ -245,6 +248,17 int QValuesAxisPrivate::ticksCount() const | |||
|
245 | 248 | return m_ticksCount; |
|
246 | 249 | } |
|
247 | 250 | |
|
251 | ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
|
252 | { | |
|
253 | Q_Q(QValuesAxis); | |
|
254 | if(m_orientation == Qt::Vertical){ | |
|
255 | return new ChartAxisY(q,presenter); | |
|
256 | }else{ | |
|
257 | return new ChartAxisX(q,presenter); | |
|
258 | } | |
|
259 | ||
|
260 | } | |
|
261 | ||
|
248 | 262 | #include "moc_qvaluesaxis.cpp" |
|
249 | 263 | #include "moc_qvaluesaxis_p.cpp" |
|
250 | 264 |
@@ -48,6 +48,9 Q_SIGNALS: | |||
|
48 | 48 | public Q_SLOTS: |
|
49 | 49 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
50 | 50 | |
|
51 | public: | |
|
52 | ChartAxis* createGraphics(ChartPresenter* presenter); | |
|
53 | ||
|
51 | 54 | protected: |
|
52 | 55 | void setMin(const QVariant& min); |
|
53 | 56 | void setMax(const QVariant& max); |
@@ -608,16 +608,14 QList<LegendMarker*> QBarSeriesPrivate::createLegendMarker(QLegend* legend) | |||
|
608 | 608 | return markers; |
|
609 | 609 | } |
|
610 | 610 | |
|
611 | QAbstractAxis* QBarSeriesPrivate::createAxisX() | |
|
611 | QAbstractAxis* QBarSeriesPrivate::createAxisX(QObject* parent) | |
|
612 | 612 | { |
|
613 | // TODO: parent? | |
|
614 | return new QValuesAxis(this); | |
|
613 | return new QValuesAxis(parent); | |
|
615 | 614 | } |
|
616 | 615 | |
|
617 | QAbstractAxis* QBarSeriesPrivate::createAxisY() | |
|
616 | QAbstractAxis* QBarSeriesPrivate::createAxisY(QObject* parent) | |
|
618 | 617 | { |
|
619 | // TODO: parent? | |
|
620 | return new QValuesAxis(this); | |
|
618 | return new QValuesAxis(parent); | |
|
621 | 619 | } |
|
622 | 620 | |
|
623 | 621 | bool QBarSeriesPrivate::append(QBarSet *set) |
@@ -56,8 +56,8 public: | |||
|
56 | 56 | Chart* createGraphics(ChartPresenter* presenter); |
|
57 | 57 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
58 | 58 | |
|
59 | QAbstractAxis* createAxisX(); | |
|
60 | QAbstractAxis* createAxisY(); | |
|
59 | QAbstractAxis* createAxisX(QObject* parent = 0); | |
|
60 | QAbstractAxis* createAxisY(QObject* parent = 0); | |
|
61 | 61 | |
|
62 | 62 | bool append(QBarSet *set); |
|
63 | 63 | bool remove(QBarSet *set); |
@@ -31,19 +31,9 | |||
|
31 | 31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
32 | 32 | |
|
33 | 33 | ChartDataSet::ChartDataSet(QChart *parent):QObject(parent), |
|
34 | m_axisX(new QValuesAxis(this)), | |
|
35 | m_axisY(new QValuesAxis(this)), | |
|
36 | m_domainIndex(0), | |
|
37 | m_axisXInitialized(false), | |
|
38 | m_axisYInitialized(false) | |
|
34 | m_domainIndex(0) | |
|
39 | 35 | { |
|
40 | //create main domain | |
|
41 | Domain* domain = new Domain(m_axisY); | |
|
42 | m_axisDomainMap.insert(m_axisY,domain); | |
|
43 | QObject::connect(m_axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); | |
|
44 | QObject::connect(m_axisX->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); | |
|
45 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),m_axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
|
46 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),m_axisX->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
|
36 | ||
|
47 | 37 | } |
|
48 | 38 | |
|
49 | 39 | ChartDataSet::~ChartDataSet() |
@@ -60,44 +50,33 void ChartDataSet::addSeries(QAbstractSeries* series) | |||
|
60 | 50 | return; |
|
61 | 51 | } |
|
62 | 52 | |
|
63 | QAbstractAxis* axisX = series->d_ptr->createAxisX(); | |
|
64 |
QAbstractAxis* axisY = |
|
|
53 | QAbstractAxis* axisX = series->d_ptr->createAxisX(this); | |
|
54 | QAbstractAxis* axisY = series->d_ptr->createAxisY(this); | |
|
65 | 55 | |
|
66 | 56 | series->setParent(this); // take ownership |
|
67 | //axisY->setParent(this); // take ownership | |
|
68 | 57 | |
|
69 |
Domain* domain = |
|
|
58 | Domain* domain = new Domain(series); | |
|
70 | 59 | |
|
71 |
if( |
|
|
72 | domain = new Domain(axisY); | |
|
60 | if(axisX){ | |
|
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))); | |
|
63 | axisX->d_ptr->m_orientation=Qt::Horizontal; | |
|
64 | emit axisAdded(axisX,domain); | |
|
65 | m_seriesAxisYMap.insert(series,axisX); | |
|
66 | } | |
|
67 | ||
|
68 | if(axisY){ | |
|
73 | 69 | QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); |
|
74 | QObject::connect(axisX->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int))); | |
|
75 | 70 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); |
|
76 | //initialize | |
|
77 | m_axisDomainMap.insert(axisY,domain); | |
|
71 | axisY->d_ptr->m_orientation=Qt::Vertical; | |
|
78 | 72 | emit axisAdded(axisY,domain); |
|
73 | m_seriesAxisYMap.insert(series,axisY); | |
|
79 | 74 | } |
|
80 | 75 | |
|
81 | if(!m_axisXInitialized){ | |
|
82 | m_axisXInitialized=true; | |
|
83 | // emit axisAdded(m_axisX,domain); | |
|
84 | emit axisAdded(axisX,domain); | |
|
85 | } | |
|
86 | ||
|
87 | if(!m_axisYInitialized && axisY==m_axisY){ | |
|
88 | m_axisYInitialized=true; | |
|
89 | emit axisAdded(m_axisY,domain); | |
|
90 | } | |
|
76 | m_seriesDomainMap.insert(series,domain); | |
|
91 | 77 | |
|
92 | 78 | series->d_ptr->scaleDomain(*domain); |
|
93 | 79 | |
|
94 | if (series->type()== QAbstractSeries::SeriesTypePie && m_seriesAxisXMap.count() == 0) { | |
|
95 | axisX->hide(); | |
|
96 | axisY->hide(); | |
|
97 | } | |
|
98 | ||
|
99 | m_seriesAxisXMap.insert(series,axisY); | |
|
100 | ||
|
101 | 80 | QMapIterator<int, QAbstractSeries*> i(m_indexSeriesMap); |
|
102 | 81 | |
|
103 | 82 | int key=0; |
@@ -118,18 +97,23 void ChartDataSet::addSeries(QAbstractSeries* series) | |||
|
118 | 97 | |
|
119 | 98 | } |
|
120 | 99 | |
|
121 |
|
|
|
100 | void ChartDataSet::removeSeries(QAbstractSeries* series) | |
|
122 | 101 | { |
|
123 |
|
|
|
102 | Domain* domain = m_seriesDomainMap.take(series); | |
|
124 | 103 | |
|
125 |
if(! |
|
|
104 | if(!domain) { | |
|
126 | 105 | qWarning()<<"Can not remove series. Series not found on the chart."; |
|
127 | return 0; | |
|
106 | } | |
|
107 | else { | |
|
108 | delete domain; | |
|
109 | domain =0; | |
|
128 | 110 | } |
|
129 | 111 | |
|
130 | 112 | emit seriesRemoved(series); |
|
131 | 113 | |
|
132 |
m_seriesAxisXMap. |
|
|
114 | QAbstractAxis* axisX = m_seriesAxisXMap.take(series); | |
|
115 | QAbstractAxis* axisY = m_seriesAxisYMap.take(series); | |
|
116 | ||
|
133 | 117 | int key = seriesIndex(series); |
|
134 | 118 | Q_ASSERT(key!=-1); |
|
135 | 119 | |
@@ -139,77 +123,53 QAbstractAxis* ChartDataSet::removeSeries(QAbstractSeries* series) | |||
|
139 | 123 | series->d_ptr->m_chart = 0; |
|
140 | 124 | series->d_ptr->m_dataset = 0; |
|
141 | 125 | |
|
142 |
QList<QAbstractAxis*> axes = |
|
|
126 | QList<QAbstractAxis*> axesX = m_seriesAxisXMap.values(); | |
|
127 | QList<QAbstractAxis*> axesY = m_seriesAxisYMap.values(); | |
|
143 | 128 | |
|
144 |
int |
|
|
129 | int x = axesX.indexOf(axisX); | |
|
130 | int y = axesY.indexOf(axisY); | |
|
145 | 131 | |
|
146 |
if( |
|
|
147 | Domain* domain = m_axisDomainMap.take(axis); | |
|
148 |
|
|
|
149 | if(axis!=m_axisY){ | |
|
150 | axis->setParent(0); | |
|
151 | delete domain; | |
|
152 | }else{ | |
|
153 | m_axisYInitialized=false; | |
|
154 | m_axisDomainMap.insert(m_axisY,domain); | |
|
155 | } | |
|
132 | if(x==-1) { | |
|
133 | emit axisRemoved(axisX); | |
|
134 | delete axisX; | |
|
156 | 135 | } |
|
157 | 136 | |
|
158 | if(m_seriesAxisXMap.values().size()==0) | |
|
159 | { | |
|
160 | m_axisXInitialized=false; | |
|
161 | emit axisRemoved(m_axisX); | |
|
137 | if(y==-1) { | |
|
138 | emit axisRemoved(axisY); | |
|
139 | delete axisY; | |
|
162 | 140 | } |
|
163 | ||
|
164 | return axis; | |
|
165 | 141 | } |
|
166 | 142 | |
|
167 | 143 | void ChartDataSet::removeAllSeries() |
|
168 | 144 | { |
|
169 |
QList<QAbstractSeries*> series = m_series |
|
|
170 | QList<QAbstractAxis*> axes; | |
|
145 | QList<QAbstractSeries*> series = m_seriesDomainMap.keys(); | |
|
171 | 146 | foreach(QAbstractSeries *s , series) { |
|
172 |
|
|
|
173 | if(axis==m_axisY) continue; | |
|
174 | int i = axes.indexOf(axis); | |
|
175 | if(i==-1){ | |
|
176 | axes<<axis; | |
|
177 | } | |
|
147 | removeSeries(s); | |
|
178 | 148 | } |
|
179 | 149 | |
|
180 | 150 | Q_ASSERT(m_seriesAxisXMap.count()==0); |
|
181 |
Q_ASSERT(m_ |
|
|
151 | Q_ASSERT(m_seriesAxisXMap.count()==0); | |
|
152 | Q_ASSERT(m_seriesDomainMap.count()==0); | |
|
182 | 153 | |
|
183 | 154 | qDeleteAll(series); |
|
184 | qDeleteAll(axes); | |
|
185 | 155 | } |
|
186 | 156 | |
|
187 | 157 | void ChartDataSet::zoomInDomain(const QRectF& rect, const QSizeF& size) |
|
188 | 158 | { |
|
189 |
QMapIterator<QAbstract |
|
|
190 | //main domain has to be the last one; | |
|
191 | Domain *domain = m_axisDomainMap.value(m_axisY); | |
|
192 | Q_ASSERT(domain); | |
|
159 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
|
193 | 160 | while (i.hasNext()) { |
|
194 | 161 | i.next(); |
|
195 | if(i.value()==domain) continue; | |
|
196 | 162 | i.value()->zoomIn(rect,size); |
|
197 | 163 | } |
|
198 | domain->zoomIn(rect,size); | |
|
199 | 164 | } |
|
200 | 165 | |
|
201 | 166 | void ChartDataSet::zoomOutDomain(const QRectF& rect, const QSizeF& size) |
|
202 | 167 | { |
|
203 |
QMapIterator<QAbstract |
|
|
204 | //main domain has to be the last one; | |
|
205 | Domain *domain = m_axisDomainMap.value(m_axisY); | |
|
206 | Q_ASSERT(domain); | |
|
168 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
|
207 | 169 | while (i.hasNext()) { |
|
208 | 170 | i.next(); |
|
209 | if(i.value()==domain) continue; | |
|
210 | 171 | i.value()->zoomOut(rect,size); |
|
211 | 172 | } |
|
212 | domain->zoomOut(rect,size); | |
|
213 | 173 | } |
|
214 | 174 | |
|
215 | 175 | int ChartDataSet::seriesCount(QAbstractSeries::SeriesType type) |
@@ -236,14 +196,11 int ChartDataSet::seriesIndex(QAbstractSeries *series) | |||
|
236 | 196 | |
|
237 | 197 | QAbstractAxis* ChartDataSet::axisX(QAbstractSeries *series) const |
|
238 | 198 | { |
|
239 | qDebug() << "axisX"; | |
|
240 | if (series == 0) return m_axisX; | |
|
241 | 199 | return m_seriesAxisXMap.value(series); |
|
242 | 200 | } |
|
243 | 201 | |
|
244 | 202 | QAbstractAxis* ChartDataSet::axisY(QAbstractSeries *series) const |
|
245 | 203 | { |
|
246 | if(series == 0) return m_axisY; | |
|
247 | 204 | return m_seriesAxisYMap.value(series); |
|
248 | 205 | } |
|
249 | 206 | |
@@ -257,36 +214,13 void ChartDataSet::setAxisY(QAbstractSeries *series, QAbstractAxis *axis) | |||
|
257 | 214 | m_seriesAxisYMap.insert(series,axis); |
|
258 | 215 | } |
|
259 | 216 | |
|
260 | Domain* ChartDataSet::domain(QAbstractSeries *series) const | |
|
261 | { | |
|
262 | QAbstractAxis* axis = m_seriesAxisXMap.value(series); | |
|
263 | if(axis){ | |
|
264 | return m_axisDomainMap.value(axis); | |
|
265 | }else | |
|
266 | return 0; | |
|
267 | } | |
|
268 | ||
|
269 | Domain* ChartDataSet::domain(QAbstractAxis* axis) const | |
|
270 | { | |
|
271 | if(!axis || axis==m_axisX) { | |
|
272 | return m_axisDomainMap.value(m_axisY); | |
|
273 | } | |
|
274 | else { | |
|
275 | return m_axisDomainMap.value(axis); | |
|
276 | } | |
|
277 | } | |
|
278 | ||
|
279 | 217 | void ChartDataSet::scrollDomain(qreal dx,qreal dy,const QSizeF& size) |
|
280 | 218 | { |
|
281 |
QMapIterator<QAbstract |
|
|
282 | //main domain has to be the last one; | |
|
283 | Domain *domain = m_axisDomainMap.value(m_axisY); | |
|
219 | QMapIterator<QAbstractSeries*, Domain*> i(m_seriesDomainMap); | |
|
284 | 220 | while (i.hasNext()) { |
|
285 | 221 | i.next(); |
|
286 | if(i.value()==domain) continue; | |
|
287 | 222 | i.value()->move(dx,dy,size); |
|
288 | 223 | } |
|
289 | domain->move(dx,dy,size); | |
|
290 | 224 | } |
|
291 | 225 | |
|
292 | 226 | QList<QAbstractSeries*> ChartDataSet::series() const |
@@ -46,7 +46,7 public: | |||
|
46 | 46 | virtual ~ChartDataSet(); |
|
47 | 47 | |
|
48 | 48 | void addSeries(QAbstractSeries* series); |
|
49 |
|
|
|
49 | void removeSeries(QAbstractSeries* series); | |
|
50 | 50 | void removeAllSeries(); |
|
51 | 51 | void updateSeries(QAbstractSeries* series); |
|
52 | 52 | |
@@ -57,9 +57,6 public: | |||
|
57 | 57 | int seriesCount(QAbstractSeries::SeriesType type); |
|
58 | 58 | int seriesIndex(QAbstractSeries *series); |
|
59 | 59 | |
|
60 | Domain* domain(QAbstractSeries* series) const; | |
|
61 | Domain* domain(QAbstractAxis* axis) const; | |
|
62 | ||
|
63 | 60 | QAbstractAxis* axisX(QAbstractSeries *series) const; |
|
64 | 61 | QAbstractAxis* axisY(QAbstractSeries *series) const; |
|
65 | 62 | |
@@ -82,14 +79,10 private: | |||
|
82 | 79 | private: |
|
83 | 80 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisXMap; |
|
84 | 81 | QMap<QAbstractSeries*, QAbstractAxis*> m_seriesAxisYMap; |
|
85 |
QMap<QAbstract |
|
|
82 | QMap<QAbstractSeries*, Domain*> m_seriesDomainMap; | |
|
86 | 83 | QMap<int, QAbstractSeries*> m_indexSeriesMap; |
|
87 | QAbstractAxis* m_axisX; | |
|
88 | QAbstractAxis* m_axisY; | |
|
89 | ||
|
90 | 84 | int m_domainIndex; |
|
91 | bool m_axisXInitialized; | |
|
92 | bool m_axisYInitialized; | |
|
85 | ||
|
93 | 86 | }; |
|
94 | 87 | |
|
95 | 88 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -21,6 +21,7 | |||
|
21 | 21 | #include "qchart.h" |
|
22 | 22 | #include "qchart_p.h" |
|
23 | 23 | #include "qabstractaxis.h" |
|
24 | #include "qabstractaxis_p.h" | |
|
24 | 25 | #include "chartdataset_p.h" |
|
25 | 26 | #include "charttheme_p.h" |
|
26 | 27 | #include "chartanimator_p.h" |
@@ -69,20 +70,15 void ChartPresenter::setGeometry(const QRectF& rect) | |||
|
69 | 70 | |
|
70 | 71 | void ChartPresenter::handleAxisAdded(QAbstractAxis* axis,Domain* domain) |
|
71 | 72 | { |
|
72 | ChartAxis* item; | |
|
73 | ||
|
74 | if(axis == m_dataset->axisX(0)){ | |
|
75 | item = new ChartAxisX(axis,this); | |
|
76 | }else{ | |
|
77 | item = new ChartAxisY(axis,this); | |
|
78 | } | |
|
73 | ChartAxis* item = axis->d_ptr->createGraphics(this); | |
|
74 | item->setDomain(domain); | |
|
79 | 75 | |
|
80 | 76 | if(m_options.testFlag(QChart::GridAxisAnimations)){ |
|
81 | 77 | item->setAnimator(m_animator); |
|
82 | 78 | item->setAnimation(new AxisAnimation(item)); |
|
83 | 79 | } |
|
84 | 80 | |
|
85 | if(axis==m_dataset->axisX(0)){ | |
|
81 | if(item->axisType()==ChartAxis::X_AXIS){ | |
|
86 | 82 | m_chartTheme->decorate(axis,true); |
|
87 | 83 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int))); |
|
88 | 84 | //initialize |
@@ -115,6 +111,8 void ChartPresenter::handleSeriesAdded(QAbstractSeries* series,Domain* domain) | |||
|
115 | 111 | { |
|
116 | 112 | Chart *item = series->d_ptr->createGraphics(this); |
|
117 | 113 | Q_ASSERT(item); |
|
114 | item->setDomain(domain); | |
|
115 | ||
|
118 | 116 | QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF))); |
|
119 | 117 | QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal))); |
|
120 | 118 | //initialize |
@@ -177,19 +175,23 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options) | |||
|
177 | 175 | |
|
178 | 176 | void ChartPresenter::resetAllElements() |
|
179 | 177 | { |
|
180 |
Q |
|
|
181 | QList<QAbstractSeries *> seriesList = m_chartItems.uniqueKeys(); | |
|
182 | ||
|
183 | foreach(QAbstractAxis *axis, axisList) { | |
|
184 | handleAxisRemoved(axis); | |
|
185 |
handleAxis |
|
|
186 | } | |
|
187 | foreach(QAbstractSeries *series, seriesList) { | |
|
188 | handleSeriesRemoved(series); | |
|
189 | handleSeriesAdded(series,m_dataset->domain(series)); | |
|
190 | // m_dataset->removeSeries(series); | |
|
191 | // m_dataset->addSeries(series); | |
|
178 | QMapIterator<QAbstractAxis*, ChartAxis*> i(m_axisItems); | |
|
179 | while (i.hasNext()) { | |
|
180 | i.next(); | |
|
181 | Domain* domain = i.value()->domain(); | |
|
182 | QAbstractAxis* axis = i.key(); | |
|
183 | handleAxisRemoved(axis); | |
|
184 | handleAxisAdded(axis,domain); | |
|
192 | 185 | } |
|
186 | ||
|
187 | QMapIterator<QAbstractSeries*, Chart*> j(m_chartItems); | |
|
188 | while (j.hasNext()) { | |
|
189 | j.next(); | |
|
190 | Domain* domain = j.value()->domain(); | |
|
191 | QAbstractSeries* series = j.key(); | |
|
192 | handleSeriesRemoved(series); | |
|
193 | handleSeriesAdded(series,domain); | |
|
194 | } | |
|
193 | 195 | } |
|
194 | 196 | |
|
195 | 197 | void ChartPresenter::zoomIn(qreal factor) |
@@ -24,7 +24,6 | |||
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | #include "qvaluesaxis.h" | |
|
28 | 27 | |
|
29 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 29 | |
@@ -130,18 +129,6 Chart* QLineSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||
|
130 | 129 | return line; |
|
131 | 130 | } |
|
132 | 131 | |
|
133 | QAbstractAxis* QLineSeriesPrivate::createAxisX() | |
|
134 | { | |
|
135 | // TODO: parent? | |
|
136 | return new QValuesAxis(this); | |
|
137 | } | |
|
138 | ||
|
139 | QAbstractAxis* QLineSeriesPrivate::createAxisY() | |
|
140 | { | |
|
141 | // TODO: parent? | |
|
142 | return new QValuesAxis(this); | |
|
143 | } | |
|
144 | ||
|
145 | 132 | #include "moc_qlineseries.cpp" |
|
146 | 133 | |
|
147 | 134 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -40,8 +40,6 class QLineSeriesPrivate: public QXYSeriesPrivate | |||
|
40 | 40 | public: |
|
41 | 41 | QLineSeriesPrivate(QLineSeries* q); |
|
42 | 42 | Chart* createGraphics(ChartPresenter* presenter); |
|
43 | QAbstractAxis* createAxisX(); | |
|
44 | QAbstractAxis* createAxisY(); | |
|
45 | 43 | |
|
46 | 44 | private: |
|
47 | 45 | Q_DECLARE_PUBLIC(QLineSeries); |
@@ -755,13 +755,15 QList<LegendMarker*> QPieSeriesPrivate::createLegendMarker(QLegend* legend) | |||
|
755 | 755 | return markers; |
|
756 | 756 | } |
|
757 | 757 | |
|
758 | QAbstractAxis* QPieSeriesPrivate::createAxisX() | |
|
758 | QAbstractAxis* QPieSeriesPrivate::createAxisX(QObject* parent) | |
|
759 | 759 | { |
|
760 | Q_UNUSED(parent); | |
|
760 | 761 | return 0; |
|
761 | 762 | } |
|
762 | 763 | |
|
763 | QAbstractAxis* QPieSeriesPrivate::createAxisY() | |
|
764 | QAbstractAxis* QPieSeriesPrivate::createAxisY(QObject* parent) | |
|
764 | 765 | { |
|
766 | Q_UNUSED(parent); | |
|
765 | 767 | return 0; |
|
766 | 768 | } |
|
767 | 769 |
@@ -47,8 +47,8 public: | |||
|
47 | 47 | void scaleDomain(Domain& domain); |
|
48 | 48 | Chart* createGraphics(ChartPresenter *presenter); |
|
49 | 49 | QList<LegendMarker*> createLegendMarker(QLegend *legend); |
|
50 | QAbstractAxis* createAxisX(); | |
|
51 | QAbstractAxis* createAxisY(); | |
|
50 | QAbstractAxis* createAxisX(QObject* parent); | |
|
51 | QAbstractAxis* createAxisY(QObject* parent); | |
|
52 | 52 | |
|
53 | 53 | void updateDerivativeData(); |
|
54 | 54 |
@@ -52,8 +52,8 public: | |||
|
52 | 52 | virtual void scaleDomain(Domain& domain) = 0; |
|
53 | 53 | virtual Chart* createGraphics(ChartPresenter* presenter) = 0; |
|
54 | 54 | virtual QList<LegendMarker*> createLegendMarker(QLegend* legend) = 0; |
|
55 | virtual QAbstractAxis* createAxisX() = 0; | |
|
56 | virtual QAbstractAxis* createAxisY() = 0; | |
|
55 | virtual QAbstractAxis* createAxisX(QObject* parent) = 0; | |
|
56 | virtual QAbstractAxis* createAxisY(QObject* parent) = 0; | |
|
57 | 57 | |
|
58 | 58 | protected: |
|
59 | 59 | QAbstractSeries *q_ptr; |
@@ -398,15 +398,11 void QChart::setMarginsMinimum(const QRectF& margins) | |||
|
398 | 398 | |
|
399 | 399 | void QChart::setAxisX(QAbstractSeries *series, QAbstractAxis* axis) |
|
400 | 400 | { |
|
401 | // Q_UNUSED(series); | |
|
402 | // Q_UNUSED(axis); | |
|
403 | 401 | d_ptr->m_dataset->setAxisX(series, axis); |
|
404 | 402 | } |
|
405 | 403 | |
|
406 | 404 | void QChart::setAxisY(QAbstractSeries *series, QAbstractAxis* axis) |
|
407 | 405 | { |
|
408 | // Q_UNUSED(series); | |
|
409 | // Q_UNUSED(axis); | |
|
410 | 406 | d_ptr->m_dataset->setAxisY(series, axis); |
|
411 | 407 | } |
|
412 | 408 |
@@ -24,7 +24,6 | |||
|
24 | 24 | #include "chartdataset_p.h" |
|
25 | 25 | #include "charttheme_p.h" |
|
26 | 26 | #include "chartanimator_p.h" |
|
27 | #include "qvaluesaxis.h" | |
|
28 | 27 | |
|
29 | 28 | /*! |
|
30 | 29 | \class QScatterSeries |
@@ -250,19 +249,6 Chart* QScatterSeriesPrivate::createGraphics(ChartPresenter* presenter) | |||
|
250 | 249 | return scatter; |
|
251 | 250 | } |
|
252 | 251 | |
|
253 | QAbstractAxis* QScatterSeriesPrivate::createAxisX() | |
|
254 | { | |
|
255 | // TODO: parent? | |
|
256 | return new QValuesAxis(this); | |
|
257 | } | |
|
258 | ||
|
259 | QAbstractAxis* QScatterSeriesPrivate::createAxisY() | |
|
260 | { | |
|
261 | // TODO: parent? | |
|
262 | return new QValuesAxis(this); | |
|
263 | } | |
|
264 | ||
|
265 | ||
|
266 | 252 | #include "moc_qscatterseries.cpp" |
|
267 | 253 | |
|
268 | 254 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -39,8 +39,6 class QScatterSeriesPrivate: public QXYSeriesPrivate | |||
|
39 | 39 | public: |
|
40 | 40 | QScatterSeriesPrivate(QScatterSeries* q); |
|
41 | 41 | Chart* createGraphics(ChartPresenter* presenter); |
|
42 | QAbstractAxis* createAxisX(); | |
|
43 | QAbstractAxis* createAxisY(); | |
|
44 | 42 | |
|
45 | 43 | private: |
|
46 | 44 | QScatterSeries::MarkerShape m_shape; |
@@ -22,6 +22,7 | |||
|
22 | 22 | #include "qxyseries_p.h" |
|
23 | 23 | #include "domain_p.h" |
|
24 | 24 | #include "legendmarker_p.h" |
|
25 | #include "qvaluesaxis.h" | |
|
25 | 26 | |
|
26 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | 28 | |
@@ -434,6 +435,16 QList<LegendMarker*> QXYSeriesPrivate::createLegendMarker(QLegend* legend) | |||
|
434 | 435 | return list << new XYLegendMarker(q,legend); |
|
435 | 436 | } |
|
436 | 437 | |
|
438 | QAbstractAxis* QXYSeriesPrivate::createAxisX(QObject* parent) | |
|
439 | { | |
|
440 | return new QValuesAxis(parent); | |
|
441 | } | |
|
442 | ||
|
443 | QAbstractAxis* QXYSeriesPrivate::createAxisY(QObject* parent) | |
|
444 | { | |
|
445 | return new QValuesAxis(parent); | |
|
446 | } | |
|
447 | ||
|
437 | 448 | #include "moc_qxyseries.cpp" |
|
438 | 449 | #include "moc_qxyseries_p.cpp" |
|
439 | 450 |
@@ -35,6 +35,7 | |||
|
35 | 35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
36 | 36 | |
|
37 | 37 | class QXYSeries; |
|
38 | class QAbstractAxis; | |
|
38 | 39 | |
|
39 | 40 | class QXYSeriesPrivate: public QAbstractSeriesPrivate |
|
40 | 41 | { |
@@ -46,6 +47,9 public: | |||
|
46 | 47 | void scaleDomain(Domain& domain); |
|
47 | 48 | QList<LegendMarker*> createLegendMarker(QLegend* legend); |
|
48 | 49 | |
|
50 | QAbstractAxis* createAxisX(QObject* parent); | |
|
51 | QAbstractAxis* createAxisY(QObject* parent); | |
|
52 | ||
|
49 | 53 | Q_SIGNALS: |
|
50 | 54 | void updated(); |
|
51 | 55 | // void pointReplaced(int index); |
General Comments 0
You need to be logged in to leave comments.
Login now