##// END OF EJS Templates
Adds new API classes...
Michal Klocek -
r1540:83291e82d983
parent child
Show More
This diff has been collapsed as it changes many lines, (573 lines changed) Show them Hide them
@@ -0,0 +1,573
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 #include "qabstractaxis.h"
22 #include "qabstractaxis_p.h"
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
26 /*!
27 \class QAbstractAxis
28 \brief The QAbstractAxis class is used for manipulating chart's axis.
29 \mainclass
30
31 There is only one x Axis, however there can be multiple y axes.
32 Each chart series can be bound to exactly one Y axis and the shared common X axis.
33 Axis can be setup to show axis line with tick marks, grid lines and shades.
34 */
35
36 /*!
37 \qmlclass Axis QAbstractAxis
38 \brief The Axis element is used for manipulating chart's axes
39
40 There is only one x Axis, however there can be multiple y axes on a ChartView.
41 Each chart series can be bound to exactly one Y axis and the shared common X axis.
42 Axis can be setup to show axis line with tick marks, grid lines and shades.
43
44 To access Axes you can use ChartView API. For example:
45 \code
46 ChartView {
47 axisX.min: 0
48 axisX.max: 3
49 axisX.ticksCount: 4
50 axisY.min: 0
51 axisY.max: 4
52 // Add a few series...
53 }
54 \endcode
55 */
56
57 /*!
58 \property QAbstractAxis::labelsVisible
59 Defines if axis labels are visible.
60 */
61 /*!
62 \qmlproperty bool Axis::labelsVisible
63 Defines if axis labels are visible.
64 */
65
66 /*!
67 \property QAbstractAxis::min
68 Defines the minimum value on the axis.
69 */
70 /*!
71 \qmlproperty real Axis::min
72 Defines the minimum value on the axis.
73 */
74
75 /*!
76 \property QAbstractAxis::max
77 Defines the maximum value on the axis.
78 */
79 /*!
80 \qmlproperty real Axis::max
81 Defines the maximum value on the axis.
82 */
83
84 /*!
85 \property QAbstractAxis::visible
86 The visibility of the axis.
87 */
88 /*!
89 \qmlproperty bool Axis::visible
90 The visibility of the axis.
91 */
92
93 /*!
94 \property QAbstractAxis::gridVisible
95 The visibility of the grid lines.
96 */
97 /*!
98 \qmlproperty bool Axis::gridVisible
99 The visibility of the grid lines.
100 */
101
102 /*!
103 \property QAbstractAxis::color
104 The color of the axis and ticks.
105 */
106 /*!
107 \qmlproperty color Axis::color
108 The color of the axis and ticks.
109 */
110
111 /*!
112 \property QAxis::labelsFont
113 The font of the axis labels.
114 */
115 /*!
116 \qmlproperty Font Axis::labelsFont
117 The font of the axis labels.
118
119 See the \l {Font} {QML Font Element} for detailed documentation.
120 */
121
122 /*!
123 \property QAbstractAxis::labelsColor
124 The color of the axis labels.
125 */
126 /*!
127 \qmlproperty color Axis::labelsColor
128 The color of the axis labels.
129 */
130
131 /*!
132 \property QAbstractAxis::labelsAngle
133 The angle of the axis labels in degrees.
134 */
135 /*!
136 \qmlproperty int Axis::labelsAngle
137 The angle of the axis labels in degrees.
138 */
139
140 /*!
141 \property QAbstractAxis::shadesVisible
142 The visibility of the axis shades.
143 */
144 /*!
145 \qmlproperty bool Axis::shadesVisible
146 The visibility of the axis shades.
147 */
148
149 /*!
150 \property QAbstractAxis::shadesColor
151 The fill (brush) color of the axis shades.
152 */
153 /*!
154 \qmlproperty color Axis::shadesColor
155 The fill (brush) color of the axis shades.
156 */
157
158 /*!
159 \property QAbstractAxis::shadesBorderColor
160 The border (pen) color of the axis shades.
161 */
162 /*!
163 \qmlproperty color Axis::shadesBorderColor
164 The border (pen) color of the axis shades.
165 */
166
167 /*!
168 \property QAbstractAxis::ticksCount
169 The number of tick marks for the axis.
170 */
171 /*!
172 \qmlproperty int Axis::ticksCount
173 The number of tick marks for the axis.
174 */
175
176 /*!
177 \property QAbstractAxis::niceNumbersEnabled
178 Whether the nice numbers algorithm is enabled or not for the axis.
179 */
180 /*!
181 \qmlproperty bool Axis::niceNumbersEnabled
182 Whether the nice numbers algorithm is enabled or not for the axis.
183 */
184
185 /*!
186 \fn void QAbstractAxis::visibleChanged(bool)
187 Visiblity of the axis has changed to \a visible.
188 */
189
190 /*!
191 \fn void QAbstractAxis::labelsVisibleChanged(bool)
192 Visiblity of the labels of the axis has changed to \a visible.
193 */
194
195 /*!
196 \fn void QAbstractAxis::gridVisibleChanged(bool)
197 Visiblity of the grid lines of the axis has changed to \a visible.
198 */
199
200 /*!
201 \fn void QAbstractAxis::minChanged(qreal min)
202 Axis emits signal when \a min of axis has changed.
203 */
204
205 /*!
206 \fn void QAbstractAxis::maxChanged(qreal max)
207 Axis emits signal when \a max of axis has changed.
208 */
209
210 /*!
211 \fn void QAbstractAxis::rangeChanged(qreal min, qreal max)
212 Axis emits signal when \a min or \a max of axis has changed.
213 */
214
215 /*!
216 \fn QChartAxisCategories* QAbstractAxis::categories()
217 Returns pointer to the list of categories which correspond to the values on the axis.
218 */
219
220 /*!
221 \fn void QAbstractAxis::colorChanged(QColor)
222 Emitted if the \a color of the axis is changed.
223 */
224
225 /*!
226 \fn void QAbstractAxis::labelsColorChanged(QColor)
227 Emitted if the \a color of the axis labels is changed.
228 */
229
230 /*!
231 \fn void QAbstractAxis::shadesVisibleChanged(bool)
232 Emitted if the visibility of the axis shades is changed to \a visible.
233 */
234
235 /*!
236 \fn void QAbstractAxis::shadesColorChanged(QColor)
237 Emitted if the \a color of the axis shades is changed.
238 */
239
240 /*!
241 \fn void QAbstractAxis::shadesBorderColorChanged(QColor)
242 Emitted if the border \a color of the axis shades is changed.
243 */
244
245 /*!
246 Constructs new axis object which is a child of \a parent. Ownership is taken by
247 QChart when axis added.
248 */
249
250 QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) :
251 QObject(parent),
252 d_ptr(&d)
253 {
254 }
255
256 /*!
257 Destructor of the axis object. When axis is added to chart, chart object takes ownership.
258 */
259
260 QAbstractAxis::~QAbstractAxis()
261 {
262 }
263
264 /*!
265 Sets \a pen used to draw axis line and ticks.
266 */
267 void QAbstractAxis::setAxisPen(const QPen &pen)
268 {
269 if (d_ptr->m_axisPen!=pen) {
270 d_ptr->m_axisPen = pen;
271 emit d_ptr->updated();
272 }
273 }
274
275 /*!
276 Returns pen used to draw axis and ticks.
277 */
278 QPen QAbstractAxis::axisPen() const
279 {
280 return d_ptr->m_axisPen;
281 }
282
283 void QAbstractAxis::setAxisPenColor(QColor color)
284 {
285 QPen p = d_ptr->m_axisPen;
286 if (p.color() != color) {
287 p.setColor(color);
288 setAxisPen(p);
289 emit colorChanged(color);
290 }
291 }
292
293 QColor QAbstractAxis::axisPenColor() const
294 {
295 return d_ptr->m_axisPen.color();
296 }
297
298 /*!
299 Sets if axis and ticks are \a visible.
300 */
301 void QAbstractAxis::setAxisVisible(bool visible)
302 {
303 if (d_ptr->m_axisVisible != visible) {
304 d_ptr->m_axisVisible = visible;
305 emit d_ptr->updated();
306 emit visibleChanged(visible);
307 }
308 }
309
310 bool QAbstractAxis::isAxisVisible() const
311 {
312 return d_ptr->m_axisVisible;
313 }
314
315 void QAbstractAxis::setGridLineVisible(bool visible)
316 {
317 if (d_ptr->m_gridLineVisible != visible) {
318 d_ptr->m_gridLineVisible = visible;
319 emit d_ptr->updated();
320 emit gridVisibleChanged(visible);
321 }
322 }
323
324 bool QAbstractAxis::isGridLineVisible() const
325 {
326 return d_ptr->m_gridLineVisible;
327 }
328
329 /*!
330 Sets \a pen used to draw grid line.
331 */
332 void QAbstractAxis::setGridLinePen(const QPen &pen)
333 {
334 if (d_ptr->m_gridLinePen != pen) {
335 d_ptr->m_gridLinePen = pen;
336 emit d_ptr->updated();
337 }
338 }
339
340 /*!
341 Returns pen used to draw grid.
342 */
343 QPen QAbstractAxis::gridLinePen() const
344 {
345 return d_ptr->m_gridLinePen;
346 }
347
348 void QAbstractAxis::setLabelsVisible(bool visible)
349 {
350 if (d_ptr->m_labelsVisible != visible) {
351 d_ptr->m_labelsVisible = visible;
352 emit d_ptr->updated();
353 emit labelsVisibleChanged(visible);
354 }
355 }
356
357 bool QAbstractAxis::labelsVisible() const
358 {
359 return d_ptr->m_labelsVisible;
360 }
361
362 /*!
363 Sets \a pen used to draw labels.
364 */
365 void QAbstractAxis::setLabelsPen(const QPen &pen)
366 {
367 if (d_ptr->m_labelsPen != pen) {
368 d_ptr->m_labelsPen = pen;
369 emit d_ptr->updated();
370 }
371 }
372
373 /*!
374 Returns the pen used to labels.
375 */
376 QPen QAbstractAxis::labelsPen() const
377 {
378 return d_ptr->m_labelsPen;
379 }
380
381 /*!
382 Sets \a brush used to draw labels.
383 */
384 void QAbstractAxis::setLabelsBrush(const QBrush &brush)
385 {
386 if (d_ptr->m_labelsBrush != brush) {
387 d_ptr->m_labelsBrush = brush;
388 emit d_ptr->updated();
389 }
390 }
391
392 /*!
393 Returns brush used to draw labels.
394 */
395 QBrush QAbstractAxis::labelsBrush() const
396 {
397 return d_ptr->m_labelsBrush;
398 }
399
400 /*!
401 Sets \a font used to draw labels.
402 */
403 void QAbstractAxis::setLabelsFont(const QFont &font)
404 {
405 if (d_ptr->m_labelsFont != font) {
406 d_ptr->m_labelsFont = font;
407 emit d_ptr->updated();
408 }
409 }
410
411 /*!
412 Returns font used to draw labels.
413 */
414 QFont QAbstractAxis::labelsFont() const
415 {
416 return d_ptr->m_labelsFont;
417 }
418
419 void QAbstractAxis::setLabelsAngle(int angle)
420 {
421 if (d_ptr->m_labelsAngle != angle) {
422 d_ptr->m_labelsAngle = angle;
423 emit d_ptr->updated();
424 }
425 }
426
427 int QAbstractAxis::labelsAngle() const
428 {
429 return d_ptr->m_labelsAngle;
430 }
431
432 void QAbstractAxis::setLabelsColor(QColor color)
433 {
434 QBrush b = d_ptr->m_labelsBrush;
435 if (b.color() != color) {
436 b.setColor(color);
437 setLabelsBrush(b);
438 emit labelsColorChanged(color);
439 }
440 }
441
442 QColor QAbstractAxis::labelsColor() const
443 {
444 return d_ptr->m_labelsBrush.color();
445 }
446
447 void QAbstractAxis::setShadesVisible(bool visible)
448 {
449 if (d_ptr->m_shadesVisible != visible) {
450 d_ptr->m_shadesVisible = visible;
451 emit d_ptr->updated();
452 emit shadesVisibleChanged(visible);
453 }
454 }
455
456 bool QAbstractAxis::shadesVisible() const
457 {
458 return d_ptr->m_shadesVisible;
459 }
460
461 /*!
462 Sets \a pen used to draw shades.
463 */
464 void QAbstractAxis::setShadesPen(const QPen &pen)
465 {
466 if (d_ptr->m_shadesPen != pen) {
467 d_ptr->m_shadesPen = pen;
468 emit d_ptr->updated();
469 }
470 }
471
472 /*!
473 Returns pen used to draw shades.
474 */
475 QPen QAbstractAxis::shadesPen() const
476 {
477 return d_ptr->m_shadesPen;
478 }
479
480 /*!
481 Sets \a brush used to draw shades.
482 */
483 void QAbstractAxis::setShadesBrush(const QBrush &brush)
484 {
485 if (d_ptr->m_shadesBrush != brush) {
486 d_ptr->m_shadesBrush = brush;
487 emit d_ptr->updated();
488 emit shadesColorChanged(brush.color());
489 }
490 }
491
492 /*!
493 Returns brush used to draw shades.
494 */
495 QBrush QAbstractAxis::shadesBrush() const
496 {
497 return d_ptr->m_shadesBrush;
498 }
499
500 void QAbstractAxis::setShadesColor(QColor color)
501 {
502 QBrush b = d_ptr->m_shadesBrush;
503 b.setColor(color);
504 setShadesBrush(b);
505 }
506
507 QColor QAbstractAxis::shadesColor() const
508 {
509 return d_ptr->m_shadesBrush.color();
510 }
511
512 void QAbstractAxis::setShadesBorderColor(QColor color)
513 {
514 QPen p = d_ptr->m_shadesPen;
515 p.setColor(color);
516 setShadesPen(p);
517 }
518
519 QColor QAbstractAxis::shadesBorderColor() const
520 {
521 return d_ptr->m_shadesPen.color();
522 }
523
524
525 /*!
526 Sets axis, shades, labels and grid lines to be visible.
527 */
528 void QAbstractAxis::show()
529 {
530 d_ptr->m_axisVisible=true;
531 d_ptr->m_gridLineVisible=true;
532 d_ptr->m_labelsVisible=true;
533 d_ptr->m_shadesVisible=true;
534 emit d_ptr->updated();
535 }
536
537 /*!
538 Sets axis, shades, labels and grid lines to not be visible.
539 */
540 void QAbstractAxis::hide()
541 {
542 d_ptr->m_axisVisible = false;
543 d_ptr->m_gridLineVisible = false;
544 d_ptr->m_labelsVisible = false;
545 d_ptr->m_shadesVisible = false;
546 emit d_ptr->updated();
547 }
548
549
550 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
551
552 QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q):
553 q_ptr(q),
554 m_axisVisible(true),
555 m_gridLineVisible(true),
556 m_labelsVisible(true),
557 m_labelsAngle(0),
558 m_shadesVisible(false),
559 m_shadesBrush(Qt::SolidPattern),
560 m_shadesOpacity(1.0)
561 {
562
563 }
564
565 QAbstractAxisPrivate::~QAbstractAxisPrivate()
566 {
567
568 }
569
570 #include "moc_qabstractaxis.cpp"
571 #include "moc_qabstractaxis_p.cpp"
572
573 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,128
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 #ifndef QABSTRACTAXIS_H
22 #define QABSTRACTAXIS_H
23
24 #include <qchartglobal.h>
25 #include <QPen>
26 #include <QFont>
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
30 class QAbstractAxisPrivate;
31
32 class QTCOMMERCIALCHART_EXPORT QAbstractAxis : public QObject
33 {
34 Q_OBJECT
35
36 Q_PROPERTY(bool visible READ isAxisVisible WRITE setAxisVisible NOTIFY visibleChanged)
37 Q_PROPERTY(QColor color READ axisPenColor WRITE setAxisPenColor NOTIFY colorChanged)
38 Q_PROPERTY(bool labelsVisible READ labelsVisible WRITE setLabelsVisible NOTIFY labelsVisibleChanged)
39 Q_PROPERTY(int labelsAngle READ labelsAngle WRITE setLabelsAngle)
40 Q_PROPERTY(QFont labelsFont READ labelsFont WRITE setLabelsFont)
41 Q_PROPERTY(QColor labelsColor READ labelsColor WRITE setLabelsColor NOTIFY labelsColorChanged)
42 Q_PROPERTY(bool gridVisible READ isGridLineVisible WRITE setGridLineVisible NOTIFY gridVisibleChanged)
43 Q_PROPERTY(bool shadesVisible READ shadesVisible WRITE setShadesVisible NOTIFY shadesVisibleChanged)
44 Q_PROPERTY(QColor shadesColor READ shadesColor WRITE setShadesColor NOTIFY shadesColorChanged)
45 Q_PROPERTY(QColor shadesBorderColor READ shadesBorderColor WRITE setShadesBorderColor NOTIFY shadesBorderColorChanged)
46 //Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged)
47 //Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged)
48
49 public:
50
51 enum AxisType {
52 AxisTypeValues,
53 AxisTypeCategories
54 };
55
56 protected:
57 explicit QAbstractAxis(QAbstractAxisPrivate &d,QObject *parent = 0);
58
59 public:
60 ~QAbstractAxis();
61
62 virtual AxisType type() const = 0;
63
64 //axis handling
65 bool isAxisVisible() const;
66 void setAxisVisible(bool visible = true);
67 void setAxisPen(const QPen &pen);
68 QPen axisPen() const;
69 void setAxisPenColor(QColor color);
70 QColor axisPenColor() const;
71
72 //grid handling
73 bool isGridLineVisible() const;
74 void setGridLineVisible(bool visible = true);
75 void setGridLinePen(const QPen &pen);
76 QPen gridLinePen() const;
77
78 //labels handling
79 bool labelsVisible() const;
80 void setLabelsVisible(bool visible = true);
81 void setLabelsPen(const QPen &pen);
82 QPen labelsPen() const;
83 void setLabelsBrush(const QBrush &brush);
84 QBrush labelsBrush() const;
85 void setLabelsFont(const QFont &font);
86 QFont labelsFont() const;
87 void setLabelsAngle(int angle);
88 int labelsAngle() const;
89 void setLabelsColor(QColor color);
90 QColor labelsColor() const;
91
92 //shades handling
93 bool shadesVisible() const;
94 void setShadesVisible(bool visible = true);
95 void setShadesPen(const QPen &pen);
96 QPen shadesPen() const;
97 void setShadesBrush(const QBrush &brush);
98 QBrush shadesBrush() const;
99 void setShadesColor(QColor color);
100 QColor shadesColor() const;
101 void setShadesBorderColor(QColor color);
102 QColor shadesBorderColor() const;
103
104 int ticksCount() const;
105
106 void show();
107 void hide();
108
109 Q_SIGNALS:
110 void visibleChanged(bool visible);
111 void labelsVisibleChanged(bool visible);
112 void gridVisibleChanged(bool visible);
113 void rangeChanged();
114 void colorChanged(QColor color);
115 void labelsColorChanged(QColor color);
116 void shadesVisibleChanged(bool visible);
117 void shadesColorChanged(QColor color);
118 void shadesBorderColorChanged(QColor color);
119 void minChanged();
120 void maxChanged();
121
122 protected:
123 QScopedPointer<QAbstractAxisPrivate> d_ptr;
124 Q_DISABLE_COPY(QAbstractAxis)
125 };
126
127 QTCOMMERCIALCHART_END_NAMESPACE
128 #endif
@@ -0,0 +1,73
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 QABSTRACTAXIS_P_H
31 #define QABSTRACTAXIS_P_H
32
33 #include "qabstractaxis.h"
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
37 class QAbstractAxisPrivate : public QObject
38 {
39 Q_OBJECT
40 public:
41 QAbstractAxisPrivate(QAbstractAxis *q);
42 ~QAbstractAxisPrivate();
43
44 Q_SIGNALS:
45 void updated();
46
47 protected:
48 QAbstractAxis *q_ptr;
49
50 bool m_axisVisible;
51 QPen m_axisPen;
52 QBrush m_axisBrush;
53
54 bool m_gridLineVisible;
55 QPen m_gridLinePen;
56
57 bool m_labelsVisible;
58 QPen m_labelsPen;
59 QBrush m_labelsBrush;
60 QFont m_labelsFont;
61 int m_labelsAngle;
62
63 bool m_shadesVisible;
64 QPen m_shadesPen;
65 QBrush m_shadesBrush;
66 qreal m_shadesOpacity;
67
68 friend class QAbstractAxis;
69 };
70
71 QTCOMMERCIALCHART_END_NAMESPACE
72
73 #endif
@@ -0,0 +1,173
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 #include "qcategoriesaxis.h"
22 #include "qcategoriesaxis_p.h"
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
26 QCategoriesAxis::QCategoriesAxis(QObject *parent):
27 QAbstractAxis(*new QCategoriesAxisPrivate(this),parent)
28 {
29
30 }
31
32 QCategoriesAxis::~QCategoriesAxis()
33 {
34
35 }
36
37 QCategoriesAxis::QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent):QAbstractAxis(d,parent)
38 {
39
40 }
41
42 /*!
43 Appends \a categories to axis
44 */
45 void QCategoriesAxis::append(QStringList &categories)
46 {
47 Q_D(QCategoriesAxis);
48 d->m_categories.append(categories);
49 emit categoriesChanged();
50 }
51
52 /*!
53 Appends \a category to axis
54 */
55 void QCategoriesAxis::append(const QString &category)
56 {
57 Q_D(QCategoriesAxis);
58 d->m_categories.append(category);
59 emit categoriesChanged();
60 }
61
62 /*!
63 Removes \a category from axis
64 */
65 void QCategoriesAxis::remove(const QString &category)
66 {
67 Q_D(QCategoriesAxis);
68 if (d->m_categories.contains(category)) {
69 d->m_categories.removeAt(d->m_categories.indexOf(category));
70 emit categoriesChanged();
71 }
72 }
73
74 /*!
75 Inserts \a category to axis at \a index
76 */
77 void QCategoriesAxis::insert(int index, const QString &category)
78 {
79 Q_D(QCategoriesAxis);
80 d->m_categories.insert(index,category);
81 emit categoriesChanged();
82 }
83
84 /*!
85 Removes all categories.
86 */
87 void QCategoriesAxis::clear()
88 {
89 Q_D(QCategoriesAxis);
90 d->m_categories.clear();
91 emit categoriesChanged();
92 }
93
94 /*!
95 Returns number of categories.
96 */
97 int QCategoriesAxis::count()
98 {
99 Q_D(QCategoriesAxis);
100 return d->m_categories.count();
101 }
102
103 /*!
104 Returns category at \a index. Index must be valid.
105 */
106 QString QCategoriesAxis::at(int index) const
107 {
108 Q_D(const QCategoriesAxis);
109 return d->m_categories.at(index);
110 }
111
112 /*!
113 Sets minimum category to \a minCategory.
114 */
115 void QCategoriesAxis::setMin(QString minCategory)
116 {
117 Q_D(QCategoriesAxis);
118 int minIndex = d->m_categories.indexOf(minCategory);
119 if (minIndex == -1)
120 return;
121 // else
122 // QAbstractAxis::setMin(minIndex);
123 }
124
125 /*!
126 Sets maximum category to \a maxCategory.
127 */
128 void QCategoriesAxis::setMax(QString maxCategory)
129 {
130 Q_D(QCategoriesAxis);
131 int maxIndex = d->m_categories.indexOf(maxCategory);
132 if (maxIndex == -1)
133 return;
134 // else
135 // QAbstractAxis::setMax(maxIndex);
136 }
137
138 /*!
139 Sets range from \a minCategory to \a maxCategory
140 */
141 void QCategoriesAxis::setRange(QString minCategory, QString maxCategory)
142 {
143 // TODO: what if maxCategory < minCategory?
144 setMin(minCategory);
145 setMax(maxCategory);
146 }
147
148 /*!
149 Returns the type of axis.
150 */
151 QAbstractAxis::AxisType QCategoriesAxis::type() const
152 {
153 return AxisTypeCategories;
154 }
155
156
157 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
158
159 QCategoriesAxisPrivate::QCategoriesAxisPrivate(QCategoriesAxis* q):
160 QAbstractAxisPrivate(q)
161 {
162
163 }
164
165 QCategoriesAxisPrivate::~QCategoriesAxisPrivate()
166 {
167
168 }
169
170 #include "moc_qcategoriesaxis.cpp"
171 #include "moc_qcategoriesaxis_p.cpp"
172
173 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,67
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 #ifndef QCATEGORIESAXIS_H
22 #define QCATEGORIESAXIS_H
23
24 #include "qabstractaxis.h"
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
28 class QCategoriesAxisPrivate;
29
30 class QTCOMMERCIALCHART_EXPORT QCategoriesAxis : public QAbstractAxis
31 {
32 Q_OBJECT
33
34 public:
35 explicit QCategoriesAxis(QObject *parent = 0);
36 ~QCategoriesAxis();
37
38 protected:
39 QCategoriesAxis(QCategoriesAxisPrivate &d,QObject *parent = 0);
40
41 public:
42 AxisType type() const;
43 void append(QStringList &categories);
44 void append(const QString &category);
45 void remove(const QString &category);
46 void insert(int index, const QString &category);
47 void clear();
48 int count();
49
50 QString at(int index) const;
51
52 //range handling convenience functions
53 void setMin(QString minCategory);
54 void setMax(QString maxCategory);
55 void setRange(QString minCategory, QString maxCategory);
56
57 Q_SIGNALS:
58 void categoriesChanged();
59
60 private:
61 Q_DECLARE_PRIVATE(QCategoriesAxis)
62 Q_DISABLE_COPY(QCategoriesAxis)
63 };
64
65 QTCOMMERCIALCHART_END_NAMESPACE
66
67 #endif // QCATEGORIESAXIS_H
@@ -0,0 +1,60
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 QCATEGORIESAXIS_P_H
31 #define QCATEGORIESAXIS_P_H
32
33 #include "qcategoriesaxis.h"
34 #include "qabstractaxis_p.h"
35
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37
38 class QCategoriesAxisPrivate : public QAbstractAxisPrivate
39 {
40 Q_OBJECT
41
42 public:
43 QCategoriesAxisPrivate(QCategoriesAxis *q);
44 ~QCategoriesAxisPrivate();
45
46 private:
47 QStringList m_categories;
48 QString m_minCategory;
49 QString m_maxCategory;
50
51 Q_SIGNALS:
52 void updated();
53
54 private:
55 Q_DECLARE_PUBLIC(QCategoriesAxis)
56 };
57
58 QTCOMMERCIALCHART_END_NAMESPACE
59
60 #endif // QCATEGORIESAXIS_P_H
@@ -0,0 +1,160
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 #include "qvaluesaxis.h"
22 #include "qvaluesaxis_p.h"
23
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
26 QValuesAxis::QValuesAxis(QObject *parent) :
27 QAbstractAxis(*new QValuesAxisPrivate(this),parent)
28 {
29
30 }
31
32 QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent)
33 {
34
35 }
36
37 QValuesAxis::~QValuesAxis()
38 {
39
40 }
41
42 void QValuesAxis::setMin(qreal min)
43 {
44 Q_D(QValuesAxis);
45 setRange(min,d->m_max);
46 }
47
48 qreal QValuesAxis::min() const
49 {
50 Q_D(const QValuesAxis);
51 return d->m_min;
52 }
53
54 void QValuesAxis::setMax(qreal max)
55 {
56 Q_D(QValuesAxis);
57 setRange(d->m_min,max);
58 }
59
60 qreal QValuesAxis::max() const
61 {
62 Q_D(const QValuesAxis);
63 return d->m_max;
64 }
65
66 /*!
67 Sets range from \a min to \a max on the axis.
68 */
69 void QValuesAxis::setRange(qreal min, qreal max)
70 {
71 Q_D(QValuesAxis);
72 bool changed = false;
73 if (!qFuzzyIsNull(d->m_min - min)) {
74 d->m_min = min;
75 changed = true;
76 emit minChanged(min);
77 }
78
79 if (!qFuzzyIsNull(d->m_max - max)) {
80 d->m_max = max;
81 changed = true;
82 emit maxChanged(max);
83 }
84
85 if (changed) {
86 emit rangeChanged(d->m_min,d->m_max);
87 emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers);
88 }
89 }
90
91 /*!
92 Sets \a count for ticks on the axis.
93 */
94 void QValuesAxis::setTicksCount(int count)
95 {
96 Q_D(QValuesAxis);
97 if (d->m_ticksCount != count) {
98 d->m_ticksCount = count;
99 emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers);
100 }
101 }
102
103 /*!
104 \fn int QAbstractAxis::ticksCount() const
105 Return number of ticks on the axis
106 */
107 int QValuesAxis::ticksCount() const
108 {
109 Q_D(const QValuesAxis);
110 return d->m_ticksCount;
111 }
112
113 void QValuesAxis::setNiceNumbersEnabled(bool enable)
114 {
115 Q_D(QValuesAxis);
116 if (d->m_niceNumbers != enable){
117 d->m_niceNumbers = enable;
118 emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers);
119 }
120 }
121
122 bool QValuesAxis::niceNumbersEnabled() const
123 {
124 Q_D(const QValuesAxis);
125 return d->m_niceNumbers;
126 }
127
128 QAbstractAxis::AxisType QValuesAxis::type() const
129 {
130 return AxisTypeValues;
131 }
132
133 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
134
135 QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q):
136 QAbstractAxisPrivate(q),
137 m_min(0),
138 m_max(0),
139 m_niceNumbers(false),
140 m_ticksCount(5)
141 {
142
143 }
144
145 QValuesAxisPrivate::~QValuesAxisPrivate()
146 {
147
148 }
149
150 void QValuesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count)
151 {
152 Q_Q(QValuesAxis);
153 q->setRange(min,max);
154 q->setTicksCount(count);
155 }
156
157 #include "moc_qvaluesaxis.cpp"
158 #include "moc_qvaluesaxis_p.cpp"
159
160 QTCOMMERCIALCHART_END_NAMESPACE
@@ -0,0 +1,74
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 #ifndef QVALUESAXIS_H
22 #define QVALUESAXIS_H
23
24 #include "qabstractaxis.h"
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
28 class QValuesAxisPrivate;
29
30 class QTCOMMERCIALCHART_EXPORT QValuesAxis : public QAbstractAxis
31 {
32 Q_OBJECT
33 Q_PROPERTY(int ticksCount READ ticksCount WRITE setTicksCount)
34 Q_PROPERTY(bool niceNumbersEnabled READ niceNumbersEnabled WRITE setNiceNumbersEnabled)
35 Q_PROPERTY(qreal min READ min WRITE setMin NOTIFY minChanged)
36 Q_PROPERTY(qreal max READ max WRITE setMax NOTIFY maxChanged)
37
38 public:
39 explicit QValuesAxis(QObject *parent = 0);
40 ~QValuesAxis();
41
42 protected:
43 QValuesAxis(QValuesAxisPrivate &d,QObject *parent = 0);
44
45 public:
46 AxisType type() const;
47
48 //range handling
49 void setMin(qreal min);
50 qreal min() const;
51 void setMax(qreal max);
52 qreal max() const;
53 void setRange(qreal min, qreal max);
54
55 //ticks handling
56 void setTicksCount(int count);
57 int ticksCount() const;
58
59 void setNiceNumbersEnabled(bool enable = true);
60 bool niceNumbersEnabled() const;
61
62 Q_SIGNALS:
63 void minChanged(qreal min);
64 void maxChanged(qreal max);
65 void rangeChanged(qreal min, qreal max);
66
67 private:
68 Q_DECLARE_PRIVATE(QValuesAxis)
69 Q_DISABLE_COPY(QValuesAxis)
70 };
71
72 QTCOMMERCIALCHART_END_NAMESPACE
73
74 #endif // QVALUESAXIS_H
@@ -0,0 +1,61
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 QVALUESAXIS_P_H
31 #define QVALUESAXIS_P_H
32
33 #include "qvaluesaxis.h"
34 #include "qabstractaxis_p.h"
35
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37
38 class QValuesAxisPrivate : public QAbstractAxisPrivate
39 {
40 Q_OBJECT
41 public:
42 QValuesAxisPrivate(QValuesAxis *q);
43 ~QValuesAxisPrivate();
44
45 Q_SIGNALS:
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 qreal m_min;
53 qreal m_max;
54 bool m_niceNumbers;
55 int m_ticksCount;
56 Q_DECLARE_PUBLIC(QValuesAxis)
57 };
58
59 QTCOMMERCIALCHART_END_NAMESPACE
60
61 #endif // QVALUESAXIS_P_H
@@ -6,15 +6,24 SOURCES += \
6 $$PWD/chartaxisx.cpp \
6 $$PWD/chartaxisx.cpp \
7 $$PWD/chartaxisy.cpp \
7 $$PWD/chartaxisy.cpp \
8 $$PWD/qaxis.cpp \
8 $$PWD/qaxis.cpp \
9 $$PWD/qaxiscategories.cpp
9 $$PWD/qaxiscategories.cpp \
10 $$PWD/qcategoriesaxis.cpp \
11 $$PWD/qvaluesaxis.cpp \
12 $$PWD/qabstractaxis.cpp
10
13
11 PRIVATE_HEADERS += \
14 PRIVATE_HEADERS += \
12 $$PWD/chartaxis_p.h \
15 $$PWD/chartaxis_p.h \
13 $$PWD/chartaxisx_p.h \
16 $$PWD/chartaxisx_p.h \
14 $$PWD/chartaxisy_p.h \
17 $$PWD/chartaxisy_p.h \
15 $$PWD/qaxis_p.h \
18 $$PWD/qaxis_p.h \
16 $$PWD/qaxiscategories_p.h
19 $$PWD/qaxiscategories_p.h \
20 $$PWD/qcategoriesaxis_p.h \
21 $$PWD/qvaluesaxis_p.h \
22 $$PWD/qabstractaxis_p.h
17
23
18 PUBLIC_HEADERS += \
24 PUBLIC_HEADERS += \
19 $$PWD/qaxis.h \
25 $$PWD/qaxis.h \
20 $$PWD/qaxiscategories.h No newline at end of file
26 $$PWD/qaxiscategories.h \
27 $$PWD/qcategoriesaxis.h \
28 $$PWD/qvaluesaxis.h \
29 $$PWD/qabstractaxis.h No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now