##// END OF EJS Templates
fixed doc for QAxis
Marek Rosa -
r1019:1264e4f3ca37
parent child
Show More
@@ -1,533 +1,533
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #include "qaxis.h"
22 22 #include "qaxis_p.h"
23 23
24 24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 25
26 26 /*!
27 \class QChartAxis
27 \class QAxis
28 28 \brief The QChartAxis class is used for manipulating chart's axis
29 29 and for adding optional axes to the chart.
30 30 \mainclass
31 31
32 32 There is only one x Axis, however there can be multiple y axes.
33 33 Each chart series can be bound to exactly one Y axis and the share common X axis.
34 34 Axis can be setup to show axis line with ticks, gird lines and shades.
35 35
36 36 */
37 37
38 38 /*!
39 39 \fn bool QAxis::isAxisVisible() const
40 40 \brief Returns if axis is visible
41 41 \sa setAxisVisible()
42 42 */
43 43
44 44 /*!
45 45 \fn QPen QAxis::axisPen() const
46 46 \brief Returns pen used to draw axis and ticks.
47 47 \sa setAxisPen()
48 48 */
49 49
50 50
51 51 /*!
52 52 \fn bool QAxis::isGridLineVisible() const
53 53 \brief Returns if grid is visible
54 54 \sa setGridLineVisible()
55 55 */
56 56
57 57 /*!
58 58 \fn QPen QAxis::gridLinePen() const
59 59 \brief Returns pen used to draw grid.
60 60 \sa setGridLinePen()
61 61 */
62 62
63 63 /*!
64 64 \fn bool QAxis::labelsVisible() const
65 65 \brief Returns if grid is visible
66 66 \sa setLabelsVisible()
67 67 */
68 68
69 69 /*!
70 70 \fn QPen QAxis::labelsPen() const
71 71 \brief Returns the pen used to labels.
72 72 \sa setLabelsPen()
73 73 */
74 74
75 75 /*!
76 76 \fn QBrush QAxis::labelsBrush() const
77 77 \brief Returns brush used to draw labels.
78 78 \sa setLabelsBrush()
79 79 */
80 80
81 81 /*!
82 82 \fn QFont QAxis::labelsFont() const
83 83 \brief Returns font used to draw labels.
84 84 \sa setLabelsFont()
85 85 */
86 86
87 87 /*!
88 88 \fn QFont QAxis::labelsAngle() const
89 89 \brief Returns angle used to draw labels.
90 90 \sa setLabelsAngle()
91 91 */
92 92
93 93 /*!
94 94 \fn bool QAxis::shadesVisible() const
95 95 \brief Returns if shades are visible.
96 96 \sa setShadesVisible()
97 97 */
98 98
99 99 /*!
100 100 \fn qreal QAxis::shadesOpacity() const
101 101 \brief Returns opacity of shades.
102 102 */
103 103
104 104 /*!
105 105 \fn QPen QAxis::shadesPen() const
106 106 \brief Returns pen used to draw shades.
107 107 \sa setShadesPen()
108 108 */
109 109
110 110 /*!
111 111 \fn QBrush QAxis::shadesBrush() const
112 112 \brief Returns brush used to draw shades.
113 113 \sa setShadesBrush()
114 114 */
115 115
116 116 /*!
117 117 \fn qreal QAxis::min() const
118 118 \brief Returns minimum value on the axis.
119 119 \sa setMin()
120 120 */
121 121
122 122 /*!
123 123 \fn qreal QAxis::max() const
124 124 \brief Returns maximim value on the axis.
125 125 \sa setMax()
126 126 */
127 127
128 128 /*!
129 129 \fn void QAxis::minChanged(qreal min)
130 130 \brief Axis emits signal when \a min of axis has changed.
131 131 */
132 132
133 133 /*!
134 134 \fn void QAxis::maxChanged(qreal max)
135 135 \brief Axis emits signal when \a max of axis has changed.
136 136 */
137 137
138 138 /*!
139 139 \fn void QAxis::rangeChanged(qreal min, qreal max)
140 140 \brief Axis emits signal when \a min or \a max of axis has changed.
141 141 */
142 142
143 143 /*!
144 144 \fn int QAxis::ticksCount() const
145 145 \brief Return number of ticks on the axis
146 146 \sa setTicksCount()
147 147 */
148 148
149 149 /*!
150 150 \fn QChartAxisCategories* QAxis::categories()
151 151 \brief Returns pointer to the list of categories which correspond to the values on the axis.
152 152 */
153 153
154 154 /*!
155 155 \fn void QAxis::ticksCountChanged(int count)
156 156 \brief Emits the new \a count of ticks on the axis
157 157 Signal is emitted when the number of the ticks on the axis has been changed to a different value.
158 158 Parementer count\a count is the new number of ticks on the axis.
159 159 */
160 160
161 161 /*!
162 162 Constructs new axis object which is a child of \a parent. Ownership is taken by
163 163 QChatView or QChart when axis added.
164 164 */
165 165
166 166 QAxis::QAxis(QObject *parent) : QObject(parent),
167 167 d_ptr(new QAxisPrivate(this))
168 168 {
169 169
170 170 }
171 171
172 172 /*!
173 173 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
174 174 */
175 175
176 176 QAxis::~QAxis()
177 177 {
178 178 }
179 179
180 180 /*!
181 181 Sets \a pen used to draw axis line and ticks.
182 182 */
183 183 void QAxis::setAxisPen(const QPen &pen)
184 184 {
185 185 if (d_ptr->m_axisPen!=pen) {
186 186 d_ptr->m_axisPen = pen;
187 187 emit d_ptr->updated();
188 188 }
189 189 }
190 190
191 191 QPen QAxis::axisPen() const
192 192 {
193 193 return d_ptr->m_axisPen;
194 194 }
195 195
196 196 /*!
197 197 Sets if axis and ticks are \a visible.
198 198 */
199 199 void QAxis::setAxisVisible(bool visible)
200 200 {
201 201 if (d_ptr->m_axisVisible != visible) {
202 202 d_ptr->m_axisVisible = visible;
203 203 emit d_ptr->updated();
204 204 }
205 205 }
206 206
207 207 bool QAxis::isAxisVisible() const
208 208 {
209 209 return d_ptr->m_axisVisible;
210 210 }
211 211
212 212 /*!
213 213 Sets if grid line is \a visible.
214 214 */
215 215 void QAxis::setGridLineVisible(bool visible)
216 216 {
217 217 if (d_ptr->m_gridLineVisible != visible) {
218 218 d_ptr->m_gridLineVisible = visible;
219 219 emit d_ptr->updated();
220 220 }
221 221 }
222 222
223 223 bool QAxis::isGridLineVisible() const
224 224 {
225 225 return d_ptr->m_gridLineVisible;
226 226 }
227 227 /*!
228 228 Sets \a pen used to draw grid line.
229 229 */
230 230 void QAxis::setGridLinePen(const QPen &pen)
231 231 {
232 232 if (d_ptr->m_gridLinePen != pen) {
233 233 d_ptr->m_gridLinePen = pen;
234 234 emit d_ptr->updated();
235 235 }
236 236 }
237 237
238 238 QPen QAxis::gridLinePen() const
239 239 {
240 240 return d_ptr->m_gridLinePen;
241 241 }
242 242
243 243 /*!
244 244 Sets if axis' labels are \a visible.
245 245 */
246 246 void QAxis::setLabelsVisible(bool visible)
247 247 {
248 248 if (d_ptr->m_labelsVisible != visible) {
249 249 d_ptr->m_labelsVisible = visible;
250 250 emit d_ptr->updated();
251 251 }
252 252 }
253 253
254 254 bool QAxis::labelsVisible() const
255 255 {
256 256 return d_ptr->m_labelsVisible;
257 257 }
258 258 /*!
259 259 Sets \a pen used to draw labels.
260 260 */
261 261 void QAxis::setLabelsPen(const QPen &pen)
262 262 {
263 263 if (d_ptr->m_labelsPen != pen) {
264 264 d_ptr->m_labelsPen = pen;
265 265 emit d_ptr->updated();
266 266 }
267 267 }
268 268
269 269 QPen QAxis::labelsPen() const
270 270 {
271 271 return d_ptr->m_labelsPen;
272 272 }
273 273
274 274 /*!
275 275 Sets \a brush used to draw labels.
276 276 */
277 277 void QAxis::setLabelsBrush(const QBrush &brush)
278 278 {
279 279 if (d_ptr->m_labelsBrush != brush) {
280 280 d_ptr->m_labelsBrush = brush;
281 281 emit d_ptr->updated();
282 282 }
283 283 }
284 284
285 285 QBrush QAxis::labelsBrush() const
286 286 {
287 287 return d_ptr->m_labelsBrush;
288 288 }
289 289
290 290 /*!
291 291 Sets \a font used to draw labels.
292 292 */
293 293 void QAxis::setLabelsFont(const QFont &font)
294 294 {
295 295 if (d_ptr->m_labelsFont != font) {
296 296 d_ptr->m_labelsFont = font;
297 297 emit d_ptr->updated();
298 298 }
299 299 }
300 300
301 301 QFont QAxis::labelsFont() const
302 302 {
303 303 return d_ptr->m_labelsFont;
304 304 }
305 305
306 306 /*!
307 307 Sets \a angle for all the labels on given axis.
308 308 */
309 309 void QAxis::setLabelsAngle(int angle)
310 310 {
311 311 if (d_ptr->m_labelsAngle != angle) {
312 312 d_ptr->m_labelsAngle = angle;
313 313 emit d_ptr->updated();
314 314 }
315 315 }
316 316
317 317 int QAxis::labelsAngle() const
318 318 {
319 319 return d_ptr->m_labelsAngle;
320 320 }
321 321
322 322 /*!
323 323 Sets if shades are \a visible.
324 324 */
325 325 void QAxis::setShadesVisible(bool visible)
326 326 {
327 327 if (d_ptr->m_shadesVisible != visible) {
328 328 d_ptr->m_shadesVisible = visible;
329 329 emit d_ptr->updated();
330 330 }
331 331 }
332 332
333 333 bool QAxis::shadesVisible() const
334 334 {
335 335 return d_ptr->m_shadesVisible;
336 336 }
337 337
338 338 /*!
339 339 Sets \a pen used to draw shades.
340 340 */
341 341 void QAxis::setShadesPen(const QPen &pen)
342 342 {
343 343 if (d_ptr->m_shadesPen != pen) {
344 344 d_ptr->m_shadesPen = pen;
345 345 emit d_ptr->updated();
346 346 }
347 347 }
348 348
349 349 QPen QAxis::shadesPen() const
350 350 {
351 351 return d_ptr->m_shadesPen;
352 352 }
353 353
354 354 /*!
355 355 Sets \a brush used to draw shades.
356 356 */
357 357 void QAxis::setShadesBrush(const QBrush &brush)
358 358 {
359 359 if (d_ptr->m_shadesBrush != brush) {
360 360 d_ptr->m_shadesBrush = brush;
361 361 emit d_ptr->updated();
362 362 }
363 363 }
364 364
365 365 QBrush QAxis::shadesBrush() const
366 366 {
367 367 return d_ptr->m_shadesBrush;
368 368 }
369 369
370 370 /*!
371 371 Sets \a opacity of the shades.
372 372 */
373 373 void QAxis::setShadesOpacity(qreal opacity)
374 374 {
375 375 if (d_ptr->m_shadesOpacity != opacity) {
376 376 d_ptr->m_shadesOpacity=opacity;
377 377 emit d_ptr->updated();
378 378 }
379 379 }
380 380
381 381 qreal QAxis::shadesOpacity() const
382 382 {
383 383 return d_ptr->m_shadesOpacity;
384 384 }
385 385
386 386 /*!
387 387 Sets \a min value on the axis.
388 388 */
389 389 void QAxis::setMin(qreal min)
390 390 {
391 391 setRange(min,d_ptr->m_max);
392 392 }
393 393
394 394 qreal QAxis::min() const
395 395 {
396 396 return d_ptr->m_min;
397 397 }
398 398
399 399 /*!
400 400 Sets \a max value on the axis.
401 401 */
402 402 void QAxis::setMax(qreal max)
403 403 {
404 404 setRange(d_ptr->m_min,max);
405 405 }
406 406
407 407 qreal QAxis::max() const
408 408 {
409 409 return d_ptr->m_max;
410 410 }
411 411
412 412 /*!
413 413 Sets range from \a min to \a max on the axis.
414 414 */
415 415 void QAxis::setRange(qreal min, qreal max)
416 416 {
417 417 bool changed = false;
418 418 if (!qFuzzyIsNull(d_ptr->m_min - min)) {
419 419 d_ptr->m_min = min;
420 420 changed = true;
421 421 emit minChanged(min);
422 422 }
423 423
424 424 if (!qFuzzyIsNull(d_ptr->m_max - max)) {
425 425 d_ptr->m_max = max;
426 426 changed = true;
427 427 emit maxChanged(max);
428 428 }
429 429
430 430 if (changed) {
431 431 emit rangeChanged(d_ptr->m_min,d_ptr->m_max);
432 432 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
433 433 }
434 434 }
435 435
436 436 /*!
437 437 Sets \a count for ticks on the axis.
438 438 */
439 439 void QAxis::setTicksCount(int count)
440 440 {
441 441 if (d_ptr->m_ticksCount != count) {
442 442 d_ptr->m_ticksCount = count;
443 443 emit ticksCountChanged(count);
444 444 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
445 445 }
446 446 }
447 447
448 448 int QAxis::ticksCount() const
449 449 {
450 450 return d_ptr->m_ticksCount;
451 451 }
452 452
453 453 /*!
454 454 Sets axis, shades, labels and grid lines to be visible.
455 455 */
456 456 void QAxis::show()
457 457 {
458 458 d_ptr->m_axisVisible=true;
459 459 d_ptr->m_gridLineVisible=true;
460 460 d_ptr->m_labelsVisible=true;
461 461 d_ptr->m_shadesVisible=true;
462 462 emit d_ptr->updated();
463 463 }
464 464
465 465 /*!
466 466 Sets axis, shades, labels and grid lines to not be visible.
467 467 */
468 468 void QAxis::hide()
469 469 {
470 470 d_ptr->m_axisVisible = false;
471 471 d_ptr->m_gridLineVisible = false;
472 472 d_ptr->m_labelsVisible = false;
473 473 d_ptr->m_shadesVisible = false;
474 474 emit d_ptr->updated();
475 475 }
476 476
477 477 /*!
478 478 Sets the nice numbers state to \a enable
479 479 */
480 480 void QAxis::setNiceNumbersEnabled(bool enable)
481 481 {
482 482 if (d_ptr->m_niceNumbers != enable){
483 483 d_ptr->m_niceNumbers = enable;
484 484 emit d_ptr->changed(d_ptr->m_min, d_ptr->m_max, d_ptr->m_ticksCount, d_ptr->m_niceNumbers);
485 485 }
486 486 }
487 487
488 488 /*!
489 489 Returns whether nice numbers are enabled or not.
490 490 */
491 491 bool QAxis::niceNumbersEnabled() const
492 492 {
493 493 return d_ptr->m_niceNumbers;
494 494 }
495 495
496 496 QChartAxisCategories* QAxis::categories()
497 497 {
498 498 return &d_ptr->m_category;
499 499 }
500 500
501 501 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
502 502
503 503 QAxisPrivate::QAxisPrivate(QAxis* q):
504 504 q_ptr(q),
505 505 m_axisVisible(true),
506 506 m_gridLineVisible(true),
507 507 m_labelsVisible(true),
508 508 m_labelsAngle(0),
509 509 m_shadesVisible(false),
510 510 m_shadesOpacity(1.0),
511 511 m_min(0),
512 512 m_max(0),
513 513 m_ticksCount(5),
514 514 m_niceNumbers(false)
515 515 {
516 516
517 517 }
518 518
519 519 QAxisPrivate::~QAxisPrivate()
520 520 {
521 521
522 522 }
523 523
524 524 void QAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
525 525 {
526 526 q_ptr->setRange(min,max);
527 527 q_ptr->setTicksCount(count);
528 528 }
529 529
530 530 #include "moc_qaxis.cpp"
531 531 #include "moc_qaxis_p.cpp"
532 532
533 533 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now