@@ -20,7 +20,7 | |||||
20 | #include "stackedbarpresenter_p.h" |
|
20 | #include "stackedbarpresenter_p.h" | |
21 | #include "percentbarpresenter_p.h" |
|
21 | #include "percentbarpresenter_p.h" | |
22 | #include "linechartitem_p.h" |
|
22 | #include "linechartitem_p.h" | |
23 |
#include "pie |
|
23 | #include "piechartitem_p.h" | |
24 | #include "scatterchartitem_p.h" |
|
24 | #include "scatterchartitem_p.h" | |
25 | #include "splinechartitem_p.h" |
|
25 | #include "splinechartitem_p.h" | |
26 |
|
26 | |||
@@ -222,7 +222,7 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain) | |||||
222 |
|
222 | |||
223 | case QSeries::SeriesTypePie: { |
|
223 | case QSeries::SeriesTypePie: { | |
224 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); |
|
224 | QPieSeries *pieSeries = static_cast<QPieSeries *>(series); | |
225 |
Pie |
|
225 | PieChartItem* pie = new PieChartItem(m_chart, pieSeries); | |
226 | if(m_options.testFlag(QChart::SeriesAnimations)) { |
|
226 | if(m_options.testFlag(QChart::SeriesAnimations)) { | |
227 | // m_animator->addAnimation(pie); |
|
227 | // m_animator->addAnimation(pie); | |
228 | } |
|
228 | } |
@@ -24,7 +24,7 | |||||
24 | #include "linechartitem_p.h" |
|
24 | #include "linechartitem_p.h" | |
25 | #include "areachartitem_p.h" |
|
25 | #include "areachartitem_p.h" | |
26 | #include "scatterchartitem_p.h" |
|
26 | #include "scatterchartitem_p.h" | |
27 |
#include "pie |
|
27 | #include "piechartitem_p.h" | |
28 | #include "splinechartitem_p.h" |
|
28 | #include "splinechartitem_p.h" | |
29 |
|
29 | |||
30 | //themes |
|
30 | //themes | |
@@ -177,7 +177,7 void ChartTheme::decorate(QScatterSeries* series, int index) | |||||
177 | } |
|
177 | } | |
178 | } |
|
178 | } | |
179 |
|
179 | |||
180 |
void ChartTheme::decorate(Pie |
|
180 | void ChartTheme::decorate(PieChartItem* item, QPieSeries* series, int index) | |
181 | { |
|
181 | { | |
182 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient |
|
182 | // Get color for a slice from a gradient linearly, beginning from the start of the gradient | |
183 | for (int i(0); i < series->slices().count(); i++) { |
|
183 | for (int i(0); i < series->slices().count(); i++) { |
@@ -20,7 +20,7 class QPercentBarSeries; | |||||
20 | class PercentBarPresenter; |
|
20 | class PercentBarPresenter; | |
21 | class QScatterSeries; |
|
21 | class QScatterSeries; | |
22 | class ScatterChartItem; |
|
22 | class ScatterChartItem; | |
23 |
class Pie |
|
23 | class PieChartItem; | |
24 | class QPieSeries; |
|
24 | class QPieSeries; | |
25 | class SplineChartItem; |
|
25 | class SplineChartItem; | |
26 | class QSplineSeries; |
|
26 | class QSplineSeries; | |
@@ -51,7 +51,7 public: | |||||
51 | void decorate(QLineSeries* series, int index); |
|
51 | void decorate(QLineSeries* series, int index); | |
52 | void decorate(QAreaSeries* series, int index); |
|
52 | void decorate(QAreaSeries* series, int index); | |
53 | void decorate(QScatterSeries* series, int index); |
|
53 | void decorate(QScatterSeries* series, int index); | |
54 |
void decorate(Pie |
|
54 | void decorate(PieChartItem* item, QPieSeries* series, int index); | |
55 | void decorate(QSplineSeries* series, int index); |
|
55 | void decorate(QSplineSeries* series, int index); | |
56 | void decorate(QChartAxis* axis, bool axisX); |
|
56 | void decorate(QChartAxis* axis, bool axisX); | |
57 |
|
57 |
@@ -4,11 +4,11 DEPENDPATH += $$PWD | |||||
4 | SOURCES += \ |
|
4 | SOURCES += \ | |
5 | $$PWD/qpieseries.cpp \ |
|
5 | $$PWD/qpieseries.cpp \ | |
6 | $$PWD/pieslice.cpp \ |
|
6 | $$PWD/pieslice.cpp \ | |
7 |
$$PWD/pie |
|
7 | $$PWD/piechartitem.cpp \ | |
8 | $$PWD/qpieslice.cpp |
|
8 | $$PWD/qpieslice.cpp | |
9 |
|
9 | |||
10 | PRIVATE_HEADERS += \ |
|
10 | PRIVATE_HEADERS += \ | |
11 |
$$PWD/pie |
|
11 | $$PWD/piechartitem_p.h \ | |
12 | $$PWD/pieslice_p.h \ |
|
12 | $$PWD/pieslice_p.h \ | |
13 |
|
13 | |||
14 | PUBLIC_HEADERS += \ |
|
14 | PUBLIC_HEADERS += \ |
@@ -1,4 +1,4 | |||||
1 |
#include "pie |
|
1 | #include "piechartitem_p.h" | |
2 | #include "pieslice_p.h" |
|
2 | #include "pieslice_p.h" | |
3 | #include "qpieslice.h" |
|
3 | #include "qpieslice.h" | |
4 | #include "qpieseries.h" |
|
4 | #include "qpieseries.h" | |
@@ -9,7 +9,7 | |||||
9 |
|
9 | |||
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
11 |
|
11 | |||
12 |
Pie |
|
12 | PieChartItem::PieChartItem(QGraphicsItem *parent, QPieSeries *series) | |
13 | :ChartItem(parent), |
|
13 | :ChartItem(parent), | |
14 | m_series(series) |
|
14 | m_series(series) | |
15 | { |
|
15 | { | |
@@ -20,12 +20,12 PiePresenter::PiePresenter(QGraphicsItem *parent, QPieSeries *series) | |||||
20 | setZValue(ChartPresenter::PieSeriesZValue); |
|
20 | setZValue(ChartPresenter::PieSeriesZValue); | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 | PiePresenter::~PiePresenter() |
|
23 | PieChartItem::~PieChartItem() | |
24 | { |
|
24 | { | |
25 | // slices deleted automatically through QGraphicsItem |
|
25 | // slices deleted automatically through QGraphicsItem | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 |
void Pie |
|
28 | void PieChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) | |
29 | { |
|
29 | { | |
30 | // TODO: paint shadows for all components |
|
30 | // TODO: paint shadows for all components | |
31 | // - get paths from items & merge & offset and draw with shadow color? |
|
31 | // - get paths from items & merge & offset and draw with shadow color? | |
@@ -33,14 +33,14 void PiePresenter::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QW | |||||
33 | //painter->drawRect(m_debugRect); |
|
33 | //painter->drawRect(m_debugRect); | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 |
void Pie |
|
36 | void PieChartItem::handleSeriesChanged() | |
37 | { |
|
37 | { | |
38 | QVector<PieSliceLayout> sliceLayout = calculateLayout(); |
|
38 | QVector<PieSliceLayout> sliceLayout = calculateLayout(); | |
39 | applyLayout(sliceLayout); |
|
39 | applyLayout(sliceLayout); | |
40 | update(); |
|
40 | update(); | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 |
void Pie |
|
43 | void PieChartItem::handleSliceChanged() | |
44 | { |
|
44 | { | |
45 | // TODO: optimize don't need to handle all slices |
|
45 | // TODO: optimize don't need to handle all slices | |
46 | QVector<PieSliceLayout> sliceLayout = calculateLayout(); |
|
46 | QVector<PieSliceLayout> sliceLayout = calculateLayout(); | |
@@ -48,12 +48,12 void PiePresenter::handleSliceChanged() | |||||
48 | update(); |
|
48 | update(); | |
49 | } |
|
49 | } | |
50 |
|
50 | |||
51 |
void Pie |
|
51 | void PieChartItem::handleDomainChanged(qreal, qreal, qreal, qreal) | |
52 | { |
|
52 | { | |
53 | // TODO |
|
53 | // TODO | |
54 | } |
|
54 | } | |
55 |
|
55 | |||
56 |
void Pie |
|
56 | void PieChartItem::handleGeometryChanged(const QRectF& rect) | |
57 | { |
|
57 | { | |
58 | prepareGeometryChange(); |
|
58 | prepareGeometryChange(); | |
59 | m_rect = rect; |
|
59 | m_rect = rect; | |
@@ -63,7 +63,7 void PiePresenter::handleGeometryChanged(const QRectF& rect) | |||||
63 | } |
|
63 | } | |
64 |
|
64 | |||
65 |
|
65 | |||
66 |
QVector<PieSliceLayout> Pie |
|
66 | QVector<PieSliceLayout> PieChartItem::calculateLayout() | |
67 | { |
|
67 | { | |
68 | // find pie center coordinates |
|
68 | // find pie center coordinates | |
69 | QPointF center; |
|
69 | QPointF center; | |
@@ -92,7 +92,7 QVector<PieSliceLayout> PiePresenter::calculateLayout() | |||||
92 | return layout; |
|
92 | return layout; | |
93 | } |
|
93 | } | |
94 |
|
94 | |||
95 |
void Pie |
|
95 | void PieChartItem::applyLayout(const QVector<PieSliceLayout> &layout) | |
96 | { |
|
96 | { | |
97 | //if(m_animator) |
|
97 | //if(m_animator) | |
98 | // m_animator->applyLayout(this,points); |
|
98 | // m_animator->applyLayout(this,points); | |
@@ -100,7 +100,7 void PiePresenter::applyLayout(const QVector<PieSliceLayout> &layout) | |||||
100 | setLayout(layout); |
|
100 | setLayout(layout); | |
101 | } |
|
101 | } | |
102 |
|
102 | |||
103 |
void Pie |
|
103 | void PieChartItem::setLayout(const QVector<PieSliceLayout> &layout) | |
104 | { |
|
104 | { | |
105 | foreach (PieSliceLayout l, layout) { |
|
105 | foreach (PieSliceLayout l, layout) { | |
106 |
|
106 | |||
@@ -138,6 +138,6 void PiePresenter::setLayout(const QVector<PieSliceLayout> &layout) | |||||
138 | } |
|
138 | } | |
139 | } |
|
139 | } | |
140 |
|
140 | |||
141 |
#include "moc_pie |
|
141 | #include "moc_piechartitem_p.cpp" | |
142 |
|
142 | |||
143 | QTCOMMERCIALCHART_END_NAMESPACE |
|
143 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,5 +1,5 | |||||
1 |
#ifndef PIE |
|
1 | #ifndef PIECHARTITEM_H | |
2 |
#define PIE |
|
2 | #define PIECHARTITEM_H | |
3 |
|
3 | |||
4 | #include "qpieseries.h" |
|
4 | #include "qpieseries.h" | |
5 | #include "chartitem_p.h" |
|
5 | #include "chartitem_p.h" | |
@@ -9,14 +9,14 class QGraphicsItem; | |||||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
10 | class QPieSlice; |
|
10 | class QPieSlice; | |
11 |
|
11 | |||
12 |
class Pie |
|
12 | class PieChartItem : public QObject, public ChartItem | |
13 | { |
|
13 | { | |
14 | Q_OBJECT |
|
14 | Q_OBJECT | |
15 |
|
15 | |||
16 | public: |
|
16 | public: | |
17 | // TODO: use a generic data class instead of x and y |
|
17 | // TODO: use a generic data class instead of x and y | |
18 |
Pie |
|
18 | PieChartItem(QGraphicsItem *parent, QPieSeries *series); | |
19 |
~Pie |
|
19 | ~PieChartItem(); | |
20 |
|
20 | |||
21 | public: // from QGraphicsItem |
|
21 | public: // from QGraphicsItem | |
22 | QRectF boundingRect() const { return m_rect; } |
|
22 | QRectF boundingRect() const { return m_rect; } | |
@@ -45,4 +45,4 private: | |||||
45 |
|
45 | |||
46 | QTCOMMERCIALCHART_END_NAMESPACE |
|
46 | QTCOMMERCIALCHART_END_NAMESPACE | |
47 |
|
47 | |||
48 |
#endif // PIE |
|
48 | #endif // PIECHARTITEM_H |
@@ -1,5 +1,5 | |||||
1 | #include "pieslice_p.h" |
|
1 | #include "pieslice_p.h" | |
2 |
#include "pie |
|
2 | #include "piechartitem_p.h" | |
3 | #include "qpieseries.h" |
|
3 | #include "qpieseries.h" | |
4 | #include "qpieslice.h" |
|
4 | #include "qpieslice.h" | |
5 | #include "chartpresenter_p.h" |
|
5 | #include "chartpresenter_p.h" |
@@ -12,7 +12,7 | |||||
12 | #define PIESLICE_LABEL_GAP 5 |
|
12 | #define PIESLICE_LABEL_GAP 5 | |
13 |
|
13 | |||
14 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
14 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
15 |
class Pie |
|
15 | class PieChartItem; | |
16 | class PieSliceLabel; |
|
16 | class PieSliceLabel; | |
17 | class QPieSlice; |
|
17 | class QPieSlice; | |
18 |
|
18 |
@@ -11,7 +11,7 | |||||
11 |
|
11 | |||
12 | class QGraphicsObject; |
|
12 | class QGraphicsObject; | |
13 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
13 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
14 |
class Pie |
|
14 | class PieChartItem; | |
15 | class PieSlice; |
|
15 | class PieSlice; | |
16 | class QPieSlice; |
|
16 | class QPieSlice; | |
17 |
|
17 | |||
@@ -112,7 +112,7 private: | |||||
112 | Q_DISABLE_COPY(QPieSeries) |
|
112 | Q_DISABLE_COPY(QPieSeries) | |
113 |
|
113 | |||
114 | // TODO: use PIML |
|
114 | // TODO: use PIML | |
115 |
friend class Pie |
|
115 | friend class PieChartItem; | |
116 | friend class PieSlice; |
|
116 | friend class PieSlice; | |
117 |
|
117 | |||
118 | QList<QPieSlice*> m_slices; |
|
118 | QList<QPieSlice*> m_slices; |
General Comments 0
You need to be logged in to leave comments.
Login now