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