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