##// END OF EJS Templates
QPieSlice: angle() -> startAngle(), angleSpan() -> endAngle()
Jani Honkonen -
r355:b889b21eeadf
parent child
Show More
@@ -123,7 +123,7 void PiePresenter::updateGeometry()
123 foreach (QPieSlice* s, m_series->m_slices) {
123 foreach (QPieSlice* s, m_series->m_slices) {
124
124
125 // calculate the farthest point in the slice from the pie center
125 // calculate the farthest point in the slice from the pie center
126 qreal centerAngle = s->angle() + (s->angleSpan() / 2);
126 qreal centerAngle = s->m_startAngle + (s->m_angleSpan / 2);
127 qreal len = pieRadius + s->labelArmLength() + s->explodeDistance();
127 qreal len = pieRadius + s->labelArmLength() + s->explodeDistance();
128 QPointF dp(qSin(centerAngle*(PI/180)) * len, -qCos(centerAngle*(PI/180)) * len);
128 QPointF dp(qSin(centerAngle*(PI/180)) * len, -qCos(centerAngle*(PI/180)) * len);
129 QPointF p = pieRect.center() + dp;
129 QPointF p = pieRect.center() + dp;
@@ -21,7 +21,7 QPointF offset(qreal angle, qreal length)
21 PieSlice::PieSlice(QGraphicsItem* parent)
21 PieSlice::PieSlice(QGraphicsItem* parent)
22 :QGraphicsObject(parent),
22 :QGraphicsObject(parent),
23 m_slicelabel(new PieSliceLabel(this)),
23 m_slicelabel(new PieSliceLabel(this)),
24 m_angle(0),
24 m_startAngle(0),
25 m_angleSpan(0),
25 m_angleSpan(0),
26 m_isExploded(false),
26 m_isExploded(false),
27 m_explodeDistance(0)
27 m_explodeDistance(0)
@@ -80,7 +80,7 void PieSlice::updateGeometry()
80 prepareGeometryChange();
80 prepareGeometryChange();
81
81
82 // calculate center angle
82 // calculate center angle
83 qreal centerAngle = m_angle + (m_angleSpan/2);
83 qreal centerAngle = m_startAngle + (m_angleSpan/2);
84
84
85 // adjust rect for exploding
85 // adjust rect for exploding
86 QRectF rect = m_pieRect;
86 QRectF rect = m_pieRect;
@@ -94,7 +94,7 void PieSlice::updateGeometry()
94 // TODO: draw the shape so that it might have a hole in the center
94 // TODO: draw the shape so that it might have a hole in the center
95 QPainterPath path;
95 QPainterPath path;
96 path.moveTo(rect.center());
96 path.moveTo(rect.center());
97 path.arcTo(rect, -m_angle + 90, -m_angleSpan);
97 path.arcTo(rect, -m_startAngle + 90, -m_angleSpan);
98 path.closeSubpath();
98 path.closeSubpath();
99 m_path = path;
99 m_path = path;
100
100
@@ -113,8 +113,8 void PieSlice::updateData(const QPieSlice* sliceData)
113 {
113 {
114 // TODO: compare what has changes to avoid unneccesary geometry updates
114 // TODO: compare what has changes to avoid unneccesary geometry updates
115
115
116 m_angle = sliceData->angle();
116 m_startAngle = sliceData->startAngle();
117 m_angleSpan = sliceData->angleSpan();
117 m_angleSpan = sliceData->m_angleSpan;
118 m_isExploded = sliceData->isExploded();
118 m_isExploded = sliceData->isExploded();
119 m_explodeDistance = sliceData->explodeDistance(); // TODO: expose to public API
119 m_explodeDistance = sliceData->explodeDistance(); // TODO: expose to public API
120 m_pen = sliceData->pen();
120 m_pen = sliceData->pen();
@@ -49,7 +49,7 private:
49 QRectF m_pieRect;
49 QRectF m_pieRect;
50 QPainterPath m_path;
50 QPainterPath m_path;
51
51
52 qreal m_angle;
52 qreal m_startAngle;
53 qreal m_angleSpan;
53 qreal m_angleSpan;
54
54
55 bool m_isExploded;
55 bool m_isExploded;
@@ -518,8 +518,8 void QPieSeries::updateDerivativeData()
518 changed = true;
518 changed = true;
519 }
519 }
520
520
521 if (s->m_angle != sliceAngle) {
521 if (s->m_startAngle != sliceAngle) {
522 s->m_angle = sliceAngle;
522 s->m_startAngle = sliceAngle;
523 changed = true;
523 changed = true;
524 }
524 }
525 sliceAngle += sliceSpan;
525 sliceAngle += sliceSpan;
@@ -44,7 +44,7 QPieSlice::QPieSlice(QObject *parent)
44 m_isExploded(false),
44 m_isExploded(false),
45 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
45 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
46 m_percentage(0),
46 m_percentage(0),
47 m_angle(0),
47 m_startAngle(0),
48 m_angleSpan(0),
48 m_angleSpan(0),
49 m_pen(DEFAULT_PEN_COLOR),
49 m_pen(DEFAULT_PEN_COLOR),
50 m_brush(DEFAULT_BRUSH_COLOR),
50 m_brush(DEFAULT_BRUSH_COLOR),
@@ -67,7 +67,7 QPieSlice::QPieSlice(qreal value, QString label, QObject *parent)
67 m_isExploded(false),
67 m_isExploded(false),
68 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
68 m_explodeDistance(DEFAULT_EXPOLODE_DISTANCE),
69 m_percentage(0),
69 m_percentage(0),
70 m_angle(0),
70 m_startAngle(0),
71 m_angleSpan(0),
71 m_angleSpan(0),
72 m_pen(DEFAULT_PEN_COLOR),
72 m_pen(DEFAULT_PEN_COLOR),
73 m_brush(DEFAULT_BRUSH_COLOR),
73 m_brush(DEFAULT_BRUSH_COLOR),
@@ -150,21 +150,21 qreal QPieSlice::percentage() const
150
150
151 Updated internally after the slice is added to the series.
151 Updated internally after the slice is added to the series.
152 */
152 */
153 qreal QPieSlice::angle() const
153 qreal QPieSlice::startAngle() const
154 {
154 {
155 return m_angle;
155 return m_startAngle;
156 }
156 }
157
157
158 /*!
158 /*!
159 Returns the angle span of this slice in the series it belongs to.
159 Returns the end angle of this slice in the series it belongs to.
160
160
161 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
161 Full pie is 360 degrees where 0 degrees is at 12 a'clock.
162
162
163 Updated internally after the slice is added to the series.
163 Updated internally after the slice is added to the series.
164 */
164 */
165 qreal QPieSlice::angleSpan() const
165 qreal QPieSlice::endAngle() const
166 {
166 {
167 return m_angleSpan;
167 return m_startAngle + m_angleSpan;
168 }
168 }
169
169
170 /*!
170 /*!
@@ -29,8 +29,8 public:
29
29
30 // generated data
30 // generated data
31 qreal percentage() const;
31 qreal percentage() const;
32 qreal angle() const;
32 qreal startAngle() const;
33 qreal angleSpan() const;
33 qreal endAngle() const;
34
34
35 // customization
35 // customization
36 QPen pen() const;
36 QPen pen() const;
@@ -70,6 +70,7 private:
70 // TODO: use private class
70 // TODO: use private class
71 friend class QPieSeries;
71 friend class QPieSeries;
72 friend class PiePresenter;
72 friend class PiePresenter;
73 friend class PieSlice;
73
74
74 // data
75 // data
75 qreal m_value;
76 qreal m_value;
@@ -80,7 +81,7 private:
80
81
81 // generated data
82 // generated data
82 qreal m_percentage;
83 qreal m_percentage;
83 qreal m_angle;
84 qreal m_startAngle;
84 qreal m_angleSpan;
85 qreal m_angleSpan;
85
86
86 // customization
87 // customization
General Comments 0
You need to be logged in to leave comments. Login now