@@ -64,21 +64,21 public: | |||||
64 | return true; |
|
64 | return true; | |
65 |
|
65 | |||
66 | if (m_isExploded != other.m_isExploded || |
|
66 | if (m_isExploded != other.m_isExploded || | |
67 |
m_explodeDistanceFactor |
|
67 | !qFuzzyIsNull(m_explodeDistanceFactor - other.m_explodeDistanceFactor)) | |
68 | return true; |
|
68 | return true; | |
69 |
|
69 | |||
70 | if (m_isLabelVisible != other.m_isLabelVisible || |
|
70 | if (m_isLabelVisible != other.m_isLabelVisible || | |
71 | m_labelText != other.m_labelText || |
|
71 | m_labelText != other.m_labelText || | |
72 | m_labelFont != other.m_labelFont || |
|
72 | m_labelFont != other.m_labelFont || | |
73 |
m_labelArmLengthFactor |
|
73 | !qFuzzyIsNull(m_labelArmLengthFactor - other.m_labelArmLengthFactor) || | |
74 | m_labelPen != other.m_labelPen) |
|
74 | m_labelPen != other.m_labelPen) | |
75 | return true; |
|
75 | return true; | |
76 |
|
76 | |||
77 |
if (m_percentage |
|
77 | if (!qFuzzyIsNull(m_percentage - other.m_percentage) || | |
78 | m_center != other.m_center || |
|
78 | m_center != other.m_center || | |
79 |
m_radius |
|
79 | !qFuzzyIsNull(m_radius - other.m_radius) || | |
80 |
m_startAngle |
|
80 | !qFuzzyIsNull(m_startAngle - other.m_startAngle) || | |
81 |
m_angleSpan |
|
81 | !qFuzzyIsNull(m_angleSpan - other.m_angleSpan)) | |
82 | return true; |
|
82 | return true; | |
83 |
|
83 | |||
84 | return false; |
|
84 | return false; |
@@ -36,7 +36,7 void QPieSeriesPrivate::updateDerivativeData() | |||||
36 | m_total += s->value(); |
|
36 | m_total += s->value(); | |
37 |
|
37 | |||
38 | // nothing to show.. |
|
38 | // nothing to show.. | |
39 |
if (m_total |
|
39 | if (qFuzzyIsNull(m_total)) | |
40 | return; |
|
40 | return; | |
41 |
|
41 | |||
42 | // update slice attributes |
|
42 | // update slice attributes | |
@@ -45,28 +45,16 void QPieSeriesPrivate::updateDerivativeData() | |||||
45 | QVector<QPieSlice*> changed; |
|
45 | QVector<QPieSlice*> changed; | |
46 | foreach (QPieSlice* s, m_slices) { |
|
46 | foreach (QPieSlice* s, m_slices) { | |
47 |
|
47 | |||
48 | bool isChanged = false; |
|
48 | PieSliceData data = s->data_ptr()->m_data; | |
|
49 | data.m_percentage = s->value() / m_total; | |||
|
50 | data.m_angleSpan = pieSpan * data.m_percentage; | |||
|
51 | data.m_startAngle = sliceAngle; | |||
|
52 | sliceAngle += data.m_angleSpan; | |||
49 |
|
53 | |||
50 | qreal percentage = s->value() / m_total; |
|
54 | if (s->data_ptr()->m_data != data) { | |
51 |
|
|
55 | s->data_ptr()->m_data = data; | |
52 | s->data_ptr()->m_data.m_percentage = percentage; |
|
|||
53 | isChanged = true; |
|
|||
54 | } |
|
|||
55 |
|
||||
56 | qreal sliceSpan = pieSpan * percentage; |
|
|||
57 | if (s->data_ptr()->m_data.m_angleSpan != sliceSpan) { |
|
|||
58 | s->data_ptr()->m_data.m_angleSpan = sliceSpan; |
|
|||
59 | isChanged = true; |
|
|||
60 | } |
|
|||
61 |
|
||||
62 | if (s->data_ptr()->m_data.m_startAngle != sliceAngle) { |
|
|||
63 | s->data_ptr()->m_data.m_startAngle = sliceAngle; |
|
|||
64 | isChanged = true; |
|
|||
65 | } |
|
|||
66 | sliceAngle += sliceSpan; |
|
|||
67 |
|
||||
68 | if (isChanged) |
|
|||
69 | changed << s; |
|
56 | changed << s; | |
|
57 | } | |||
70 | } |
|
58 | } | |
71 |
|
59 | |||
72 | // emit signals |
|
60 | // emit signals | |
@@ -385,7 +373,8 void QPieSeries::setPiePosition(qreal relativeHorizontalPosition, qreal relative | |||||
385 | relativeVerticalPosition < 0.0 || relativeVerticalPosition > 1.0) |
|
373 | relativeVerticalPosition < 0.0 || relativeVerticalPosition > 1.0) | |
386 | return; |
|
374 | return; | |
387 |
|
375 | |||
388 |
if (d->m_pieRelativeHorPos |
|
376 | if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativeHorizontalPosition) || | |
|
377 | !qFuzzyIsNull(d->m_pieRelativeVerPos - relativeVerticalPosition)) { | |||
389 | d->m_pieRelativeHorPos = relativeHorizontalPosition; |
|
378 | d->m_pieRelativeHorPos = relativeHorizontalPosition; | |
390 | d->m_pieRelativeVerPos = relativeVerticalPosition; |
|
379 | d->m_pieRelativeVerPos = relativeVerticalPosition; | |
391 | emit piePositionChanged(); |
|
380 | emit piePositionChanged(); | |
@@ -443,7 +432,7 void QPieSeries::setPieSize(qreal relativeSize) | |||||
443 | if (relativeSize < 0.0 || relativeSize > 1.0) |
|
432 | if (relativeSize < 0.0 || relativeSize > 1.0) | |
444 | return; |
|
433 | return; | |
445 |
|
434 | |||
446 |
if (d->m_pieRelativeSize |
|
435 | if (!qFuzzyIsNull(d->m_pieRelativeSize- relativeSize)) { | |
447 | d->m_pieRelativeSize = relativeSize; |
|
436 | d->m_pieRelativeSize = relativeSize; | |
448 | emit pieSizeChanged(); |
|
437 | emit pieSizeChanged(); | |
449 | } |
|
438 | } | |
@@ -477,7 +466,11 qreal QPieSeries::pieSize() const | |||||
477 | void QPieSeries::setPieStartAngle(qreal angle) |
|
466 | void QPieSeries::setPieStartAngle(qreal angle) | |
478 | { |
|
467 | { | |
479 | Q_D(QPieSeries); |
|
468 | Q_D(QPieSeries); | |
480 | if (angle >= 0 && angle <= 360 && angle != d->m_pieStartAngle && angle <= d->m_pieEndAngle) { |
|
469 | ||
|
470 | if (angle < 0 || angle > 360 || angle > d->m_pieEndAngle) | |||
|
471 | return; | |||
|
472 | ||||
|
473 | if (!qFuzzyIsNull(angle - d->m_pieStartAngle)) { | |||
481 | d->m_pieStartAngle = angle; |
|
474 | d->m_pieStartAngle = angle; | |
482 | d->updateDerivativeData(); |
|
475 | d->updateDerivativeData(); | |
483 | } |
|
476 | } | |
@@ -508,7 +501,11 qreal QPieSeries::pieStartAngle() const | |||||
508 | void QPieSeries::setPieEndAngle(qreal angle) |
|
501 | void QPieSeries::setPieEndAngle(qreal angle) | |
509 | { |
|
502 | { | |
510 | Q_D(QPieSeries); |
|
503 | Q_D(QPieSeries); | |
511 | if (angle >= 0 && angle <= 360 && angle != d->m_pieEndAngle && angle >= d->m_pieStartAngle) { |
|
504 | ||
|
505 | if (angle < 0 || angle > 360 || angle < d->m_pieStartAngle) | |||
|
506 | return; | |||
|
507 | ||||
|
508 | if (!qFuzzyIsNull(angle - d->m_pieEndAngle)) { | |||
512 | d->m_pieEndAngle = angle; |
|
509 | d->m_pieEndAngle = angle; | |
513 | d->updateDerivativeData(); |
|
510 | d->updateDerivativeData(); | |
514 | } |
|
511 | } |
@@ -257,7 +257,7 qreal QPieSlice::labelArmLengthFactor() const | |||||
257 | void QPieSlice::setValue(qreal value) |
|
257 | void QPieSlice::setValue(qreal value) | |
258 | { |
|
258 | { | |
259 | Q_D(QPieSlice); |
|
259 | Q_D(QPieSlice); | |
260 |
if (d->m_data.m_value |
|
260 | if (!qFuzzyIsNull(d->m_data.m_value - value)) { | |
261 | d->m_data.m_value = value; |
|
261 | d->m_data.m_value = value; | |
262 |
|
262 | |||
263 | QPieSeries *series = qobject_cast<QPieSeries*>(parent()); |
|
263 | QPieSeries *series = qobject_cast<QPieSeries*>(parent()); | |
@@ -321,7 +321,7 void QPieSlice::setExploded(bool exploded) | |||||
321 | void QPieSlice::setExplodeDistanceFactor(qreal factor) |
|
321 | void QPieSlice::setExplodeDistanceFactor(qreal factor) | |
322 | { |
|
322 | { | |
323 | Q_D(QPieSlice); |
|
323 | Q_D(QPieSlice); | |
324 |
if (d->m_data.m_explodeDistanceFactor |
|
324 | if (!qFuzzyIsNull(d->m_data.m_explodeDistanceFactor - factor)) { | |
325 | d->m_data.m_explodeDistanceFactor = factor; |
|
325 | d->m_data.m_explodeDistanceFactor = factor; | |
326 | emit changed(); |
|
326 | emit changed(); | |
327 | } |
|
327 | } | |
@@ -401,7 +401,7 void QPieSlice::setLabelFont(const QFont &font) | |||||
401 | void QPieSlice::setLabelArmLengthFactor(qreal factor) |
|
401 | void QPieSlice::setLabelArmLengthFactor(qreal factor) | |
402 | { |
|
402 | { | |
403 | Q_D(QPieSlice); |
|
403 | Q_D(QPieSlice); | |
404 |
if (d->m_data.m_labelArmLengthFactor |
|
404 | if (!qFuzzyIsNull(d->m_data.m_labelArmLengthFactor - factor)) { | |
405 | d->m_data.m_labelArmLengthFactor = factor; |
|
405 | d->m_data.m_labelArmLengthFactor = factor; | |
406 | emit changed(); |
|
406 | emit changed(); | |
407 | } |
|
407 | } |
General Comments 0
You need to be logged in to leave comments.
Login now