@@ -224,11 +224,11 void ChartAnimator::updateLayout(XYChartItem* item, QVector<QPointF>& oldPoints | |||
|
224 | 224 | QTimer::singleShot(0,animation,SLOT(start())); |
|
225 | 225 | } |
|
226 | 226 | |
|
227 |
void ChartAnimator::addAnimation(PieChartItem* item, QPieSlice *slice, const PieSlice |
|
|
227 | void ChartAnimator::addAnimation(PieChartItem* item, QPieSlice *slice, const PieSliceData &sliceData, bool isEmpty) | |
|
228 | 228 | { |
|
229 | 229 | PieAnimation* animation = static_cast<PieAnimation*>(m_animations.value(item)); |
|
230 | 230 | Q_ASSERT(animation); |
|
231 |
animation->addSlice(slice, la |
|
|
231 | animation->addSlice(slice, sliceData, isEmpty); | |
|
232 | 232 | } |
|
233 | 233 | |
|
234 | 234 | void ChartAnimator::removeAnimation(PieChartItem* item, QPieSlice *slice) |
@@ -245,11 +245,11 void ChartAnimator::updateLayout(PieChartItem* item, const PieLayout &layout) | |||
|
245 | 245 | animation->updateValues(layout); |
|
246 | 246 | } |
|
247 | 247 | |
|
248 |
void ChartAnimator::updateLayout(PieChartItem* item, QPieSlice *slice, const PieSlice |
|
|
248 | void ChartAnimator::updateLayout(PieChartItem* item, QPieSlice *slice, const PieSliceData &sliceData) | |
|
249 | 249 | { |
|
250 | 250 | PieAnimation* animation = static_cast<PieAnimation*>(m_animations.value(item)); |
|
251 | 251 | Q_ASSERT(animation); |
|
252 |
animation->updateValue(slice, la |
|
|
252 | animation->updateValue(slice, sliceData); | |
|
253 | 253 | } |
|
254 | 254 | |
|
255 | 255 | void ChartAnimator::setState(State state,const QPointF& point) |
@@ -35,10 +35,10 public: | |||
|
35 | 35 | void updateLayout(SplineChartItem* item, QVector<QPointF>& oldPoints , QVector<QPointF>& newPoints, QVector<QPointF>& oldControlPoints, QVector<QPointF>& newContorlPoints,int index); |
|
36 | 36 | void updateLayout(AxisItem* item, QVector<qreal>& layout); |
|
37 | 37 | |
|
38 |
void addAnimation(PieChartItem* item, QPieSlice *slice, const PieSlice |
|
|
38 | void addAnimation(PieChartItem* item, QPieSlice *slice, const PieSliceData &sliceData, bool isEmpty); | |
|
39 | 39 | void removeAnimation(PieChartItem* item, QPieSlice *slice); |
|
40 | 40 | void updateLayout(PieChartItem* item, const PieLayout &layout); |
|
41 |
void updateLayout(PieChartItem* item, QPieSlice *slice, const PieSlice |
|
|
41 | void updateLayout(PieChartItem* item, QPieSlice *slice, const PieSliceData &sliceData); | |
|
42 | 42 | |
|
43 | 43 | void setState(State state,const QPointF& point = QPointF()); |
|
44 | 44 |
@@ -22,32 +22,32 void PieAnimation::updateValues(const PieLayout &newValues) | |||
|
22 | 22 | updateValue(s, newValues.value(s)); |
|
23 | 23 | } |
|
24 | 24 | |
|
25 |
void PieAnimation::updateValue(QPieSlice *slice, const PieSlice |
|
|
25 | void PieAnimation::updateValue(QPieSlice *slice, const PieSliceData &sliceData) | |
|
26 | 26 | { |
|
27 | 27 | PieSliceAnimation *animation = m_animations.value(slice); |
|
28 | 28 | Q_ASSERT(animation); |
|
29 | 29 | animation->stop(); |
|
30 | 30 | |
|
31 |
animation->updateValue( |
|
|
31 | animation->updateValue(sliceData); | |
|
32 | 32 | animation->setDuration(1000); |
|
33 | 33 | animation->setEasingCurve(QEasingCurve::OutQuart); |
|
34 | 34 | |
|
35 | 35 | QTimer::singleShot(0, animation, SLOT(start())); |
|
36 | 36 | } |
|
37 | 37 | |
|
38 |
void PieAnimation::addSlice(QPieSlice *slice, const PieSlice |
|
|
38 | void PieAnimation::addSlice(QPieSlice *slice, const PieSliceData &sliceData, bool isEmpty) | |
|
39 | 39 | { |
|
40 | 40 | PieSliceAnimation *animation = new PieSliceAnimation(m_item, slice); |
|
41 | 41 | m_animations.insert(slice, animation); |
|
42 | 42 | |
|
43 |
PieSlice |
|
|
44 |
start |
|
|
43 | PieSliceData startValue = sliceData; | |
|
44 | startValue.m_radius = 0; | |
|
45 | 45 | if (isEmpty) |
|
46 |
start |
|
|
46 | startValue.m_startAngle = 0; | |
|
47 | 47 | else |
|
48 |
start |
|
|
49 |
start |
|
|
50 |
animation->setValue(start |
|
|
48 | startValue.m_startAngle = sliceData.m_startAngle + (sliceData.m_angleSpan/2); | |
|
49 | startValue.m_angleSpan = 0; | |
|
50 | animation->setValue(startValue, sliceData); | |
|
51 | 51 | |
|
52 | 52 | animation->setDuration(1000); |
|
53 | 53 | animation->setEasingCurve(QEasingCurve::OutQuart); |
@@ -60,13 +60,13 void PieAnimation::removeSlice(QPieSlice *slice) | |||
|
60 | 60 | Q_ASSERT(animation); |
|
61 | 61 | animation->stop(); |
|
62 | 62 | |
|
63 |
PieSlice |
|
|
64 |
end |
|
|
63 | PieSliceData endValue = animation->currentSliceValue(); | |
|
64 | endValue.m_radius = 0; | |
|
65 | 65 | // TODO: find the actual angle where this slice disappears |
|
66 |
end |
|
|
67 |
end |
|
|
66 | endValue.m_startAngle = endValue.m_startAngle + endValue.m_angleSpan; | |
|
67 | endValue.m_angleSpan = 0; | |
|
68 | 68 | |
|
69 |
animation->updateValue(end |
|
|
69 | animation->updateValue(endValue); | |
|
70 | 70 | animation->setDuration(1000); |
|
71 | 71 | animation->setEasingCurve(QEasingCurve::OutQuart); |
|
72 | 72 |
@@ -17,8 +17,8 public: | |||
|
17 | 17 | PieAnimation(PieChartItem *item); |
|
18 | 18 | ~PieAnimation(); |
|
19 | 19 | void updateValues(const PieLayout &newValues); |
|
20 |
void updateValue(QPieSlice *slice, const PieSlice |
|
|
21 |
void addSlice(QPieSlice *slice, const PieSlice |
|
|
20 | void updateValue(QPieSlice *slice, const PieSliceData &newValue); | |
|
21 | void addSlice(QPieSlice *slice, const PieSliceData &endValue, bool isEmpty); | |
|
22 | 22 | void removeSlice(QPieSlice *slice); |
|
23 | 23 | |
|
24 | 24 | public: // from QVariantAnimation |
@@ -2,7 +2,7 | |||
|
2 | 2 | #include "piechartitem_p.h" |
|
3 | 3 | #include "qpieslice.h" |
|
4 | 4 | |
|
5 |
Q_DECLARE_METATYPE(QtCommercialChart::PieSlice |
|
|
5 | Q_DECLARE_METATYPE(QtCommercialChart::PieSliceData) | |
|
6 | 6 | |
|
7 | 7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | 8 | |
@@ -49,7 +49,7 PieSliceAnimation::~PieSliceAnimation() | |||
|
49 | 49 | { |
|
50 | 50 | } |
|
51 | 51 | |
|
52 |
void PieSliceAnimation::setValue(const PieSlice |
|
|
52 | void PieSliceAnimation::setValue(const PieSliceData &startValue, const PieSliceData &endValue) | |
|
53 | 53 | { |
|
54 | 54 | if (state() != QAbstractAnimation::Stopped) |
|
55 | 55 | stop(); |
@@ -60,7 +60,7 void PieSliceAnimation::setValue(const PieSliceLayout &startValue, const PieSlic | |||
|
60 | 60 | setKeyValueAt(1.0, qVariantFromValue(endValue)); |
|
61 | 61 | } |
|
62 | 62 | |
|
63 |
void PieSliceAnimation::updateValue(const PieSlice |
|
|
63 | void PieSliceAnimation::updateValue(const PieSliceData &endValue) | |
|
64 | 64 | { |
|
65 | 65 | if (state() != QAbstractAnimation::Stopped) |
|
66 | 66 | stop(); |
@@ -69,7 +69,7 void PieSliceAnimation::updateValue(const PieSliceLayout &endValue) | |||
|
69 | 69 | setKeyValueAt(1.0, qVariantFromValue(endValue)); |
|
70 | 70 | } |
|
71 | 71 | |
|
72 |
PieSlice |
|
|
72 | PieSliceData PieSliceAnimation::currentSliceValue() | |
|
73 | 73 | { |
|
74 | 74 | // NOTE: |
|
75 | 75 | // We must use an internal current value because QVariantAnimation::currentValue() is updated |
@@ -81,10 +81,10 PieSliceLayout PieSliceAnimation::currentSliceValue() | |||
|
81 | 81 | |
|
82 | 82 | QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant &end, qreal progress) const |
|
83 | 83 | { |
|
84 |
PieSlice |
|
|
85 |
PieSlice |
|
|
84 | PieSliceData startValue = qVariantValue<PieSliceData>(start); | |
|
85 | PieSliceData endValue = qVariantValue<PieSliceData>(end); | |
|
86 | 86 | |
|
87 |
PieSlice |
|
|
87 | PieSliceData result; | |
|
88 | 88 | result = endValue; |
|
89 | 89 | result.m_center = linearPos(startValue.m_center, endValue.m_center, progress); |
|
90 | 90 | result.m_radius = linearPos(startValue.m_radius, endValue.m_radius, progress); |
@@ -99,7 +99,7 QVariant PieSliceAnimation::interpolated(const QVariant &start, const QVariant & | |||
|
99 | 99 | void PieSliceAnimation::updateCurrentValue(const QVariant &value) |
|
100 | 100 | { |
|
101 | 101 | if (state() != QAbstractAnimation::Stopped) { //workaround |
|
102 |
m_currentValue = qVariantValue<PieSlice |
|
|
102 | m_currentValue = qVariantValue<PieSliceData>(value); | |
|
103 | 103 | m_item->setLayout(m_slice, m_currentValue); |
|
104 | 104 | } |
|
105 | 105 | } |
@@ -14,9 +14,9 class PieSliceAnimation : public QVariantAnimation | |||
|
14 | 14 | public: |
|
15 | 15 | PieSliceAnimation(PieChartItem *item, QPieSlice *slice); |
|
16 | 16 | ~PieSliceAnimation(); |
|
17 |
void setValue(const PieSlice |
|
|
18 |
void updateValue(const PieSlice |
|
|
19 |
PieSlice |
|
|
17 | void setValue(const PieSliceData &startValue, const PieSliceData &endValue); | |
|
18 | void updateValue(const PieSliceData &endValue); | |
|
19 | PieSliceData currentSliceValue(); | |
|
20 | 20 | |
|
21 | 21 | protected: |
|
22 | 22 | QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const; |
@@ -25,7 +25,7 protected: | |||
|
25 | 25 | private: |
|
26 | 26 | PieChartItem *m_item; |
|
27 | 27 | QPieSlice *m_slice; |
|
28 |
PieSlice |
|
|
28 | PieSliceData m_currentValue; | |
|
29 | 29 | }; |
|
30 | 30 | |
|
31 | 31 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -61,12 +61,12 void PieChartItem::handleSlicesAdded(QList<QPieSlice*> slices) | |||
|
61 | 61 | connect(slice, SIGNAL(hoverEnter()), s, SIGNAL(hoverEnter())); |
|
62 | 62 | connect(slice, SIGNAL(hoverLeave()), s, SIGNAL(hoverLeave())); |
|
63 | 63 | |
|
64 |
PieSlice |
|
|
64 | PieSliceData data = sliceData(s); | |
|
65 | 65 | |
|
66 | 66 | if (m_animator) |
|
67 |
m_animator->addAnimation(this, s, |
|
|
67 | m_animator->addAnimation(this, s, data, isEmpty); | |
|
68 | 68 | else |
|
69 |
setLayout(s, |
|
|
69 | setLayout(s, data); | |
|
70 | 70 | } |
|
71 | 71 | } |
|
72 | 72 | |
@@ -93,8 +93,8 void PieChartItem::handleSliceChanged() | |||
|
93 | 93 | { |
|
94 | 94 | QPieSlice* slice = qobject_cast<QPieSlice *>(sender()); |
|
95 | 95 | Q_ASSERT(m_slices.contains(slice)); |
|
96 |
PieSlice |
|
|
97 |
updateLayout(slice, |
|
|
96 | PieSliceData data = sliceData(slice); | |
|
97 | updateLayout(slice, data); | |
|
98 | 98 | update(); |
|
99 | 99 | } |
|
100 | 100 | |
@@ -125,16 +125,31 void PieChartItem::calculatePieLayout() | |||
|
125 | 125 | m_pieRadius *= m_series->pieSize(); |
|
126 | 126 | } |
|
127 | 127 | |
|
128 |
PieSlice |
|
|
128 | PieSliceData PieChartItem::sliceData(QPieSlice *slice) | |
|
129 | 129 | { |
|
130 |
PieSlice |
|
|
131 | sliceLayout.m_center = PieSlice::sliceCenter(m_pieCenter, m_pieRadius, slice); | |
|
132 | sliceLayout.m_radius = m_pieRadius; | |
|
133 | sliceLayout.m_startAngle = slice->startAngle(); | |
|
134 | sliceLayout.m_angleSpan = slice->m_angleSpan; | |
|
135 | sliceLayout.m_pen = slice->m_slicePen; | |
|
136 |
slice |
|
|
137 | return sliceLayout; | |
|
130 | PieSliceData sliceData; | |
|
131 | ||
|
132 | // TODO: | |
|
133 | // sliceData = slice->m_data; | |
|
134 | ||
|
135 | sliceData.m_center = PieSlice::sliceCenter(m_pieCenter, m_pieRadius, slice); | |
|
136 | sliceData.m_radius = m_pieRadius; | |
|
137 | sliceData.m_startAngle = slice->startAngle(); | |
|
138 | sliceData.m_angleSpan = slice->m_angleSpan; | |
|
139 | ||
|
140 | sliceData.m_pen = slice->m_slicePen; | |
|
141 | sliceData.m_brush = slice->m_sliceBrush; | |
|
142 | ||
|
143 | sliceData.m_isExploded = slice->isExploded(); | |
|
144 | sliceData.m_explodeDistanceFactor = slice->explodeDistanceFactor(); | |
|
145 | ||
|
146 | sliceData.m_labelVisible = slice->isLabelVisible(); | |
|
147 | sliceData.m_labelText = slice->label(); | |
|
148 | sliceData.m_labelFont = slice->labelFont(); | |
|
149 | sliceData.m_labelArmLengthFactor = slice->labelArmLengthFactor(); | |
|
150 | sliceData.m_labelArmPen = slice->labelArmPen(); | |
|
151 | ||
|
152 | return sliceData; | |
|
138 | 153 | } |
|
139 | 154 | |
|
140 | 155 | PieLayout PieChartItem::calculateLayout() |
@@ -143,7 +158,7 PieLayout PieChartItem::calculateLayout() | |||
|
143 | 158 |
PieLayout |
|
144 | 159 | foreach (QPieSlice* s, m_series->slices()) { |
|
145 | 160 | if (m_slices.contains(s)) // calculate layout only for those slices that are already visible |
|
146 |
layout.insert(s, |
|
|
161 | layout.insert(s, sliceData(s)); | |
|
147 | 162 | } |
|
148 | 163 | return layout; |
|
149 | 164 | } |
@@ -156,12 +171,12 void PieChartItem::applyLayout(const PieLayout &layout) | |||
|
156 | 171 | setLayout(layout); |
|
157 | 172 | } |
|
158 | 173 | |
|
159 |
void PieChartItem::updateLayout(QPieSlice *slice, const PieSlice |
|
|
174 | void PieChartItem::updateLayout(QPieSlice *slice, const PieSliceData &sliceData) | |
|
160 | 175 | { |
|
161 | 176 | if (m_animator) |
|
162 |
m_animator->updateLayout(this, slice, la |
|
|
177 | m_animator->updateLayout(this, slice, sliceData); | |
|
163 | 178 | else |
|
164 |
setLayout(slice, la |
|
|
179 | setLayout(slice, sliceData); | |
|
165 | 180 | } |
|
166 | 181 | |
|
167 | 182 | void PieChartItem::setLayout(const PieLayout &layout) |
@@ -169,21 +184,18 void PieChartItem::setLayout(const PieLayout &layout) | |||
|
169 | 184 | foreach (QPieSlice *slice, layout.keys()) { |
|
170 | 185 | PieSlice *s = m_slices.value(slice); |
|
171 | 186 | Q_ASSERT(s); |
|
172 |
s->set |
|
|
173 | s->updateData(slice); | |
|
187 | s->setSliceData(layout.value(slice)); | |
|
174 | 188 | s->updateGeometry(); |
|
175 | 189 | s->update(); |
|
176 | 190 | } |
|
177 | 191 | } |
|
178 | 192 | |
|
179 |
void PieChartItem::setLayout(QPieSlice *slice, const PieSlice |
|
|
193 | void PieChartItem::setLayout(QPieSlice *slice, const PieSliceData &sliceData) | |
|
180 | 194 | { |
|
181 | 195 | // find slice |
|
182 | 196 | PieSlice *s = m_slices.value(slice); |
|
183 | 197 | Q_ASSERT(s); |
|
184 |
s->set |
|
|
185 | if (m_series->m_slices.contains(slice)) // Slice has been deleted if not found. Animations ongoing... | |
|
186 | s->updateData(slice); | |
|
198 | s->setSliceData(sliceData); | |
|
187 | 199 | s->updateGeometry(); |
|
188 | 200 | s->update(); |
|
189 | 201 | } |
@@ -10,7 +10,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
10 | 10 | class QPieSlice; |
|
11 | 11 | class ChartPresenter; |
|
12 | 12 | |
|
13 |
typedef QHash<QPieSlice*, PieSlice |
|
|
13 | typedef QHash<QPieSlice*, PieSliceData> PieLayout; | |
|
14 | 14 | |
|
15 | 15 | class PieChartItem : public QObject, public ChartItem |
|
16 | 16 | { |
@@ -36,12 +36,12 public Q_SLOTS: | |||
|
36 | 36 | |
|
37 | 37 | public: |
|
38 | 38 | void calculatePieLayout(); |
|
39 |
PieSlice |
|
|
39 | PieSliceData sliceData(QPieSlice *slice); | |
|
40 | 40 | PieLayout calculateLayout(); |
|
41 | 41 | void applyLayout(const PieLayout &layout); |
|
42 |
void updateLayout(QPieSlice *slice, const PieSlice |
|
|
42 | void updateLayout(QPieSlice *slice, const PieSliceData &sliceData); | |
|
43 | 43 | void setLayout(const PieLayout &layout); |
|
44 |
void setLayout(QPieSlice *slice, const PieSlice |
|
|
44 | void setLayout(QPieSlice *slice, const PieSliceData &sliceData); | |
|
45 | 45 | void destroySlice(QPieSlice *slice); |
|
46 | 46 | |
|
47 | 47 | private: |
@@ -21,11 +21,7 QPointF offset(qreal angle, qreal length) | |||
|
21 | 21 | } |
|
22 | 22 | |
|
23 | 23 | PieSlice::PieSlice(QGraphicsItem* parent) |
|
24 |
:QGraphicsObject(parent) |
|
|
25 | m_isExploded(false), | |
|
26 | m_explodeDistanceFactor(0), | |
|
27 | m_labelVisible(false), | |
|
28 | m_labelArmLengthFactor(0) | |
|
24 | :QGraphicsObject(parent) | |
|
29 | 25 | { |
|
30 | 26 | setAcceptHoverEvents(true); |
|
31 | 27 | setAcceptedMouseButtons(Qt::LeftButton); |
@@ -54,19 +50,19 void PieSlice::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option | |||
|
54 | 50 | painter->setClipRect(parentItem()->boundingRect()); |
|
55 | 51 | |
|
56 | 52 | painter->save(); |
|
57 |
painter->setPen(m_ |
|
|
58 |
painter->setBrush(m_ |
|
|
53 | painter->setPen(m_data.m_pen); | |
|
54 | painter->setBrush(m_data.m_brush); | |
|
59 | 55 | painter->drawPath(m_slicePath); |
|
60 | 56 | painter->restore(); |
|
61 | 57 | |
|
62 | if (m_labelVisible) { | |
|
58 | if (m_data.m_labelVisible) { | |
|
63 | 59 | painter->save(); |
|
64 | painter->setPen(m_labelArmPen); | |
|
60 | painter->setPen(m_data.m_labelArmPen); | |
|
65 | 61 | painter->drawPath(m_labelArmPath); |
|
66 | 62 | painter->restore(); |
|
67 | 63 | |
|
68 | painter->setFont(m_labelFont); | |
|
69 | painter->drawText(m_labelTextRect.bottomLeft(), m_labelText); | |
|
64 | painter->setFont(m_data.m_labelFont); | |
|
65 | painter->drawText(m_labelTextRect.bottomLeft(), m_data.m_labelText); | |
|
70 | 66 | } |
|
71 | 67 | } |
|
72 | 68 | |
@@ -85,14 +81,14 void PieSlice::mousePressEvent(QGraphicsSceneMouseEvent* /*event*/) | |||
|
85 | 81 | emit clicked(); |
|
86 | 82 | } |
|
87 | 83 | |
|
88 |
void PieSlice::set |
|
|
84 | void PieSlice::setSliceData(PieSliceData sliceData) | |
|
89 | 85 | { |
|
90 |
m_ |
|
|
86 | m_data = sliceData; | |
|
91 | 87 | } |
|
92 | 88 | |
|
93 | 89 | void PieSlice::updateGeometry() |
|
94 | 90 | { |
|
95 |
if (m_ |
|
|
91 | if (m_data.m_radius <= 0) | |
|
96 | 92 | return; |
|
97 | 93 | |
|
98 | 94 | prepareGeometryChange(); |
@@ -100,14 +96,14 void PieSlice::updateGeometry() | |||
|
100 | 96 | // update slice path |
|
101 | 97 | qreal centerAngle; |
|
102 | 98 | QPointF armStart; |
|
103 |
m_slicePath = slicePath(m_ |
|
|
99 | m_slicePath = slicePath(m_data.m_center, m_data.m_radius, m_data.m_startAngle, m_data.m_angleSpan, ¢erAngle, &armStart); | |
|
104 | 100 | |
|
105 | 101 | // update text rect |
|
106 | m_labelTextRect = labelTextRect(m_labelFont, m_labelText); | |
|
102 | m_labelTextRect = labelTextRect(m_data.m_labelFont, m_data.m_labelText); | |
|
107 | 103 | |
|
108 | 104 | // update label arm path |
|
109 | 105 | QPointF labelTextStart; |
|
110 |
m_labelArmPath = labelArmPath(armStart, centerAngle, m_ |
|
|
106 | m_labelArmPath = labelArmPath(armStart, centerAngle, m_data.m_radius * m_data.m_labelArmLengthFactor, m_labelTextRect.width(), &labelTextStart); | |
|
111 | 107 | |
|
112 | 108 | // update text position |
|
113 | 109 | m_labelTextRect.moveBottomLeft(labelTextStart); |
@@ -116,20 +112,6 void PieSlice::updateGeometry() | |||
|
116 | 112 | m_boundingRect = m_slicePath.boundingRect().united(m_labelArmPath.boundingRect()).united(m_labelTextRect); |
|
117 | 113 | } |
|
118 | 114 | |
|
119 | void PieSlice::updateData(const QPieSlice* sliceData) | |
|
120 | { | |
|
121 | // TODO: compare what has changes to avoid unneccesary geometry updates | |
|
122 | ||
|
123 | m_isExploded = sliceData->isExploded(); | |
|
124 | m_explodeDistanceFactor = sliceData->explodeDistanceFactor(); | |
|
125 | ||
|
126 | m_labelVisible = sliceData->isLabelVisible(); | |
|
127 | m_labelText = sliceData->label(); | |
|
128 | m_labelFont = sliceData->labelFont(); | |
|
129 | m_labelArmLengthFactor = sliceData->labelArmLengthFactor(); | |
|
130 | m_labelArmPen = sliceData->labelArmPen(); | |
|
131 | } | |
|
132 | ||
|
133 | 115 | QPointF PieSlice::sliceCenter(QPointF point, qreal radius, QPieSlice *slice) |
|
134 | 116 | { |
|
135 | 117 | if (slice->isExploded()) { |
@@ -16,15 +16,25 class PieChartItem; | |||
|
16 | 16 | class PieSliceLabel; |
|
17 | 17 | class QPieSlice; |
|
18 | 18 | |
|
19 |
class PieSlice |
|
|
19 | class PieSliceData | |
|
20 | 20 | { |
|
21 | 21 | public: |
|
22 | 22 | QPointF m_center; |
|
23 | 23 | qreal m_radius; |
|
24 | 24 | qreal m_startAngle; |
|
25 | 25 | qreal m_angleSpan; |
|
26 | ||
|
26 | 27 | QPen m_pen; |
|
27 | 28 | QBrush m_brush; |
|
29 | ||
|
30 | bool m_isExploded; | |
|
31 | qreal m_explodeDistanceFactor; | |
|
32 | ||
|
33 | bool m_labelVisible; | |
|
34 | QString m_labelText; | |
|
35 | QFont m_labelFont; | |
|
36 | qreal m_labelArmLengthFactor; | |
|
37 | QPen m_labelArmPen; | |
|
28 | 38 | }; |
|
29 | 39 | |
|
30 | 40 | class PieSlice : public QGraphicsObject |
@@ -49,30 +59,19 Q_SIGNALS: | |||
|
49 | 59 | void hoverLeave(); |
|
50 | 60 | |
|
51 | 61 | public: |
|
52 |
void set |
|
|
62 | void setSliceData(PieSliceData sliceData); | |
|
53 | 63 | void updateGeometry(); |
|
54 | void updateData(const QPieSlice *sliceData); | |
|
55 | 64 | static QPointF sliceCenter(QPointF point, qreal radius, QPieSlice *slice); |
|
56 | 65 | static QPainterPath slicePath(QPointF center, qreal radius, qreal startAngle, qreal angleSpan, qreal* centerAngle, QPointF* armStart); |
|
57 | 66 | static QPainterPath labelArmPath(QPointF start, qreal angle, qreal length, qreal textWidth, QPointF* textStart); |
|
58 | 67 | static QRectF labelTextRect(QFont font, QString text); |
|
59 | 68 | |
|
60 | 69 | private: |
|
61 |
PieSlice |
|
|
70 | PieSliceData m_data; | |
|
62 | 71 | QRectF m_boundingRect; |
|
63 | ||
|
64 | 72 | QPainterPath m_slicePath; |
|
65 | bool m_isExploded; | |
|
66 | qreal m_explodeDistanceFactor; | |
|
67 | bool m_labelVisible; | |
|
68 | ||
|
69 | 73 | QPainterPath m_labelArmPath; |
|
70 | qreal m_labelArmLengthFactor; | |
|
71 | QPen m_labelArmPen; | |
|
72 | ||
|
73 | 74 | QRectF m_labelTextRect; |
|
74 | QFont m_labelFont; | |
|
75 | QString m_labelText; | |
|
76 | 75 | }; |
|
77 | 76 | |
|
78 | 77 | QTCOMMERCIALCHART_END_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now