@@ -1,604 +1,587 | |||||
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 "qabstractaxis.h" |
|
21 | #include "qabstractaxis.h" | |
22 | #include "qabstractaxis_p.h" |
|
22 | #include "qabstractaxis_p.h" | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
24 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
25 |
|
25 | |||
26 | /*! |
|
26 | /*! | |
27 | \class QAbstractAxis |
|
27 | \class QAbstractAxis | |
28 | \brief The QAbstractAxis class is used for manipulating chart's axis. |
|
28 | \brief The QAbstractAxis class is used for manipulating chart's axis. | |
29 | \mainclass |
|
29 | \mainclass | |
30 |
|
30 | |||
31 | There is only one x Axis, however there can be multiple y axes. |
|
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. |
|
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. |
|
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \qmlclass Axis QAbstractAxis |
|
37 | \qmlclass Axis QAbstractAxis | |
38 | \brief The Axis element is used for manipulating chart's axes |
|
38 | \brief The Axis element is used for manipulating chart's axes | |
39 |
|
39 | |||
40 | There is only one x Axis, however there can be multiple y axes on a ChartView. |
|
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. |
|
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. |
|
42 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
43 |
|
43 | |||
44 | To access Axes you can use ChartView API. For example: |
|
44 | To access Axes you can use ChartView API. For example: | |
45 | \code |
|
45 | \code | |
46 | ChartView { |
|
46 | ChartView { | |
47 | axisX.min: 0 |
|
47 | axisX.min: 0 | |
48 | axisX.max: 3 |
|
48 | axisX.max: 3 | |
49 | axisX.ticksCount: 4 |
|
49 | axisX.ticksCount: 4 | |
50 | axisY.min: 0 |
|
50 | axisY.min: 0 | |
51 | axisY.max: 4 |
|
51 | axisY.max: 4 | |
52 | // Add a few series... |
|
52 | // Add a few series... | |
53 | } |
|
53 | } | |
54 | \endcode |
|
54 | \endcode | |
55 | */ |
|
55 | */ | |
56 |
|
56 | |||
57 | /*! |
|
57 | /*! | |
58 | \enum QAbstractAxis::AxisType |
|
58 | \enum QAbstractAxis::AxisType | |
59 |
|
59 | |||
60 | The type of the series object. |
|
60 | The type of the series object. | |
61 |
|
61 | |||
62 | \value AxisTypeValues |
|
62 | \value AxisTypeValues | |
63 | \value AxisTypeCategories |
|
63 | \value AxisTypeCategories | |
64 | */ |
|
64 | */ | |
65 |
|
65 | |||
66 |
/* |
|
66 | /* | |
67 | \property QAbstractAxis::type |
|
67 | \property QAbstractAxis::type | |
68 | The type of the axis. |
|
68 | The type of the axis. | |
69 | */ |
|
69 | */ | |
70 |
|
70 | |||
71 | /*! |
|
71 | /*! | |
72 | \property QAbstractAxis::labelsVisible |
|
72 | \property QAbstractAxis::labelsVisible | |
73 | Defines if axis labels are visible. |
|
73 | Defines if axis labels are visible. | |
74 | */ |
|
74 | */ | |
75 | /*! |
|
75 | /*! | |
76 | \qmlproperty bool Axis::labelsVisible |
|
76 | \qmlproperty bool Axis::labelsVisible | |
77 | Defines if axis labels are visible. |
|
77 | Defines if axis labels are visible. | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 |
/* |
|
80 | /* | |
81 | \property QAbstractAxis::min |
|
81 | \property QAbstractAxis::min | |
82 | Defines the minimum value on the axis. |
|
82 | Defines the minimum value on the axis. | |
83 | */ |
|
83 | */ | |
84 |
/* |
|
84 | /* | |
85 | \qmlproperty real Axis::min |
|
85 | \qmlproperty real Axis::min | |
86 | Defines the minimum value on the axis. |
|
86 | Defines the minimum value on the axis. | |
87 | */ |
|
87 | */ | |
88 |
|
88 | |||
89 |
/* |
|
89 | /* | |
90 | \property QAbstractAxis::max |
|
90 | \property QAbstractAxis::max | |
91 | Defines the maximum value on the axis. |
|
91 | Defines the maximum value on the axis. | |
92 | */ |
|
92 | */ | |
93 |
/* |
|
93 | /* | |
94 | \qmlproperty real Axis::max |
|
94 | \qmlproperty real Axis::max | |
95 | Defines the maximum value on the axis. |
|
95 | Defines the maximum value on the axis. | |
96 | */ |
|
96 | */ | |
97 |
|
97 | |||
98 | /*! |
|
98 | /*! | |
99 | \property QAbstractAxis::visible |
|
99 | \property QAbstractAxis::visible | |
100 | The visibility of the axis. |
|
100 | The visibility of the axis. | |
101 | */ |
|
101 | */ | |
102 | /*! |
|
102 | /*! | |
103 | \qmlproperty bool Axis::visible |
|
103 | \qmlproperty bool Axis::visible | |
104 | The visibility of the axis. |
|
104 | The visibility of the axis. | |
105 | */ |
|
105 | */ | |
106 |
|
106 | |||
107 | /*! |
|
107 | /*! | |
108 | \property QAbstractAxis::gridVisible |
|
108 | \property QAbstractAxis::gridVisible | |
109 | The visibility of the grid lines. |
|
109 | The visibility of the grid lines. | |
110 | */ |
|
110 | */ | |
111 | /*! |
|
111 | /*! | |
112 | \qmlproperty bool Axis::gridVisible |
|
112 | \qmlproperty bool Axis::gridVisible | |
113 | The visibility of the grid lines. |
|
113 | The visibility of the grid lines. | |
114 | */ |
|
114 | */ | |
115 |
|
115 | |||
116 | /*! |
|
116 | /*! | |
117 | \property QAbstractAxis::color |
|
117 | \property QAbstractAxis::color | |
118 | The color of the axis and ticks. |
|
118 | The color of the axis and ticks. | |
119 | */ |
|
119 | */ | |
120 | /*! |
|
120 | /*! | |
121 | \qmlproperty color Axis::color |
|
121 | \qmlproperty color Axis::color | |
122 | The color of the axis and ticks. |
|
122 | The color of the axis and ticks. | |
123 | */ |
|
123 | */ | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | \property QAxis::labelsFont |
|
126 | \property QAbstractAxis::labelsFont | |
127 | The font of the axis labels. |
|
127 | The font of the axis labels. | |
128 | */ |
|
128 | */ | |
|
129 | ||||
129 | /*! |
|
130 | /*! | |
130 | \qmlproperty Font Axis::labelsFont |
|
131 | \qmlproperty Font Axis::labelsFont | |
131 | The font of the axis labels. |
|
132 | The font of the axis labels. | |
132 |
|
133 | |||
133 | See the \l {Font} {QML Font Element} for detailed documentation. |
|
134 | See the \l {Font} {QML Font Element} for detailed documentation. | |
134 | */ |
|
135 | */ | |
135 |
|
136 | |||
136 | /*! |
|
137 | /*! | |
137 | \property QAbstractAxis::labelsColor |
|
138 | \property QAbstractAxis::labelsColor | |
138 | The color of the axis labels. |
|
139 | The color of the axis labels. | |
139 | */ |
|
140 | */ | |
140 | /*! |
|
141 | /*! | |
141 | \qmlproperty color Axis::labelsColor |
|
142 | \qmlproperty color Axis::labelsColor | |
142 | The color of the axis labels. |
|
143 | The color of the axis labels. | |
143 | */ |
|
144 | */ | |
144 |
|
145 | |||
145 | /*! |
|
146 | /*! | |
146 | \property QAbstractAxis::labelsAngle |
|
147 | \property QAbstractAxis::labelsAngle | |
147 | The angle of the axis labels in degrees. |
|
148 | The angle of the axis labels in degrees. | |
148 | */ |
|
149 | */ | |
149 | /*! |
|
150 | /*! | |
150 | \qmlproperty int Axis::labelsAngle |
|
151 | \qmlproperty int Axis::labelsAngle | |
151 | The angle of the axis labels in degrees. |
|
152 | The angle of the axis labels in degrees. | |
152 | */ |
|
153 | */ | |
153 |
|
154 | |||
154 | /*! |
|
155 | /*! | |
155 | \property QAbstractAxis::shadesVisible |
|
156 | \property QAbstractAxis::shadesVisible | |
156 | The visibility of the axis shades. |
|
157 | The visibility of the axis shades. | |
157 | */ |
|
158 | */ | |
158 | /*! |
|
159 | /*! | |
159 | \qmlproperty bool Axis::shadesVisible |
|
160 | \qmlproperty bool Axis::shadesVisible | |
160 | The visibility of the axis shades. |
|
161 | The visibility of the axis shades. | |
161 | */ |
|
162 | */ | |
162 |
|
163 | |||
163 | /*! |
|
164 | /*! | |
164 | \property QAbstractAxis::shadesColor |
|
165 | \property QAbstractAxis::shadesColor | |
165 | The fill (brush) color of the axis shades. |
|
166 | The fill (brush) color of the axis shades. | |
166 | */ |
|
167 | */ | |
167 | /*! |
|
168 | /*! | |
168 | \qmlproperty color Axis::shadesColor |
|
169 | \qmlproperty color Axis::shadesColor | |
169 | The fill (brush) color of the axis shades. |
|
170 | The fill (brush) color of the axis shades. | |
170 | */ |
|
171 | */ | |
171 |
|
172 | |||
172 | /*! |
|
173 | /*! | |
173 | \property QAbstractAxis::shadesBorderColor |
|
174 | \property QAbstractAxis::shadesBorderColor | |
174 | The border (pen) color of the axis shades. |
|
175 | The border (pen) color of the axis shades. | |
175 | */ |
|
176 | */ | |
176 | /*! |
|
177 | /*! | |
177 | \qmlproperty color Axis::shadesBorderColor |
|
178 | \qmlproperty color Axis::shadesBorderColor | |
178 | The border (pen) color of the axis shades. |
|
179 | The border (pen) color of the axis shades. | |
179 | */ |
|
180 | */ | |
180 |
|
181 | |||
181 | /*! |
|
182 | /*! | |
182 | \property QAbstractAxis::ticksCount |
|
|||
183 | The number of tick marks for the axis. |
|
|||
184 | */ |
|
|||
185 | /*! |
|
|||
186 | \qmlproperty int Axis::ticksCount |
|
|||
187 | The number of tick marks for the axis. |
|
|||
188 | */ |
|
|||
189 |
|
||||
190 | /*! |
|
|||
191 | \property QAbstractAxis::niceNumbersEnabled |
|
|||
192 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
|||
193 | */ |
|
|||
194 | /*! |
|
|||
195 | \qmlproperty bool Axis::niceNumbersEnabled |
|
|||
196 | Whether the nice numbers algorithm is enabled or not for the axis. |
|
|||
197 | */ |
|
|||
198 |
|
||||
199 | /*! |
|
|||
200 | \fn void QAbstractAxis::visibleChanged(bool) |
|
183 | \fn void QAbstractAxis::visibleChanged(bool) | |
201 | Visiblity of the axis has changed to \a visible. |
|
184 | Visiblity of the axis has changed to \a visible. | |
202 | */ |
|
185 | */ | |
203 |
|
186 | |||
204 | /*! |
|
187 | /*! | |
205 | \fn void QAbstractAxis::labelsVisibleChanged(bool) |
|
188 | \fn void QAbstractAxis::labelsVisibleChanged(bool) | |
206 | Visiblity of the labels of the axis has changed to \a visible. |
|
189 | Visiblity of the labels of the axis has changed to \a visible. | |
207 | */ |
|
190 | */ | |
208 |
|
191 | |||
209 | /*! |
|
192 | /*! | |
210 | \fn void QAbstractAxis::gridVisibleChanged(bool) |
|
193 | \fn void QAbstractAxis::gridVisibleChanged(bool) | |
211 | Visiblity of the grid lines of the axis has changed to \a visible. |
|
194 | Visiblity of the grid lines of the axis has changed to \a visible. | |
212 | */ |
|
195 | */ | |
213 |
|
196 | |||
214 |
/* |
|
197 | /* | |
215 | \fn void QAbstractAxis::minChanged(qreal min) |
|
198 | \fn void QAbstractAxis::minChanged(qreal min) | |
216 | Axis emits signal when \a min of axis has changed. |
|
199 | Axis emits signal when \a min of axis has changed. | |
217 | */ |
|
200 | */ | |
218 |
|
201 | |||
219 |
/* |
|
202 | /* | |
220 | \fn void QAbstractAxis::maxChanged(qreal max) |
|
203 | \fn void QAbstractAxis::maxChanged(qreal max) | |
221 | Axis emits signal when \a max of axis has changed. |
|
204 | Axis emits signal when \a max of axis has changed. | |
222 | */ |
|
205 | */ | |
223 |
|
206 | |||
224 |
/* |
|
207 | /* | |
225 | \fn void QAbstractAxis::rangeChanged(qreal min, qreal max) |
|
208 | \fn void QAbstractAxis::rangeChanged(qreal min, qreal max) | |
226 | Axis emits signal when \a min or \a max of axis has changed. |
|
209 | Axis emits signal when \a min or \a max of axis has changed. | |
227 | */ |
|
210 | */ | |
228 |
|
211 | |||
229 |
/* |
|
212 | /* | |
230 | \fn QChartAxisCategories* QAbstractAxis::categories() |
|
213 | \fn QChartAxisCategories* QAbstractAxis::categories() | |
231 | Returns pointer to the list of categories which correspond to the values on the axis. |
|
214 | Returns pointer to the list of categories which correspond to the values on the axis. | |
232 | */ |
|
215 | */ | |
233 |
|
216 | |||
234 | /*! |
|
217 | /*! | |
235 | \fn void QAbstractAxis::colorChanged(QColor) |
|
218 | \fn void QAbstractAxis::colorChanged(QColor) | |
236 | Emitted if the \a color of the axis is changed. |
|
219 | Emitted if the \a color of the axis is changed. | |
237 | */ |
|
220 | */ | |
238 |
|
221 | |||
239 | /*! |
|
222 | /*! | |
240 | \fn void QAbstractAxis::labelsColorChanged(QColor) |
|
223 | \fn void QAbstractAxis::labelsColorChanged(QColor) | |
241 | Emitted if the \a color of the axis labels is changed. |
|
224 | Emitted if the \a color of the axis labels is changed. | |
242 | */ |
|
225 | */ | |
243 |
|
226 | |||
244 | /*! |
|
227 | /*! | |
245 | \fn void QAbstractAxis::shadesVisibleChanged(bool) |
|
228 | \fn void QAbstractAxis::shadesVisibleChanged(bool) | |
246 | Emitted if the visibility of the axis shades is changed to \a visible. |
|
229 | Emitted if the visibility of the axis shades is changed to \a visible. | |
247 | */ |
|
230 | */ | |
248 |
|
231 | |||
249 | /*! |
|
232 | /*! | |
250 | \fn void QAbstractAxis::shadesColorChanged(QColor) |
|
233 | \fn void QAbstractAxis::shadesColorChanged(QColor) | |
251 | Emitted if the \a color of the axis shades is changed. |
|
234 | Emitted if the \a color of the axis shades is changed. | |
252 | */ |
|
235 | */ | |
253 |
|
236 | |||
254 | /*! |
|
237 | /*! | |
255 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) |
|
238 | \fn void QAbstractAxis::shadesBorderColorChanged(QColor) | |
256 | Emitted if the border \a color of the axis shades is changed. |
|
239 | Emitted if the border \a color of the axis shades is changed. | |
257 | */ |
|
240 | */ | |
258 |
|
241 | |||
259 | /*! |
|
242 | /*! | |
260 | Constructs new axis object which is a child of \a parent. Ownership is taken by |
|
243 | Constructs new axis object which is a child of \a parent. Ownership is taken by | |
261 | QChart when axis added. |
|
244 | QChart when axis added. | |
262 | */ |
|
245 | */ | |
263 |
|
246 | |||
264 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) : |
|
247 | QAbstractAxis::QAbstractAxis(QAbstractAxisPrivate &d, QObject *parent) : | |
265 | QObject(parent), |
|
248 | QObject(parent), | |
266 | d_ptr(&d) |
|
249 | d_ptr(&d) | |
267 | { |
|
250 | { | |
268 | } |
|
251 | } | |
269 |
|
252 | |||
270 | /*! |
|
253 | /*! | |
271 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. |
|
254 | Destructor of the axis object. When axis is added to chart, chart object takes ownership. | |
272 | */ |
|
255 | */ | |
273 |
|
256 | |||
274 | QAbstractAxis::~QAbstractAxis() |
|
257 | QAbstractAxis::~QAbstractAxis() | |
275 | { |
|
258 | { | |
276 | } |
|
259 | } | |
277 |
|
260 | |||
278 | /*! |
|
261 | /*! | |
279 | Sets \a pen used to draw axis line and ticks. |
|
262 | Sets \a pen used to draw axis line and ticks. | |
280 | */ |
|
263 | */ | |
281 | void QAbstractAxis::setAxisPen(const QPen &pen) |
|
264 | void QAbstractAxis::setAxisPen(const QPen &pen) | |
282 | { |
|
265 | { | |
283 | if (d_ptr->m_axisPen!=pen) { |
|
266 | if (d_ptr->m_axisPen!=pen) { | |
284 | d_ptr->m_axisPen = pen; |
|
267 | d_ptr->m_axisPen = pen; | |
285 | emit d_ptr->updated(); |
|
268 | emit d_ptr->updated(); | |
286 | } |
|
269 | } | |
287 | } |
|
270 | } | |
288 |
|
271 | |||
289 | /*! |
|
272 | /*! | |
290 | Returns pen used to draw axis and ticks. |
|
273 | Returns pen used to draw axis and ticks. | |
291 | */ |
|
274 | */ | |
292 | QPen QAbstractAxis::axisPen() const |
|
275 | QPen QAbstractAxis::axisPen() const | |
293 | { |
|
276 | { | |
294 | return d_ptr->m_axisPen; |
|
277 | return d_ptr->m_axisPen; | |
295 | } |
|
278 | } | |
296 |
|
279 | |||
297 | void QAbstractAxis::setAxisPenColor(QColor color) |
|
280 | void QAbstractAxis::setAxisPenColor(QColor color) | |
298 | { |
|
281 | { | |
299 | QPen p = d_ptr->m_axisPen; |
|
282 | QPen p = d_ptr->m_axisPen; | |
300 | if (p.color() != color) { |
|
283 | if (p.color() != color) { | |
301 | p.setColor(color); |
|
284 | p.setColor(color); | |
302 | setAxisPen(p); |
|
285 | setAxisPen(p); | |
303 | emit colorChanged(color); |
|
286 | emit colorChanged(color); | |
304 | } |
|
287 | } | |
305 | } |
|
288 | } | |
306 |
|
289 | |||
307 | QColor QAbstractAxis::axisPenColor() const |
|
290 | QColor QAbstractAxis::axisPenColor() const | |
308 | { |
|
291 | { | |
309 | return d_ptr->m_axisPen.color(); |
|
292 | return d_ptr->m_axisPen.color(); | |
310 | } |
|
293 | } | |
311 |
|
294 | |||
312 | /*! |
|
295 | /*! | |
313 | Sets if axis and ticks are \a visible. |
|
296 | Sets if axis and ticks are \a visible. | |
314 | */ |
|
297 | */ | |
315 | void QAbstractAxis::setAxisVisible(bool visible) |
|
298 | void QAbstractAxis::setAxisVisible(bool visible) | |
316 | { |
|
299 | { | |
317 | if (d_ptr->m_axisVisible != visible) { |
|
300 | if (d_ptr->m_axisVisible != visible) { | |
318 | d_ptr->m_axisVisible = visible; |
|
301 | d_ptr->m_axisVisible = visible; | |
319 | emit d_ptr->updated(); |
|
302 | emit d_ptr->updated(); | |
320 | emit visibleChanged(visible); |
|
303 | emit visibleChanged(visible); | |
321 | } |
|
304 | } | |
322 | } |
|
305 | } | |
323 |
|
306 | |||
324 | bool QAbstractAxis::isAxisVisible() const |
|
307 | bool QAbstractAxis::isAxisVisible() const | |
325 | { |
|
308 | { | |
326 | return d_ptr->m_axisVisible; |
|
309 | return d_ptr->m_axisVisible; | |
327 | } |
|
310 | } | |
328 |
|
311 | |||
329 | void QAbstractAxis::setGridLineVisible(bool visible) |
|
312 | void QAbstractAxis::setGridLineVisible(bool visible) | |
330 | { |
|
313 | { | |
331 | if (d_ptr->m_gridLineVisible != visible) { |
|
314 | if (d_ptr->m_gridLineVisible != visible) { | |
332 | d_ptr->m_gridLineVisible = visible; |
|
315 | d_ptr->m_gridLineVisible = visible; | |
333 | emit d_ptr->updated(); |
|
316 | emit d_ptr->updated(); | |
334 | emit gridVisibleChanged(visible); |
|
317 | emit gridVisibleChanged(visible); | |
335 | } |
|
318 | } | |
336 | } |
|
319 | } | |
337 |
|
320 | |||
338 | bool QAbstractAxis::isGridLineVisible() const |
|
321 | bool QAbstractAxis::isGridLineVisible() const | |
339 | { |
|
322 | { | |
340 | return d_ptr->m_gridLineVisible; |
|
323 | return d_ptr->m_gridLineVisible; | |
341 | } |
|
324 | } | |
342 |
|
325 | |||
343 | /*! |
|
326 | /*! | |
344 | Sets \a pen used to draw grid line. |
|
327 | Sets \a pen used to draw grid line. | |
345 | */ |
|
328 | */ | |
346 | void QAbstractAxis::setGridLinePen(const QPen &pen) |
|
329 | void QAbstractAxis::setGridLinePen(const QPen &pen) | |
347 | { |
|
330 | { | |
348 | if (d_ptr->m_gridLinePen != pen) { |
|
331 | if (d_ptr->m_gridLinePen != pen) { | |
349 | d_ptr->m_gridLinePen = pen; |
|
332 | d_ptr->m_gridLinePen = pen; | |
350 | emit d_ptr->updated(); |
|
333 | emit d_ptr->updated(); | |
351 | } |
|
334 | } | |
352 | } |
|
335 | } | |
353 |
|
336 | |||
354 | /*! |
|
337 | /*! | |
355 | Returns pen used to draw grid. |
|
338 | Returns pen used to draw grid. | |
356 | */ |
|
339 | */ | |
357 | QPen QAbstractAxis::gridLinePen() const |
|
340 | QPen QAbstractAxis::gridLinePen() const | |
358 | { |
|
341 | { | |
359 | return d_ptr->m_gridLinePen; |
|
342 | return d_ptr->m_gridLinePen; | |
360 | } |
|
343 | } | |
361 |
|
344 | |||
362 | void QAbstractAxis::setLabelsVisible(bool visible) |
|
345 | void QAbstractAxis::setLabelsVisible(bool visible) | |
363 | { |
|
346 | { | |
364 | if (d_ptr->m_labelsVisible != visible) { |
|
347 | if (d_ptr->m_labelsVisible != visible) { | |
365 | d_ptr->m_labelsVisible = visible; |
|
348 | d_ptr->m_labelsVisible = visible; | |
366 | emit d_ptr->updated(); |
|
349 | emit d_ptr->updated(); | |
367 | emit labelsVisibleChanged(visible); |
|
350 | emit labelsVisibleChanged(visible); | |
368 | } |
|
351 | } | |
369 | } |
|
352 | } | |
370 |
|
353 | |||
371 | bool QAbstractAxis::labelsVisible() const |
|
354 | bool QAbstractAxis::labelsVisible() const | |
372 | { |
|
355 | { | |
373 | return d_ptr->m_labelsVisible; |
|
356 | return d_ptr->m_labelsVisible; | |
374 | } |
|
357 | } | |
375 |
|
358 | |||
376 | /*! |
|
359 | /*! | |
377 | Sets \a pen used to draw labels. |
|
360 | Sets \a pen used to draw labels. | |
378 | */ |
|
361 | */ | |
379 | void QAbstractAxis::setLabelsPen(const QPen &pen) |
|
362 | void QAbstractAxis::setLabelsPen(const QPen &pen) | |
380 | { |
|
363 | { | |
381 | if (d_ptr->m_labelsPen != pen) { |
|
364 | if (d_ptr->m_labelsPen != pen) { | |
382 | d_ptr->m_labelsPen = pen; |
|
365 | d_ptr->m_labelsPen = pen; | |
383 | emit d_ptr->updated(); |
|
366 | emit d_ptr->updated(); | |
384 | } |
|
367 | } | |
385 | } |
|
368 | } | |
386 |
|
369 | |||
387 | /*! |
|
370 | /*! | |
388 | Returns the pen used to labels. |
|
371 | Returns the pen used to labels. | |
389 | */ |
|
372 | */ | |
390 | QPen QAbstractAxis::labelsPen() const |
|
373 | QPen QAbstractAxis::labelsPen() const | |
391 | { |
|
374 | { | |
392 | return d_ptr->m_labelsPen; |
|
375 | return d_ptr->m_labelsPen; | |
393 | } |
|
376 | } | |
394 |
|
377 | |||
395 | /*! |
|
378 | /*! | |
396 | Sets \a brush used to draw labels. |
|
379 | Sets \a brush used to draw labels. | |
397 | */ |
|
380 | */ | |
398 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) |
|
381 | void QAbstractAxis::setLabelsBrush(const QBrush &brush) | |
399 | { |
|
382 | { | |
400 | if (d_ptr->m_labelsBrush != brush) { |
|
383 | if (d_ptr->m_labelsBrush != brush) { | |
401 | d_ptr->m_labelsBrush = brush; |
|
384 | d_ptr->m_labelsBrush = brush; | |
402 | emit d_ptr->updated(); |
|
385 | emit d_ptr->updated(); | |
403 | } |
|
386 | } | |
404 | } |
|
387 | } | |
405 |
|
388 | |||
406 | /*! |
|
389 | /*! | |
407 | Returns brush used to draw labels. |
|
390 | Returns brush used to draw labels. | |
408 | */ |
|
391 | */ | |
409 | QBrush QAbstractAxis::labelsBrush() const |
|
392 | QBrush QAbstractAxis::labelsBrush() const | |
410 | { |
|
393 | { | |
411 | return d_ptr->m_labelsBrush; |
|
394 | return d_ptr->m_labelsBrush; | |
412 | } |
|
395 | } | |
413 |
|
396 | |||
414 | /*! |
|
397 | /*! | |
415 | Sets \a font used to draw labels. |
|
398 | Sets \a font used to draw labels. | |
416 | */ |
|
399 | */ | |
417 | void QAbstractAxis::setLabelsFont(const QFont &font) |
|
400 | void QAbstractAxis::setLabelsFont(const QFont &font) | |
418 | { |
|
401 | { | |
419 | if (d_ptr->m_labelsFont != font) { |
|
402 | if (d_ptr->m_labelsFont != font) { | |
420 | d_ptr->m_labelsFont = font; |
|
403 | d_ptr->m_labelsFont = font; | |
421 | emit d_ptr->updated(); |
|
404 | emit d_ptr->updated(); | |
422 | } |
|
405 | } | |
423 | } |
|
406 | } | |
424 |
|
407 | |||
425 | /*! |
|
408 | /*! | |
426 | Returns font used to draw labels. |
|
409 | Returns font used to draw labels. | |
427 | */ |
|
410 | */ | |
428 | QFont QAbstractAxis::labelsFont() const |
|
411 | QFont QAbstractAxis::labelsFont() const | |
429 | { |
|
412 | { | |
430 | return d_ptr->m_labelsFont; |
|
413 | return d_ptr->m_labelsFont; | |
431 | } |
|
414 | } | |
432 |
|
415 | |||
433 | void QAbstractAxis::setLabelsAngle(int angle) |
|
416 | void QAbstractAxis::setLabelsAngle(int angle) | |
434 | { |
|
417 | { | |
435 | if (d_ptr->m_labelsAngle != angle) { |
|
418 | if (d_ptr->m_labelsAngle != angle) { | |
436 | d_ptr->m_labelsAngle = angle; |
|
419 | d_ptr->m_labelsAngle = angle; | |
437 | emit d_ptr->updated(); |
|
420 | emit d_ptr->updated(); | |
438 | } |
|
421 | } | |
439 | } |
|
422 | } | |
440 |
|
423 | |||
441 | int QAbstractAxis::labelsAngle() const |
|
424 | int QAbstractAxis::labelsAngle() const | |
442 | { |
|
425 | { | |
443 | return d_ptr->m_labelsAngle; |
|
426 | return d_ptr->m_labelsAngle; | |
444 | } |
|
427 | } | |
445 |
|
428 | |||
446 | void QAbstractAxis::setLabelsColor(QColor color) |
|
429 | void QAbstractAxis::setLabelsColor(QColor color) | |
447 | { |
|
430 | { | |
448 | QBrush b = d_ptr->m_labelsBrush; |
|
431 | QBrush b = d_ptr->m_labelsBrush; | |
449 | if (b.color() != color) { |
|
432 | if (b.color() != color) { | |
450 | b.setColor(color); |
|
433 | b.setColor(color); | |
451 | setLabelsBrush(b); |
|
434 | setLabelsBrush(b); | |
452 | emit labelsColorChanged(color); |
|
435 | emit labelsColorChanged(color); | |
453 | } |
|
436 | } | |
454 | } |
|
437 | } | |
455 |
|
438 | |||
456 | QColor QAbstractAxis::labelsColor() const |
|
439 | QColor QAbstractAxis::labelsColor() const | |
457 | { |
|
440 | { | |
458 | return d_ptr->m_labelsBrush.color(); |
|
441 | return d_ptr->m_labelsBrush.color(); | |
459 | } |
|
442 | } | |
460 |
|
443 | |||
461 | void QAbstractAxis::setShadesVisible(bool visible) |
|
444 | void QAbstractAxis::setShadesVisible(bool visible) | |
462 | { |
|
445 | { | |
463 | if (d_ptr->m_shadesVisible != visible) { |
|
446 | if (d_ptr->m_shadesVisible != visible) { | |
464 | d_ptr->m_shadesVisible = visible; |
|
447 | d_ptr->m_shadesVisible = visible; | |
465 | emit d_ptr->updated(); |
|
448 | emit d_ptr->updated(); | |
466 | emit shadesVisibleChanged(visible); |
|
449 | emit shadesVisibleChanged(visible); | |
467 | } |
|
450 | } | |
468 | } |
|
451 | } | |
469 |
|
452 | |||
470 | bool QAbstractAxis::shadesVisible() const |
|
453 | bool QAbstractAxis::shadesVisible() const | |
471 | { |
|
454 | { | |
472 | return d_ptr->m_shadesVisible; |
|
455 | return d_ptr->m_shadesVisible; | |
473 | } |
|
456 | } | |
474 |
|
457 | |||
475 | /*! |
|
458 | /*! | |
476 | Sets \a pen used to draw shades. |
|
459 | Sets \a pen used to draw shades. | |
477 | */ |
|
460 | */ | |
478 | void QAbstractAxis::setShadesPen(const QPen &pen) |
|
461 | void QAbstractAxis::setShadesPen(const QPen &pen) | |
479 | { |
|
462 | { | |
480 | if (d_ptr->m_shadesPen != pen) { |
|
463 | if (d_ptr->m_shadesPen != pen) { | |
481 | d_ptr->m_shadesPen = pen; |
|
464 | d_ptr->m_shadesPen = pen; | |
482 | emit d_ptr->updated(); |
|
465 | emit d_ptr->updated(); | |
483 | } |
|
466 | } | |
484 | } |
|
467 | } | |
485 |
|
468 | |||
486 | /*! |
|
469 | /*! | |
487 | Returns pen used to draw shades. |
|
470 | Returns pen used to draw shades. | |
488 | */ |
|
471 | */ | |
489 | QPen QAbstractAxis::shadesPen() const |
|
472 | QPen QAbstractAxis::shadesPen() const | |
490 | { |
|
473 | { | |
491 | return d_ptr->m_shadesPen; |
|
474 | return d_ptr->m_shadesPen; | |
492 | } |
|
475 | } | |
493 |
|
476 | |||
494 | /*! |
|
477 | /*! | |
495 | Sets \a brush used to draw shades. |
|
478 | Sets \a brush used to draw shades. | |
496 | */ |
|
479 | */ | |
497 | void QAbstractAxis::setShadesBrush(const QBrush &brush) |
|
480 | void QAbstractAxis::setShadesBrush(const QBrush &brush) | |
498 | { |
|
481 | { | |
499 | if (d_ptr->m_shadesBrush != brush) { |
|
482 | if (d_ptr->m_shadesBrush != brush) { | |
500 | d_ptr->m_shadesBrush = brush; |
|
483 | d_ptr->m_shadesBrush = brush; | |
501 | emit d_ptr->updated(); |
|
484 | emit d_ptr->updated(); | |
502 | emit shadesColorChanged(brush.color()); |
|
485 | emit shadesColorChanged(brush.color()); | |
503 | } |
|
486 | } | |
504 | } |
|
487 | } | |
505 |
|
488 | |||
506 | /*! |
|
489 | /*! | |
507 | Returns brush used to draw shades. |
|
490 | Returns brush used to draw shades. | |
508 | */ |
|
491 | */ | |
509 | QBrush QAbstractAxis::shadesBrush() const |
|
492 | QBrush QAbstractAxis::shadesBrush() const | |
510 | { |
|
493 | { | |
511 | return d_ptr->m_shadesBrush; |
|
494 | return d_ptr->m_shadesBrush; | |
512 | } |
|
495 | } | |
513 |
|
496 | |||
514 | void QAbstractAxis::setShadesColor(QColor color) |
|
497 | void QAbstractAxis::setShadesColor(QColor color) | |
515 | { |
|
498 | { | |
516 | QBrush b = d_ptr->m_shadesBrush; |
|
499 | QBrush b = d_ptr->m_shadesBrush; | |
517 | b.setColor(color); |
|
500 | b.setColor(color); | |
518 | setShadesBrush(b); |
|
501 | setShadesBrush(b); | |
519 | } |
|
502 | } | |
520 |
|
503 | |||
521 | QColor QAbstractAxis::shadesColor() const |
|
504 | QColor QAbstractAxis::shadesColor() const | |
522 | { |
|
505 | { | |
523 | return d_ptr->m_shadesBrush.color(); |
|
506 | return d_ptr->m_shadesBrush.color(); | |
524 | } |
|
507 | } | |
525 |
|
508 | |||
526 | void QAbstractAxis::setShadesBorderColor(QColor color) |
|
509 | void QAbstractAxis::setShadesBorderColor(QColor color) | |
527 | { |
|
510 | { | |
528 | QPen p = d_ptr->m_shadesPen; |
|
511 | QPen p = d_ptr->m_shadesPen; | |
529 | p.setColor(color); |
|
512 | p.setColor(color); | |
530 | setShadesPen(p); |
|
513 | setShadesPen(p); | |
531 | } |
|
514 | } | |
532 |
|
515 | |||
533 | QColor QAbstractAxis::shadesBorderColor() const |
|
516 | QColor QAbstractAxis::shadesBorderColor() const | |
534 | { |
|
517 | { | |
535 | return d_ptr->m_shadesPen.color(); |
|
518 | return d_ptr->m_shadesPen.color(); | |
536 | } |
|
519 | } | |
537 |
|
520 | |||
538 |
|
521 | |||
539 | /*! |
|
522 | /*! | |
540 | Sets axis, shades, labels and grid lines to be visible. |
|
523 | Sets axis, shades, labels and grid lines to be visible. | |
541 | */ |
|
524 | */ | |
542 | void QAbstractAxis::show() |
|
525 | void QAbstractAxis::show() | |
543 | { |
|
526 | { | |
544 | d_ptr->m_axisVisible=true; |
|
527 | d_ptr->m_axisVisible=true; | |
545 | d_ptr->m_gridLineVisible=true; |
|
528 | d_ptr->m_gridLineVisible=true; | |
546 | d_ptr->m_labelsVisible=true; |
|
529 | d_ptr->m_labelsVisible=true; | |
547 | d_ptr->m_shadesVisible=true; |
|
530 | d_ptr->m_shadesVisible=true; | |
548 | emit d_ptr->updated(); |
|
531 | emit d_ptr->updated(); | |
549 | } |
|
532 | } | |
550 |
|
533 | |||
551 | /*! |
|
534 | /*! | |
552 | Sets axis, shades, labels and grid lines to not be visible. |
|
535 | Sets axis, shades, labels and grid lines to not be visible. | |
553 | */ |
|
536 | */ | |
554 | void QAbstractAxis::hide() |
|
537 | void QAbstractAxis::hide() | |
555 | { |
|
538 | { | |
556 | d_ptr->m_axisVisible = false; |
|
539 | d_ptr->m_axisVisible = false; | |
557 | d_ptr->m_gridLineVisible = false; |
|
540 | d_ptr->m_gridLineVisible = false; | |
558 | d_ptr->m_labelsVisible = false; |
|
541 | d_ptr->m_labelsVisible = false; | |
559 | d_ptr->m_shadesVisible = false; |
|
542 | d_ptr->m_shadesVisible = false; | |
560 | emit d_ptr->updated(); |
|
543 | emit d_ptr->updated(); | |
561 | } |
|
544 | } | |
562 |
|
545 | |||
563 |
|
546 | |||
564 | void QAbstractAxis::setMin(const qreal min) |
|
547 | void QAbstractAxis::setMin(const qreal min) | |
565 | { |
|
548 | { | |
566 | d_ptr->setMin(min); |
|
549 | d_ptr->setMin(min); | |
567 | } |
|
550 | } | |
568 | void QAbstractAxis::setMax(const qreal max) |
|
551 | void QAbstractAxis::setMax(const qreal max) | |
569 | { |
|
552 | { | |
570 | d_ptr->setMax(max); |
|
553 | d_ptr->setMax(max); | |
571 | } |
|
554 | } | |
572 | void QAbstractAxis::setRange(const qreal min, const qreal max) |
|
555 | void QAbstractAxis::setRange(const qreal min, const qreal max) | |
573 | { |
|
556 | { | |
574 | d_ptr->setRange(min,max); |
|
557 | d_ptr->setRange(min,max); | |
575 | } |
|
558 | } | |
576 |
|
559 | |||
577 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
560 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
578 |
|
561 | |||
579 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): |
|
562 | QAbstractAxisPrivate::QAbstractAxisPrivate(QAbstractAxis* q): | |
580 | q_ptr(q), |
|
563 | q_ptr(q), | |
581 | m_axisVisible(true), |
|
564 | m_axisVisible(true), | |
582 | m_gridLineVisible(true), |
|
565 | m_gridLineVisible(true), | |
583 | m_labelsVisible(true), |
|
566 | m_labelsVisible(true), | |
584 | m_labelsAngle(0), |
|
567 | m_labelsAngle(0), | |
585 | m_shadesVisible(false), |
|
568 | m_shadesVisible(false), | |
586 | m_shadesBrush(Qt::SolidPattern), |
|
569 | m_shadesBrush(Qt::SolidPattern), | |
587 | m_shadesOpacity(1.0), |
|
570 | m_shadesOpacity(1.0), | |
588 | m_orientation(Qt::Orientation(0)), |
|
571 | m_orientation(Qt::Orientation(0)), | |
589 | m_min(0), |
|
572 | m_min(0), | |
590 | m_max(0), |
|
573 | m_max(0), | |
591 | m_ticksCount(5) |
|
574 | m_ticksCount(5) | |
592 | { |
|
575 | { | |
593 |
|
576 | |||
594 | } |
|
577 | } | |
595 |
|
578 | |||
596 | QAbstractAxisPrivate::~QAbstractAxisPrivate() |
|
579 | QAbstractAxisPrivate::~QAbstractAxisPrivate() | |
597 | { |
|
580 | { | |
598 |
|
581 | |||
599 | } |
|
582 | } | |
600 |
|
583 | |||
601 | #include "moc_qabstractaxis.cpp" |
|
584 | #include "moc_qabstractaxis.cpp" | |
602 | #include "moc_qabstractaxis_p.cpp" |
|
585 | #include "moc_qabstractaxis_p.cpp" | |
603 |
|
586 | |||
604 | QTCOMMERCIALCHART_END_NAMESPACE |
|
587 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,257 +1,277 | |||||
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 "qvaluesaxis.h" |
|
21 | #include "qvaluesaxis.h" | |
22 | #include "qvaluesaxis_p.h" |
|
22 | #include "qvaluesaxis_p.h" | |
23 | #include "chartvaluesaxisx_p.h" |
|
23 | #include "chartvaluesaxisx_p.h" | |
24 | #include "chartvaluesaxisy_p.h" |
|
24 | #include "chartvaluesaxisy_p.h" | |
25 | #include <QDebug> |
|
25 | #include <QDebug> | |
26 |
|
26 | |||
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
27 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
28 | /*! |
|
28 | /*! | |
29 | \class QValuesAxis |
|
29 | \class QValuesAxis | |
30 | \brief The QValuesAxis class is used for manipulating chart's axis. |
|
30 | \brief The QValuesAxis class is used for manipulating chart's axis. | |
31 | \mainclass |
|
31 | \mainclass | |
32 |
|
32 | |||
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
33 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
34 | */ |
|
34 | */ | |
35 |
|
35 | |||
36 | /*! |
|
36 | /*! | |
37 | \qmlclass Axis QValuesAxis |
|
37 | \qmlclass Axis QValuesAxis | |
38 | \brief The Axis element is used for manipulating chart's axes |
|
38 | \brief The Axis element is used for manipulating chart's axes | |
39 |
|
39 | |||
40 | Axis can be setup to show axis line with tick marks, grid lines and shades. |
|
40 | Axis can be setup to show axis line with tick marks, grid lines and shades. | |
41 |
|
41 | |||
42 | To access Axes you can use ChartView API. For example: |
|
42 | To access Axes you can use ChartView API. For example: | |
43 | \code |
|
43 | \code | |
44 | ChartView { |
|
44 | ChartView { | |
45 | axisX.min: 0 |
|
45 | axisX.min: 0 | |
46 | axisX.max: 3 |
|
46 | axisX.max: 3 | |
47 | axisX.ticksCount: 4 |
|
47 | axisX.ticksCount: 4 | |
48 | axisY.min: 0 |
|
48 | axisY.min: 0 | |
49 | axisY.max: 4 |
|
49 | axisY.max: 4 | |
50 | // Add a few series... |
|
50 | // Add a few series... | |
51 | } |
|
51 | } | |
52 | \endcode |
|
52 | \endcode | |
53 | */ |
|
53 | */ | |
54 |
|
54 | |||
55 | /*! |
|
55 | /*! | |
56 | \property QValuesAxis::min |
|
56 | \property QValuesAxis::min | |
57 | Defines the minimum value on the axis. |
|
57 | Defines the minimum value on the axis. | |
58 | */ |
|
58 | */ | |
59 | /*! |
|
59 | /*! | |
60 | \qmlproperty real Axis::min |
|
60 | \qmlproperty real Axis::min | |
61 | Defines the minimum value on the axis. |
|
61 | Defines the minimum value on the axis. | |
62 | */ |
|
62 | */ | |
63 |
|
63 | |||
64 | /*! |
|
64 | /*! | |
65 | \property QValuesAxis::max |
|
65 | \property QValuesAxis::max | |
66 | Defines the maximum value on the axis. |
|
66 | Defines the maximum value on the axis. | |
67 | */ |
|
67 | */ | |
68 | /*! |
|
68 | /*! | |
69 | \qmlproperty real Axis::max |
|
69 | \qmlproperty real Axis::max | |
70 | Defines the maximum value on the axis. |
|
70 | Defines the maximum value on the axis. | |
71 | */ |
|
71 | */ | |
72 |
|
72 | |||
73 | /*! |
|
73 | /*! | |
74 | \fn void QValuesAxis::minChanged(qreal min) |
|
74 | \fn void QValuesAxis::minChanged(qreal min) | |
75 | Axis emits signal when \a min of axis has changed. |
|
75 | Axis emits signal when \a min of axis has changed. | |
76 | */ |
|
76 | */ | |
77 |
|
77 | |||
78 | /*! |
|
78 | /*! | |
79 | \fn void QValuesAxis::maxChanged(qreal max) |
|
79 | \fn void QValuesAxis::maxChanged(qreal max) | |
80 | Axis emits signal when \a max of axis has changed. |
|
80 | Axis emits signal when \a max of axis has changed. | |
81 | */ |
|
81 | */ | |
82 |
|
82 | |||
83 | /*! |
|
83 | /*! | |
84 | \fn void QValuesAxis::rangeChanged(qreal min, qreal max) |
|
84 | \fn void QValuesAxis::rangeChanged(qreal min, qreal max) | |
85 | Axis emits signal when \a min or \a max of axis has changed. |
|
85 | Axis emits signal when \a min or \a max of axis has changed. | |
86 | */ |
|
86 | */ | |
87 |
|
87 | |||
|
88 | /*! | |||
|
89 | \property QValuesAxis::ticksCount | |||
|
90 | The number of tick marks for the axis. | |||
|
91 | */ | |||
|
92 | ||||
|
93 | /*! | |||
|
94 | \qmlproperty int Axis::ticksCount | |||
|
95 | The number of tick marks for the axis. | |||
|
96 | */ | |||
|
97 | ||||
|
98 | /*! | |||
|
99 | \property QValuesAxis::niceNumbersEnabled | |||
|
100 | Whether the nice numbers algorithm is enabled or not for the axis. | |||
|
101 | */ | |||
|
102 | ||||
|
103 | /*! | |||
|
104 | \qmlproperty bool Axis::niceNumbersEnabled | |||
|
105 | Whether the nice numbers algorithm is enabled or not for the axis. | |||
|
106 | */ | |||
|
107 | ||||
88 | QValuesAxis::QValuesAxis(QObject *parent) : |
|
108 | QValuesAxis::QValuesAxis(QObject *parent) : | |
89 | QAbstractAxis(*new QValuesAxisPrivate(this),parent) |
|
109 | QAbstractAxis(*new QValuesAxisPrivate(this),parent) | |
90 | { |
|
110 | { | |
91 |
|
111 | |||
92 | } |
|
112 | } | |
93 |
|
113 | |||
94 | QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent) |
|
114 | QValuesAxis::QValuesAxis(QValuesAxisPrivate &d,QObject *parent) : QAbstractAxis(d,parent) | |
95 | { |
|
115 | { | |
96 |
|
116 | |||
97 | } |
|
117 | } | |
98 |
|
118 | |||
99 | QValuesAxis::~QValuesAxis() |
|
119 | QValuesAxis::~QValuesAxis() | |
100 | { |
|
120 | { | |
101 |
|
121 | |||
102 | } |
|
122 | } | |
103 |
|
123 | |||
104 | void QValuesAxis::setMin(qreal min) |
|
124 | void QValuesAxis::setMin(qreal min) | |
105 | { |
|
125 | { | |
106 | Q_D(QValuesAxis); |
|
126 | Q_D(QValuesAxis); | |
107 | setRange(min,d->m_max); |
|
127 | setRange(min,d->m_max); | |
108 | } |
|
128 | } | |
109 |
|
129 | |||
110 | qreal QValuesAxis::min() const |
|
130 | qreal QValuesAxis::min() const | |
111 | { |
|
131 | { | |
112 | Q_D(const QValuesAxis); |
|
132 | Q_D(const QValuesAxis); | |
113 | return d->m_min; |
|
133 | return d->m_min; | |
114 | } |
|
134 | } | |
115 |
|
135 | |||
116 | void QValuesAxis::setMax(qreal max) |
|
136 | void QValuesAxis::setMax(qreal max) | |
117 | { |
|
137 | { | |
118 | Q_D(QValuesAxis); |
|
138 | Q_D(QValuesAxis); | |
119 | setRange(d->m_min,max); |
|
139 | setRange(d->m_min,max); | |
120 | } |
|
140 | } | |
121 |
|
141 | |||
122 | qreal QValuesAxis::max() const |
|
142 | qreal QValuesAxis::max() const | |
123 | { |
|
143 | { | |
124 | Q_D(const QValuesAxis); |
|
144 | Q_D(const QValuesAxis); | |
125 | return d->m_max; |
|
145 | return d->m_max; | |
126 | } |
|
146 | } | |
127 |
|
147 | |||
128 | /*! |
|
148 | /*! | |
129 | Sets range from \a min to \a max on the axis. |
|
149 | Sets range from \a min to \a max on the axis. | |
130 | */ |
|
150 | */ | |
131 | void QValuesAxis::setRange(qreal min, qreal max) |
|
151 | void QValuesAxis::setRange(qreal min, qreal max) | |
132 | { |
|
152 | { | |
133 | Q_D(QValuesAxis); |
|
153 | Q_D(QValuesAxis); | |
134 | d->setRange(min,max); |
|
154 | d->setRange(min,max); | |
135 | } |
|
155 | } | |
136 |
|
156 | |||
137 | /*! |
|
157 | /*! | |
138 | Sets \a count for ticks on the axis. |
|
158 | Sets \a count for ticks on the axis. | |
139 | */ |
|
159 | */ | |
140 | void QValuesAxis::setTicksCount(int count) |
|
160 | void QValuesAxis::setTicksCount(int count) | |
141 | { |
|
161 | { | |
142 | Q_D(QValuesAxis); |
|
162 | Q_D(QValuesAxis); | |
143 | if (d->m_ticksCount != count) { |
|
163 | if (d->m_ticksCount != count) { | |
144 | d->m_ticksCount = count; |
|
164 | d->m_ticksCount = count; | |
145 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); |
|
165 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); | |
146 | } |
|
166 | } | |
147 | } |
|
167 | } | |
148 |
|
168 | |||
149 | /*! |
|
169 | /*! | |
150 |
\fn int Q |
|
170 | \fn int QValuesAxis::ticksCount() const | |
151 | Return number of ticks on the axis |
|
171 | Return number of ticks on the axis | |
152 | */ |
|
172 | */ | |
153 | int QValuesAxis::ticksCount() const |
|
173 | int QValuesAxis::ticksCount() const | |
154 | { |
|
174 | { | |
155 | Q_D(const QValuesAxis); |
|
175 | Q_D(const QValuesAxis); | |
156 | return d->m_ticksCount; |
|
176 | return d->m_ticksCount; | |
157 | } |
|
177 | } | |
158 |
|
178 | |||
159 | void QValuesAxis::setNiceNumbersEnabled(bool enable) |
|
179 | void QValuesAxis::setNiceNumbersEnabled(bool enable) | |
160 | { |
|
180 | { | |
161 | Q_D(QValuesAxis); |
|
181 | Q_D(QValuesAxis); | |
162 | if (d->m_niceNumbers != enable){ |
|
182 | if (d->m_niceNumbers != enable){ | |
163 | d->m_niceNumbers = enable; |
|
183 | d->m_niceNumbers = enable; | |
164 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); |
|
184 | emit d->changed(d->m_min, d->m_max, d->m_ticksCount, d->m_niceNumbers); | |
165 | } |
|
185 | } | |
166 | } |
|
186 | } | |
167 |
|
187 | |||
168 | bool QValuesAxis::niceNumbersEnabled() const |
|
188 | bool QValuesAxis::niceNumbersEnabled() const | |
169 | { |
|
189 | { | |
170 | Q_D(const QValuesAxis); |
|
190 | Q_D(const QValuesAxis); | |
171 | return d->m_niceNumbers; |
|
191 | return d->m_niceNumbers; | |
172 | } |
|
192 | } | |
173 |
|
193 | |||
174 | QAbstractAxis::AxisType QValuesAxis::type() const |
|
194 | QAbstractAxis::AxisType QValuesAxis::type() const | |
175 | { |
|
195 | { | |
176 | return AxisTypeValues; |
|
196 | return AxisTypeValues; | |
177 | } |
|
197 | } | |
178 |
|
198 | |||
179 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
199 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
180 |
|
200 | |||
181 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): |
|
201 | QValuesAxisPrivate::QValuesAxisPrivate(QValuesAxis* q): | |
182 | QAbstractAxisPrivate(q), |
|
202 | QAbstractAxisPrivate(q), | |
183 | m_niceNumbers(false) |
|
203 | m_niceNumbers(false) | |
184 | { |
|
204 | { | |
185 |
|
205 | |||
186 | } |
|
206 | } | |
187 |
|
207 | |||
188 | QValuesAxisPrivate::~QValuesAxisPrivate() |
|
208 | QValuesAxisPrivate::~QValuesAxisPrivate() | |
189 | { |
|
209 | { | |
190 |
|
210 | |||
191 | } |
|
211 | } | |
192 |
|
212 | |||
193 | void QValuesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) |
|
213 | void QValuesAxisPrivate::handleAxisRangeChanged(qreal min, qreal max,int count) | |
194 | { |
|
214 | { | |
195 | Q_Q(QValuesAxis); |
|
215 | Q_Q(QValuesAxis); | |
196 | q->setRange(min,max); |
|
216 | q->setRange(min,max); | |
197 | q->setTicksCount(count); |
|
217 | q->setTicksCount(count); | |
198 | } |
|
218 | } | |
199 |
|
219 | |||
200 |
|
220 | |||
201 | void QValuesAxisPrivate::setMin(const qreal min) |
|
221 | void QValuesAxisPrivate::setMin(const qreal min) | |
202 | { |
|
222 | { | |
203 | setRange(min,m_max); |
|
223 | setRange(min,m_max); | |
204 | } |
|
224 | } | |
205 |
|
225 | |||
206 | void QValuesAxisPrivate::setMax(const qreal max) |
|
226 | void QValuesAxisPrivate::setMax(const qreal max) | |
207 | { |
|
227 | { | |
208 | setRange(m_min,max); |
|
228 | setRange(m_min,max); | |
209 | } |
|
229 | } | |
210 |
|
230 | |||
211 | void QValuesAxisPrivate::setRange(const qreal min, const qreal max, bool force) |
|
231 | void QValuesAxisPrivate::setRange(const qreal min, const qreal max, bool force) | |
212 | { |
|
232 | { | |
213 | Q_Q(QValuesAxis); |
|
233 | Q_Q(QValuesAxis); | |
214 | bool changed = false; |
|
234 | bool changed = false; | |
215 | if (!qFuzzyIsNull(m_min - min)) { |
|
235 | if (!qFuzzyIsNull(m_min - min)) { | |
216 | m_min = min; |
|
236 | m_min = min; | |
217 | changed = true; |
|
237 | changed = true; | |
218 | emit q->minChanged(min); |
|
238 | emit q->minChanged(min); | |
219 | } |
|
239 | } | |
220 |
|
240 | |||
221 | if (!qFuzzyIsNull(m_max - max)) { |
|
241 | if (!qFuzzyIsNull(m_max - max)) { | |
222 | m_max = max; |
|
242 | m_max = max; | |
223 | changed = true; |
|
243 | changed = true; | |
224 | emit q->maxChanged(max); |
|
244 | emit q->maxChanged(max); | |
225 | } |
|
245 | } | |
226 |
|
246 | |||
227 | if ((changed) ||(force)) { |
|
247 | if ((changed) ||(force)) { | |
228 | emit q->rangeChanged(m_min,m_max); |
|
248 | emit q->rangeChanged(m_min,m_max); | |
229 | emit this->changed(m_min, m_max, m_ticksCount, m_niceNumbers); |
|
249 | emit this->changed(m_min, m_max, m_ticksCount, m_niceNumbers); | |
230 | } |
|
250 | } | |
231 | } |
|
251 | } | |
232 |
|
252 | |||
233 | int QValuesAxisPrivate::ticksCount() const |
|
253 | int QValuesAxisPrivate::ticksCount() const | |
234 | { |
|
254 | { | |
235 | return m_ticksCount; |
|
255 | return m_ticksCount; | |
236 | } |
|
256 | } | |
237 |
|
257 | |||
238 | ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) |
|
258 | ChartAxis* QValuesAxisPrivate::createGraphics(ChartPresenter* presenter) | |
239 | { |
|
259 | { | |
240 | Q_Q(QValuesAxis); |
|
260 | Q_Q(QValuesAxis); | |
241 | if(m_orientation == Qt::Vertical){ |
|
261 | if(m_orientation == Qt::Vertical){ | |
242 | return new ChartValuesAxisY(q,presenter); |
|
262 | return new ChartValuesAxisY(q,presenter); | |
243 | }else{ |
|
263 | }else{ | |
244 | return new ChartValuesAxisX(q,presenter); |
|
264 | return new ChartValuesAxisX(q,presenter); | |
245 | } |
|
265 | } | |
246 |
|
266 | |||
247 | } |
|
267 | } | |
248 |
|
268 | |||
249 | void QValuesAxisPrivate::updateRange() |
|
269 | void QValuesAxisPrivate::updateRange() | |
250 | { |
|
270 | { | |
251 | setRange(m_min,m_max,true); |
|
271 | setRange(m_min,m_max,true); | |
252 | } |
|
272 | } | |
253 |
|
273 | |||
254 | #include "moc_qvaluesaxis.cpp" |
|
274 | #include "moc_qvaluesaxis.cpp" | |
255 | #include "moc_qvaluesaxis_p.cpp" |
|
275 | #include "moc_qvaluesaxis_p.cpp" | |
256 |
|
276 | |||
257 | QTCOMMERCIALCHART_END_NAMESPACE |
|
277 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,548 +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 "qlegend.h" |
|
21 | #include "qlegend.h" | |
22 | #include "qlegend_p.h" |
|
22 | #include "qlegend_p.h" | |
23 | #include "qabstractseries.h" |
|
23 | #include "qabstractseries.h" | |
24 | #include "qabstractseries_p.h" |
|
24 | #include "qabstractseries_p.h" | |
25 | #include "qchart_p.h" |
|
25 | #include "qchart_p.h" | |
26 | #include "legendlayout_p.h" |
|
26 | #include "legendlayout_p.h" | |
27 | #include "legendmarker_p.h" |
|
27 | #include "legendmarker_p.h" | |
28 | #include "qxyseries.h" |
|
28 | #include "qxyseries.h" | |
29 | #include "qlineseries.h" |
|
29 | #include "qlineseries.h" | |
30 | #include "qareaseries.h" |
|
30 | #include "qareaseries.h" | |
31 | #include "qscatterseries.h" |
|
31 | #include "qscatterseries.h" | |
32 | #include "qsplineseries.h" |
|
32 | #include "qsplineseries.h" | |
33 | #include "qbarseries.h" |
|
33 | #include "qbarseries.h" | |
34 | #include "qstackedbarseries.h" |
|
34 | #include "qstackedbarseries.h" | |
35 | #include "qpercentbarseries.h" |
|
35 | #include "qpercentbarseries.h" | |
36 | #include "qbarset.h" |
|
36 | #include "qbarset.h" | |
37 | #include "qpieseries.h" |
|
37 | #include "qpieseries.h" | |
38 | #include "qpieseries_p.h" |
|
38 | #include "qpieseries_p.h" | |
39 | #include "qpieslice.h" |
|
39 | #include "qpieslice.h" | |
40 | #include "chartpresenter_p.h" |
|
40 | #include "chartpresenter_p.h" | |
41 | #include <QPainter> |
|
41 | #include <QPainter> | |
42 | #include <QPen> |
|
42 | #include <QPen> | |
43 | #include <QTimer> |
|
43 | #include <QTimer> | |
44 | #include <QGraphicsLayout> |
|
44 | #include <QGraphicsLayout> | |
45 | #include <QGraphicsSceneEvent> |
|
45 | #include <QGraphicsSceneEvent> | |
46 |
|
46 | |||
47 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
47 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
48 |
|
48 | |||
49 | /*! |
|
49 | /*! | |
50 | \class QLegend |
|
50 | \class QLegend | |
51 | \brief Legend object |
|
51 | \brief Legend object | |
52 | \mainclass |
|
52 | \mainclass | |
53 |
|
53 | |||
54 | QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when |
|
54 | QLegend is a graphical object, whics displays legend of the chart. Legend state is updated by QChart, when | |
55 | series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and |
|
55 | series have been changed. By default, legend is drawn by QChart, but user can set a new parent to legend and | |
56 | handle the drawing manually. |
|
56 | handle the drawing manually. | |
57 | User isn't supposed to create or delete legend objects, but can reference it via QChart class. |
|
57 | User isn't supposed to create or delete legend objects, but can reference it via QChart class. | |
58 |
|
58 | |||
59 | \image examples_percentbarchart_legend.png |
|
59 | \image examples_percentbarchart_legend.png | |
60 |
|
60 | |||
61 | \sa QChart |
|
61 | \sa QChart | |
62 | */ |
|
62 | */ | |
63 | /*! |
|
63 | /*! | |
64 | \qmlclass Legend QLegend |
|
64 | \qmlclass Legend QLegend | |
65 | \brief Legend is part of QtCommercial Chart QML API. |
|
65 | \brief Legend is part of QtCommercial Chart QML API. | |
66 |
|
66 | |||
67 | Legend is a graphical object, whics displays legend of the chart. Legend state is updated by ChartView, when |
|
67 | Legend is a graphical object, whics displays legend of the chart. Legend state is updated by ChartView, when | |
68 | series have been changed. Legend is used via ChartView class. For example: |
|
68 | series have been changed. Legend is used via ChartView class. For example: | |
69 | \code |
|
69 | \code | |
70 | ChartView { |
|
70 | ChartView { | |
71 | legend.visible: true |
|
71 | legend.visible: true | |
72 | legend.alignment: Qt.AlignBottom |
|
72 | legend.alignment: Qt.AlignBottom | |
73 | // Add a few series... |
|
73 | // Add a few series... | |
74 | } |
|
74 | } | |
75 | \endcode |
|
75 | \endcode | |
76 |
|
76 | |||
77 | \image examples_percentbarchart_legend.png |
|
77 | \image examples_percentbarchart_legend.png | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \property QLegend::alignment |
|
81 | \property QLegend::alignment | |
82 | \brief The alignment of the legend. |
|
82 | \brief The alignment of the legend. | |
83 |
|
83 | |||
84 | Legend paints on the defined position in the chart. The following alignments are supported: |
|
84 | Legend paints on the defined position in the chart. The following alignments are supported: | |
85 | Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight. If you set more than one flag the result is undefined. |
|
85 | Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight. If you set more than one flag the result is undefined. | |
86 | */ |
|
86 | */ | |
87 | /*! |
|
87 | /*! | |
88 | \qmlproperty Qt.Alignment Legend::alignment |
|
88 | \qmlproperty Qt.Alignment Legend::alignment | |
89 | \brief The alignment of the legend. |
|
89 | \brief The alignment of the legend. | |
90 |
|
90 | |||
91 | Legend paints on the defined position in the chart. The following alignments are supported: |
|
91 | Legend paints on the defined position in the chart. The following alignments are supported: | |
92 | Qt.AlignTop, Qt.AlignBottom, Qt.AlignLeft, Qt.AlignRight. If you set more than one flag the result is undefined. |
|
92 | Qt.AlignTop, Qt.AlignBottom, Qt.AlignLeft, Qt.AlignRight. If you set more than one flag the result is undefined. | |
93 | */ |
|
93 | */ | |
94 |
|
94 | |||
95 | /*! |
|
95 | /*! | |
96 | \property QLegend::backgroundVisible |
|
96 | \property QLegend::backgroundVisible | |
97 | Whether the legend background is visible or not. |
|
97 | Whether the legend background is visible or not. | |
98 | */ |
|
98 | */ | |
99 | /*! |
|
99 | /*! | |
100 | \qmlproperty bool Legend::backgroundVisible |
|
100 | \qmlproperty bool Legend::backgroundVisible | |
101 | Whether the legend background is visible or not. |
|
101 | Whether the legend background is visible or not. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \property QLegend::color |
|
105 | \property QLegend::color | |
106 | The color of the legend, i.e. the background (brush) color. Note that if you change the color |
|
106 | The color of the legend, i.e. the background (brush) color. Note that if you change the color | |
107 | of the legend, the style of the legend brush is set to Qt::SolidPattern. |
|
107 | of the legend, the style of the legend brush is set to Qt::SolidPattern. | |
108 | */ |
|
108 | */ | |
109 | /*! |
|
109 | /*! | |
110 | \qmlproperty color Legend::color |
|
110 | \qmlproperty color Legend::color | |
111 | The color of the legend, i.e. the background (brush) color. |
|
111 | The color of the legend, i.e. the background (brush) color. | |
112 | */ |
|
112 | */ | |
113 |
|
113 | |||
114 | /*! |
|
114 | /*! | |
115 | \property QLegend::borderColor |
|
115 | \property QLegend::borderColor | |
116 | The border color of the legend, i.e. the line color. |
|
116 | The border color of the legend, i.e. the line color. | |
117 | */ |
|
117 | */ | |
118 | /*! |
|
118 | /*! | |
119 | \qmlproperty color Legend::borderColor |
|
119 | \qmlproperty color Legend::borderColor | |
120 | The border color of the legend, i.e. the line color. |
|
120 | The border color of the legend, i.e. the line color. | |
121 | */ |
|
121 | */ | |
122 |
|
122 | |||
123 | /*! |
|
123 | /*! | |
124 | \property QLegend::font |
|
124 | \property QLegend::font | |
125 | The font of markers used by legend |
|
125 | The font of markers used by legend | |
126 | */ |
|
126 | */ | |
127 | /*! |
|
127 | /*! | |
128 | \qmlproperty color Legend::font |
|
128 | \qmlproperty color Legend::font | |
129 | The font of markers used by legend |
|
129 | The font of markers used by legend | |
130 | */ |
|
130 | */ | |
131 |
|
131 | |||
132 | /*! |
|
132 | /*! | |
133 | \property QLegend::labelColor |
|
133 | \property QLegend::labelColor | |
134 | The color of brush used to draw labels. |
|
134 | The color of brush used to draw labels. | |
135 | */ |
|
135 | */ | |
136 | /*! |
|
136 | /*! | |
137 | \qmlproperty color QLegend::labelColor |
|
137 | \qmlproperty color QLegend::labelColor | |
138 | The color of brush used to draw labels. |
|
138 | The color of brush used to draw labels. | |
139 | */ |
|
139 | */ | |
140 |
|
140 | |||
141 | /*! |
|
141 | /*! | |
142 | \fn void QLegend::backgroundVisibleChanged(bool) |
|
142 | \fn void QLegend::backgroundVisibleChanged(bool) | |
143 | The visibility of the legend background changed to \a visible. |
|
143 | The visibility of the legend background changed to \a visible. | |
144 | */ |
|
144 | */ | |
145 |
|
145 | |||
146 | /*! |
|
146 | /*! | |
147 | \fn void QLegend::colorChanged(QColor) |
|
147 | \fn void QLegend::colorChanged(QColor) | |
148 | The color of the legend background changed to \a color. |
|
148 | The color of the legend background changed to \a color. | |
149 | */ |
|
149 | */ | |
150 |
|
150 | |||
151 | /*! |
|
151 | /*! | |
152 | \fn void QLegend::borderColorChanged(QColor) |
|
152 | \fn void QLegend::borderColorChanged(QColor) | |
153 | The border color of the legend background changed to \a color. |
|
153 | The border color of the legend background changed to \a color. | |
154 | */ |
|
154 | */ | |
155 |
|
155 | |||
156 | /*! |
|
156 | /*! | |
157 | \fn void QLegend::fontChanged(QFont) |
|
157 | \fn void QLegend::fontChanged(QFont) | |
158 | The font of markers of the legend changed to \a font. |
|
158 | The font of markers of the legend changed to \a font. | |
159 | */ |
|
159 | */ | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | \fn void QLegend::labelBrushChanged(QBrush brush) |
|
|||
163 | This signal is emitted when the brush used to draw labels has changed to \a brush. |
|
|||
164 | */ |
|
|||
165 |
|
||||
166 | /*! |
|
|||
167 | \fn void QLegend::labelColorChanged(QColor color) |
|
162 | \fn void QLegend::labelColorChanged(QColor color) | |
168 | This signal is emitted when the color of brush used to draw labels has changed to \a color. |
|
163 | This signal is emitted when the color of brush used to draw labels has changed to \a color. | |
169 | */ |
|
164 | */ | |
170 |
|
165 | |||
171 | /*! |
|
166 | /*! | |
172 | \fn qreal QLegend::minWidth() const |
|
|||
173 | Returns minimum width of the legend |
|
|||
174 | */ |
|
|||
175 |
|
||||
176 | /*! |
|
|||
177 | \fn qreal QLegend::minHeight() const |
|
|||
178 | Returns minimum height of the legend |
|
|||
179 | */ |
|
|||
180 |
|
||||
181 | /*! |
|
|||
182 | Constructs the legend object and sets the parent to \a parent |
|
167 | Constructs the legend object and sets the parent to \a parent | |
183 | */ |
|
168 | */ | |
184 |
|
169 | |||
185 | QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), |
|
170 | QLegend::QLegend(QChart *chart):QGraphicsWidget(chart), | |
186 | d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter,chart,this)) |
|
171 | d_ptr(new QLegendPrivate(chart->d_ptr->m_presenter,chart,this)) | |
187 | { |
|
172 | { | |
188 | setZValue(ChartPresenter::LegendZValue); |
|
173 | setZValue(ChartPresenter::LegendZValue); | |
189 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
174 | setFlags(QGraphicsItem::ItemClipsChildrenToShape); | |
190 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),d_ptr.data(),SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); |
|
175 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),d_ptr.data(),SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); | |
191 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesRemoved(QAbstractSeries*))); |
|
176 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesRemoved(QAbstractSeries*))); | |
192 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesUpdated(QAbstractSeries*))); |
|
177 | QObject::connect(chart->d_ptr->m_dataset,SIGNAL(seriesUpdated(QAbstractSeries*)),d_ptr.data(),SLOT(handleSeriesUpdated(QAbstractSeries*))); | |
193 | setLayout(d_ptr->m_layout); |
|
178 | setLayout(d_ptr->m_layout); | |
194 | } |
|
179 | } | |
195 |
|
180 | |||
196 | /*! |
|
181 | /*! | |
197 | Destroys the legend object. Legend is always owned by a QChart, so an application should never call this. |
|
182 | Destroys the legend object. Legend is always owned by a QChart, so an application should never call this. | |
198 | */ |
|
183 | */ | |
199 | QLegend::~QLegend() |
|
184 | QLegend::~QLegend() | |
200 | { |
|
185 | { | |
201 | } |
|
186 | } | |
202 |
|
187 | |||
203 | /*! |
|
188 | /*! | |
204 | \internal |
|
189 | \internal | |
205 | */ |
|
190 | */ | |
206 | void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
191 | void QLegend::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | |
207 | { |
|
192 | { | |
208 | Q_UNUSED(option) |
|
193 | Q_UNUSED(option) | |
209 | Q_UNUSED(widget) |
|
194 | Q_UNUSED(widget) | |
210 | if(!d_ptr->m_backgroundVisible) return; |
|
195 | if(!d_ptr->m_backgroundVisible) return; | |
211 |
|
196 | |||
212 | painter->setOpacity(opacity()); |
|
197 | painter->setOpacity(opacity()); | |
213 | painter->setPen(d_ptr->m_pen); |
|
198 | painter->setPen(d_ptr->m_pen); | |
214 | painter->setBrush(d_ptr->m_brush); |
|
199 | painter->setBrush(d_ptr->m_brush); | |
215 | painter->drawRoundRect(rect(),d_ptr->roundness(rect().width()),d_ptr->roundness(rect().height())); |
|
200 | painter->drawRoundRect(rect(),d_ptr->roundness(rect().width()),d_ptr->roundness(rect().height())); | |
216 |
|
201 | |||
217 | } |
|
202 | } | |
218 |
|
203 | |||
219 |
|
204 | |||
220 | /*! |
|
205 | /*! | |
221 | Sets the \a brush of legend. Brush affects the background of legend. |
|
206 | Sets the \a brush of legend. Brush affects the background of legend. | |
222 | */ |
|
207 | */ | |
223 | void QLegend::setBrush(const QBrush &brush) |
|
208 | void QLegend::setBrush(const QBrush &brush) | |
224 | { |
|
209 | { | |
225 | if (d_ptr->m_brush != brush) { |
|
210 | if (d_ptr->m_brush != brush) { | |
226 | d_ptr->m_brush = brush; |
|
211 | d_ptr->m_brush = brush; | |
227 | update(); |
|
212 | update(); | |
228 | emit colorChanged(brush.color()); |
|
213 | emit colorChanged(brush.color()); | |
229 | } |
|
214 | } | |
230 | } |
|
215 | } | |
231 |
|
216 | |||
232 | /*! |
|
217 | /*! | |
233 | Returns the brush used by legend. |
|
218 | Returns the brush used by legend. | |
234 | */ |
|
219 | */ | |
235 | QBrush QLegend::brush() const |
|
220 | QBrush QLegend::brush() const | |
236 | { |
|
221 | { | |
237 | return d_ptr->m_brush; |
|
222 | return d_ptr->m_brush; | |
238 | } |
|
223 | } | |
239 |
|
224 | |||
240 | void QLegend::setColor(QColor color) |
|
225 | void QLegend::setColor(QColor color) | |
241 | { |
|
226 | { | |
242 | QBrush b = d_ptr->m_brush; |
|
227 | QBrush b = d_ptr->m_brush; | |
243 | if (b.style() != Qt::SolidPattern || b.color() != color) { |
|
228 | if (b.style() != Qt::SolidPattern || b.color() != color) { | |
244 | b.setStyle(Qt::SolidPattern); |
|
229 | b.setStyle(Qt::SolidPattern); | |
245 | b.setColor(color); |
|
230 | b.setColor(color); | |
246 | setBrush(b); |
|
231 | setBrush(b); | |
247 | } |
|
232 | } | |
248 | } |
|
233 | } | |
249 |
|
234 | |||
250 | QColor QLegend::color() |
|
235 | QColor QLegend::color() | |
251 | { |
|
236 | { | |
252 | return d_ptr->m_brush.color(); |
|
237 | return d_ptr->m_brush.color(); | |
253 | } |
|
238 | } | |
254 |
|
239 | |||
255 | /*! |
|
240 | /*! | |
256 | Sets the \a pen of legend. Pen affects the legend borders. |
|
241 | Sets the \a pen of legend. Pen affects the legend borders. | |
257 | */ |
|
242 | */ | |
258 | void QLegend::setPen(const QPen &pen) |
|
243 | void QLegend::setPen(const QPen &pen) | |
259 | { |
|
244 | { | |
260 | if (d_ptr->m_pen != pen) { |
|
245 | if (d_ptr->m_pen != pen) { | |
261 | d_ptr->m_pen = pen; |
|
246 | d_ptr->m_pen = pen; | |
262 | update(); |
|
247 | update(); | |
263 | emit borderColorChanged(pen.color()); |
|
248 | emit borderColorChanged(pen.color()); | |
264 | } |
|
249 | } | |
265 | } |
|
250 | } | |
266 |
|
251 | |||
267 | /*! |
|
252 | /*! | |
268 | Returns the pen used by legend |
|
253 | Returns the pen used by legend | |
269 | */ |
|
254 | */ | |
270 |
|
255 | |||
271 | QPen QLegend::pen() const |
|
256 | QPen QLegend::pen() const | |
272 | { |
|
257 | { | |
273 | return d_ptr->m_pen; |
|
258 | return d_ptr->m_pen; | |
274 | } |
|
259 | } | |
275 |
|
260 | |||
276 | void QLegend::setFont(const QFont &font) |
|
261 | void QLegend::setFont(const QFont &font) | |
277 | { |
|
262 | { | |
278 | if (d_ptr->m_font != font) { |
|
263 | if (d_ptr->m_font != font) { | |
279 | d_ptr->m_font = font; |
|
264 | d_ptr->m_font = font; | |
280 |
|
265 | |||
281 | foreach (LegendMarker *marker, d_ptr->markers()) { |
|
266 | foreach (LegendMarker *marker, d_ptr->markers()) { | |
282 | marker->setFont(d_ptr->m_font); |
|
267 | marker->setFont(d_ptr->m_font); | |
283 | } |
|
268 | } | |
284 | layout()->invalidate(); |
|
269 | layout()->invalidate(); | |
285 | emit fontChanged(font); |
|
270 | emit fontChanged(font); | |
286 | } |
|
271 | } | |
287 | } |
|
272 | } | |
288 |
|
273 | |||
289 | QFont QLegend::font() const |
|
274 | QFont QLegend::font() const | |
290 | { |
|
275 | { | |
291 | return d_ptr->m_font; |
|
276 | return d_ptr->m_font; | |
292 | } |
|
277 | } | |
293 |
|
278 | |||
294 | void QLegend::setBorderColor(QColor color) |
|
279 | void QLegend::setBorderColor(QColor color) | |
295 | { |
|
280 | { | |
296 | QPen p = d_ptr->m_pen; |
|
281 | QPen p = d_ptr->m_pen; | |
297 | if (p.color() != color) { |
|
282 | if (p.color() != color) { | |
298 | p.setColor(color); |
|
283 | p.setColor(color); | |
299 | setPen(p); |
|
284 | setPen(p); | |
300 | } |
|
285 | } | |
301 | } |
|
286 | } | |
302 |
|
287 | |||
303 | QColor QLegend::borderColor() |
|
288 | QColor QLegend::borderColor() | |
304 | { |
|
289 | { | |
305 | return d_ptr->m_pen.color(); |
|
290 | return d_ptr->m_pen.color(); | |
306 | } |
|
291 | } | |
307 |
|
292 | |||
308 | /*! |
|
293 | /*! | |
309 | Set brush used to draw labels to \a brush. |
|
294 | Set brush used to draw labels to \a brush. | |
310 | */ |
|
295 | */ | |
311 | void QLegend::setLabelBrush(const QBrush &brush) |
|
296 | void QLegend::setLabelBrush(const QBrush &brush) | |
312 | { |
|
297 | { | |
313 | if (d_ptr->m_labelBrush != brush) { |
|
298 | if (d_ptr->m_labelBrush != brush) { | |
314 | d_ptr->m_labelBrush = brush; |
|
299 | d_ptr->m_labelBrush = brush; | |
315 | foreach (LegendMarker *marker, d_ptr->markers()) { |
|
300 | foreach (LegendMarker *marker, d_ptr->markers()) { | |
316 | marker->setLabelBrush(d_ptr->m_labelBrush); |
|
301 | marker->setLabelBrush(d_ptr->m_labelBrush); | |
317 | } |
|
302 | } | |
318 | emit labelColorChanged(brush.color()); |
|
303 | emit labelColorChanged(brush.color()); | |
319 | } |
|
304 | } | |
320 | } |
|
305 | } | |
321 |
|
306 | |||
322 | /*! |
|
307 | /*! | |
323 | Brush used to draw labels. |
|
308 | Brush used to draw labels. | |
324 | */ |
|
309 | */ | |
325 | QBrush QLegend::labelBrush() const |
|
310 | QBrush QLegend::labelBrush() const | |
326 | { |
|
311 | { | |
327 | return d_ptr->m_labelBrush; |
|
312 | return d_ptr->m_labelBrush; | |
328 | } |
|
313 | } | |
329 |
|
314 | |||
330 | void QLegend::setLabelColor(QColor color) |
|
315 | void QLegend::setLabelColor(QColor color) | |
331 | { |
|
316 | { | |
332 | QBrush b = d_ptr->m_labelBrush; |
|
317 | QBrush b = d_ptr->m_labelBrush; | |
333 | if (b.style() != Qt::SolidPattern || b.color() != color) { |
|
318 | if (b.style() != Qt::SolidPattern || b.color() != color) { | |
334 | b.setStyle(Qt::SolidPattern); |
|
319 | b.setStyle(Qt::SolidPattern); | |
335 | b.setColor(color); |
|
320 | b.setColor(color); | |
336 | setLabelBrush(b); |
|
321 | setLabelBrush(b); | |
337 | } |
|
322 | } | |
338 | } |
|
323 | } | |
339 |
|
324 | |||
340 | QColor QLegend::labelColor() const |
|
325 | QColor QLegend::labelColor() const | |
341 | { |
|
326 | { | |
342 | return d_ptr->m_labelBrush.color(); |
|
327 | return d_ptr->m_labelBrush.color(); | |
343 | } |
|
328 | } | |
344 |
|
329 | |||
345 |
|
330 | |||
346 | void QLegend::setAlignment(Qt::Alignment alignment) |
|
331 | void QLegend::setAlignment(Qt::Alignment alignment) | |
347 | { |
|
332 | { | |
348 | if(d_ptr->m_alignment!=alignment) { |
|
333 | if(d_ptr->m_alignment!=alignment) { | |
349 | d_ptr->m_alignment = alignment; |
|
334 | d_ptr->m_alignment = alignment; | |
350 | updateGeometry(); |
|
335 | updateGeometry(); | |
351 | if(isAttachedToChart()){ |
|
336 | if(isAttachedToChart()){ | |
352 | d_ptr->m_presenter->layout()->invalidate(); |
|
337 | d_ptr->m_presenter->layout()->invalidate(); | |
353 | }else{ |
|
338 | }else{ | |
354 | layout()->invalidate(); |
|
339 | layout()->invalidate(); | |
355 | } |
|
340 | } | |
356 | } |
|
341 | } | |
357 | } |
|
342 | } | |
358 |
|
343 | |||
359 | Qt::Alignment QLegend::alignment() const |
|
344 | Qt::Alignment QLegend::alignment() const | |
360 | { |
|
345 | { | |
361 | return d_ptr->m_alignment; |
|
346 | return d_ptr->m_alignment; | |
362 | } |
|
347 | } | |
363 |
|
348 | |||
364 | /*! |
|
349 | /*! | |
365 | Detaches the legend from chart. Chart won't change layout of the legend. |
|
350 | Detaches the legend from chart. Chart won't change layout of the legend. | |
366 | */ |
|
351 | */ | |
367 | void QLegend::detachFromChart() |
|
352 | void QLegend::detachFromChart() | |
368 | { |
|
353 | { | |
369 | d_ptr->m_attachedToChart = false; |
|
354 | d_ptr->m_attachedToChart = false; | |
370 | d_ptr->m_layout->invalidate(); |
|
355 | d_ptr->m_layout->invalidate(); | |
371 | setParent(0); |
|
356 | setParent(0); | |
372 |
|
357 | |||
373 | } |
|
358 | } | |
374 |
|
359 | |||
375 | /*! |
|
360 | /*! | |
376 | Attaches the legend to chart. Chart may change layout of the legend. |
|
361 | Attaches the legend to chart. Chart may change layout of the legend. | |
377 | */ |
|
362 | */ | |
378 | void QLegend::attachToChart() |
|
363 | void QLegend::attachToChart() | |
379 | { |
|
364 | { | |
380 | d_ptr->m_attachedToChart = true; |
|
365 | d_ptr->m_attachedToChart = true; | |
381 | d_ptr->m_layout->invalidate(); |
|
366 | d_ptr->m_layout->invalidate(); | |
382 | setParent(d_ptr->m_chart); |
|
367 | setParent(d_ptr->m_chart); | |
383 | } |
|
368 | } | |
384 |
|
369 | |||
385 | /*! |
|
370 | /*! | |
386 | Returns true, if legend is attached to chart. |
|
371 | Returns true, if legend is attached to chart. | |
387 | */ |
|
372 | */ | |
388 | bool QLegend::isAttachedToChart() |
|
373 | bool QLegend::isAttachedToChart() | |
389 | { |
|
374 | { | |
390 | return d_ptr->m_attachedToChart; |
|
375 | return d_ptr->m_attachedToChart; | |
391 | } |
|
376 | } | |
392 |
|
377 | |||
393 | /*! |
|
378 | /*! | |
394 | Sets the visibility of legend background to \a visible |
|
379 | Sets the visibility of legend background to \a visible | |
395 | */ |
|
380 | */ | |
396 | void QLegend::setBackgroundVisible(bool visible) |
|
381 | void QLegend::setBackgroundVisible(bool visible) | |
397 | { |
|
382 | { | |
398 | if(d_ptr->m_backgroundVisible != visible) { |
|
383 | if(d_ptr->m_backgroundVisible != visible) { | |
399 | d_ptr->m_backgroundVisible = visible; |
|
384 | d_ptr->m_backgroundVisible = visible; | |
400 | update(); |
|
385 | update(); | |
401 | emit backgroundVisibleChanged(visible); |
|
386 | emit backgroundVisibleChanged(visible); | |
402 | } |
|
387 | } | |
403 | } |
|
388 | } | |
404 |
|
389 | |||
405 | /*! |
|
390 | /*! | |
406 | Returns the visibility of legend background |
|
391 | Returns the visibility of legend background | |
407 | */ |
|
392 | */ | |
408 | bool QLegend::isBackgroundVisible() const |
|
393 | bool QLegend::isBackgroundVisible() const | |
409 | { |
|
394 | { | |
410 | return d_ptr->m_backgroundVisible; |
|
395 | return d_ptr->m_backgroundVisible; | |
411 | } |
|
396 | } | |
412 |
|
397 | |||
413 | /*! |
|
398 | /*! | |
414 | \internal \a event see QGraphicsWidget for details |
|
399 | \internal \a event see QGraphicsWidget for details | |
415 | */ |
|
400 | */ | |
416 | void QLegend::hideEvent(QHideEvent *event) |
|
401 | void QLegend::hideEvent(QHideEvent *event) | |
417 | { |
|
402 | { | |
418 | QGraphicsWidget::hideEvent(event); |
|
403 | QGraphicsWidget::hideEvent(event); | |
419 | d_ptr->m_presenter->layout()->invalidate(); |
|
404 | d_ptr->m_presenter->layout()->invalidate(); | |
420 | } |
|
405 | } | |
421 |
|
406 | |||
422 | /*! |
|
407 | /*! | |
423 | \internal \a event see QGraphicsWidget for details |
|
408 | \internal \a event see QGraphicsWidget for details | |
424 | */ |
|
409 | */ | |
425 | void QLegend::showEvent(QShowEvent *event) |
|
410 | void QLegend::showEvent(QShowEvent *event) | |
426 | { |
|
411 | { | |
427 | QGraphicsWidget::showEvent(event); |
|
412 | QGraphicsWidget::showEvent(event); | |
428 | d_ptr->m_presenter->layout()->invalidate(); |
|
413 | d_ptr->m_presenter->layout()->invalidate(); | |
429 | } |
|
414 | } | |
430 |
|
415 | |||
431 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
416 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
432 |
|
417 | |||
433 | QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend *q): |
|
418 | QLegendPrivate::QLegendPrivate(ChartPresenter* presenter, QChart *chart, QLegend *q): | |
434 | q_ptr(q), |
|
419 | q_ptr(q), | |
435 | m_presenter(presenter), |
|
420 | m_presenter(presenter), | |
436 | m_layout(new LegendLayout(q)), |
|
421 | m_layout(new LegendLayout(q)), | |
437 | m_chart(chart), |
|
422 | m_chart(chart), | |
438 | m_items(new QGraphicsItemGroup(q)), |
|
423 | m_items(new QGraphicsItemGroup(q)), | |
439 | m_alignment(Qt::AlignTop), |
|
424 | m_alignment(Qt::AlignTop), | |
440 | m_brush(QBrush()), |
|
425 | m_brush(QBrush()), | |
441 | m_pen(QPen()), |
|
426 | m_pen(QPen()), | |
442 | m_labelBrush(QBrush()), |
|
427 | m_labelBrush(QBrush()), | |
443 | m_diameter(5), |
|
428 | m_diameter(5), | |
444 | m_attachedToChart(true), |
|
429 | m_attachedToChart(true), | |
445 | m_backgroundVisible(false) |
|
430 | m_backgroundVisible(false) | |
446 | { |
|
431 | { | |
447 |
|
432 | |||
448 | } |
|
433 | } | |
449 |
|
434 | |||
450 | QLegendPrivate::~QLegendPrivate() |
|
435 | QLegendPrivate::~QLegendPrivate() | |
451 | { |
|
436 | { | |
452 |
|
437 | |||
453 | } |
|
438 | } | |
454 |
|
439 | |||
455 | void QLegendPrivate::setOffset(qreal x, qreal y) |
|
440 | void QLegendPrivate::setOffset(qreal x, qreal y) | |
456 | { |
|
441 | { | |
457 | m_layout->setOffset(x,y); |
|
442 | m_layout->setOffset(x,y); | |
458 | } |
|
443 | } | |
459 |
|
444 | |||
460 | QPointF QLegendPrivate::offset() const |
|
445 | QPointF QLegendPrivate::offset() const | |
461 | { |
|
446 | { | |
462 | return m_layout->offset(); |
|
447 | return m_layout->offset(); | |
463 | } |
|
448 | } | |
464 |
|
449 | |||
465 | int QLegendPrivate::roundness(qreal size) |
|
450 | int QLegendPrivate::roundness(qreal size) | |
466 | { |
|
451 | { | |
467 | return 100*m_diameter/int(size); |
|
452 | return 100*m_diameter/int(size); | |
468 | } |
|
453 | } | |
469 |
|
454 | |||
470 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) |
|
455 | void QLegendPrivate::handleSeriesAdded(QAbstractSeries *series, Domain *domain) | |
471 | { |
|
456 | { | |
472 | Q_UNUSED(domain) |
|
457 | Q_UNUSED(domain) | |
473 |
|
458 | |||
474 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); |
|
459 | QList<LegendMarker*> markers = series->d_ptr->createLegendMarker(q_ptr); | |
475 |
|
460 | |||
476 | foreach(LegendMarker* marker, markers) { |
|
461 | foreach(LegendMarker* marker, markers) { | |
477 | marker->setFont(m_font); |
|
462 | marker->setFont(m_font); | |
478 | marker->setLabelBrush(m_labelBrush); |
|
463 | marker->setLabelBrush(m_labelBrush); | |
479 | m_items->addToGroup(marker); |
|
464 | m_items->addToGroup(marker); | |
480 | m_markers<<marker; |
|
465 | m_markers<<marker; | |
481 | } |
|
466 | } | |
482 |
|
467 | |||
483 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); |
|
468 | QObject::connect(series, SIGNAL(visibleChanged()), this, SLOT(handleSeriesVisibleChanged())); | |
484 |
|
469 | |||
485 | if(series->type() == QAbstractSeries::SeriesTypePie) { |
|
470 | if(series->type() == QAbstractSeries::SeriesTypePie) { | |
486 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
471 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
487 | QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
472 | QObject::connect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
488 | QObject::connect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
473 | QObject::connect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
489 | } |
|
474 | } | |
490 |
|
475 | |||
491 | q_ptr->layout()->invalidate(); |
|
476 | q_ptr->layout()->invalidate(); | |
492 | q_ptr->layout()->activate(); |
|
477 | q_ptr->layout()->activate(); | |
493 | } |
|
478 | } | |
494 |
|
479 | |||
495 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) |
|
480 | void QLegendPrivate::handleSeriesRemoved(QAbstractSeries *series) | |
496 | { |
|
481 | { | |
497 | foreach (LegendMarker *marker, m_markers) { |
|
482 | foreach (LegendMarker *marker, m_markers) { | |
498 | if (marker->series() == series) { |
|
483 | if (marker->series() == series) { | |
499 | delete marker; |
|
484 | delete marker; | |
500 | m_markers.removeAll(marker); |
|
485 | m_markers.removeAll(marker); | |
501 | } |
|
486 | } | |
502 | } |
|
487 | } | |
503 |
|
488 | |||
504 | if(series->type() == QAbstractSeries::SeriesTypePie) |
|
489 | if(series->type() == QAbstractSeries::SeriesTypePie) | |
505 | { |
|
490 | { | |
506 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
491 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
507 | QObject::disconnect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
492 | QObject::disconnect(pieSeries, SIGNAL(added(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
508 | QObject::disconnect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); |
|
493 | QObject::disconnect(pieSeries, SIGNAL(removed(QList<QPieSlice*>)), this, SLOT(handleUpdatePieSeries())); | |
509 | } |
|
494 | } | |
510 |
|
495 | |||
511 | q_ptr->layout()->invalidate(); |
|
496 | q_ptr->layout()->invalidate(); | |
512 | } |
|
497 | } | |
513 |
|
498 | |||
514 | void QLegendPrivate::handleSeriesUpdated(QAbstractSeries *series) |
|
499 | void QLegendPrivate::handleSeriesUpdated(QAbstractSeries *series) | |
515 | { |
|
500 | { | |
516 | // TODO: find out which markers are are added or removed. Update them |
|
501 | // TODO: find out which markers are are added or removed. Update them | |
517 | // TODO: better implementation |
|
502 | // TODO: better implementation | |
518 | handleSeriesRemoved(series); |
|
503 | handleSeriesRemoved(series); | |
519 | Domain domain; |
|
504 | Domain domain; | |
520 | handleSeriesAdded(series, &domain); |
|
505 | handleSeriesAdded(series, &domain); | |
521 | } |
|
506 | } | |
522 |
|
507 | |||
523 | void QLegendPrivate::handleUpdatePieSeries() |
|
508 | void QLegendPrivate::handleUpdatePieSeries() | |
524 | { |
|
509 | { | |
525 | //TODO: reimplement to be optimal |
|
510 | //TODO: reimplement to be optimal | |
526 | QPieSeries* series = qobject_cast<QPieSeries *> (sender()); |
|
511 | QPieSeries* series = qobject_cast<QPieSeries *> (sender()); | |
527 | Q_ASSERT(series); |
|
512 | Q_ASSERT(series); | |
528 | handleSeriesRemoved(series); |
|
513 | handleSeriesRemoved(series); | |
529 | handleSeriesAdded(series, 0); |
|
514 | handleSeriesAdded(series, 0); | |
530 | } |
|
515 | } | |
531 |
|
516 | |||
532 | void QLegendPrivate::handleSeriesVisibleChanged() |
|
517 | void QLegendPrivate::handleSeriesVisibleChanged() | |
533 | { |
|
518 | { | |
534 | QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender()); |
|
519 | QAbstractSeries* series = qobject_cast<QAbstractSeries *> (sender()); | |
535 |
|
520 | |||
536 | foreach (LegendMarker* marker, m_markers) { |
|
521 | foreach (LegendMarker* marker, m_markers) { | |
537 | if (marker->series() == series) { |
|
522 | if (marker->series() == series) { | |
538 | marker->setVisible(!marker->isVisible()); |
|
523 | marker->setVisible(!marker->isVisible()); | |
539 | } |
|
524 | } | |
540 | } |
|
525 | } | |
541 |
|
526 | |||
542 | q_ptr->layout()->invalidate(); |
|
527 | q_ptr->layout()->invalidate(); | |
543 | } |
|
528 | } | |
544 |
|
529 | |||
545 | #include "moc_qlegend.cpp" |
|
530 | #include "moc_qlegend.cpp" | |
546 | #include "moc_qlegend_p.cpp" |
|
531 | #include "moc_qlegend_p.cpp" | |
547 |
|
532 | |||
548 | QTCOMMERCIALCHART_END_NAMESPACE |
|
533 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,435 +1,435 | |||||
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 "qchart.h" |
|
21 | #include "qchart.h" | |
22 | #include "qchart_p.h" |
|
22 | #include "qchart_p.h" | |
23 | #include "legendscroller_p.h" |
|
23 | #include "legendscroller_p.h" | |
24 | #include "qlegend_p.h" |
|
24 | #include "qlegend_p.h" | |
25 | #include "chartbackground_p.h" |
|
25 | #include "chartbackground_p.h" | |
26 | #include "qabstractaxis.h" |
|
26 | #include "qabstractaxis.h" | |
27 | #include <QGraphicsScene> |
|
27 | #include <QGraphicsScene> | |
28 | #include <QGraphicsSceneResizeEvent> |
|
28 | #include <QGraphicsSceneResizeEvent> | |
29 | #include <QGraphicsLayout> |
|
29 | #include <QGraphicsLayout> | |
30 |
|
30 | |||
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
31 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
32 |
|
32 | |||
33 | /*! |
|
33 | /*! | |
34 | \enum QChart::ChartTheme |
|
34 | \enum QChart::ChartTheme | |
35 |
|
35 | |||
36 | This enum describes the theme used by the chart. |
|
36 | This enum describes the theme used by the chart. | |
37 |
|
37 | |||
38 | \value ChartThemeLight The default theme |
|
38 | \value ChartThemeLight The default theme | |
39 | \value ChartThemeBlueCerulean |
|
39 | \value ChartThemeBlueCerulean | |
40 | \value ChartThemeDark |
|
40 | \value ChartThemeDark | |
41 | \value ChartThemeBrownSand |
|
41 | \value ChartThemeBrownSand | |
42 | \value ChartThemeBlueNcs |
|
42 | \value ChartThemeBlueNcs | |
43 | \value ChartThemeHighContrast |
|
43 | \value ChartThemeHighContrast | |
44 | \value ChartThemeBlueIcy |
|
44 | \value ChartThemeBlueIcy | |
45 | */ |
|
45 | */ | |
46 |
|
46 | |||
47 | /*! |
|
47 | /*! | |
48 | \enum QChart::AnimationOption |
|
48 | \enum QChart::AnimationOption | |
49 |
|
49 | |||
50 | For enabling/disabling animations. Defaults to NoAnimation. |
|
50 | For enabling/disabling animations. Defaults to NoAnimation. | |
51 |
|
51 | |||
52 | \value NoAnimation |
|
52 | \value NoAnimation | |
53 | \value GridAxisAnimations |
|
53 | \value GridAxisAnimations | |
54 | \value SeriesAnimations |
|
54 | \value SeriesAnimations | |
55 | \value AllAnimations |
|
55 | \value AllAnimations | |
56 | */ |
|
56 | */ | |
57 |
|
57 | |||
58 | /*! |
|
58 | /*! | |
59 | \class QChart |
|
59 | \class QChart | |
60 | \brief QtCommercial chart API. |
|
60 | \brief QtCommercial chart API. | |
61 |
|
61 | |||
62 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical |
|
62 | QChart is a QGraphicsWidget that you can show in a QGraphicsScene. It manages the graphical | |
63 | representation of different types of series and other chart related objects like |
|
63 | representation of different types of series and other chart related objects like | |
64 | QAxis and QLegend. If you simply want to show a chart in a layout, you can use the |
|
64 | QAxis and QLegend. If you simply want to show a chart in a layout, you can use the | |
65 | convenience class QChartView instead of QChart. |
|
65 | convenience class QChartView instead of QChart. | |
66 | \sa QChartView |
|
66 | \sa QChartView | |
67 | */ |
|
67 | */ | |
68 |
|
68 | |||
69 | /*! |
|
69 | /*! | |
70 | \property QChart::animationOptions |
|
70 | \property QChart::animationOptions | |
71 | The animation \a options for the chart. Animations are enabled/disabled based on this setting. |
|
71 | The animation \a options for the chart. Animations are enabled/disabled based on this setting. | |
72 | */ |
|
72 | */ | |
73 |
|
73 | |||
74 | /*! |
|
74 | /*! | |
75 | \property QChart::backgroundVisible |
|
75 | \property QChart::backgroundVisible | |
76 | Whether the chart background is visible or not. |
|
76 | Whether the chart background is visible or not. | |
77 | \sa setBackgroundBrush(), setBackgroundPen() |
|
77 | \sa setBackgroundBrush(), setBackgroundPen() | |
78 | */ |
|
78 | */ | |
79 |
|
79 | |||
80 | /*! |
|
80 | /*! | |
81 | \property QChart::dropShadowEnabled |
|
81 | \property QChart::dropShadowEnabled | |
82 | If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop |
|
82 | If set to true, the background drop shadow effect is enabled. If set to false, it is disabled. Note that the drop | |
83 | shadow effect depends on theme, which means the setting may be changed if you switch to another theme. |
|
83 | shadow effect depends on theme, which means the setting may be changed if you switch to another theme. | |
84 | */ |
|
84 | */ | |
85 |
|
85 | |||
86 | /*! |
|
86 | /*! | |
87 | \property QChart::margins |
|
87 | \property QChart::margins | |
88 | Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes. |
|
88 | Margins around the plot area. Note that the margin area is used for drawing chart title, legend and axes. | |
89 | */ |
|
89 | */ | |
90 |
|
90 | |||
91 | /*! |
|
91 | /*! | |
92 | \property QChart::theme |
|
92 | \property QChart::theme | |
93 | Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors, |
|
93 | Theme is a built-in collection of UI style related settings applied for all visual elements of a chart, like colors, | |
94 | pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few |
|
94 | pens, brushes and fonts of series, axes, title and legend. \l {Chart themes demo} shows an example with a few | |
95 | different themes. |
|
95 | different themes. | |
96 | Note: changing the theme will overwrite all customizations previously applied to the series. |
|
96 | Note: changing the theme will overwrite all customizations previously applied to the series. | |
97 | */ |
|
97 | */ | |
98 |
|
98 | |||
99 | /*! |
|
99 | /*! | |
100 | \property QChart::title |
|
100 | \property QChart::title | |
101 | Title is the name (label) of a chart. It is shown as a headline on top of the chart. |
|
101 | Title is the name (label) of a chart. It is shown as a headline on top of the chart. | |
102 | */ |
|
102 | */ | |
103 |
|
103 | |||
104 | /*! |
|
104 | /*! | |
105 | \fn void QChart::marginsChanged(QRectF newMargins) |
|
105 | \fn void QChart::marginsChanged(QRectF newMargins) | |
106 | The margins around plot area have changed to \a newMargins. This may happen for example if you change title font size, |
|
106 | The margins around plot area have changed to \a newMargins. This may happen for example if you change title font size, | |
107 | modify axes or hide/show legend. |
|
107 | modify axes or hide/show legend. | |
108 | */ |
|
108 | */ | |
109 |
|
109 | |||
110 | /*! |
|
110 | /*! | |
111 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. |
|
111 | Constructs a chart object which is a child of a\a parent. Parameter \a wFlags is passed to the QGraphicsWidget constructor. | |
112 | */ |
|
112 | */ | |
113 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), |
|
113 | QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags), | |
114 | d_ptr(new QChartPrivate()) |
|
114 | d_ptr(new QChartPrivate()) | |
115 | { |
|
115 | { | |
116 | d_ptr->m_dataset = new ChartDataSet(this); |
|
116 | d_ptr->m_dataset = new ChartDataSet(this); | |
117 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); |
|
117 | d_ptr->m_presenter = new ChartPresenter(this,d_ptr->m_dataset); | |
118 | d_ptr->createConnections(); |
|
118 | d_ptr->createConnections(); | |
119 | d_ptr->m_legend = new LegendScroller(this); |
|
119 | d_ptr->m_legend = new LegendScroller(this); | |
120 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); |
|
120 | d_ptr->m_presenter->setTheme(QChart::ChartThemeLight, false); | |
121 | //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF))); |
|
121 | //connect(d_ptr->m_presenter, SIGNAL(marginsChanged(QRectF)), this, SIGNAL(marginsChanged(QRectF))); | |
122 | setLayout(d_ptr->m_presenter->layout()); |
|
122 | setLayout(d_ptr->m_presenter->layout()); | |
123 | } |
|
123 | } | |
124 |
|
124 | |||
125 | /*! |
|
125 | /*! | |
126 | Destroys the object and it's children, like series and axis objects added to it. |
|
126 | Destroys the object and it's children, like series and axis objects added to it. | |
127 | */ |
|
127 | */ | |
128 | QChart::~QChart() |
|
128 | QChart::~QChart() | |
129 | { |
|
129 | { | |
130 | //delete first presenter , since this is a root of all the graphical items |
|
130 | //delete first presenter , since this is a root of all the graphical items | |
131 | setLayout(0); |
|
131 | setLayout(0); | |
132 | delete d_ptr->m_presenter; |
|
132 | delete d_ptr->m_presenter; | |
133 | d_ptr->m_presenter=0; |
|
133 | d_ptr->m_presenter=0; | |
134 | } |
|
134 | } | |
135 |
|
135 | |||
136 | /*! |
|
136 | /*! | |
137 |
Adds the \a series |
|
137 | Adds the \a series onto the chart and takes the ownership of the object. | |
138 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and |
|
138 | If auto scaling is enabled, re-scales the axes the series is bound to (both the x axis and | |
139 | the y axis). |
|
139 | the y axis). | |
140 |
|
140 | |||
141 | \sa removeSeries(), removeAllSeries() |
|
141 | \sa removeSeries(), removeAllSeries() | |
142 | */ |
|
142 | */ | |
143 | void QChart::addSeries(QAbstractSeries *series) |
|
143 | void QChart::addSeries(QAbstractSeries *series) | |
144 | { |
|
144 | { | |
145 | Q_ASSERT(series); |
|
145 | Q_ASSERT(series); | |
146 | d_ptr->m_dataset->addSeries(series); |
|
146 | d_ptr->m_dataset->addSeries(series); | |
147 | } |
|
147 | } | |
148 |
|
148 | |||
149 | /*! |
|
149 | /*! | |
150 | Removes the \a series specified in a perameter from the QChartView. |
|
150 | Removes the \a series specified in a perameter from the QChartView. | |
151 | It releses its ownership of the specified QChartSeries object. |
|
151 | It releses its ownership of the specified QChartSeries object. | |
152 | It does not delete the pointed QChartSeries data object |
|
152 | It does not delete the pointed QChartSeries data object | |
153 | \sa addSeries(), removeAllSeries() |
|
153 | \sa addSeries(), removeAllSeries() | |
154 | */ |
|
154 | */ | |
155 | void QChart::removeSeries(QAbstractSeries *series) |
|
155 | void QChart::removeSeries(QAbstractSeries *series) | |
156 | { |
|
156 | { | |
157 | Q_ASSERT(series); |
|
157 | Q_ASSERT(series); | |
158 | d_ptr->m_dataset->removeSeries(series); |
|
158 | d_ptr->m_dataset->removeSeries(series); | |
159 | } |
|
159 | } | |
160 |
|
160 | |||
161 | /*! |
|
161 | /*! | |
162 | Removes all the QChartSeries that have been added to the QChartView |
|
162 | Removes all the QChartSeries that have been added to the QChartView | |
163 | It also deletes the pointed QChartSeries data objects |
|
163 | It also deletes the pointed QChartSeries data objects | |
164 | \sa addSeries(), removeSeries() |
|
164 | \sa addSeries(), removeSeries() | |
165 | */ |
|
165 | */ | |
166 | void QChart::removeAllSeries() |
|
166 | void QChart::removeAllSeries() | |
167 | { |
|
167 | { | |
168 | d_ptr->m_dataset->removeAllSeries(); |
|
168 | d_ptr->m_dataset->removeAllSeries(); | |
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | /*! |
|
171 | /*! | |
172 | Sets the \a brush that is used for painting the background of the chart area. |
|
172 | Sets the \a brush that is used for painting the background of the chart area. | |
173 | */ |
|
173 | */ | |
174 | void QChart::setBackgroundBrush(const QBrush& brush) |
|
174 | void QChart::setBackgroundBrush(const QBrush& brush) | |
175 | { |
|
175 | { | |
176 | d_ptr->m_presenter->setBackgroundBrush(brush); |
|
176 | d_ptr->m_presenter->setBackgroundBrush(brush); | |
177 | } |
|
177 | } | |
178 |
|
178 | |||
179 | /*! |
|
179 | /*! | |
180 | Gets the brush that is used for painting the background of the chart area. |
|
180 | Gets the brush that is used for painting the background of the chart area. | |
181 | */ |
|
181 | */ | |
182 | QBrush QChart::backgroundBrush() const |
|
182 | QBrush QChart::backgroundBrush() const | |
183 | { |
|
183 | { | |
184 | return d_ptr->m_presenter->backgroundBrush(); |
|
184 | return d_ptr->m_presenter->backgroundBrush(); | |
185 | } |
|
185 | } | |
186 |
|
186 | |||
187 | /*! |
|
187 | /*! | |
188 | Sets the \a pen that is used for painting the background of the chart area. |
|
188 | Sets the \a pen that is used for painting the background of the chart area. | |
189 | */ |
|
189 | */ | |
190 | void QChart::setBackgroundPen(const QPen& pen) |
|
190 | void QChart::setBackgroundPen(const QPen& pen) | |
191 | { |
|
191 | { | |
192 | d_ptr->m_presenter->setBackgroundPen(pen); |
|
192 | d_ptr->m_presenter->setBackgroundPen(pen); | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | /*! |
|
195 | /*! | |
196 | Gets the pen that is used for painting the background of the chart area. |
|
196 | Gets the pen that is used for painting the background of the chart area. | |
197 | */ |
|
197 | */ | |
198 | QPen QChart::backgroundPen() const |
|
198 | QPen QChart::backgroundPen() const | |
199 | { |
|
199 | { | |
200 | return d_ptr->m_presenter->backgroundPen(); |
|
200 | return d_ptr->m_presenter->backgroundPen(); | |
201 | } |
|
201 | } | |
202 |
|
202 | |||
203 | /*! |
|
203 | /*! | |
204 | Sets the chart \a title. The description text that is drawn above the chart. |
|
204 | Sets the chart \a title. The description text that is drawn above the chart. | |
205 | */ |
|
205 | */ | |
206 | void QChart::setTitle(const QString& title) |
|
206 | void QChart::setTitle(const QString& title) | |
207 | { |
|
207 | { | |
208 | d_ptr->m_presenter->setTitle(title); |
|
208 | d_ptr->m_presenter->setTitle(title); | |
209 | } |
|
209 | } | |
210 |
|
210 | |||
211 | /*! |
|
211 | /*! | |
212 | Returns the chart title. The description text that is drawn above the chart. |
|
212 | Returns the chart title. The description text that is drawn above the chart. | |
213 | */ |
|
213 | */ | |
214 | QString QChart::title() const |
|
214 | QString QChart::title() const | |
215 | { |
|
215 | { | |
216 | return d_ptr->m_presenter->title(); |
|
216 | return d_ptr->m_presenter->title(); | |
217 | } |
|
217 | } | |
218 |
|
218 | |||
219 | /*! |
|
219 | /*! | |
220 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. |
|
220 | Sets the \a font that is used for drawing the chart description text that is rendered above the chart. | |
221 | */ |
|
221 | */ | |
222 | void QChart::setTitleFont(const QFont& font) |
|
222 | void QChart::setTitleFont(const QFont& font) | |
223 | { |
|
223 | { | |
224 | d_ptr->m_presenter->setTitleFont(font); |
|
224 | d_ptr->m_presenter->setTitleFont(font); | |
225 | } |
|
225 | } | |
226 |
|
226 | |||
227 | /*! |
|
227 | /*! | |
228 | Gets the font that is used for drawing the chart description text that is rendered above the chart. |
|
228 | Gets the font that is used for drawing the chart description text that is rendered above the chart. | |
229 | */ |
|
229 | */ | |
230 | QFont QChart::titleFont() const |
|
230 | QFont QChart::titleFont() const | |
231 | { |
|
231 | { | |
232 | return d_ptr->m_presenter->titleFont(); |
|
232 | return d_ptr->m_presenter->titleFont(); | |
233 | } |
|
233 | } | |
234 |
|
234 | |||
235 | /*! |
|
235 | /*! | |
236 | Sets the \a brush used for rendering the title text. |
|
236 | Sets the \a brush used for rendering the title text. | |
237 | */ |
|
237 | */ | |
238 | void QChart::setTitleBrush(const QBrush &brush) |
|
238 | void QChart::setTitleBrush(const QBrush &brush) | |
239 | { |
|
239 | { | |
240 | d_ptr->m_presenter->setTitleBrush(brush); |
|
240 | d_ptr->m_presenter->setTitleBrush(brush); | |
241 | } |
|
241 | } | |
242 |
|
242 | |||
243 | /*! |
|
243 | /*! | |
244 | Returns the brush used for rendering the title text. |
|
244 | Returns the brush used for rendering the title text. | |
245 | */ |
|
245 | */ | |
246 | QBrush QChart::titleBrush() const |
|
246 | QBrush QChart::titleBrush() const | |
247 | { |
|
247 | { | |
248 | return d_ptr->m_presenter->titleBrush(); |
|
248 | return d_ptr->m_presenter->titleBrush(); | |
249 | } |
|
249 | } | |
250 |
|
250 | |||
251 | void QChart::setTheme(QChart::ChartTheme theme) |
|
251 | void QChart::setTheme(QChart::ChartTheme theme) | |
252 | { |
|
252 | { | |
253 | d_ptr->m_presenter->setTheme(theme); |
|
253 | d_ptr->m_presenter->setTheme(theme); | |
254 | } |
|
254 | } | |
255 |
|
255 | |||
256 | QChart::ChartTheme QChart::theme() const |
|
256 | QChart::ChartTheme QChart::theme() const | |
257 | { |
|
257 | { | |
258 | return d_ptr->m_presenter->theme(); |
|
258 | return d_ptr->m_presenter->theme(); | |
259 | } |
|
259 | } | |
260 |
|
260 | |||
261 | /*! |
|
261 | /*! | |
262 | Zooms in the view by a factor of 2 |
|
262 | Zooms in the view by a factor of 2 | |
263 | */ |
|
263 | */ | |
264 | void QChart::zoomIn() |
|
264 | void QChart::zoomIn() | |
265 | { |
|
265 | { | |
266 | d_ptr->m_presenter->zoomIn(2.0); |
|
266 | d_ptr->m_presenter->zoomIn(2.0); | |
267 | } |
|
267 | } | |
268 |
|
268 | |||
269 | /*! |
|
269 | /*! | |
270 | Zooms in the view to a maximum level at which \a rect is still fully visible. |
|
270 | Zooms in the view to a maximum level at which \a rect is still fully visible. | |
271 | */ |
|
271 | */ | |
272 | void QChart::zoomIn(const QRectF& rect) |
|
272 | void QChart::zoomIn(const QRectF& rect) | |
273 | { |
|
273 | { | |
274 | if (!rect.isValid()) return; |
|
274 | if (!rect.isValid()) return; | |
275 | d_ptr->m_presenter->zoomIn(rect); |
|
275 | d_ptr->m_presenter->zoomIn(rect); | |
276 | } |
|
276 | } | |
277 |
|
277 | |||
278 | /*! |
|
278 | /*! | |
279 | Restores the view zoom level to the previous one. |
|
279 | Restores the view zoom level to the previous one. | |
280 | */ |
|
280 | */ | |
281 | void QChart::zoomOut() |
|
281 | void QChart::zoomOut() | |
282 | { |
|
282 | { | |
283 | d_ptr->m_presenter->zoomOut(2.0); |
|
283 | d_ptr->m_presenter->zoomOut(2.0); | |
284 | } |
|
284 | } | |
285 |
|
285 | |||
286 | /*! |
|
286 | /*! | |
287 | Zooms in the view by a \a factor. |
|
287 | Zooms in the view by a \a factor. | |
288 |
|
288 | |||
289 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. |
|
289 | A factor over 1.0 zooms the view in and factor between 0.0 and 1.0 zooms out. | |
290 | */ |
|
290 | */ | |
291 | void QChart::zoom(qreal factor) |
|
291 | void QChart::zoom(qreal factor) | |
292 | { |
|
292 | { | |
293 | if (qFuzzyIsNull(factor)) |
|
293 | if (qFuzzyIsNull(factor)) | |
294 | return; |
|
294 | return; | |
295 |
|
295 | |||
296 | if (qFuzzyCompare(factor, 1.0)) |
|
296 | if (qFuzzyCompare(factor, 1.0)) | |
297 | return; |
|
297 | return; | |
298 |
|
298 | |||
299 | if (factor < 0) |
|
299 | if (factor < 0) | |
300 | return; |
|
300 | return; | |
301 |
|
301 | |||
302 | if (factor > 1.0) |
|
302 | if (factor > 1.0) | |
303 | d_ptr->m_presenter->zoomIn(factor); |
|
303 | d_ptr->m_presenter->zoomIn(factor); | |
304 | else |
|
304 | else | |
305 | d_ptr->m_presenter->zoomOut(1.0 / factor); |
|
305 | d_ptr->m_presenter->zoomOut(1.0 / factor); | |
306 | } |
|
306 | } | |
307 |
|
307 | |||
308 | /*! |
|
308 | /*! | |
309 | Returns the pointer to the x axis object of the chart |
|
309 | Returns the pointer to the x axis object of the chart | |
310 | */ |
|
310 | */ | |
311 | QAbstractAxis* QChart::axisX(QAbstractSeries* series) const |
|
311 | QAbstractAxis* QChart::axisX(QAbstractSeries* series) const | |
312 | { |
|
312 | { | |
313 | return d_ptr->m_dataset->axisX(series); |
|
313 | return d_ptr->m_dataset->axisX(series); | |
314 | } |
|
314 | } | |
315 |
|
315 | |||
316 | /*! |
|
316 | /*! | |
317 | Returns the pointer to the y axis object of the \a series |
|
317 | Returns the pointer to the y axis object of the \a series | |
318 | If no \a series is provided then default Y axis of the chart is returned. |
|
318 | If no \a series is provided then default Y axis of the chart is returned. | |
319 | */ |
|
319 | */ | |
320 | QAbstractAxis* QChart::axisY(QAbstractSeries *series) const |
|
320 | QAbstractAxis* QChart::axisY(QAbstractSeries *series) const | |
321 | { |
|
321 | { | |
322 | return d_ptr->m_dataset->axisY(series); |
|
322 | return d_ptr->m_dataset->axisY(series); | |
323 | } |
|
323 | } | |
324 |
|
324 | |||
325 | /*! |
|
325 | /*! | |
326 | Returns the legend object of the chart. Ownership stays in chart. |
|
326 | Returns the legend object of the chart. Ownership stays in chart. | |
327 | */ |
|
327 | */ | |
328 | QLegend* QChart::legend() const |
|
328 | QLegend* QChart::legend() const | |
329 | { |
|
329 | { | |
330 | return d_ptr->m_legend; |
|
330 | return d_ptr->m_legend; | |
331 | } |
|
331 | } | |
332 |
|
332 | |||
333 | /*! |
|
333 | /*! | |
334 | Returns the rect that contains information about margins (distance between chart widget edge and axes). |
|
334 | Returns the rect that contains information about margins (distance between chart widget edge and axes). | |
335 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. |
|
335 | Individual margins can be obtained by calling left, top, right, bottom on the returned rect. | |
336 | */ |
|
336 | */ | |
337 | QRectF QChart::margins() const |
|
337 | QRectF QChart::margins() const | |
338 | { |
|
338 | { | |
339 | return d_ptr->m_presenter->margins(); |
|
339 | return d_ptr->m_presenter->margins(); | |
340 | } |
|
340 | } | |
341 |
|
341 | |||
342 | /*! |
|
342 | /*! | |
343 | Sets animation \a options for the chart |
|
343 | Sets animation \a options for the chart | |
344 | */ |
|
344 | */ | |
345 |
|
345 | |||
346 | void QChart::setAnimationOptions(AnimationOptions options) |
|
346 | void QChart::setAnimationOptions(AnimationOptions options) | |
347 | { |
|
347 | { | |
348 | d_ptr->m_presenter->setAnimationOptions(options); |
|
348 | d_ptr->m_presenter->setAnimationOptions(options); | |
349 | } |
|
349 | } | |
350 |
|
350 | |||
351 | QChart::AnimationOptions QChart::animationOptions() const |
|
351 | QChart::AnimationOptions QChart::animationOptions() const | |
352 | { |
|
352 | { | |
353 | return d_ptr->m_presenter->animationOptions(); |
|
353 | return d_ptr->m_presenter->animationOptions(); | |
354 | } |
|
354 | } | |
355 |
|
355 | |||
356 | /*! |
|
356 | /*! | |
357 |
Scrolls the visible area of the chart by the distance defined in the \a d |
|
357 | Scrolls the visible area of the chart by the distance defined in the \a dx and \a dy. | |
358 | */ |
|
358 | */ | |
359 | void QChart::scroll(qreal dx, qreal dy) |
|
359 | void QChart::scroll(qreal dx, qreal dy) | |
360 | { |
|
360 | { | |
361 | d_ptr->m_presenter->scroll(dx, dy); |
|
361 | d_ptr->m_presenter->scroll(dx, dy); | |
362 | } |
|
362 | } | |
363 |
|
363 | |||
364 | void QChart::setBackgroundVisible(bool visible) |
|
364 | void QChart::setBackgroundVisible(bool visible) | |
365 | { |
|
365 | { | |
366 | d_ptr->m_presenter->setBackgroundVisible(visible); |
|
366 | d_ptr->m_presenter->setBackgroundVisible(visible); | |
367 | } |
|
367 | } | |
368 |
|
368 | |||
369 | bool QChart::isBackgroundVisible() const |
|
369 | bool QChart::isBackgroundVisible() const | |
370 | { |
|
370 | { | |
371 | return d_ptr->m_presenter->isBackgroundVisible(); |
|
371 | return d_ptr->m_presenter->isBackgroundVisible(); | |
372 | } |
|
372 | } | |
373 |
|
373 | |||
374 | void QChart::setDropShadowEnabled(bool enabled) |
|
374 | void QChart::setDropShadowEnabled(bool enabled) | |
375 | { |
|
375 | { | |
376 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); |
|
376 | d_ptr->m_presenter->setBackgroundDropShadowEnabled(enabled); | |
377 | } |
|
377 | } | |
378 |
|
378 | |||
379 | bool QChart::isDropShadowEnabled() const |
|
379 | bool QChart::isDropShadowEnabled() const | |
380 | { |
|
380 | { | |
381 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); |
|
381 | return d_ptr->m_presenter->isBackgroundDropShadowEnabled(); | |
382 | } |
|
382 | } | |
383 |
|
383 | |||
384 | /*! |
|
384 | /*! | |
385 | Returns all the series that are added to the chart. |
|
385 | Returns all the series that are added to the chart. | |
386 |
|
386 | |||
387 | \sa addSeries(), removeSeries(), removeAllSeries() |
|
387 | \sa addSeries(), removeSeries(), removeAllSeries() | |
388 | */ |
|
388 | */ | |
389 | QList<QAbstractSeries*> QChart::series() const |
|
389 | QList<QAbstractSeries*> QChart::series() const | |
390 | { |
|
390 | { | |
391 | return d_ptr->m_dataset->series(); |
|
391 | return d_ptr->m_dataset->series(); | |
392 | } |
|
392 | } | |
393 |
|
393 | |||
394 | void QChart::setMarginsMinimum(const QRectF& margins) |
|
394 | void QChart::setMarginsMinimum(const QRectF& margins) | |
395 | { |
|
395 | { | |
396 | d_ptr->m_presenter->setMarginsMinimum(margins); |
|
396 | d_ptr->m_presenter->setMarginsMinimum(margins); | |
397 | } |
|
397 | } | |
398 |
|
398 | |||
399 | void QChart::setAxisX(QAbstractSeries *series, QAbstractAxis* axis) |
|
399 | void QChart::setAxisX(QAbstractSeries *series, QAbstractAxis* axis) | |
400 | { |
|
400 | { | |
401 | d_ptr->m_dataset->setAxisX(series, axis); |
|
401 | d_ptr->m_dataset->setAxisX(series, axis); | |
402 | } |
|
402 | } | |
403 |
|
403 | |||
404 | void QChart::setAxisY(QAbstractSeries *series, QAbstractAxis* axis) |
|
404 | void QChart::setAxisY(QAbstractSeries *series, QAbstractAxis* axis) | |
405 | { |
|
405 | { | |
406 | d_ptr->m_dataset->setAxisY(series, axis); |
|
406 | d_ptr->m_dataset->setAxisY(series, axis); | |
407 | } |
|
407 | } | |
408 |
|
408 | |||
409 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
409 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
410 |
|
410 | |||
411 | QChartPrivate::QChartPrivate(): |
|
411 | QChartPrivate::QChartPrivate(): | |
412 | m_legend(0), |
|
412 | m_legend(0), | |
413 | m_dataset(0), |
|
413 | m_dataset(0), | |
414 | m_presenter(0) |
|
414 | m_presenter(0) | |
415 | { |
|
415 | { | |
416 |
|
416 | |||
417 | } |
|
417 | } | |
418 |
|
418 | |||
419 | QChartPrivate::~QChartPrivate() |
|
419 | QChartPrivate::~QChartPrivate() | |
420 | { |
|
420 | { | |
421 |
|
421 | |||
422 | } |
|
422 | } | |
423 |
|
423 | |||
424 | void QChartPrivate::createConnections() |
|
424 | void QChartPrivate::createConnections() | |
425 | { |
|
425 | { | |
426 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); |
|
426 | QObject::connect(m_dataset,SIGNAL(seriesAdded(QAbstractSeries*,Domain*)),m_presenter,SLOT(handleSeriesAdded(QAbstractSeries*,Domain*))); | |
427 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*))); |
|
427 | QObject::connect(m_dataset,SIGNAL(seriesRemoved(QAbstractSeries*)),m_presenter,SLOT(handleSeriesRemoved(QAbstractSeries*))); | |
428 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*))); |
|
428 | QObject::connect(m_dataset,SIGNAL(axisAdded(QAbstractAxis*,Domain*)),m_presenter,SLOT(handleAxisAdded(QAbstractAxis*,Domain*))); | |
429 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*))); |
|
429 | QObject::connect(m_dataset,SIGNAL(axisRemoved(QAbstractAxis*)),m_presenter,SLOT(handleAxisRemoved(QAbstractAxis*))); | |
430 | //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF))); |
|
430 | //QObject::connect(m_presenter, SIGNAL(marginsChanged(QRectF)), q_ptr, SIGNAL(marginsChanged(QRectF))); | |
431 | } |
|
431 | } | |
432 |
|
432 | |||
433 | #include "moc_qchart.cpp" |
|
433 | #include "moc_qchart.cpp" | |
434 |
|
434 | |||
435 | QTCOMMERCIALCHART_END_NAMESPACE |
|
435 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now