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