@@ -0,0 +1,14 | |||
|
1 | INCLUDEPATH += $$PWD | |
|
2 | DEPENDPATH += $$PWD | |
|
3 | ||
|
4 | SOURCES += \ | |
|
5 | $$PWD/qpieseries.cpp \ | |
|
6 | $$PWD/pieslice.cpp \ | |
|
7 | $$PWD/piepresenter.cpp | |
|
8 | ||
|
9 | PRIVATE_HEADERS += \ | |
|
10 | $$PWD/piepresenter.h \ | |
|
11 | $$PWD/pieslice.h | |
|
12 | ||
|
13 | PUBLIC_HEADERS += \ | |
|
14 | $$PWD/qpieseries.h |
@@ -4,8 +4,7 | |||
|
4 | 4 | #include "barchartseries.h" |
|
5 | 5 | #include "stackedbarchartseries.h" |
|
6 | 6 | #include "percentbarchartseries.h" |
|
7 |
#include " |
|
|
8 | #include "piechart/piepresentation.h" | |
|
7 | #include "qpieseries.h" | |
|
9 | 8 | |
|
10 | 9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | 10 |
@@ -16,7 +16,7 | |||
|
16 | 16 | #include "linechartitem_p.h" |
|
17 | 17 | #include "percentbargroup.h" |
|
18 | 18 | #include "linechartanimationitem_p.h" |
|
19 |
#include "piepresent |
|
|
19 | #include "piepresenter.h" | |
|
20 | 20 | |
|
21 | 21 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
22 | 22 | |
@@ -149,11 +149,11 void ChartPresenter::handleSeriesAdded(QChartSeries* series) | |||
|
149 | 149 | |
|
150 | 150 | case QChartSeries::SeriesTypePie: { |
|
151 | 151 | QPieSeries *pieSeries = qobject_cast<QPieSeries *>(series); |
|
152 |
PiePresent |
|
|
153 |
pieSeries->m_piePresent |
|
|
154 |
QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie |
|
|
155 |
QObject::connect(m_dataset, SIGNAL(domainChanged(const Domain&)), pie |
|
|
156 |
m_chartItems.insert(series, pie |
|
|
152 | PiePresenter* pie = new PiePresenter(m_chart, pieSeries); | |
|
153 | pieSeries->m_piePresenter = pie; // TODO: remove this pointer passing use signals&slots | |
|
154 | QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&))); | |
|
155 | QObject::connect(m_dataset, SIGNAL(domainChanged(const Domain&)), pie, SLOT(handleDomainChanged(const Domain&))); | |
|
156 | m_chartItems.insert(series, pie); | |
|
157 | 157 | break; |
|
158 | 158 | } |
|
159 | 159 |
@@ -1,11 +1,11 | |||
|
1 | 1 | |
|
2 |
#include "piepresent |
|
|
2 | #include "piepresenter.h" | |
|
3 | 3 | #include "pieslice.h" |
|
4 | 4 | #include <QDebug> |
|
5 | 5 | |
|
6 | 6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | 7 | |
|
8 |
PiePresent |
|
|
8 | PiePresenter::PiePresenter(QGraphicsItem *parent, QPieSeries *series) : | |
|
9 | 9 | ChartItem(parent), |
|
10 | 10 | m_pieSeries(series) |
|
11 | 11 | { |
@@ -15,13 +15,13 PiePresentation::PiePresentation(QGraphicsItem *parent, QPieSeries *series) : | |||
|
15 | 15 | setAcceptHoverEvents(true); |
|
16 | 16 | } |
|
17 | 17 | |
|
18 |
PiePresent |
|
|
18 | PiePresenter::~PiePresenter() | |
|
19 | 19 | { |
|
20 | 20 | while (m_slices.count()) |
|
21 | 21 | delete m_slices.takeLast(); |
|
22 | 22 | } |
|
23 | 23 | |
|
24 |
void PiePresent |
|
|
24 | void PiePresenter::seriesChanged() | |
|
25 | 25 | { |
|
26 | 26 | const qreal fullPie = 360; |
|
27 | 27 | qreal total = 0; |
@@ -47,7 +47,7 void PiePresentation::seriesChanged() | |||
|
47 | 47 | resize(); |
|
48 | 48 | } |
|
49 | 49 | |
|
50 |
void PiePresent |
|
|
50 | void PiePresenter::setSize(const QSizeF &size) | |
|
51 | 51 | { |
|
52 | 52 | // TODO: allow user setting the size? |
|
53 | 53 | // TODO: allow user defining the margins? |
@@ -55,12 +55,12 void PiePresentation::setSize(const QSizeF &size) | |||
|
55 | 55 | resize(); |
|
56 | 56 | } |
|
57 | 57 | |
|
58 |
void PiePresent |
|
|
58 | void PiePresenter::setPlotDomain(const PlotDomain& plotDomain) | |
|
59 | 59 | { |
|
60 | 60 | // TODO |
|
61 | 61 | } |
|
62 | 62 | |
|
63 |
void PiePresent |
|
|
63 | void PiePresenter::resize() | |
|
64 | 64 | { |
|
65 | 65 | m_pieRect = m_rect; |
|
66 | 66 | |
@@ -107,16 +107,16 void PiePresentation::resize() | |||
|
107 | 107 | qDebug() << "pie rect:" << m_pieRect; |
|
108 | 108 | } |
|
109 | 109 | |
|
110 |
void PiePresent |
|
|
110 | void PiePresenter::handleDomainChanged(const Domain& domain) | |
|
111 | 111 | { |
|
112 | 112 | // TODO |
|
113 | 113 | } |
|
114 | 114 | |
|
115 |
void PiePresent |
|
|
115 | void PiePresenter::handleGeometryChanged(const QRectF& rect) | |
|
116 | 116 | { |
|
117 | 117 | setSize(rect.size()); |
|
118 | 118 | } |
|
119 | 119 | |
|
120 |
#include "moc_piepresent |
|
|
120 | #include "moc_piepresenter.cpp" | |
|
121 | 121 | |
|
122 | 122 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,5 +1,5 | |||
|
1 |
#ifndef PIEPRESENT |
|
|
2 |
#define PIEPRESENT |
|
|
1 | #ifndef PIEPRESENTER_H | |
|
2 | #define PIEPRESENTER_H | |
|
3 | 3 | |
|
4 | 4 | #include "chartitem_p.h" |
|
5 | 5 | #include "qpieseries.h" |
@@ -8,14 +8,14 class QGraphicsItem; | |||
|
8 | 8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | 9 | class PieSlice; |
|
10 | 10 | |
|
11 |
class PiePresent |
|
|
11 | class PiePresenter : public QObject, public ChartItem | |
|
12 | 12 | { |
|
13 | 13 | Q_OBJECT |
|
14 | 14 | |
|
15 | 15 | public: |
|
16 | 16 | // TODO: use a generic data class instead of x and y |
|
17 |
PiePresent |
|
|
18 |
~PiePresent |
|
|
17 | PiePresenter(QGraphicsItem *parent, QPieSeries *series); | |
|
18 | ~PiePresenter(); | |
|
19 | 19 | |
|
20 | 20 | public: // from ChartItem |
|
21 | 21 | void setSize(const QSizeF &size); |
@@ -42,4 +42,4 private: | |||
|
42 | 42 | |
|
43 | 43 | QTCOMMERCIALCHART_END_NAMESPACE |
|
44 | 44 | |
|
45 |
#endif // PIEPRESENT |
|
|
45 | #endif // PIEPRESENTER_H |
@@ -1,11 +1,11 | |||
|
1 | 1 | #include "pieslice.h" |
|
2 |
#include "piepresent |
|
|
2 | #include "piepresenter.h" | |
|
3 | 3 | #include <QPainter> |
|
4 | 4 | #include <QDebug> |
|
5 | 5 | |
|
6 | 6 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | 7 | |
|
8 |
PieSlice::PieSlice(PiePresent |
|
|
8 | PieSlice::PieSlice(PiePresenter *piePresentation, int seriesIndex, qreal startAngle, qreal span) | |
|
9 | 9 | :QGraphicsItem(piePresentation), |
|
10 | 10 | m_seriesIndex(seriesIndex), |
|
11 | 11 | m_startAngle(startAngle), |
@@ -27,7 +27,7 QRectF PieSlice::boundingRect() const | |||
|
27 | 27 | |
|
28 | 28 | QPainterPath PieSlice::shape() const |
|
29 | 29 | { |
|
30 |
QRectF rect = (static_cast<PiePresent |
|
|
30 | QRectF rect = (static_cast<PiePresenter*>(parentItem()))->pieRect(); | |
|
31 | 31 | qreal angle = (-m_startAngle) + (90); |
|
32 | 32 | qreal span = -m_span; |
|
33 | 33 | |
@@ -55,7 +55,7 void PieSlice::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option | |||
|
55 | 55 | //painter->setPen(m_theme.linePen); |
|
56 | 56 | // TODO: |
|
57 | 57 | |
|
58 |
QPieSlice data = (static_cast<PiePresent |
|
|
58 | QPieSlice data = (static_cast<PiePresenter*>(parentItem()))->m_pieSeries->slice(m_seriesIndex); | |
|
59 | 59 | painter->setBrush(data.m_color); |
|
60 | 60 | |
|
61 | 61 |
@@ -8,12 +8,12 | |||
|
8 | 8 | #include <QColor> |
|
9 | 9 | |
|
10 | 10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 |
class PiePresent |
|
|
11 | class PiePresenter; | |
|
12 | 12 | |
|
13 | 13 | class PieSlice : public QGraphicsItem |
|
14 | 14 | { |
|
15 | 15 | public: |
|
16 |
PieSlice(PiePresent |
|
|
16 | PieSlice(PiePresenter *piePresentation, int seriesIndex, qreal startAngle, qreal span); | |
|
17 | 17 | ~PieSlice(); |
|
18 | 18 | |
|
19 | 19 | public: // from QGraphicsItem |
@@ -1,5 +1,5 | |||
|
1 | 1 | #include "qpieseries.h" |
|
2 |
#include "piepresent |
|
|
2 | #include "piepresenter.h" | |
|
3 | 3 | #include "pieslice.h" |
|
4 | 4 | #include <QDebug> |
|
5 | 5 | |
@@ -7,7 +7,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE | |||
|
7 | 7 | |
|
8 | 8 | QPieSeries::QPieSeries(QObject *parent) : |
|
9 | 9 | QChartSeries(parent), |
|
10 |
m_piePresent |
|
|
10 | m_piePresenter(0), | |
|
11 | 11 | m_sizeFactor(1.0), |
|
12 | 12 | m_position(PiePositionMaximized) |
|
13 | 13 | { |
@@ -21,19 +21,19 QPieSeries::~QPieSeries() | |||
|
21 | 21 | void QPieSeries::set(QList<QPieSlice> slices) |
|
22 | 22 | { |
|
23 | 23 | m_slices = slices; |
|
24 |
if (m_piePresent |
|
|
25 |
m_piePresent |
|
|
26 |
m_piePresent |
|
|
24 | if (m_piePresenter) { | |
|
25 | m_piePresenter->seriesChanged(); | |
|
26 | m_piePresenter->update(); | |
|
27 | 27 | } |
|
28 | 28 | } |
|
29 | 29 | |
|
30 | 30 | void QPieSeries::add(QList<QPieSlice> slices) |
|
31 | 31 | { |
|
32 | 32 | m_slices += slices; |
|
33 |
if (m_piePresent |
|
|
34 |
m_piePresent |
|
|
35 |
// TODO: m_piePresent |
|
|
36 |
m_piePresent |
|
|
33 | if (m_piePresenter) { | |
|
34 | m_piePresenter->seriesChanged(); | |
|
35 | // TODO: m_piePresenter->seriesAppended()?? | |
|
36 | m_piePresenter->update(); | |
|
37 | 37 | } |
|
38 | 38 | } |
|
39 | 39 | |
@@ -53,11 +53,11 bool QPieSeries::update(int index, QPieSlice slice) | |||
|
53 | 53 | { |
|
54 | 54 | if ((index >= 0) && (index < m_slices.count())) { |
|
55 | 55 | m_slices[index] = slice; |
|
56 |
if (m_piePresent |
|
|
57 |
m_piePresent |
|
|
56 | if (m_piePresenter) { | |
|
57 | m_piePresenter->seriesChanged(); | |
|
58 | 58 | // TODO: for a nice animation we need something like |
|
59 |
// m_piePresent |
|
|
60 |
m_piePresent |
|
|
59 | // m_piePresenter->sliceChanged(index, oldslice, newslice) | |
|
60 | m_piePresenter->update(); | |
|
61 | 61 | } |
|
62 | 62 | return true; |
|
63 | 63 | } |
@@ -69,9 +69,9 void QPieSeries::setSizeFactor(qreal factor) | |||
|
69 | 69 | if (factor > 0.0) |
|
70 | 70 | m_sizeFactor = factor; |
|
71 | 71 | |
|
72 |
if (m_piePresent |
|
|
73 |
m_piePresent |
|
|
74 |
m_piePresent |
|
|
72 | if (m_piePresenter) { | |
|
73 | m_piePresenter->resize(); | |
|
74 | m_piePresenter->update(); | |
|
75 | 75 | // TODO: do we have to update the parent item also? |
|
76 | 76 | // - potential issue: what if this function is called from the parent context? |
|
77 | 77 | } |
@@ -80,9 +80,9 void QPieSeries::setSizeFactor(qreal factor) | |||
|
80 | 80 | void QPieSeries::setPosition(PiePosition position) |
|
81 | 81 | { |
|
82 | 82 | m_position = position; |
|
83 |
if (m_piePresent |
|
|
84 |
m_piePresent |
|
|
85 |
m_piePresent |
|
|
83 | if (m_piePresenter) { | |
|
84 | m_piePresenter->resize(); | |
|
85 | m_piePresenter->update(); | |
|
86 | 86 | // TODO: do we have to update the parent item also? |
|
87 | 87 | // - potential issue: what if this function is called from the parent context? |
|
88 | 88 | } |
@@ -8,7 +8,7 | |||
|
8 | 8 | |
|
9 | 9 | class QGraphicsObject; |
|
10 | 10 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 |
class PiePresent |
|
|
11 | class PiePresenter; | |
|
12 | 12 | class PieSlice; |
|
13 | 13 | |
|
14 | 14 | class QPieSlice |
@@ -74,8 +74,8 private: | |||
|
74 | 74 | // TODO: use PIML |
|
75 | 75 | friend class ChartPresenter; |
|
76 | 76 | friend class ChartDataSet; |
|
77 |
friend class PiePresent |
|
|
78 |
PiePresent |
|
|
77 | friend class PiePresenter; | |
|
78 | PiePresenter *m_piePresenter; | |
|
79 | 79 | QList<QPieSlice> m_slices; |
|
80 | 80 | qreal m_sizeFactor; |
|
81 | 81 | PiePosition m_position; |
@@ -17,9 +17,6 SOURCES += barchart/barchartseries.cpp \ | |||
|
17 | 17 | linechart/linechartanimationitem.cpp \ |
|
18 | 18 | linechart/linechartitem.cpp \ |
|
19 | 19 | linechart/qlinechartseries.cpp \ |
|
20 | piechart/qpieseries.cpp \ | |
|
21 | piechart/pieslice.cpp \ | |
|
22 | piechart/piepresentation.cpp \ | |
|
23 | 20 | barchart/separator.cpp \ |
|
24 | 21 | barchart/bargroupbase.cpp \ |
|
25 | 22 | barchart/barchartseriesbase.cpp \ |
@@ -39,8 +36,6 PRIVATE_HEADERS += linechart/linechartitem_p.h \ | |||
|
39 | 36 | barchart/barlabel_p.h \ |
|
40 | 37 | barchart/bar_p.h \ |
|
41 | 38 | barchart/separator_p.h \ |
|
42 | piechart/piepresentation.h \ | |
|
43 | piechart/pieslice.h \ | |
|
44 | 39 | plotdomain_p.h \ |
|
45 | 40 | qscatterseries_p.h \ |
|
46 | 41 | axisitem_p.h \ |
@@ -58,13 +53,15 PUBLIC_HEADERS += linechart/qlinechartseries.h \ | |||
|
58 | 53 | barchart/percentbargroup.h \ |
|
59 | 54 | barchart/barchartseriesbase.h \ |
|
60 | 55 | barchart/bargroupbase.h \ |
|
61 | piechart/qpieseries.h \ | |
|
62 | 56 | qchartseries.h \ |
|
63 | 57 | qscatterseries.h \ |
|
64 | 58 | qchart.h \ |
|
65 | 59 | qchartglobal.h \ |
|
66 | 60 | qchartview.h \ |
|
67 | 61 | qchartaxis.h |
|
62 | ||
|
63 | include(piechart/piechart.pri) | |
|
64 | ||
|
68 | 65 | THEMES += themes/chartthemeicy_p.h \ |
|
69 | 66 | themes/chartthemegrayscale_p.h \ |
|
70 | 67 | themes/chartthemescientific_p.h \ |
@@ -74,7 +71,6 HEADERS += $$PRIVATE_HEADERS | |||
|
74 | 71 | HEADERS += $$THEMES |
|
75 | 72 | INCLUDEPATH += linechart \ |
|
76 | 73 | barchart \ |
|
77 | piechart \ | |
|
78 | 74 | themes \ |
|
79 | 75 | . |
|
80 | 76 | OBJECTS_DIR = $$CHART_BUILD_DIR/lib |
General Comments 0
You need to be logged in to leave comments.
Login now