@@ -0,0 +1,85 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
|
25 | // implementation detail. This header file may change from version to | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | #ifndef QCHARTAXIS_P_H_ | |
|
31 | #define QCHARTAXIS_P_H_ | |
|
32 | ||
|
33 | #include "qchartaxis.h" | |
|
34 | ||
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
36 | ||
|
37 | class QChartAxisPrivate : public QObject | |
|
38 | { | |
|
39 | Q_OBJECT | |
|
40 | public: | |
|
41 | QChartAxisPrivate(QChartAxis *q); | |
|
42 | ~QChartAxisPrivate(); | |
|
43 | ||
|
44 | Q_SIGNALS: | |
|
45 | void updated(); | |
|
46 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); | |
|
47 | ||
|
48 | public Q_SLOTS: | |
|
49 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |
|
50 | ||
|
51 | private: | |
|
52 | QChartAxis *q_ptr; | |
|
53 | ||
|
54 | bool m_axisVisible; | |
|
55 | QPen m_axisPen; | |
|
56 | QBrush m_axisBrush; | |
|
57 | ||
|
58 | bool m_gridLineVisible; | |
|
59 | QPen m_gridLinePen; | |
|
60 | ||
|
61 | bool m_labelsVisible; | |
|
62 | QPen m_labelsPen; | |
|
63 | QBrush m_labelsBrush; | |
|
64 | QFont m_labelsFont; | |
|
65 | int m_labelsAngle; | |
|
66 | ||
|
67 | bool m_shadesVisible; | |
|
68 | QPen m_shadesPen; | |
|
69 | QBrush m_shadesBrush; | |
|
70 | qreal m_shadesOpacity; | |
|
71 | ||
|
72 | qreal m_min; | |
|
73 | qreal m_max; | |
|
74 | ||
|
75 | int m_ticksCount; | |
|
76 | QChartAxisCategories m_category; | |
|
77 | ||
|
78 | bool m_niceNumbers; | |
|
79 | ||
|
80 | friend class QChartAxis; | |
|
81 | }; | |
|
82 | ||
|
83 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
84 | ||
|
85 | #endif |
@@ -0,0 +1,56 | |||
|
1 | /**************************************************************************** | |
|
2 | ** | |
|
3 | ** Copyright (C) 2012 Digia Plc | |
|
4 | ** All rights reserved. | |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
|
6 | ** | |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
|
8 | ** | |
|
9 | ** $QT_BEGIN_LICENSE$ | |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
|
13 | ** a written agreement between you and Digia. | |
|
14 | ** | |
|
15 | ** If you have questions regarding the use of this file, please use | |
|
16 | ** contact form at http://qt.digia.com | |
|
17 | ** $QT_END_LICENSE$ | |
|
18 | ** | |
|
19 | ****************************************************************************/ | |
|
20 | ||
|
21 | // W A R N I N G | |
|
22 | // ------------- | |
|
23 | // | |
|
24 | // This file is not part of the QtCommercial Chart API. It exists purely as an | |
|
25 | // implementation detail. This header file may change from version to | |
|
26 | // version without notice, or even be removed. | |
|
27 | // | |
|
28 | // We mean it. | |
|
29 | ||
|
30 | #ifndef QCHARTAXISCATEGORIES_P_H_ | |
|
31 | #define QCHARTAXISCATEGORIES_P_H_ | |
|
32 | ||
|
33 | #include "qchartaxiscategories.h" | |
|
34 | ||
|
35 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
|
36 | ||
|
37 | class QChartAxisCategoriesPrivate : public QObject | |
|
38 | { | |
|
39 | Q_OBJECT | |
|
40 | public: | |
|
41 | QChartAxisCategoriesPrivate(QChartAxisCategories *q); | |
|
42 | ~QChartAxisCategoriesPrivate(); | |
|
43 | ||
|
44 | Q_SIGNALS: | |
|
45 | void updated(); | |
|
46 | ||
|
47 | private: | |
|
48 | QChartAxisCategories *q_ptr; | |
|
49 | QMap<qreal,QString> m_map; | |
|
50 | friend class QChartAxisCategories; | |
|
51 | ||
|
52 | }; | |
|
53 | ||
|
54 | QTCOMMERCIALCHART_END_NAMESPACE | |
|
55 | ||
|
56 | #endif |
@@ -20,6 +20,8 | |||
|
20 | 20 | |
|
21 | 21 | #include "axis_p.h" |
|
22 | 22 | #include "qchartaxis.h" |
|
23 | #include "qchartaxis_p.h" | |
|
24 | #include "qchartaxiscategories_p.h" | |
|
23 | 25 | #include "chartpresenter_p.h" |
|
24 | 26 | #include "chartanimator_p.h" |
|
25 | 27 | #include <QPainter> |
@@ -48,8 +50,8 Axis::Axis(QChartAxis *axis,ChartPresenter *presenter,AxisType type) : Chart(pre | |||
|
48 | 50 | m_shades->setZValue(ChartPresenter::ShadesZValue); |
|
49 | 51 | m_grid->setZValue(ChartPresenter::GridZValue); |
|
50 | 52 | |
|
51 | connect(m_chartAxis,SIGNAL(updated()),this,SLOT(handleAxisUpdated())); | |
|
52 | connect(m_chartAxis->categories(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated())); | |
|
53 | QObject::connect(m_chartAxis->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisUpdated())); | |
|
54 | QObject::connect(m_chartAxis->categories()->d_ptr.data(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated())); | |
|
53 | 55 | |
|
54 | 56 | handleAxisUpdated(); |
|
55 | 57 | } |
@@ -455,10 +457,9 void Axis::handleGeometryChanged(const QRectF &rect) | |||
|
455 | 457 | |
|
456 | 458 | void Axis::axisSelected() |
|
457 | 459 | { |
|
458 | qDebug()<<"TODO axis clicked"; | |
|
460 | qDebug()<<"TODO: axis clicked"; | |
|
459 | 461 | } |
|
460 | 462 | |
|
461 | //TODO "nice numbers algorithm" | |
|
462 | 463 | #include "moc_axis_p.cpp" |
|
463 | 464 | |
|
464 | 465 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -7,7 +7,9 SOURCES += \ | |||
|
7 | 7 | $$PWD/qchartaxiscategories.cpp |
|
8 | 8 | |
|
9 | 9 | PRIVATE_HEADERS += \ |
|
10 | $$PWD/axis_p.h | |
|
10 | $$PWD/axis_p.h \ | |
|
11 | $$PWD/qchartaxis_p.h \ | |
|
12 | $$PWD/qchartaxiscategories_p.h | |
|
11 | 13 | |
|
12 | 14 | PUBLIC_HEADERS += \ |
|
13 | 15 | $$PWD/qchartaxis.h \ |
@@ -19,6 +19,7 | |||
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qchartaxis.h" |
|
22 | #include "qchartaxis_p.h" | |
|
22 | 23 | |
|
23 | 24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 25 | |
@@ -178,16 +179,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
178 | 179 | */ |
|
179 | 180 | |
|
180 | 181 | QChartAxis::QChartAxis(QObject *parent) : QObject(parent), |
|
181 | m_axisVisible(true), | |
|
182 | m_gridLineVisible(true), | |
|
183 | m_labelsVisible(true), | |
|
184 | m_labelsAngle(0), | |
|
185 | m_shadesVisible(false), | |
|
186 | m_shadesOpacity(1.0), | |
|
187 | m_min(0), | |
|
188 | m_max(0), | |
|
189 | m_ticksCount(5), | |
|
190 | m_niceNumbers(false) | |
|
182 | d_ptr(new QChartAxisPrivate(this)) | |
|
191 | 183 | { |
|
192 | 184 | |
|
193 | 185 | } |
@@ -205,10 +197,15 QChartAxis::~QChartAxis() | |||
|
205 | 197 | */ |
|
206 | 198 | void QChartAxis::setAxisPen(const QPen &pen) |
|
207 | 199 | { |
|
208 |
if (pen |
|
|
209 |
|
|
|
210 | emit updated(); | |
|
200 | if (d_ptr->m_axisPen!=pen) { | |
|
201 | d_ptr->m_axisPen = pen; | |
|
202 | emit d_ptr->updated(); | |
|
203 | } | |
|
211 | 204 |
|
|
205 | ||
|
206 | QPen QChartAxis::axisPen() const | |
|
207 | { | |
|
208 | return d_ptr->m_axisPen; | |
|
212 | 209 | } |
|
213 | 210 | |
|
214 | 211 | /*! |
@@ -216,10 +213,15 void QChartAxis::setAxisPen(const QPen &pen) | |||
|
216 | 213 | */ |
|
217 | 214 | void QChartAxis::setAxisVisible(bool visible) |
|
218 | 215 | { |
|
219 | if (m_axisVisible != visible) { | |
|
220 | m_axisVisible = visible; | |
|
221 | emit updated(); | |
|
216 | if (d_ptr->m_axisVisible != visible) { | |
|
217 | d_ptr->m_axisVisible = visible; | |
|
218 | emit d_ptr->updated(); | |
|
219 | } | |
|
222 | 220 |
|
|
221 | ||
|
222 | bool QChartAxis::isAxisVisible() const | |
|
223 | { | |
|
224 | return d_ptr->m_axisVisible; | |
|
223 | 225 | } |
|
224 | 226 | |
|
225 | 227 | /*! |
@@ -227,43 +229,61 void QChartAxis::setAxisVisible(bool visible) | |||
|
227 | 229 | */ |
|
228 | 230 | void QChartAxis::setGridLineVisible(bool visible) |
|
229 | 231 | { |
|
230 | if (m_gridLineVisible != visible) { | |
|
231 | m_gridLineVisible = visible; | |
|
232 | emit updated(); | |
|
232 | if (d_ptr->m_gridLineVisible != visible) { | |
|
233 | d_ptr->m_gridLineVisible = visible; | |
|
234 | emit d_ptr->updated(); | |
|
233 | 235 | } |
|
234 | 236 | } |
|
235 | 237 | |
|
238 | bool QChartAxis::isGridLineVisible() const | |
|
239 | { | |
|
240 | return d_ptr->m_gridLineVisible; | |
|
241 | } | |
|
236 | 242 | /*! |
|
237 | 243 | Sets \a pen used to draw grid line. |
|
238 | 244 | */ |
|
239 | 245 | void QChartAxis::setGridLinePen(const QPen &pen) |
|
240 | 246 | { |
|
241 | if (m_gridLinePen != pen) { | |
|
242 | m_gridLinePen = pen; | |
|
243 | emit updated(); | |
|
247 | if (d_ptr->m_gridLinePen != pen) { | |
|
248 | d_ptr->m_gridLinePen = pen; | |
|
249 | emit d_ptr->updated(); | |
|
244 | 250 | } |
|
245 | 251 | } |
|
246 | 252 | |
|
253 | QPen QChartAxis::gridLinePen() const | |
|
254 | { | |
|
255 | return d_ptr->m_gridLinePen; | |
|
256 | } | |
|
257 | ||
|
247 | 258 | /*! |
|
248 | 259 | Sets if axis' labels are \a visible. |
|
249 | 260 | */ |
|
250 | 261 | void QChartAxis::setLabelsVisible(bool visible) |
|
251 | 262 | { |
|
252 | if (m_labelsVisible != visible) { | |
|
253 | m_labelsVisible = visible; | |
|
254 | emit updated(); | |
|
263 | if (d_ptr->m_labelsVisible != visible) { | |
|
264 | d_ptr->m_labelsVisible = visible; | |
|
265 | emit d_ptr->updated(); | |
|
255 | 266 | } |
|
256 | 267 | } |
|
257 | 268 | |
|
269 | bool QChartAxis::labelsVisible() const | |
|
270 | { | |
|
271 | return d_ptr->m_labelsVisible; | |
|
272 | } | |
|
258 | 273 | /*! |
|
259 | 274 | Sets \a pen used to draw labels. |
|
260 | 275 | */ |
|
261 | 276 | void QChartAxis::setLabelsPen(const QPen &pen) |
|
262 | 277 | { |
|
263 | if (m_labelsPen != pen) { | |
|
264 | m_labelsPen = pen; | |
|
265 | emit updated(); | |
|
278 | if (d_ptr->m_labelsPen != pen) { | |
|
279 | d_ptr->m_labelsPen = pen; | |
|
280 | emit d_ptr->updated(); | |
|
281 | } | |
|
266 | 282 |
|
|
283 | ||
|
284 | QPen QChartAxis::labelsPen() const | |
|
285 | { | |
|
286 | return d_ptr->m_labelsPen; | |
|
267 | 287 | } |
|
268 | 288 | |
|
269 | 289 | /*! |
@@ -271,32 +291,47 void QChartAxis::setLabelsPen(const QPen &pen) | |||
|
271 | 291 | */ |
|
272 | 292 | void QChartAxis::setLabelsBrush(const QBrush &brush) |
|
273 | 293 | { |
|
274 | if (m_labelsBrush != brush) { | |
|
275 | m_labelsBrush = brush; | |
|
276 | emit updated(); | |
|
294 | if (d_ptr->m_labelsBrush != brush) { | |
|
295 | d_ptr->m_labelsBrush = brush; | |
|
296 | emit d_ptr->updated(); | |
|
277 | 297 | } |
|
278 | 298 | } |
|
279 | 299 | |
|
300 | QBrush QChartAxis::labelsBrush() const | |
|
301 | { | |
|
302 | return d_ptr->m_labelsBrush; | |
|
303 | } | |
|
304 | ||
|
280 | 305 | /*! |
|
281 | 306 | Sets \a font used to draw labels. |
|
282 | 307 | */ |
|
283 | 308 | void QChartAxis::setLabelsFont(const QFont &font) |
|
284 | 309 | { |
|
285 | if (m_labelsFont != font) { | |
|
286 | m_labelsFont = font; | |
|
287 | emit updated(); | |
|
310 | if (d_ptr->m_labelsFont != font) { | |
|
311 | d_ptr->m_labelsFont = font; | |
|
312 | emit d_ptr->updated(); | |
|
288 | 313 | } |
|
289 | 314 | } |
|
290 | 315 | |
|
316 | QFont QChartAxis::labelsFont() const | |
|
317 | { | |
|
318 | return d_ptr->m_labelsFont; | |
|
319 | } | |
|
320 | ||
|
291 | 321 | /*! |
|
292 | 322 | Sets \a angle for all the labels on given axis. |
|
293 | 323 | */ |
|
294 | 324 | void QChartAxis::setLabelsAngle(int angle) |
|
295 | 325 | { |
|
296 | if (m_labelsAngle != angle) { | |
|
297 | m_labelsAngle = angle; | |
|
298 | emit updated(); | |
|
326 | if (d_ptr->m_labelsAngle != angle) { | |
|
327 | d_ptr->m_labelsAngle = angle; | |
|
328 | emit d_ptr->updated(); | |
|
329 | } | |
|
299 | 330 |
|
|
331 | ||
|
332 | int QChartAxis::labelsAngle() const | |
|
333 | { | |
|
334 | return d_ptr->m_labelsAngle; | |
|
300 | 335 | } |
|
301 | 336 | |
|
302 | 337 | /*! |
@@ -304,10 +339,15 void QChartAxis::setLabelsAngle(int angle) | |||
|
304 | 339 | */ |
|
305 | 340 | void QChartAxis::setShadesVisible(bool visible) |
|
306 | 341 | { |
|
307 | if (m_shadesVisible != visible) { | |
|
308 | m_shadesVisible = visible; | |
|
309 | emit updated(); | |
|
342 | if (d_ptr->m_shadesVisible != visible) { | |
|
343 | d_ptr->m_shadesVisible = visible; | |
|
344 | emit d_ptr->updated(); | |
|
345 | } | |
|
310 | 346 |
|
|
347 | ||
|
348 | bool QChartAxis::shadesVisible() const | |
|
349 | { | |
|
350 | return d_ptr->m_shadesVisible; | |
|
311 | 351 | } |
|
312 | 352 | |
|
313 | 353 | /*! |
@@ -315,21 +355,31 void QChartAxis::setShadesVisible(bool visible) | |||
|
315 | 355 | */ |
|
316 | 356 | void QChartAxis::setShadesPen(const QPen &pen) |
|
317 | 357 | { |
|
318 | if (m_shadesPen != pen) { | |
|
319 | m_shadesPen = pen; | |
|
320 | emit updated(); | |
|
358 | if (d_ptr->m_shadesPen != pen) { | |
|
359 | d_ptr->m_shadesPen = pen; | |
|
360 | emit d_ptr->updated(); | |
|
321 | 361 | } |
|
322 | 362 | } |
|
323 | 363 | |
|
364 | QPen QChartAxis::shadesPen() const | |
|
365 | { | |
|
366 | return d_ptr->m_shadesPen; | |
|
367 | } | |
|
368 | ||
|
324 | 369 | /*! |
|
325 | 370 | Sets \a brush used to draw shades. |
|
326 | 371 | */ |
|
327 | 372 | void QChartAxis::setShadesBrush(const QBrush &brush) |
|
328 | 373 | { |
|
329 | if (m_shadesBrush != brush) { | |
|
330 | m_shadesBrush = brush; | |
|
331 | emit updated(); | |
|
374 | if (d_ptr->m_shadesBrush != brush) { | |
|
375 | d_ptr->m_shadesBrush = brush; | |
|
376 | emit d_ptr->updated(); | |
|
377 | } | |
|
332 | 378 |
|
|
379 | ||
|
380 | QBrush QChartAxis::shadesBrush() const | |
|
381 | { | |
|
382 | return d_ptr->m_shadesBrush; | |
|
333 | 383 | } |
|
334 | 384 | |
|
335 | 385 | /*! |
@@ -337,18 +387,28 void QChartAxis::setShadesBrush(const QBrush &brush) | |||
|
337 | 387 | */ |
|
338 | 388 | void QChartAxis::setShadesOpacity(qreal opacity) |
|
339 | 389 | { |
|
340 | if (m_shadesOpacity != opacity) { | |
|
341 | m_shadesOpacity=opacity; | |
|
342 | emit updated(); | |
|
390 | if (d_ptr->m_shadesOpacity != opacity) { | |
|
391 | d_ptr->m_shadesOpacity=opacity; | |
|
392 | emit d_ptr->updated(); | |
|
343 | 393 | } |
|
344 | 394 | } |
|
345 | 395 | |
|
396 | qreal QChartAxis::shadesOpacity() const | |
|
397 | { | |
|
398 | return d_ptr->m_shadesOpacity; | |
|
399 | } | |
|
400 | ||
|
346 | 401 | /*! |
|
347 | 402 | Sets \a min value on the axis. |
|
348 | 403 | */ |
|
349 | 404 | void QChartAxis::setMin(qreal min) |
|
350 | 405 | { |
|
351 | setRange(min,m_max); | |
|
406 | setRange(min,d_ptr->m_max); | |
|
407 | } | |
|
408 | ||
|
409 | qreal QChartAxis::min() const | |
|
410 | { | |
|
411 | return d_ptr->m_min; | |
|
352 | 412 | } |
|
353 | 413 | |
|
354 | 414 | /*! |
@@ -356,7 +416,12 void QChartAxis::setMin(qreal min) | |||
|
356 | 416 | */ |
|
357 | 417 | void QChartAxis::setMax(qreal max) |
|
358 | 418 | { |
|
359 | setRange(m_min,max); | |
|
419 | setRange(d_ptr->m_min,max); | |
|
420 | } | |
|
421 | ||
|
422 | qreal QChartAxis::max() const | |
|
423 | { | |
|
424 | return d_ptr->m_max; | |
|
360 | 425 | } |
|
361 | 426 | |
|
362 | 427 | /*! |
@@ -365,21 +430,21 void QChartAxis::setMax(qreal max) | |||
|
365 | 430 | void QChartAxis::setRange(qreal min, qreal max) |
|
366 | 431 | { |
|
367 | 432 | bool changed = false; |
|
368 | if (!qFuzzyIsNull(m_min - min)) { | |
|
369 | m_min = min; | |
|
433 | if (!qFuzzyIsNull(d_ptr->m_min - min)) { | |
|
434 | d_ptr->m_min = min; | |
|
370 | 435 | changed = true; |
|
371 | 436 | emit minChanged(min); |
|
372 | 437 | } |
|
373 | 438 | |
|
374 | if (!qFuzzyIsNull(m_max - max)) { | |
|
375 | m_max = max; | |
|
439 | if (!qFuzzyIsNull(d_ptr->m_max - max)) { | |
|
440 | d_ptr->m_max = max; | |
|
376 | 441 | changed = true; |
|
377 | 442 | emit maxChanged(max); |
|
378 | 443 | } |
|
379 | 444 | |
|
380 | 445 | if (changed) { |
|
381 | emit rangeChanged(m_min,m_max); | |
|
382 |
emit |
|
|
446 | emit rangeChanged(d_ptr->m_min,d_ptr->m_max); | |
|
447 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
|
383 | 448 | } |
|
384 | 449 | } |
|
385 | 450 | |
@@ -388,23 +453,28 void QChartAxis::setRange(qreal min, qreal max) | |||
|
388 | 453 | */ |
|
389 | 454 | void QChartAxis::setTicksCount(int count) |
|
390 | 455 | { |
|
391 | if (m_ticksCount != count) { | |
|
392 | m_ticksCount = count; | |
|
456 | if (d_ptr->m_ticksCount != count) { | |
|
457 | d_ptr->m_ticksCount = count; | |
|
393 | 458 | emit ticksCountChanged(count); |
|
394 | emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |
|
459 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
|
395 | 460 | } |
|
396 | 461 | } |
|
397 | 462 | |
|
463 | int QChartAxis::ticksCount() const | |
|
464 | { | |
|
465 | return d_ptr->m_ticksCount; | |
|
466 | } | |
|
467 | ||
|
398 | 468 | /*! |
|
399 | 469 | Sets axis, shades, labels and grid lines to be visible. |
|
400 | 470 | */ |
|
401 | 471 | void QChartAxis::show() |
|
402 | 472 | { |
|
403 | m_axisVisible=true; | |
|
404 | m_gridLineVisible=true; | |
|
405 | m_labelsVisible=true; | |
|
406 | m_shadesVisible=true; | |
|
407 | emit updated(); | |
|
473 | d_ptr->m_axisVisible=true; | |
|
474 | d_ptr->m_gridLineVisible=true; | |
|
475 | d_ptr->m_labelsVisible=true; | |
|
476 | d_ptr->m_shadesVisible=true; | |
|
477 | emit d_ptr->updated(); | |
|
408 | 478 | } |
|
409 | 479 | |
|
410 | 480 | /*! |
@@ -412,33 +482,64 void QChartAxis::show() | |||
|
412 | 482 | */ |
|
413 | 483 | void QChartAxis::hide() |
|
414 | 484 | { |
|
415 | m_axisVisible = false; | |
|
416 | m_gridLineVisible = false; | |
|
417 | m_labelsVisible = false; | |
|
418 | m_shadesVisible = false; | |
|
419 | emit updated(); | |
|
485 | d_ptr->m_axisVisible = false; | |
|
486 | d_ptr->m_gridLineVisible = false; | |
|
487 | d_ptr->m_labelsVisible = false; | |
|
488 | d_ptr->m_shadesVisible = false; | |
|
489 | emit d_ptr->updated(); | |
|
420 | 490 | } |
|
421 | 491 | |
|
422 | 492 | /*! |
|
423 | \internal | |
|
493 | Sets the nice numbers state to \a enable | |
|
424 | 494 |
|
|
425 | void QChartAxis::handleAxisRangeChanged(qreal min, qreal max,int count) | |
|
495 | void QChartAxis::setNiceNumbers(bool enable) | |
|
426 | 496 | { |
|
427 | setRange(min,max); | |
|
428 | setTicksCount(count); | |
|
497 | if (d_ptr->m_niceNumbers != enable){ | |
|
498 | d_ptr->m_niceNumbers = enable; | |
|
499 | emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers); | |
|
500 | } | |
|
429 | 501 | } |
|
430 | 502 | |
|
431 | /*! | |
|
432 | Sets the nice numbers state to \a enable | |
|
433 | */ | |
|
434 | void QChartAxis::setNiceNumbers(bool enable) | |
|
503 | bool QChartAxis::niceNumbers() const | |
|
504 | { | |
|
505 | return d_ptr->m_niceNumbers; | |
|
506 | } | |
|
507 | ||
|
508 | QChartAxisCategories* QChartAxis::categories() | |
|
435 | 509 | { |
|
436 | if (m_niceNumbers != enable){ | |
|
437 | m_niceNumbers = enable; | |
|
438 | emit changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |
|
510 | return &d_ptr->m_category; | |
|
439 | 511 | } |
|
512 | ||
|
513 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
|
514 | ||
|
515 | QChartAxisPrivate::QChartAxisPrivate(QChartAxis* q): | |
|
516 | q_ptr(q), | |
|
517 | m_axisVisible(true), | |
|
518 | m_gridLineVisible(true), | |
|
519 | m_labelsVisible(true), | |
|
520 | m_labelsAngle(0), | |
|
521 | m_shadesVisible(false), | |
|
522 | m_shadesOpacity(1.0), | |
|
523 | m_min(0), | |
|
524 | m_max(0), | |
|
525 | m_ticksCount(5), | |
|
526 | m_niceNumbers(false) | |
|
527 | { | |
|
528 | ||
|
529 | } | |
|
530 | ||
|
531 | QChartAxisPrivate::~QChartAxisPrivate() | |
|
532 | { | |
|
533 | ||
|
534 | } | |
|
535 | ||
|
536 | void QChartAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
|
537 | { | |
|
538 | q_ptr->setRange(min,max); | |
|
539 | q_ptr->setTicksCount(count); | |
|
440 | 540 | } |
|
441 | 541 | |
|
442 | 542 | #include "moc_qchartaxis.cpp" |
|
543 | #include "moc_qchartaxis_p.cpp" | |
|
443 | 544 | |
|
444 | 545 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -28,6 +28,8 | |||
|
28 | 28 | |
|
29 | 29 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
30 | 30 | |
|
31 | class QChartAxisPrivate; | |
|
32 | ||
|
31 | 33 | class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject |
|
32 | 34 | { |
|
33 | 35 | Q_OBJECT |
@@ -37,54 +39,54 public: | |||
|
37 | 39 | ~QChartAxis(); |
|
38 | 40 | |
|
39 | 41 | //axis handling |
|
40 |
bool isAxisVisible() const |
|
|
42 | bool isAxisVisible() const; | |
|
41 | 43 | void setAxisVisible(bool visible); |
|
42 | 44 | void setAxisPen(const QPen &pen); |
|
43 |
QPen axisPen() const |
|
|
45 | QPen axisPen() const; | |
|
44 | 46 | |
|
45 | 47 | //grid handling |
|
46 |
bool isGridLineVisible() const |
|
|
48 | bool isGridLineVisible() const; | |
|
47 | 49 | void setGridLineVisible(bool visible); |
|
48 | 50 | void setGridLinePen(const QPen &pen); |
|
49 |
QPen gridLinePen() const |
|
|
51 | QPen gridLinePen() const; | |
|
50 | 52 | |
|
51 | 53 | //labels handling |
|
52 |
bool labelsVisible() const |
|
|
54 | bool labelsVisible() const; | |
|
53 | 55 | void setLabelsVisible(bool visible); |
|
54 | 56 | void setLabelsPen(const QPen &pen); |
|
55 |
QPen labelsPen() const |
|
|
57 | QPen labelsPen() const; | |
|
56 | 58 | void setLabelsBrush(const QBrush &brush); |
|
57 |
QBrush labelsBrush() const |
|
|
59 | QBrush labelsBrush() const; | |
|
58 | 60 | void setLabelsFont(const QFont &font); |
|
59 |
QFont labelsFont() const |
|
|
61 | QFont labelsFont() const; | |
|
60 | 62 | void setLabelsAngle(int angle); |
|
61 |
int labelsAngle() const |
|
|
63 | int labelsAngle() const; | |
|
62 | 64 | |
|
63 | 65 | //shades handling |
|
64 |
bool shadesVisible() const |
|
|
66 | bool shadesVisible() const; | |
|
65 | 67 | void setShadesVisible(bool visible); |
|
66 | 68 | void setShadesPen(const QPen &pen); |
|
67 |
QPen shadesPen() const |
|
|
69 | QPen shadesPen() const; | |
|
68 | 70 | void setShadesBrush(const QBrush &brush); |
|
69 |
QBrush shadesBrush() const |
|
|
71 | QBrush shadesBrush() const; | |
|
70 | 72 | void setShadesOpacity(qreal opacity); |
|
71 |
qreal shadesOpacity() const |
|
|
73 | qreal shadesOpacity() const; | |
|
72 | 74 | |
|
73 | 75 | //range handling |
|
74 | 76 | void setMin(qreal min); |
|
75 |
qreal min() const |
|
|
77 | qreal min() const; | |
|
76 | 78 | void setMax(qreal max); |
|
77 |
qreal max() const |
|
|
79 | qreal max() const; | |
|
78 | 80 | void setRange(qreal min, qreal max); |
|
79 | 81 | |
|
80 | 82 | //ticks handling |
|
81 | 83 | void setTicksCount(int count); |
|
82 |
int ticksCount() const |
|
|
84 | int ticksCount() const; | |
|
83 | 85 | |
|
84 | 86 | void setNiceNumbers(bool enable); |
|
85 |
bool niceNumbers() const |
|
|
87 | bool niceNumbers() const; | |
|
86 | 88 | |
|
87 |
QChartAxisCategories* categories() |
|
|
89 | QChartAxisCategories* categories(); | |
|
88 | 90 | |
|
89 | 91 | void show(); |
|
90 | 92 | void hide(); |
@@ -95,39 +97,11 Q_SIGNALS: | |||
|
95 | 97 | void rangeChanged(qreal min, qreal max); |
|
96 | 98 | void ticksCountChanged(int count); |
|
97 | 99 | |
|
98 | //interal signal | |
|
99 | void updated(); | |
|
100 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); | |
|
101 | //internal slot | |
|
102 | public Q_SLOTS: | |
|
103 | void handleAxisRangeChanged(qreal min, qreal max,int count); | |
|
104 | ||
|
105 | 100 | private: |
|
106 | bool m_axisVisible; | |
|
107 | QPen m_axisPen; | |
|
108 | QBrush m_axisBrush; | |
|
109 | ||
|
110 | bool m_gridLineVisible; | |
|
111 | QPen m_gridLinePen; | |
|
112 | ||
|
113 | bool m_labelsVisible; | |
|
114 | QPen m_labelsPen; | |
|
115 | QBrush m_labelsBrush; | |
|
116 | QFont m_labelsFont; | |
|
117 | int m_labelsAngle; | |
|
118 | ||
|
119 | bool m_shadesVisible; | |
|
120 | QPen m_shadesPen; | |
|
121 | QBrush m_shadesBrush; | |
|
122 | qreal m_shadesOpacity; | |
|
123 | ||
|
124 | qreal m_min; | |
|
125 | qreal m_max; | |
|
126 | ||
|
127 | int m_ticksCount; | |
|
128 | QChartAxisCategories m_category; | |
|
129 | ||
|
130 | bool m_niceNumbers; | |
|
101 | QScopedPointer<QChartAxisPrivate> d_ptr; | |
|
102 | Q_DISABLE_COPY(QChartAxis); | |
|
103 | friend class ChartDataSet; | |
|
104 | friend class Axis; | |
|
131 | 105 | }; |
|
132 | 106 | |
|
133 | 107 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -19,63 +19,78 | |||
|
19 | 19 | ****************************************************************************/ |
|
20 | 20 | |
|
21 | 21 | #include "qchartaxiscategories.h" |
|
22 | #include "qchartaxiscategories_p.h" | |
|
22 | 23 | |
|
23 | 24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | 25 | |
|
25 | QChartAxisCategories::QChartAxisCategories() | |
|
26 | QChartAxisCategories::QChartAxisCategories(): | |
|
27 | d_ptr(new QChartAxisCategoriesPrivate(this)) | |
|
26 | 28 | { |
|
27 | // TODO Auto-generated constructor stub | |
|
28 | 29 | |
|
29 | 30 | } |
|
30 | 31 | |
|
31 | 32 | QChartAxisCategories::~QChartAxisCategories() |
|
32 | 33 | { |
|
33 | // TODO Auto-generated destructor stub | |
|
34 | ||
|
34 | 35 | } |
|
35 | 36 | |
|
36 | 37 | void QChartAxisCategories::insert(const QBarCategories &categories) |
|
37 | 38 | { |
|
38 | 39 | int i=1; |
|
39 | 40 | foreach (QString string , categories) { |
|
40 | m_map.insert(i,string); | |
|
41 | d_ptr->m_map.insert(i,string); | |
|
41 | 42 | i++; |
|
42 | 43 | } |
|
43 | emit updated(); | |
|
44 | emit d_ptr->updated(); | |
|
44 | 45 | } |
|
45 | 46 | |
|
46 | 47 | void QChartAxisCategories::insert(qreal value,QString label) |
|
47 | 48 | { |
|
48 | m_map.insert(value,label); | |
|
49 | emit updated(); | |
|
49 | d_ptr->m_map.insert(value,label); | |
|
50 | emit d_ptr->updated(); | |
|
50 | 51 | } |
|
51 | 52 | |
|
52 | 53 | void QChartAxisCategories::remove(qreal value) |
|
53 | 54 | { |
|
54 | m_map.remove(value); | |
|
55 | emit updated(); | |
|
55 | d_ptr->m_map.remove(value); | |
|
56 | emit d_ptr->updated(); | |
|
56 | 57 | } |
|
57 | 58 | |
|
58 | 59 | void QChartAxisCategories::clear() |
|
59 | 60 | { |
|
60 | m_map.clear(); | |
|
61 | emit updated(); | |
|
61 | d_ptr->m_map.clear(); | |
|
62 | emit d_ptr->updated(); | |
|
62 | 63 | } |
|
63 | 64 | |
|
64 | 65 | int QChartAxisCategories::count() |
|
65 | 66 | { |
|
66 | return m_map.count(); | |
|
67 | return d_ptr->m_map.count(); | |
|
67 | 68 | } |
|
68 | 69 | |
|
69 | 70 | QList<qreal> QChartAxisCategories::values() const |
|
70 | 71 | { |
|
71 | return m_map.keys(); | |
|
72 | return d_ptr->m_map.keys(); | |
|
72 | 73 | } |
|
73 | 74 | |
|
74 | 75 | QString QChartAxisCategories::label(qreal value) const |
|
75 | 76 | { |
|
76 | return m_map.value(value); | |
|
77 | return d_ptr->m_map.value(value); | |
|
78 | } | |
|
79 | ||
|
80 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
|
81 | ||
|
82 | QChartAxisCategoriesPrivate::QChartAxisCategoriesPrivate(QChartAxisCategories *q): | |
|
83 | q_ptr(q) | |
|
84 | { | |
|
85 | ||
|
86 | } | |
|
87 | ||
|
88 | QChartAxisCategoriesPrivate::~QChartAxisCategoriesPrivate() | |
|
89 | { | |
|
90 | ||
|
77 | 91 | } |
|
78 | 92 | |
|
79 | 93 | #include "moc_qchartaxiscategories.cpp" |
|
94 | #include "moc_qchartaxiscategories_p.cpp" | |
|
80 | 95 | |
|
81 | 96 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -26,6 +26,8 | |||
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 | class QChartAxisCategoriesPrivate; | |
|
30 | ||
|
29 | 31 | class QTCOMMERCIALCHART_EXPORT QChartAxisCategories : public QObject |
|
30 | 32 | { |
|
31 | 33 | Q_OBJECT |
@@ -42,14 +44,10 public: | |||
|
42 | 44 | void clear(); |
|
43 | 45 | int count(); |
|
44 | 46 | |
|
45 | //internal signal | |
|
46 | Q_SIGNALS: | |
|
47 | void updated(); | |
|
48 | ||
|
49 | 47 | private: |
|
50 | QMap<qreal,QString> m_map; | |
|
51 | ||
|
52 |
friend class |
|
|
48 | QScopedPointer<QChartAxisCategoriesPrivate> d_ptr; | |
|
49 | friend class QChartAxisPrivate; | |
|
50 | friend class Axis; | |
|
53 | 51 | }; |
|
54 | 52 | |
|
55 | 53 |
@@ -20,16 +20,12 | |||
|
20 | 20 | |
|
21 | 21 | #include "chartdataset_p.h" |
|
22 | 22 | #include "qchartaxis.h" |
|
23 | //series | |
|
23 | #include "qchartaxis_p.h" | |
|
24 | 24 | #include "qseries_p.h" |
|
25 | #include "qlineseries.h" | |
|
26 | #include "qareaseries.h" | |
|
27 | 25 | #include "qbarseries.h" |
|
28 | 26 | #include "qstackedbarseries.h" |
|
29 | 27 | #include "qpercentbarseries.h" |
|
30 | 28 | #include "qpieseries.h" |
|
31 | #include "qscatterseries.h" | |
|
32 | #include "qsplineseries.h" | |
|
33 | 29 | |
|
34 | 30 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
35 | 31 | |
@@ -68,10 +64,10 void ChartDataSet::addSeries(QSeries* series, QChartAxis *axisY) | |||
|
68 | 64 | |
|
69 | 65 | if(!domain) { |
|
70 | 66 | domain = new Domain(axisY); |
|
71 | QObject::connect(axisY,SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); | |
|
72 | QObject::connect(axisX(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); | |
|
73 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY,SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
|
74 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
|
67 | QObject::connect(axisY->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisYChanged(qreal,qreal,int,bool))); | |
|
68 | QObject::connect(axisX()->d_ptr.data(),SIGNAL(changed(qreal,qreal,int,bool)),domain,SLOT(handleAxisXChanged(qreal,qreal,int,bool))); | |
|
69 | QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),axisY->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
|
70 | QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),axisX()->d_ptr.data(),SLOT(handleAxisRangeChanged(qreal,qreal,int))); | |
|
75 | 71 | //initialize |
|
76 | 72 | m_axisDomainMap.insert(axisY,domain); |
|
77 | 73 | emit axisAdded(axisY,domain); |
General Comments 0
You need to be logged in to leave comments.
Login now