@@ -1,658 +1,658 | |||
|
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 "qabstractaxis.h" |
|
22 | 22 | #include "qabstractaxis_p.h" |
|
23 | 23 | |
|
24 | 24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
25 | 25 | |
|
26 | 26 | /*! |
|
27 | 27 | \class QAbstractAxis |
|
28 | 28 | \brief The QAbstractAxis class is used for manipulating chart's axis. |
|
29 | 29 | \mainclass |
|
30 | 30 | |
|
31 | 31 | There is only one x Axis visible at the time, however there can be multiple y axes. |
|
32 | 32 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
33 | 33 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
34 | 34 | */ |
|
35 | 35 | |
|
36 | 36 | /*! |
|
37 | 37 | \qmlclass AbstractAxis QAbstractAxis |
|
38 | 38 | \brief The Axis element is used for manipulating chart's axes |
|
39 | 39 | |
|
40 | 40 | There is only one x Axis visible at the time, however there can be multiple y axes on a ChartView. |
|
41 | 41 | Each chart series can be bound to exactly one Y axis and the shared common X axis. |
|
42 | 42 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
43 | 43 | |
|
44 | 44 | To access Axes you can use ChartView API. For example: |
|
45 | 45 | \code |
|
46 | 46 | ChartView { |
|
47 | 47 | axisX.min: 0 |
|
48 | 48 | axisX.max: 3 |
|
49 | 49 | axisX.ticksCount: 4 |
|
50 | 50 | axisY.min: 0 |
|
51 | 51 | axisY.max: 4 |
|
52 | 52 | // Add a few series... |
|
53 | 53 | } |
|
54 | 54 | \endcode |
|
55 | 55 | */ |
|
56 | 56 | |
|
57 | 57 | /*! |
|
58 | 58 | \enum QAbstractAxis::AxisType |
|
59 | 59 | |
|
60 | 60 | The type of the series object. |
|
61 | 61 | |
|
62 | 62 | \value AxisTypeNoAxis |
|
63 | 63 | \value AxisTypeValue |
|
64 | 64 | \value AxisTypeBarCategory |
|
65 | 65 | \value AxisTypeCategory |
|
66 | 66 | \value AxisTypeDateTime |
|
67 | 67 | */ |
|
68 | 68 | |
|
69 | 69 | /*! |
|
70 | 70 | *\fn void QAbstractAxis::type() const |
|
71 | 71 | Returns the type of the axis |
|
72 | 72 | */ |
|
73 | 73 | |
|
74 | 74 | /*! |
|
75 |
\property QAbstractAxis:: |
|
|
76 |
The visibility of the axis |
|
|
75 | \property QAbstractAxis::lineVisible | |
|
76 | The visibility of the axis line | |
|
77 | 77 | */ |
|
78 | 78 | /*! |
|
79 |
\qmlproperty bool AbstractAxis:: |
|
|
80 |
The visibility of the axis |
|
|
79 | \qmlproperty bool AbstractAxis::lineVisible | |
|
80 | The visibility of the axis line | |
|
81 | 81 | */ |
|
82 | 82 | |
|
83 | 83 | /*! |
|
84 | 84 | \property QAbstractAxis::labelsVisible |
|
85 | 85 | Defines if axis labels are visible. |
|
86 | 86 | */ |
|
87 | 87 | /*! |
|
88 | 88 | \qmlproperty bool AbstractAxis::labelsVisible |
|
89 | 89 | Defines if axis labels are visible. |
|
90 | 90 | */ |
|
91 | 91 | |
|
92 | 92 | /*! |
|
93 | 93 | \property QAbstractAxis::visible |
|
94 | 94 | The visibility of the axis. |
|
95 | 95 | */ |
|
96 | 96 | /*! |
|
97 | 97 | \qmlproperty bool AbstractAxis::visible |
|
98 | 98 | The visibility of the axis. |
|
99 | 99 | */ |
|
100 | 100 | |
|
101 | 101 | /*! |
|
102 | 102 | \property QAbstractAxis::gridVisible |
|
103 | 103 | The visibility of the grid lines. |
|
104 | 104 | */ |
|
105 | 105 | /*! |
|
106 | 106 | \qmlproperty bool AbstractAxis::gridVisible |
|
107 | 107 | The visibility of the grid lines. |
|
108 | 108 | */ |
|
109 | 109 | |
|
110 | 110 | /*! |
|
111 | 111 | \property QAbstractAxis::color |
|
112 | 112 | The color of the axis and ticks. |
|
113 | 113 | */ |
|
114 | 114 | /*! |
|
115 | 115 | \qmlproperty color AbstractAxis::color |
|
116 | 116 | The color of the axis and ticks. |
|
117 | 117 | */ |
|
118 | 118 | |
|
119 | 119 | /*! |
|
120 | 120 | \property QAbstractAxis::labelsFont |
|
121 | 121 | The font of the axis labels. |
|
122 | 122 | */ |
|
123 | 123 | |
|
124 | 124 | /*! |
|
125 | 125 | \qmlproperty Font AbstractAxis::labelsFont |
|
126 | 126 | The font of the axis labels. |
|
127 | 127 | |
|
128 | 128 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
129 | 129 | */ |
|
130 | 130 | |
|
131 | 131 | /*! |
|
132 | 132 | \property QAbstractAxis::labelsColor |
|
133 | 133 | The color of the axis labels. |
|
134 | 134 | */ |
|
135 | 135 | /*! |
|
136 | 136 | \qmlproperty color AbstractAxis::labelsColor |
|
137 | 137 | The color of the axis labels. |
|
138 | 138 | */ |
|
139 | 139 | |
|
140 | 140 | /*! |
|
141 | 141 | \property QAbstractAxis::labelsAngle |
|
142 | 142 | The angle of the axis labels in degrees. |
|
143 | 143 | */ |
|
144 | 144 | /*! |
|
145 | 145 | \qmlproperty int AbstractAxis::labelsAngle |
|
146 | 146 | The angle of the axis labels in degrees. |
|
147 | 147 | */ |
|
148 | 148 | |
|
149 | 149 | /*! |
|
150 | 150 | \property QAbstractAxis::shadesVisible |
|
151 | 151 | The visibility of the axis shades. |
|
152 | 152 | */ |
|
153 | 153 | /*! |
|
154 | 154 | \qmlproperty bool AbstractAxis::shadesVisible |
|
155 | 155 | The visibility of the axis shades. |
|
156 | 156 | */ |
|
157 | 157 | |
|
158 | 158 | /*! |
|
159 | 159 | \property QAbstractAxis::shadesColor |
|
160 | 160 | The fill (brush) color of the axis shades. |
|
161 | 161 | */ |
|
162 | 162 | /*! |
|
163 | 163 | \qmlproperty color AbstractAxis::shadesColor |
|
164 | 164 | The fill (brush) color of the axis shades. |
|
165 | 165 | */ |
|
166 | 166 | |
|
167 | 167 | /*! |
|
168 | 168 | \property QAbstractAxis::shadesBorderColor |
|
169 | 169 | The border (pen) color of the axis shades. |
|
170 | 170 | */ |
|
171 | 171 | /*! |
|
172 | 172 | \qmlproperty color AbstractAxis::shadesBorderColor |
|
173 | 173 | The border (pen) color of the axis shades. |
|
174 | 174 | */ |
|
175 | 175 | |
|
176 | 176 | /*! |
|
177 | 177 | \fn void QAbstractAxis::visibleChanged(bool visible) |
|
178 | 178 | Visiblity of the axis has changed to \a visible. |
|
179 | 179 | */ |
|
180 | 180 | /*! |
|
181 | 181 | \qmlsignal AbstractAxis::onVisibleChanged(bool visible) |
|
182 | 182 | Visiblity of the axis has changed to \a visible. |
|
183 | 183 | */ |
|
184 | 184 | |
|
185 | 185 | /*! |
|
186 |
\fn void QAbstractAxis:: |
|
|
187 |
Visiblity of the axis |
|
|
186 | \fn void QAbstractAxis::lineVisibleChanged(bool visible) | |
|
187 | Visiblity of the axis line has changed to \a visible. | |
|
188 | 188 | */ |
|
189 | 189 | /*! |
|
190 |
\qmlsignal AbstractAxis::on |
|
|
191 |
Visiblity of the axis |
|
|
190 | \qmlsignal AbstractAxis::onLineVisibleChanged(bool visible) | |
|
191 | Visiblity of the axis line has changed to \a visible. | |
|
192 | 192 | */ |
|
193 | 193 | |
|
194 | 194 | /*! |
|
195 | 195 | \fn void QAbstractAxis::labelsVisibleChanged(bool visible) |
|
196 | 196 | Visiblity of the labels of the axis has changed to \a visible. |
|
197 | 197 | */ |
|
198 | 198 | /*! |
|
199 | 199 | \qmlsignal AbstractAxis::onLabelsVisibleChanged(bool visible) |
|
200 | 200 | Visiblity of the labels of the axis has changed to \a visible. |
|
201 | 201 | */ |
|
202 | 202 | |
|
203 | 203 | /*! |
|
204 | 204 | \fn void QAbstractAxis::gridVisibleChanged(bool visible) |
|
205 | 205 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
206 | 206 | */ |
|
207 | 207 | /*! |
|
208 | 208 | \qmlsignal AbstractAxis::onGridVisibleChanged(bool visible) |
|
209 | 209 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
210 | 210 | */ |
|
211 | 211 | |
|
212 | 212 | /*! |
|
213 | 213 | \fn void QAbstractAxis::colorChanged(QColor color) |
|
214 | 214 | Emitted if the \a color of the axis is changed. |
|
215 | 215 | */ |
|
216 | 216 | /*! |
|
217 | 217 | \qmlsignal AbstractAxis::onColorChanged(QColor color) |
|
218 | 218 | Emitted if the \a color of the axis is changed. |
|
219 | 219 | */ |
|
220 | 220 | |
|
221 | 221 | /*! |
|
222 | 222 | \fn void QAbstractAxis::labelsColorChanged(QColor color) |
|
223 | 223 | Emitted if the \a color of the axis labels is changed. |
|
224 | 224 | */ |
|
225 | 225 | /*! |
|
226 | 226 | \qmlsignal AbstractAxis::onLabelsColorChanged(QColor color) |
|
227 | 227 | Emitted if the \a color of the axis labels is changed. |
|
228 | 228 | */ |
|
229 | 229 | |
|
230 | 230 | /*! |
|
231 | 231 | \fn void QAbstractAxis::shadesVisibleChanged(bool) |
|
232 | 232 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
233 | 233 | */ |
|
234 | 234 | /*! |
|
235 | 235 | \qmlsignal AbstractAxis::onShadesVisibleChanged(bool visible) |
|
236 | 236 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
237 | 237 | */ |
|
238 | 238 | |
|
239 | 239 | /*! |
|
240 | 240 | \fn void QAbstractAxis::shadesColorChanged(QColor color) |
|
241 | 241 | Emitted if the \a color of the axis shades is changed. |
|
242 | 242 | */ |
|
243 | 243 | /*! |
|
244 | 244 | \qmlsignal AbstractAxis::onShadesColorChanged(QColor color) |
|
245 | 245 | Emitted if the \a color of the axis shades is changed. |
|
246 | 246 | */ |
|
247 | 247 | |
|
248 | 248 | /*! |
|
249 | 249 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) |
|
250 | 250 | Emitted if the border \a color of the axis shades is changed. |
|
251 | 251 | */ |
|
252 | 252 | /*! |
|
253 | 253 | \qmlsignal AbstractAxis::onBorderColorChanged(QColor color) |
|
254 | 254 | Emitted if the border \a color of the axis shades is changed. |
|
255 | 255 | */ |
|
256 | 256 | |
|
257 | 257 | /*! |
|
258 | 258 | \internal |
|
259 | 259 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
260 | 260 | QChart when axis added. |
|
261 | 261 | */ |
|
262 | 262 | |
|
263 | 263 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) : |
|
264 | 264 | QObject(parent), |
|
265 | 265 | d_ptr(&d) |
|
266 | 266 | { |
|
267 | 267 | } |
|
268 | 268 | |
|
269 | 269 | /*! |
|
270 | 270 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
271 | 271 | */ |
|
272 | 272 | |
|
273 | 273 | QAbstractAxis::~QAbstractAxis() |
|
274 | 274 | { |
|
275 | 275 | if(d_ptr->m_dataset) qFatal("Still binded axis detected !"); |
|
276 | 276 | } |
|
277 | 277 | |
|
278 | 278 | /*! |
|
279 | 279 | Sets \a pen used to draw axis line and ticks. |
|
280 | 280 | */ |
|
281 | 281 | void QAbstractAxis::setLinePen(const QPen &pen) |
|
282 | 282 | { |
|
283 | 283 | if (d_ptr->m_axisPen!=pen) { |
|
284 | 284 | d_ptr->m_axisPen = pen; |
|
285 | 285 | d_ptr->emitUpdated(); |
|
286 | 286 | } |
|
287 | 287 | } |
|
288 | 288 | |
|
289 | 289 | /*! |
|
290 | 290 | Returns pen used to draw axis and ticks. |
|
291 | 291 | */ |
|
292 | 292 | QPen QAbstractAxis::linePen() const |
|
293 | 293 | { |
|
294 | 294 | return d_ptr->m_axisPen; |
|
295 | 295 | } |
|
296 | 296 | |
|
297 | 297 | void QAbstractAxis::setLinePenColor(QColor color) |
|
298 | 298 | { |
|
299 | 299 | QPen p = d_ptr->m_axisPen; |
|
300 | 300 | if (p.color() != color) { |
|
301 | 301 | p.setColor(color); |
|
302 | 302 | setLinePen(p); |
|
303 | 303 | emit colorChanged(color); |
|
304 | 304 | } |
|
305 | 305 | } |
|
306 | 306 | |
|
307 | 307 | QColor QAbstractAxis::linePenColor() const |
|
308 | 308 | { |
|
309 | 309 | return d_ptr->m_axisPen.color(); |
|
310 | 310 | } |
|
311 | 311 | |
|
312 | 312 | /*! |
|
313 | 313 | Sets if axis and ticks are \a visible. |
|
314 | 314 | */ |
|
315 | 315 | void QAbstractAxis::setLineVisible(bool visible) |
|
316 | 316 | { |
|
317 | 317 | if (d_ptr->m_arrowVisible != visible) { |
|
318 | 318 | d_ptr->m_arrowVisible = visible; |
|
319 | 319 | d_ptr->emitUpdated(); |
|
320 | 320 | emit lineVisibleChanged(visible); |
|
321 | 321 | } |
|
322 | 322 | } |
|
323 | 323 | |
|
324 | 324 | bool QAbstractAxis::isLineVisible() const |
|
325 | 325 | { |
|
326 | 326 | return d_ptr->m_arrowVisible; |
|
327 | 327 | } |
|
328 | 328 | |
|
329 | 329 | void QAbstractAxis::setGridLineVisible(bool visible) |
|
330 | 330 | { |
|
331 | 331 | if (d_ptr->m_gridLineVisible != visible) { |
|
332 | 332 | d_ptr->m_gridLineVisible = visible; |
|
333 | 333 | d_ptr->emitUpdated(); |
|
334 | 334 | emit gridVisibleChanged(visible); |
|
335 | 335 | } |
|
336 | 336 | } |
|
337 | 337 | |
|
338 | 338 | bool QAbstractAxis::isGridLineVisible() const |
|
339 | 339 | { |
|
340 | 340 | return d_ptr->m_gridLineVisible; |
|
341 | 341 | } |
|
342 | 342 | |
|
343 | 343 | /*! |
|
344 | 344 | Sets \a pen used to draw grid line. |
|
345 | 345 | */ |
|
346 | 346 | void QAbstractAxis::setGridLinePen(const QPen &pen) |
|
347 | 347 | { |
|
348 | 348 | if (d_ptr->m_gridLinePen != pen) { |
|
349 | 349 | d_ptr->m_gridLinePen = pen; |
|
350 | 350 | d_ptr->emitUpdated(); |
|
351 | 351 | } |
|
352 | 352 | } |
|
353 | 353 | |
|
354 | 354 | /*! |
|
355 | 355 | Returns pen used to draw grid. |
|
356 | 356 | */ |
|
357 | 357 | QPen QAbstractAxis::gridLinePen() const |
|
358 | 358 | { |
|
359 | 359 | return d_ptr->m_gridLinePen; |
|
360 | 360 | } |
|
361 | 361 | |
|
362 | 362 | void QAbstractAxis::setLabelsVisible(bool visible) |
|
363 | 363 | { |
|
364 | 364 | if (d_ptr->m_labelsVisible != visible) { |
|
365 | 365 | d_ptr->m_labelsVisible = visible; |
|
366 | 366 | d_ptr->emitUpdated(); |
|
367 | 367 | emit labelsVisibleChanged(visible); |
|
368 | 368 | } |
|
369 | 369 | } |
|
370 | 370 | |
|
371 | 371 | bool QAbstractAxis::labelsVisible() const |
|
372 | 372 | { |
|
373 | 373 | return d_ptr->m_labelsVisible; |
|
374 | 374 | } |
|
375 | 375 | |
|
376 | 376 | /*! |
|
377 | 377 | Sets \a pen used to draw labels. |
|
378 | 378 | */ |
|
379 | 379 | void QAbstractAxis::setLabelsPen(const QPen &pen) |
|
380 | 380 | { |
|
381 | 381 | if (d_ptr->m_labelsPen != pen) { |
|
382 | 382 | d_ptr->m_labelsPen = pen; |
|
383 | 383 | d_ptr->emitUpdated(); |
|
384 | 384 | } |
|
385 | 385 | } |
|
386 | 386 | |
|
387 | 387 | /*! |
|
388 | 388 | Returns the pen used to labels. |
|
389 | 389 | */ |
|
390 | 390 | QPen QAbstractAxis::labelsPen() const |
|
391 | 391 | { |
|
392 | 392 | return d_ptr->m_labelsPen; |
|
393 | 393 | } |
|
394 | 394 | |
|
395 | 395 | /*! |
|
396 | 396 | Sets \a brush used to draw labels. |
|
397 | 397 | */ |
|
398 | 398 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) |
|
399 | 399 | { |
|
400 | 400 | if (d_ptr->m_labelsBrush != brush) { |
|
401 | 401 | d_ptr->m_labelsBrush = brush; |
|
402 | 402 | d_ptr->emitUpdated(); |
|
403 | 403 | } |
|
404 | 404 | } |
|
405 | 405 | |
|
406 | 406 | /*! |
|
407 | 407 | Returns brush used to draw labels. |
|
408 | 408 | */ |
|
409 | 409 | QBrush QAbstractAxis::labelsBrush() const |
|
410 | 410 | { |
|
411 | 411 | return d_ptr->m_labelsBrush; |
|
412 | 412 | } |
|
413 | 413 | |
|
414 | 414 | /*! |
|
415 | 415 | Sets \a font used to draw labels. |
|
416 | 416 | */ |
|
417 | 417 | void QAbstractAxis::setLabelsFont(const QFont &font) |
|
418 | 418 | { |
|
419 | 419 | if (d_ptr->m_labelsFont != font) { |
|
420 | 420 | d_ptr->m_labelsFont = font; |
|
421 | 421 | d_ptr->emitUpdated(); |
|
422 | 422 | } |
|
423 | 423 | } |
|
424 | 424 | |
|
425 | 425 | /*! |
|
426 | 426 | Returns font used to draw labels. |
|
427 | 427 | */ |
|
428 | 428 | QFont QAbstractAxis::labelsFont() const |
|
429 | 429 | { |
|
430 | 430 | return d_ptr->m_labelsFont; |
|
431 | 431 | } |
|
432 | 432 | |
|
433 | 433 | void QAbstractAxis::setLabelsAngle(int angle) |
|
434 | 434 | { |
|
435 | 435 | if (d_ptr->m_labelsAngle != angle) { |
|
436 | 436 | d_ptr->m_labelsAngle = angle; |
|
437 | 437 | d_ptr->emitUpdated(); |
|
438 | 438 | } |
|
439 | 439 | } |
|
440 | 440 | |
|
441 | 441 | int QAbstractAxis::labelsAngle() const |
|
442 | 442 | { |
|
443 | 443 | return d_ptr->m_labelsAngle; |
|
444 | 444 | } |
|
445 | 445 | |
|
446 | 446 | void QAbstractAxis::setLabelsColor(QColor color) |
|
447 | 447 | { |
|
448 | 448 | QBrush b = d_ptr->m_labelsBrush; |
|
449 | 449 | if (b.color() != color) { |
|
450 | 450 | b.setColor(color); |
|
451 | 451 | setLabelsBrush(b); |
|
452 | 452 | emit labelsColorChanged(color); |
|
453 | 453 | } |
|
454 | 454 | } |
|
455 | 455 | |
|
456 | 456 | QColor QAbstractAxis::labelsColor() const |
|
457 | 457 | { |
|
458 | 458 | return d_ptr->m_labelsBrush.color(); |
|
459 | 459 | } |
|
460 | 460 | |
|
461 | 461 | void QAbstractAxis::setShadesVisible(bool visible) |
|
462 | 462 | { |
|
463 | 463 | if (d_ptr->m_shadesVisible != visible) { |
|
464 | 464 | d_ptr->m_shadesVisible = visible; |
|
465 | 465 | d_ptr->emitUpdated(); |
|
466 | 466 | emit shadesVisibleChanged(visible); |
|
467 | 467 | } |
|
468 | 468 | } |
|
469 | 469 | |
|
470 | 470 | bool QAbstractAxis::shadesVisible() const |
|
471 | 471 | { |
|
472 | 472 | return d_ptr->m_shadesVisible; |
|
473 | 473 | } |
|
474 | 474 | |
|
475 | 475 | /*! |
|
476 | 476 | Sets \a pen used to draw shades. |
|
477 | 477 | */ |
|
478 | 478 | void QAbstractAxis::setShadesPen(const QPen &pen) |
|
479 | 479 | { |
|
480 | 480 | if (d_ptr->m_shadesPen != pen) { |
|
481 | 481 | d_ptr->m_shadesPen = pen; |
|
482 | 482 | d_ptr->emitUpdated(); |
|
483 | 483 | } |
|
484 | 484 | } |
|
485 | 485 | |
|
486 | 486 | /*! |
|
487 | 487 | Returns pen used to draw shades. |
|
488 | 488 | */ |
|
489 | 489 | QPen QAbstractAxis::shadesPen() const |
|
490 | 490 | { |
|
491 | 491 | return d_ptr->m_shadesPen; |
|
492 | 492 | } |
|
493 | 493 | |
|
494 | 494 | /*! |
|
495 | 495 | Sets \a brush used to draw shades. |
|
496 | 496 | */ |
|
497 | 497 | void QAbstractAxis::setShadesBrush(const QBrush &brush) |
|
498 | 498 | { |
|
499 | 499 | if (d_ptr->m_shadesBrush != brush) { |
|
500 | 500 | d_ptr->m_shadesBrush = brush; |
|
501 | 501 | d_ptr->emitUpdated(); |
|
502 | 502 | emit shadesColorChanged(brush.color()); |
|
503 | 503 | } |
|
504 | 504 | } |
|
505 | 505 | |
|
506 | 506 | /*! |
|
507 | 507 | Returns brush used to draw shades. |
|
508 | 508 | */ |
|
509 | 509 | QBrush QAbstractAxis::shadesBrush() const |
|
510 | 510 | { |
|
511 | 511 | return d_ptr->m_shadesBrush; |
|
512 | 512 | } |
|
513 | 513 | |
|
514 | 514 | void QAbstractAxis::setShadesColor(QColor color) |
|
515 | 515 | { |
|
516 | 516 | QBrush b = d_ptr->m_shadesBrush; |
|
517 | 517 | b.setColor(color); |
|
518 | 518 | setShadesBrush(b); |
|
519 | 519 | } |
|
520 | 520 | |
|
521 | 521 | QColor QAbstractAxis::shadesColor() const |
|
522 | 522 | { |
|
523 | 523 | return d_ptr->m_shadesBrush.color(); |
|
524 | 524 | } |
|
525 | 525 | |
|
526 | 526 | void QAbstractAxis::setShadesBorderColor(QColor color) |
|
527 | 527 | { |
|
528 | 528 | QPen p = d_ptr->m_shadesPen; |
|
529 | 529 | p.setColor(color); |
|
530 | 530 | setShadesPen(p); |
|
531 | 531 | } |
|
532 | 532 | |
|
533 | 533 | QColor QAbstractAxis::shadesBorderColor() const |
|
534 | 534 | { |
|
535 | 535 | return d_ptr->m_shadesPen.color(); |
|
536 | 536 | } |
|
537 | 537 | |
|
538 | 538 | |
|
539 | 539 | bool QAbstractAxis::isVisible() const |
|
540 | 540 | { |
|
541 | 541 | return d_ptr->m_visible; |
|
542 | 542 | } |
|
543 | 543 | |
|
544 | 544 | /*! |
|
545 | 545 | Sets axis, shades, labels and grid lines to be visible. |
|
546 | 546 | */ |
|
547 | 547 | void QAbstractAxis::setVisible(bool visible) |
|
548 | 548 | { |
|
549 | 549 | if(d_ptr->m_visible!=visible){ |
|
550 | 550 | d_ptr->m_visible=visible; |
|
551 | 551 | d_ptr->emitUpdated(); |
|
552 | 552 | emit visibleChanged(visible); |
|
553 | 553 | } |
|
554 | 554 | } |
|
555 | 555 | |
|
556 | 556 | |
|
557 | 557 | /*! |
|
558 | 558 | Sets axis, shades, labels and grid lines to be visible. |
|
559 | 559 | */ |
|
560 | 560 | void QAbstractAxis::show() |
|
561 | 561 | { |
|
562 | 562 | setVisible(true); |
|
563 | 563 | } |
|
564 | 564 | |
|
565 | 565 | /*! |
|
566 | 566 | Sets axis, shades, labels and grid lines to not be visible. |
|
567 | 567 | */ |
|
568 | 568 | void QAbstractAxis::hide() |
|
569 | 569 | { |
|
570 | 570 | setVisible(false); |
|
571 | 571 | } |
|
572 | 572 | |
|
573 | 573 | /*! |
|
574 | 574 | Sets the minimum value shown on the axis. |
|
575 | 575 | Depending on the actual axis type the \a min paramter is converted to appropriate type. |
|
576 | 576 | If the conversion is impossible then the function call does nothing |
|
577 | 577 | */ |
|
578 | 578 | void QAbstractAxis::setMin(const QVariant &min) |
|
579 | 579 | { |
|
580 | 580 | d_ptr->setMin(min); |
|
581 | 581 | } |
|
582 | 582 | |
|
583 | 583 | /*! |
|
584 | 584 | Sets the maximum value shown on the axis. |
|
585 | 585 | Depending on the actual axis type the \a max paramter is converted to appropriate type. |
|
586 | 586 | If the conversion is impossible then the function call does nothing |
|
587 | 587 | */ |
|
588 | 588 | void QAbstractAxis::setMax(const QVariant &max) |
|
589 | 589 | { |
|
590 | 590 | d_ptr->setMax(max); |
|
591 | 591 | } |
|
592 | 592 | |
|
593 | 593 | /*! |
|
594 | 594 | Sets the range shown on the axis. |
|
595 | 595 | Depending on the actual axis type the \a min and \a max paramters are converted to appropriate types. |
|
596 | 596 | If the conversion is impossible then the function call does nothing. |
|
597 | 597 | */ |
|
598 | 598 | void QAbstractAxis::setRange(const QVariant &min, const QVariant &max) |
|
599 | 599 | { |
|
600 | 600 | d_ptr->setRange(min,max); |
|
601 | 601 | } |
|
602 | 602 | |
|
603 | 603 | |
|
604 | 604 | /*! |
|
605 | 605 | Returns the orientation in which the axis is being used (Vertical or Horizontal) |
|
606 | 606 | */ |
|
607 | 607 | Qt::Orientation QAbstractAxis::orientation() |
|
608 | 608 | { |
|
609 | 609 | return d_ptr->m_orientation; |
|
610 | 610 | } |
|
611 | 611 | |
|
612 | 612 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
613 | 613 | |
|
614 | 614 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): |
|
615 | 615 | q_ptr(q), |
|
616 | 616 | m_orientation(Qt::Orientation(0)), |
|
617 | 617 | m_dataset(0), |
|
618 | 618 | m_visible(false), |
|
619 | 619 | m_arrowVisible(true), |
|
620 | 620 | m_gridLineVisible(true), |
|
621 | 621 | m_labelsVisible(true), |
|
622 | 622 | m_labelsAngle(0), |
|
623 | 623 | m_shadesVisible(false), |
|
624 | 624 | m_shadesBrush(Qt::SolidPattern), |
|
625 | 625 | m_shadesOpacity(1.0), |
|
626 | 626 | m_dirty(false) |
|
627 | 627 | { |
|
628 | 628 | |
|
629 | 629 | } |
|
630 | 630 | |
|
631 | 631 | QAbstractAxisPrivate::~QAbstractAxisPrivate() |
|
632 | 632 | { |
|
633 | 633 | |
|
634 | 634 | } |
|
635 | 635 | |
|
636 | 636 | void QAbstractAxisPrivate::emitUpdated() |
|
637 | 637 | { |
|
638 | 638 | if(!m_dirty){ |
|
639 | 639 | m_dirty=true; |
|
640 | 640 | emit updated(); |
|
641 | 641 | } |
|
642 | 642 | } |
|
643 | 643 | |
|
644 | 644 | void QAbstractAxisPrivate::setDirty(bool dirty) |
|
645 | 645 | { |
|
646 | 646 | m_dirty=dirty; |
|
647 | 647 | } |
|
648 | 648 | |
|
649 | 649 | void QAbstractAxisPrivate::setOrientation(Qt::Orientation orientation) |
|
650 | 650 | { |
|
651 | 651 | m_orientation=orientation; |
|
652 | 652 | } |
|
653 | 653 | |
|
654 | 654 | |
|
655 | 655 | #include "moc_qabstractaxis.cpp" |
|
656 | 656 | #include "moc_qabstractaxis_p.cpp" |
|
657 | 657 | |
|
658 | 658 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now