@@ -1,149 +1,149 | |||
|
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 "qcategoriesaxis.h" |
|
22 | 22 | #include "qcategoriesaxis_p.h" |
|
23 | 23 | #include "chartcategoriesaxisx_p.h" |
|
24 | 24 | #include "chartcategoriesaxisy_p.h" |
|
25 | 25 | #include <qmath.h> |
|
26 | 26 | #include <QDebug> |
|
27 | 27 | |
|
28 | 28 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
29 | 29 | |
|
30 |
Q |
|
|
31 |
QValuesAxis(*new Q |
|
|
30 | QIntervalAxis::QIntervalAxis(QObject *parent): | |
|
31 | QValuesAxis(*new QIntervalAxisPrivate(this),parent) | |
|
32 | 32 | { |
|
33 | 33 | } |
|
34 | 34 | |
|
35 |
Q |
|
|
35 | QIntervalAxis::~QIntervalAxis() | |
|
36 | 36 | { |
|
37 | 37 | } |
|
38 | 38 | |
|
39 |
Q |
|
|
39 | QIntervalAxis::QIntervalAxis(QIntervalAxisPrivate &d,QObject *parent):QValuesAxis(d,parent) | |
|
40 | 40 | { |
|
41 | 41 | |
|
42 | 42 | } |
|
43 | 43 | |
|
44 | 44 | /*! |
|
45 | 45 | Appends \a categories to axis |
|
46 | 46 | */ |
|
47 |
void Q |
|
|
47 | void QIntervalAxis::append(const QString& category, qreal x) | |
|
48 | 48 | { |
|
49 |
Q_D(Q |
|
|
49 | Q_D(QIntervalAxis); | |
|
50 | 50 | if (!d->m_categories.contains(category)) |
|
51 | 51 | { |
|
52 | 52 | if(d->m_categories.isEmpty()){ |
|
53 | 53 | Range range(d->m_categoryMinimum,x); |
|
54 | 54 | d->m_categoriesMap.insert(category,range); |
|
55 | 55 | d->m_categories.append(category); |
|
56 | 56 | }else{ |
|
57 | 57 | Range range = d->m_categoriesMap.value(d->m_categories.last()); |
|
58 | 58 | d->m_categoriesMap.insert(category,Range(range.first,x)); |
|
59 | 59 | d->m_categories.append(category); |
|
60 | 60 | } |
|
61 | 61 | setRange(d->m_min,x); |
|
62 | 62 | } |
|
63 | 63 | } |
|
64 | 64 | |
|
65 |
void Q |
|
|
65 | void QIntervalAxis::setFisrtCategoryMinimum(qreal x) | |
|
66 | 66 | { |
|
67 |
Q_D(Q |
|
|
67 | Q_D(QIntervalAxis); | |
|
68 | 68 | if(d->m_categories.isEmpty()){ |
|
69 | 69 | d->m_categoryMinimum=x; |
|
70 | 70 | }else{ |
|
71 | 71 | Range range = d->m_categoriesMap.value(d->m_categories.first()); |
|
72 | 72 | d->m_categoriesMap.insert(d->m_categories.first(),Range(x,range.second)); |
|
73 | 73 | setRange(x,d->m_min); |
|
74 | 74 | } |
|
75 | 75 | } |
|
76 | 76 | |
|
77 | 77 | /*! |
|
78 | 78 | Removes \a category from axis |
|
79 | 79 | */ |
|
80 |
void Q |
|
|
80 | void QIntervalAxis::remove(const QString &category) | |
|
81 | 81 | { |
|
82 | 82 | Q_UNUSED(category); |
|
83 | 83 | //TODO |
|
84 | 84 | } |
|
85 | 85 | |
|
86 |
QStringList Q |
|
|
86 | QStringList QIntervalAxis::categories() | |
|
87 | 87 | { |
|
88 |
Q_D(Q |
|
|
88 | Q_D(QIntervalAxis); | |
|
89 | 89 | return d->m_categories; |
|
90 | 90 | } |
|
91 | 91 | |
|
92 | 92 | /*! |
|
93 | 93 | Returns number of categories. |
|
94 | 94 | */ |
|
95 |
int Q |
|
|
95 | int QIntervalAxis::count() const | |
|
96 | 96 | { |
|
97 |
Q_D(const Q |
|
|
97 | Q_D(const QIntervalAxis); | |
|
98 | 98 | return d->m_categories.count(); |
|
99 | 99 | } |
|
100 | 100 | |
|
101 | 101 | /*! |
|
102 | 102 | Returns the type of axis. |
|
103 | 103 | */ |
|
104 |
QAbstractAxis::AxisType Q |
|
|
104 | QAbstractAxis::AxisType QIntervalAxis::type() const | |
|
105 | 105 | { |
|
106 | 106 | return AxisTypeCategories; |
|
107 | 107 | } |
|
108 | 108 | |
|
109 | 109 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
110 | 110 | |
|
111 |
Q |
|
|
111 | QIntervalAxisPrivate::QIntervalAxisPrivate(QIntervalAxis* q): | |
|
112 | 112 | QValuesAxisPrivate(q), |
|
113 | 113 | m_categoryMinimum(0) |
|
114 | 114 | { |
|
115 | 115 | |
|
116 | 116 | } |
|
117 | 117 | |
|
118 |
Q |
|
|
118 | QIntervalAxisPrivate::~QIntervalAxisPrivate() | |
|
119 | 119 | { |
|
120 | 120 | |
|
121 | 121 | } |
|
122 | 122 | |
|
123 |
int Q |
|
|
123 | int QIntervalAxisPrivate::ticksCount() const | |
|
124 | 124 | { |
|
125 | 125 | return m_categories.count()+1; |
|
126 | 126 | } |
|
127 | 127 | |
|
128 |
void Q |
|
|
128 | void QIntervalAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
|
129 | 129 | { |
|
130 | 130 | m_min = min; |
|
131 | 131 | m_max = max; |
|
132 | 132 | m_ticksCount = count; |
|
133 | 133 | } |
|
134 | 134 | |
|
135 |
ChartAxis* Q |
|
|
135 | ChartAxis* QIntervalAxisPrivate::createGraphics(ChartPresenter* presenter) | |
|
136 | 136 | { |
|
137 | 137 | Q_UNUSED(presenter); |
|
138 | 138 | // Q_Q( QCategoriesAxis); |
|
139 | 139 | if(m_orientation == Qt::Vertical){ |
|
140 | 140 | return 0; |
|
141 | 141 | }else{ |
|
142 | 142 | return 0; |
|
143 | 143 | } |
|
144 | 144 | } |
|
145 | 145 | |
|
146 | 146 | #include "moc_qcategoriesaxis.cpp" |
|
147 | 147 | #include "moc_qcategoriesaxis_p.cpp" |
|
148 | 148 | |
|
149 | 149 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,64 +1,64 | |||
|
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 | #ifndef QCATEGORIESAXIS_H |
|
22 | 22 | #define QCATEGORIESAXIS_H |
|
23 | 23 | |
|
24 | 24 | #include "qabstractaxis.h" |
|
25 | 25 | #include "qvaluesaxis.h" |
|
26 | 26 | |
|
27 | 27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
28 | 28 | |
|
29 |
class Q |
|
|
29 | class QIntervalAxisPrivate; | |
|
30 | 30 | |
|
31 |
class QTCOMMERCIALCHART_EXPORT Q |
|
|
31 | class QTCOMMERCIALCHART_EXPORT QIntervalAxis : public QValuesAxis | |
|
32 | 32 | { |
|
33 | 33 | Q_OBJECT |
|
34 | 34 | |
|
35 | 35 | public: |
|
36 |
explicit Q |
|
|
37 |
~Q |
|
|
36 | explicit QIntervalAxis(QObject *parent = 0); | |
|
37 | ~QIntervalAxis(); | |
|
38 | 38 | |
|
39 | 39 | protected: |
|
40 |
Q |
|
|
40 | QIntervalAxis(QIntervalAxisPrivate &d,QObject *parent = 0); | |
|
41 | 41 | |
|
42 | 42 | public: |
|
43 | 43 | AxisType type() const; |
|
44 | 44 | |
|
45 | 45 | void append(const QString& category, qreal interval = 1); |
|
46 | 46 | void remove(const QString& category); |
|
47 | 47 | |
|
48 | 48 | void setFisrtCategoryMinimum(qreal x); |
|
49 | 49 | |
|
50 | 50 | qreal categoryMin(const QString& category) const; |
|
51 | 51 | qreal categoryMax(const QString& category) const; |
|
52 | 52 | |
|
53 | 53 | QStringList categories(); |
|
54 | 54 | int count() const; |
|
55 | 55 | |
|
56 | 56 | |
|
57 | 57 | private: |
|
58 |
Q_DECLARE_PRIVATE(Q |
|
|
59 |
Q_DISABLE_COPY(Q |
|
|
58 | Q_DECLARE_PRIVATE(QIntervalAxis) | |
|
59 | Q_DISABLE_COPY(QIntervalAxis) | |
|
60 | 60 | }; |
|
61 | 61 | |
|
62 | 62 | QTCOMMERCIALCHART_END_NAMESPACE |
|
63 | 63 | |
|
64 | 64 | #endif // QCATEGORIESAXIS_H |
@@ -1,71 +1,71 | |||
|
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 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the QtCommercial Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef QCATEGORIESAXIS_P_H |
|
31 | 31 | #define QCATEGORIESAXIS_P_H |
|
32 | 32 | |
|
33 | 33 | #include "qcategoriesaxis.h" |
|
34 | 34 | #include "qvaluesaxis_p.h" |
|
35 | 35 | |
|
36 | 36 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
37 | 37 | |
|
38 | 38 | |
|
39 | 39 | typedef QPair<qreal, qreal> Range; |
|
40 | 40 | |
|
41 |
class Q |
|
|
41 | class QIntervalAxisPrivate : public QValuesAxisPrivate | |
|
42 | 42 | { |
|
43 | 43 | Q_OBJECT |
|
44 | 44 | |
|
45 | 45 | public: |
|
46 |
Q |
|
|
47 |
~Q |
|
|
46 | QIntervalAxisPrivate(QIntervalAxis *q); | |
|
47 | ~QIntervalAxisPrivate(); | |
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | public: |
|
51 | 51 | ChartAxis* createGraphics(ChartPresenter* presenter); |
|
52 | 52 | int ticksCount() const; |
|
53 | 53 | |
|
54 | 54 | Q_SIGNALS: |
|
55 | 55 | void changed(qreal min, qreal max, int tickCount,bool niceNumbers); |
|
56 | 56 | |
|
57 | 57 | public Q_SLOTS: |
|
58 | 58 | void handleAxisRangeChanged(qreal min, qreal max,int count); |
|
59 | 59 | |
|
60 | 60 | private: |
|
61 | 61 | QMap<QString , Range> m_categoriesMap; |
|
62 | 62 | QStringList m_categories; |
|
63 | 63 | qreal m_categoryMinimum; |
|
64 | 64 | |
|
65 | 65 | private: |
|
66 |
Q_DECLARE_PUBLIC(Q |
|
|
66 | Q_DECLARE_PUBLIC(QIntervalAxis) | |
|
67 | 67 | }; |
|
68 | 68 | |
|
69 | 69 | QTCOMMERCIALCHART_END_NAMESPACE |
|
70 | 70 | |
|
71 | 71 | #endif // QCATEGORIESAXIS_P_H |
General Comments 0
You need to be logged in to leave comments.
Login now