##// END OF EJS Templates
pieslice: update docs
Jani Honkonen -
r1277:06179f33651d
parent child
Show More
@@ -31,17 +31,27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31
31
32 In addition to the obvious value and label properties the user can also control
32 In addition to the obvious value and label properties the user can also control
33 the visual appearance of a slice. By modifying the visual appearance also means that
33 the visual appearance of a slice. By modifying the visual appearance also means that
34 the user is overriding the default appearance set by the theme. Even if the theme is
34 the user is overriding the default appearance set by the theme.
35 changed users settings will persist.
36
35
37 To enable user interaction customization with the slices some basic signals
36 Note that if the user has customized slices and theme is changed all customizations will be lost.
38 are provided about clicking and hovering.
37
38 To enable user interaction with the pie some basic signals are provided about clicking and hovering.
39 */
39 */
40
40
41 /*!
41 /*!
42 \property QPieSlice::label
42 \property QPieSlice::label
43
43
44 Label of the slice.
44 Label of the slice.
45
46 \sa labelVisible, labelPen, labelFont, labelArmLengthFactor
47 */
48
49 /*!
50 \fn void QPieSlice::labelChanged()
51
52 This signal emitted when the slice label has been changed.
53
54 \sa label
45 */
55 */
46
56
47 /*!
57 /*!
@@ -53,212 +63,208 QTCOMMERCIALCHART_BEGIN_NAMESPACE
53 */
63 */
54
64
55 /*!
65 /*!
56 Constructs an empty slice with a \a parent.
66 \fn void QPieSlice::valueChanged()
57
67
58 \sa QPieSeries::append(), QPieSeries::insert()
68 This signal is emitted when the slice value changes.
59 */
60 QPieSlice::QPieSlice(QObject *parent)
61 :QObject(parent),
62 d_ptr(new QPieSlicePrivate(this))
63 {
64
69
65 }
70 \sa value
71 */
66
72
67 /*!
73 /*!
68 Constructs an empty slice with given \a value, \a label and a \a parent.
74 \property QPieSlice::labelVisible
69 \sa QPieSeries::append(), QPieSeries::insert()
75
76 Defienes the visibility of the slice label.
77
78 Default is not visible.
79
80 \sa label, labelPen, labelFont, labelArmLengthFactor
70 */
81 */
71 QPieSlice::QPieSlice(QString label, qreal value, QObject *parent)
72 :QObject(parent),
73 d_ptr(new QPieSlicePrivate(this))
74 {
75 d_ptr->m_data.m_value = value;
76 d_ptr->m_data.m_labelText = label;
77 }
78
82
79 /*!
83 /*!
80 Destroys the slice.
84 \fn void QPieSlice::labelVisibleChanged()
81 User should not delete the slice if it has been added to the series.
82 */
83 QPieSlice::~QPieSlice()
84 {
85
85
86 }
86 This signal emitted when visibility of the slice label has changed.
87
87
88 /*!
88 \sa labelVisible
89 Gets the value of the slice.
90 Note that all values in the series
91 \sa setValue()
92 */
89 */
93 qreal QPieSlice::value() const
94 {
95 return d_ptr->m_data.m_value;
96 }
97
90
98 /*!
91 /*!
99 Gets the label of the slice.
92 \property QPieSlice::exploded
100 \sa setLabel()
93
94 Defines if the slice is exploded from the pie.
95
96 \sa explodeDistanceFactor
101 */
97 */
102 QString QPieSlice::label() const
103 {
104 return d_ptr->m_data.m_labelText;
105 }
106
98
107 /*!
99 /*!
108 Returns true if label is set as visible.
100 \fn void QPieSlice::explodedChanged()
109 \sa setLabelVisible()
101
102 This signal is emitted the the slice has been exploded from the pie or is returned back to the pie.
103
104 \sa exploded
110 */
105 */
111 bool QPieSlice::isLabelVisible() const
112 {
113 return d_ptr->m_data.m_isLabelVisible;
114 }
115
106
116 /*!
107 /*!
117 Returns true if slice is exloded from the pie.
108 \property QPieSlice::pen
118 \sa setExploded(), explodeDistanceFactor(), setExplodeDistanceFactor()
109
110 Pen used to draw the slice border.
119 */
111 */
120 bool QPieSlice::isExploded() const
121 {
122 return d_ptr->m_data.m_isExploded;
123 }
124
112
125 /*!
113 /*!
126 Returns the explode distance factor.
114 \fn void QPieSlice::penChanged()
127
115
128 The factor is relative to pie radius. For example:
116 This signal is emitted when the pen of the slice has changed.
129 1.0 means the distance is the same as the radius.
117
130 0.5 means the distance is half of the radius.
118 \sa pen
119 */
131
120
132 Default value is 0.15.
121 /*!
122 \property QPieSlice::brush
133
123
134 \sa setExplodeDistanceFactor(), isExploded(), setExploded()
124 Brush used to draw the slice.
135 */
125 */
136 qreal QPieSlice::explodeDistanceFactor() const
137 {
138 return d_ptr->m_data.m_explodeDistanceFactor;
139 }
140
126
141 /*!
127 /*!
142 Returns the percentage of this slice compared to the sum of all slices in the same series.
128 \fn void QPieSlice::brushChanged()
143 The returned value ranges from 0 to 1.0.
144
129
145 Updated internally after the slice is added to the series.
130 This signal is emitted when the brush of the slice has changed.
146
131
147 \sa QPieSeries::sum()
132 \sa brush
148 */
133 */
149 qreal QPieSlice::percentage() const
150 {
151 return d_ptr->m_data.m_percentage;
152 }
153
134
154 /*!
135 /*!
155 Returns the starting angle of this slice in the series it belongs to.
136 \property QPieSlice::labelPen
156
137
157 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
138 Pen used to draw label and label arm of the slice.
158
139
159 Updated internally after the slice is added to the series.
140 \sa label, labelVisible, labelFont, labelArmLengthFactor
160 */
141 */
161 qreal QPieSlice::startAngle() const
162 {
163 return d_ptr->m_data.m_startAngle;
164 }
165
142
166 /*!
143 /*!
167 Returns the end angle of this slice in the series it belongs to.
144 \fn void QPieSlice::labelPenChanged()
168
145
169 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
146 This signal is emitted when the label pen of the slice has changed.
170
147
171 Updated internally after the slice is added to the series.
148 \sa labelPen
172 */
149 */
173 qreal QPieSlice::angleSpan() const
174 {
175 return d_ptr->m_data.m_angleSpan;
176 }
177
150
178 /*!
151 /*!
179 Returns the pen used to draw this slice.
152 \property QPieSlice::labelFont
180 \sa setPen()
153
154 Font used for drawing label text.
155
156 \sa label, labelVisible, labelArmLengthFactor
181 */
157 */
182 QPen QPieSlice::pen() const
183 {
184 return d_ptr->m_data.m_slicePen;
185 }
186
158
187 /*!
159 /*!
188 Returns the brush used to draw this slice.
160 \fn void QPieSlice::labelFontChanged()
189 \sa setBrush()
161
162 This signal is emitted when the label font of the slice has changed.
163
164 \sa labelFont
190 */
165 */
191 QBrush QPieSlice::brush() const
192 {
193 return d_ptr->m_data.m_sliceBrush;
194 }
195
166
196 /*!
167 /*!
197 Returns the pen used to draw the label in this slice.
168 \property QPieSlice::labelArmLengthFactor
198 \sa setLabelPen()
169
170 Defines the length of the label arm.
171
172 The factor is relative to pie radius. For example:
173 1.0 means the length is the same as the radius.
174 0.5 means the length is half of the radius.
175
176 Default value is 0.15
177
178 \sa label, labelVisible, labelPen, labelFont
199 */
179 */
200 QPen QPieSlice::labelPen() const
201 {
202 return d_ptr->m_data.m_labelPen;
203 }
204
180
205 /*!
181 /*!
206 Returns the font used to draw label in this slice.
182 \fn void QPieSlice::labelArmLengthFactorChanged()
207 \sa setLabelFont()
183
184 This signal is emitted when the label arm factor of the slice has changed.
185
186 \sa labelArmLengthFactor
208 */
187 */
209 QFont QPieSlice::labelFont() const
210 {
211 return d_ptr->m_data.m_labelFont;
212 }
213
188
214 /*!
189 /*!
215 Gets the label arm length factor.
190 \property QPieSlice::explodeDistanceFactor
191
192 When the slice is exploded this factor defines how far the slice is exploded away from the pie.
216
193
217 The factor is relative to pie radius. For example:
194 The factor is relative to pie radius. For example:
218 1.0 means the length is the same as the radius.
195 1.0 means the distance is the same as the radius.
219 0.5 means the length is half of the radius.
196 0.5 means the distance is half of the radius.
220
197
221 Default value is 0.15
198 Default value is 0.15
222
199
223 \sa setLabelArmLengthFactor()
200 \sa exploded
224 */
201 */
225 qreal QPieSlice::labelArmLengthFactor() const
226 {
227 return d_ptr->m_data.m_labelArmLengthFactor;
228 }
229
202
230 /*!
203 /*!
231 \fn void QPieSlice::labelChanged()
204 \fn void QPieSlice::explodeDistanceFactorChanged()
232
205
233 This signal is emitted when the slice label changes.
206 This signal is emitted when the explode distance factor of the slice has changed.
234
207
235 \sa setLabel()
208 \sa explodeDistanceFactor
236 */
209 */
237
210
238 /*!
211 /*!
239 \fn void QPieSlice::valueChanged()
212 \property QPieSlice::percentage
240
213
241 This signal is emitted when the slice value changes.
214 Percentage of the slice compared to the sum of all slices in the series.
215
216 The actual value ranges from 0.0 to 1.0.
217
218 Updated automatically once the slice is added to the series.
219
220 \sa value, QPieSeries::sum
221 */
222
223 /*!
224 \fn void QPieSlice::percentageChanged()
225
226 This signal is emitted when the percentage of the slice has changed.
227
228 \sa percentage
229 */
230
231 /*!
232 \property QPieSlice::startAngle
233
234 Defines the starting angle of this slice in the series it belongs to.
242
235
243 \sa setValue()
236 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
237
238 Updated automatically once the slice is added to the series.
244 */
239 */
245
240
246 /*!
241 /*!
247 \fn void QPieSlice::appearanceChanged()
242 \fn void QPieSlice::startAngleChanged()
243
244 This signal is emitted when the starting angle f the slice has changed.
245
246 \sa startAngle
247 */
248
248
249 This signal is emitted when visual appearance of the slice changes.
249 /*!
250 \property QPieSlice::angleSpan
251
252 Span of the slice in degrees.
253
254 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
250
255
251 \sa setPen(), setBrush(), setLabelVisible(), setExploded()
256 Updated automatically once the slice is added to the series.
252 */
257 */
253
258
254 /*!
259 /*!
255 \fn void QPieSlice::calculatedDataChanged()
260 \fn void QPieSlice::angleSpanChanged()
256
261
257 This signal is emitted when calculated data for this slice changes.
262 This signal is emitted when the angle span of the slice has changed.
258
263
259 \sa percentage(), startAngle(), endAngle()
264 \sa angleSpan
260 */
265 */
261
266
267
262 /*!
268 /*!
263 \fn void QPieSlice::clicked()
269 \fn void QPieSlice::clicked()
264
270
@@ -278,21 +284,38 qreal QPieSlice::labelArmLengthFactor() const
278 */
284 */
279
285
280 /*!
286 /*!
281 Sets the \a value of this slice.
287 Constructs an empty slice with a \a parent.
282 \sa value()
288
289 \sa QPieSeries::append(), QPieSeries::insert()
283 */
290 */
284 void QPieSlice::setValue(qreal value)
291 QPieSlice::QPieSlice(QObject *parent)
292 :QObject(parent),
293 d_ptr(new QPieSlicePrivate(this))
285 {
294 {
286 if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) {
295
287 d_ptr->m_data.m_value = value;
288 emit valueChanged();
289 }
290 }
296 }
291
297
292 /*!
298 /*!
293 Sets the \a label of the slice.
299 Constructs an empty slice with given \a value, \a label and a \a parent.
294 \sa label()
300 \sa QPieSeries::append(), QPieSeries::insert()
295 */
301 */
302 QPieSlice::QPieSlice(QString label, qreal value, QObject *parent)
303 :QObject(parent),
304 d_ptr(new QPieSlicePrivate(this))
305 {
306 d_ptr->m_data.m_value = value;
307 d_ptr->m_data.m_labelText = label;
308 }
309
310 /*!
311 Destroys the slice.
312 User should not delete the slice if it has been added to the series.
313 */
314 QPieSlice::~QPieSlice()
315 {
316
317 }
318
296 void QPieSlice::setLabel(QString label)
319 void QPieSlice::setLabel(QString label)
297 {
320 {
298 if (d_ptr->m_data.m_labelText != label) {
321 if (d_ptr->m_data.m_labelText != label) {
@@ -301,10 +324,24 void QPieSlice::setLabel(QString label)
301 }
324 }
302 }
325 }
303
326
304 /*!
327 QString QPieSlice::label() const
305 Sets the label \a visible in this slice.
328 {
306 \sa isLabelVisible(), QPieSeries::setLabelsVisible()
329 return d_ptr->m_data.m_labelText;
307 */
330 }
331
332 void QPieSlice::setValue(qreal value)
333 {
334 if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) {
335 d_ptr->m_data.m_value = value;
336 emit valueChanged();
337 }
338 }
339
340 qreal QPieSlice::value() const
341 {
342 return d_ptr->m_data.m_value;
343 }
344
308 void QPieSlice::setLabelVisible(bool visible)
345 void QPieSlice::setLabelVisible(bool visible)
309 {
346 {
310 if (d_ptr->m_data.m_isLabelVisible != visible) {
347 if (d_ptr->m_data.m_isLabelVisible != visible) {
@@ -313,13 +350,11 void QPieSlice::setLabelVisible(bool visible)
313 }
350 }
314 }
351 }
315
352
316 /*!
353 bool QPieSlice::isLabelVisible() const
317 Sets this slices \a exploded state.
354 {
318
355 return d_ptr->m_data.m_isLabelVisible;
319 If the slice is exploded it is moved away from the pie center. The distance is defined by the explode distance factor.
356 }
320
357
321 \sa isExploded(), explodeDistanceFactor(), setExplodeDistanceFactor()
322 */
323 void QPieSlice::setExploded(bool exploded)
358 void QPieSlice::setExploded(bool exploded)
324 {
359 {
325 if (d_ptr->m_data.m_isExploded != exploded) {
360 if (d_ptr->m_data.m_isExploded != exploded) {
@@ -328,84 +363,51 void QPieSlice::setExploded(bool exploded)
328 }
363 }
329 }
364 }
330
365
331 /*!
366 bool QPieSlice::isExploded() const
332 Sets the explode distance \a factor.
333
334 The factor is relative to pie radius. For example:
335 1.0 means the distance is the same as the radius.
336 0.5 means the distance is half of the radius.
337
338 Default value is 0.15
339
340 \sa explodeDistanceFactor(), isExploded(), setExploded()
341 */
342 void QPieSlice::setExplodeDistanceFactor(qreal factor)
343 {
367 {
344 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
368 return d_ptr->m_data.m_isExploded;
345 d_ptr->m_data.m_explodeDistanceFactor = factor;
346 emit explodeDistanceFactorChanged();
347 }
348 }
369 }
349
370
350 /*!
351 Sets the \a pen used to draw this slice.
352
353 Overrides the pen set by the theme.
354
355 \sa pen()
356 */
357 void QPieSlice::setPen(const QPen &pen)
371 void QPieSlice::setPen(const QPen &pen)
358 {
372 {
359 d_ptr->setPen(pen, false);
373 d_ptr->setPen(pen, false);
360 }
374 }
361
375
362 /*!
376 QPen QPieSlice::pen() const
363 Sets the \a brush used to draw this slice.
377 {
364
378 return d_ptr->m_data.m_slicePen;
365 Overrides the brush set by the theme.
379 }
366
380
367 \sa brush()
368 */
369 void QPieSlice::setBrush(const QBrush &brush)
381 void QPieSlice::setBrush(const QBrush &brush)
370 {
382 {
371 d_ptr->setBrush(brush, false);
383 d_ptr->setBrush(brush, false);
372 }
384 }
373
385
374 /*!
386 QBrush QPieSlice::brush() const
375 Sets the \a pen used to draw the label in this slice.
387 {
376
388 return d_ptr->m_data.m_sliceBrush;
377 Overrides the pen set by the theme.
389 }
378
390
379 \sa labelPen()
380 */
381 void QPieSlice::setLabelPen(const QPen &pen)
391 void QPieSlice::setLabelPen(const QPen &pen)
382 {
392 {
383 d_ptr->setLabelPen(pen, false);
393 d_ptr->setLabelPen(pen, false);
384 }
394 }
385
395
386 /*!
396 QPen QPieSlice::labelPen() const
387 Sets the \a font used to draw the label in this slice.
397 {
388
398 return d_ptr->m_data.m_labelPen;
389 Overrides the font set by the theme.
399 }
390
400
391 \sa labelFont()
392 */
393 void QPieSlice::setLabelFont(const QFont &font)
401 void QPieSlice::setLabelFont(const QFont &font)
394 {
402 {
395 d_ptr->setLabelFont(font, false);
403 d_ptr->setLabelFont(font, false);
396 }
404 }
397
405
398 /*!
406 QFont QPieSlice::labelFont() const
399 Sets the label arm length \a factor.
407 {
400
408 return d_ptr->m_data.m_labelFont;
401 The factor is relative to pie radius. For example:
409 }
402 1.0 means the length is the same as the radius.
403 0.5 means the length is half of the radius.
404
405 Default value is 0.15
406
410
407 \sa labelArmLengthFactor()
408 */
409 void QPieSlice::setLabelArmLengthFactor(qreal factor)
411 void QPieSlice::setLabelArmLengthFactor(qreal factor)
410 {
412 {
411 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
413 if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) {
@@ -414,6 +416,39 void QPieSlice::setLabelArmLengthFactor(qreal factor)
414 }
416 }
415 }
417 }
416
418
419 qreal QPieSlice::labelArmLengthFactor() const
420 {
421 return d_ptr->m_data.m_labelArmLengthFactor;
422 }
423
424 void QPieSlice::setExplodeDistanceFactor(qreal factor)
425 {
426 if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) {
427 d_ptr->m_data.m_explodeDistanceFactor = factor;
428 emit explodeDistanceFactorChanged();
429 }
430 }
431
432 qreal QPieSlice::explodeDistanceFactor() const
433 {
434 return d_ptr->m_data.m_explodeDistanceFactor;
435 }
436
437 qreal QPieSlice::percentage() const
438 {
439 return d_ptr->m_data.m_percentage;
440 }
441
442 qreal QPieSlice::startAngle() const
443 {
444 return d_ptr->m_data.m_startAngle;
445 }
446
447 qreal QPieSlice::angleSpan() const
448 {
449 return d_ptr->m_data.m_angleSpan;
450 }
451
417 QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent)
452 QPieSlicePrivate::QPieSlicePrivate(QPieSlice *parent)
418 :QObject(parent),
453 :QObject(parent),
419 q_ptr(parent)
454 q_ptr(parent)
@@ -41,7 +41,7 class QTCOMMERCIALCHART_EXPORT QPieSlice : public QObject
41 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
41 Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged)
42 Q_PROPERTY(QPen labelPen READ labelPen WRITE setLabelPen NOTIFY labelPenChanged)
42 Q_PROPERTY(QPen labelPen READ labelPen WRITE setLabelPen NOTIFY labelPenChanged)
43 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
43 Q_PROPERTY(QFont labelFont READ labelFont WRITE setLabelFont NOTIFY labelFontChanged)
44 Q_PROPERTY(qreal LabelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
44 Q_PROPERTY(qreal labelArmLengthFactor READ labelArmLengthFactor WRITE setLabelArmLengthFactor)
45 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
45 Q_PROPERTY(qreal explodeDistanceFactor READ explodeDistanceFactor WRITE setExplodeDistanceFactor)
46 Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged)
46 Q_PROPERTY(qreal percentage READ percentage NOTIFY percentageChanged)
47 Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged)
47 Q_PROPERTY(qreal startAngle READ startAngle NOTIFY startAngleChanged)
General Comments 0
You need to be logged in to leave comments. Login now