##// END OF EJS Templates
Spline initial
Marek Rosa -
r295:698d88c3d4c1
parent child
Show More
@@ -0,0 +1,6
1 #include "qsplineseries.h"
2
3 QSplineSeries::QSplineSeries(QObject *parent) :
4 QObject(parent)
5 {
6 }
@@ -0,0 +1,24
1 #ifndef QSPLINESERIES_H
2 #define QSPLINESERIES_H
3
4 #include "qchartseries.h"
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
8 class QSplineSeries : public QChartSeries
9 {
10 Q_OBJECT
11 public:
12 explicit QSplineSeries(QObject *parent = 0);
13
14 public: // from QChartSeries
15 QChartSeriesType type() const { return QChartSeries::SeriesTypeSpline; }
16 signals:
17
18 public slots:
19
20 };
21
22 QTCOMMERCIALCHART_END_NAMESPACE
23
24 #endif // QSPLINESERIES_H
@@ -0,0 +1,15
1 INCLUDEPATH += $$PWD
2 DEPENDPATH += $$PWD
3
4 SOURCES += \
5 $$PWD/qsplineseries.cpp \
6 splinechart/splinepresenter.cpp
7
8 PRIVATE_HEADERS +=
9
10 PUBLIC_HEADERS += \
11 $$PWD/qsplineseries.h
12
13 HEADERS += \
14 splinechart/qsplineseries.h \
15 splinechart/splinepresenter_p.h
@@ -0,0 +1,16
1 #include "splinepresenter_p.h"
2
3 SplinePresenter::SplinePresenter(QObject *parent) :
4 QObject(parent)
5 {
6 }
7
8 void SplinePresenter::handleGeometryChanged(const QRectF&)
9 {
10 //
11 }
12
13 void SplinePresenter::handleDomainChanged(const Domain& domain)
14 {
15 //
16 }
@@ -0,0 +1,26
1 #ifndef SPLINEPRESENTER_P_H
2 #define SPLINEPRESENTER_P_H
3
4 #include "chartitem_p.h"
5 #include <QObject>
6
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8
9 class SplinePresenter : public QObject, public ChartItem
10 {
11 Q_OBJECT
12 public:
13 SplinePresenter(QObject *parent = 0);
14
15 void handleGeometryChanged(const QRectF&);
16 void handleDomainChanged(const Domain& domain);
17
18 signals:
19
20 public slots:
21
22 };
23
24 QTCOMMERCIALCHART_END_NAMESPACE
25
26 #endif // SPLINEPRESENTER_P_H
@@ -1,226 +1,233
1 1 #include "qchart.h"
2 2 #include "qchartaxis.h"
3 3 #include "chartpresenter_p.h"
4 4 #include "chartdataset_p.h"
5 5 #include "charttheme_p.h"
6 6 //series
7 7 #include "qbarchartseries.h"
8 8 #include "qstackedbarchartseries.h"
9 9 #include "qpercentbarchartseries.h"
10 10 #include "qlinechartseries.h"
11 11 #include "qpieseries.h"
12 12 #include "qscatterseries.h"
13 #include "qsplineseries.h"
13 14 //items
14 15 #include "axisitem_p.h"
15 16 #include "barpresenter.h"
16 17 #include "stackedbarpresenter.h"
17 18 #include "linechartitem_p.h"
18 19 #include "percentbarpresenter.h"
19 20 #include "linechartanimationitem_p.h"
20 21 #include "piepresenter.h"
21 22 #include "scatterpresenter_p.h"
23 #include "splinepresenter_p.h"
22 24
23 25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
24 26
25 27 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
26 28 m_chart(chart),
27 29 m_dataset(dataset),
28 30 m_chartTheme(0),
29 31 m_marginSize(0),
30 32 m_rect(QRectF(QPoint(0,0),m_chart->size()))
31 33 {
32 34 createConnections();
33 35 setChartTheme(QChart::ChartThemeDefault);
34 36
35 37 }
36 38
37 39 ChartPresenter::~ChartPresenter()
38 40 {
39 41 }
40 42
41 43 void ChartPresenter::createConnections()
42 44 {
43 45 QObject::connect(m_chart,SIGNAL(geometryChanged()),this,SLOT(handleGeometryChanged()));
44 46 QObject::connect(m_dataset,SIGNAL(seriesAdded(QChartSeries*)),this,SLOT(handleSeriesAdded(QChartSeries*)));
45 47 QObject::connect(m_dataset,SIGNAL(seriesRemoved(QChartSeries*)),this,SLOT(handleSeriesRemoved(QChartSeries*)));
46 48 QObject::connect(m_dataset,SIGNAL(axisAdded(QChartAxis*)),this,SLOT(handleAxisAdded(QChartAxis*)));
47 49 QObject::connect(m_dataset,SIGNAL(axisRemoved(QChartAxis*)),this,SLOT(handleAxisRemoved(QChartAxis*)));
48 50 QObject::connect(m_dataset,SIGNAL(seriesDomainChanged(QChartSeries*,const Domain&)),this,SLOT(handleSeriesDomainChanged(QChartSeries*,const Domain&)));
49 51 QObject::connect(m_dataset,SIGNAL(axisLabelsChanged(QChartAxis*,const QStringList&)),this,SLOT(handleAxisLabelsChanged(QChartAxis*,const QStringList&)));
50 52 }
51 53
52 54
53 55 QRectF ChartPresenter::geometry() const
54 56 {
55 57 return m_rect;
56 58 }
57 59
58 60 void ChartPresenter::handleGeometryChanged()
59 61 {
60 62 m_rect = QRectF(QPoint(0,0),m_chart->size());
61 63 m_rect.adjust(m_marginSize,m_marginSize, -m_marginSize, -m_marginSize);
62 64 Q_ASSERT(m_rect.isValid());
63 65 emit geometryChanged(m_rect);
64 66 }
65 67
66 68 int ChartPresenter::margin() const
67 69 {
68 70 return m_marginSize;
69 71 }
70 72
71 73 void ChartPresenter::setMargin(int margin)
72 74 {
73 75 m_marginSize = margin;
74 76 }
75 77
76 78 void ChartPresenter::handleAxisAdded(QChartAxis* axis)
77 79 {
78 80 AxisItem* item ;
79 81
80 82 if(axis==m_dataset->axisX()){
81 83 item = new AxisItem(AxisItem::X_AXIS,m_chart);
82 84 }else{
83 85 item = new AxisItem(AxisItem::Y_AXIS,m_chart);
84 86 }
85 87 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
86 88 QObject::connect(axis,SIGNAL(update(QChartAxis*)),item,SLOT(handleAxisUpdate(QChartAxis*)));
87 89
88 90 item->handleAxisUpdate(axis);
89 91 item->handleGeometryChanged(m_rect);
90 92 m_chartTheme->decorate(axis,item);
91 93 m_axisItems.insert(axis,item);
92 94 }
93 95
94 96 void ChartPresenter::handleAxisRemoved(QChartAxis* axis)
95 97 {
96 98 AxisItem* item = m_axisItems.take(axis);
97 99 Q_ASSERT(item);
98 100 delete item;
99 101 }
100 102
101 103
102 104 void ChartPresenter::handleSeriesAdded(QChartSeries* series)
103 105 {
104 106 switch(series->type())
105 107 {
106 108 case QChartSeries::SeriesTypeLine: {
107 109 QLineChartSeries* lineSeries = static_cast<QLineChartSeries*>(series);
108 110 LineChartItem* item = new LineChartAnimationItem(this,lineSeries,m_chart);
109 111 m_chartTheme->decorate(item,lineSeries,m_chartItems.count());
110 112 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
111 113 QObject::connect(lineSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
112 114 m_chartItems.insert(series,item);
113 115 break;
114 116 }
115 117
116 118 case QChartSeries::SeriesTypeBar: {
117 119 QBarChartSeries* barSeries = static_cast<QBarChartSeries*>(series);
118 120 BarPresenter* item = new BarPresenter(barSeries,m_chart);
119 121 m_chartTheme->decorate(item,barSeries,m_chartItems.count());
120 122 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
121 123 QObject::connect(barSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
122 124 m_chartItems.insert(series,item);
123 125 // m_axisXItem->setVisible(false);
124 126 break;
125 127 }
126 128
127 129 case QChartSeries::SeriesTypeStackedBar: {
128 130
129 131 QStackedBarChartSeries* stackedBarSeries = static_cast<QStackedBarChartSeries*>(series);
130 132 StackedBarPresenter* item = new StackedBarPresenter(stackedBarSeries,m_chart);
131 133 m_chartTheme->decorate(item,stackedBarSeries,m_chartItems.count());
132 134 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
133 135 QObject::connect(stackedBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
134 136 m_chartItems.insert(series,item);
135 137 break;
136 138 }
137 139
138 140 case QChartSeries::SeriesTypePercentBar: {
139 141
140 142 QPercentBarChartSeries* percentBarSeries = static_cast<QPercentBarChartSeries*>(series);
141 143 PercentBarPresenter* item = new PercentBarPresenter(percentBarSeries,m_chart);
142 144 m_chartTheme->decorate(item,percentBarSeries ,m_chartItems.count());
143 145 QObject::connect(this,SIGNAL(geometryChanged(const QRectF&)),item,SLOT(handleGeometryChanged(const QRectF&)));
144 146 QObject::connect(percentBarSeries,SIGNAL(changed(int)),item,SLOT(handleModelChanged(int)));
145 147 m_chartItems.insert(series,item);
146 148 break;
147 149 }
148 150 case QChartSeries::SeriesTypeScatter: {
149 151 QScatterSeries *scatterSeries = qobject_cast<QScatterSeries *>(series);
150 152 ScatterPresenter *scatterPresenter = new ScatterPresenter(scatterSeries, m_chart);
151 153 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)),
152 154 scatterPresenter, SLOT(handleGeometryChanged(const QRectF&)));
153 155 m_chartTheme->decorate(scatterPresenter, scatterSeries, m_chartItems.count());
154 156 m_chartItems.insert(scatterSeries, scatterPresenter);
155 157 break;
156 158 }
157 159 case QChartSeries::SeriesTypePie: {
158 160 QPieSeries *s = qobject_cast<QPieSeries *>(series);
159 161 PiePresenter* pie = new PiePresenter(m_chart, s);
160 162 m_chartTheme->decorate(pie, s, m_chartItems.count());
161 163 QObject::connect(this, SIGNAL(geometryChanged(const QRectF&)), pie, SLOT(handleGeometryChanged(const QRectF&)));
162 164 m_chartItems.insert(series, pie);
163 165 break;
164 166 }
167 case QChartSeries::SeriesTypeSpline: {
168 QSplineSeries* splineSeries = qobject_cast<QSplineSeries*>(series);
169 SplinePresenter* splinePresenter = new SplinePresenter
170 break;
171 }
165 172 default: {
166 173 qDebug()<< "Series type" << series->type() << "not implemented.";
167 174 break;
168 175 }
169 176 }
170 177
171 178 if(m_rect.isValid()) emit geometryChanged(m_rect);
172 179 }
173 180
174 181 void ChartPresenter::handleSeriesRemoved(QChartSeries* series)
175 182 {
176 183 ChartItem* item = m_chartItems.take(series);
177 184 delete item;
178 185 }
179 186
180 187 void ChartPresenter::handleSeriesChanged(QChartSeries* series)
181 188 {
182 189 //TODO:
183 190 }
184 191
185 192 void ChartPresenter::handleSeriesDomainChanged(QChartSeries* series, const Domain& domain)
186 193 {
187 194 m_chartItems.value(series)->handleDomainChanged(domain);
188 195 }
189 196
190 197 void ChartPresenter::handleAxisLabelsChanged(QChartAxis* axis,const QStringList& labels)
191 198 {
192 199 m_axisItems.value(axis)->handleLabelsChanged(axis,labels);
193 200 }
194 201
195 202 void ChartPresenter::setChartTheme(QChart::ChartTheme theme)
196 203 {
197 204 delete m_chartTheme;
198 205
199 206 m_chartTheme = ChartTheme::createTheme(theme);
200 207
201 208 m_chartTheme->decorate(m_chart);
202 209 QMapIterator<QChartSeries*,ChartItem*> i(m_chartItems);
203 210
204 211 int index=0;
205 212 while (i.hasNext()) {
206 213 i.next();
207 214 index++;
208 215 m_chartTheme->decorate(i.value(),i.key(),index);
209 216 }
210 217
211 218 QMapIterator<QChartAxis*,AxisItem*> j(m_axisItems);
212 219 while (j.hasNext()) {
213 220 j.next();
214 221 m_chartTheme->decorate(j.key(),j.value());
215 222 }
216 223 }
217 224
218 225 QChart::ChartTheme ChartPresenter::chartTheme()
219 226 {
220 227 return m_chartTheme->id();
221 228 }
222 229
223 230
224 231 #include "moc_chartpresenter_p.cpp"
225 232
226 233 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,45 +1,45
1 1 #ifndef QCHARTSERIES_H
2 2 #define QCHARTSERIES_H
3 3
4 4 #include "qchartglobal.h"
5 5 #include <QObject>
6 6 #include <QAbstractItemModel>
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 10 class QTCOMMERCIALCHART_EXPORT QChartSeries : public QObject
11 11 {
12 12 Q_OBJECT
13 13 public:
14 14 enum QChartSeriesType {
15 15 SeriesTypeInvalid = -1,
16 16 SeriesTypeLine,
17 17 // SeriesTypeArea,
18 18 SeriesTypeBar,
19 19 SeriesTypeStackedBar,
20 20 SeriesTypePercentBar,
21 21 SeriesTypePie,
22 SeriesTypeScatter
23 // SeriesTypeSpline
22 SeriesTypeScatter,
23 SeriesTypeSpline
24 24 };
25 25
26 26 protected:
27 27 QChartSeries(QObject *parent = 0):QObject(parent){};
28 28
29 29 public:
30 30 virtual ~QChartSeries(){};
31 31
32 32 // Pure virtual
33 33 virtual QChartSeriesType type() const = 0;
34 34
35 35 virtual bool setData(QList<qreal> /*data*/) { return false; }
36 36 virtual bool setData(QList<qreal> /*x*/, QList<qreal> /*y*/){ return false; }
37 37
38 38 // Prototype for data model. TODO: remove the other setData methods and use something like this for now?
39 39 virtual bool setModel(QAbstractItemModel* /*model*/) { return false; }
40 40 };
41 41
42 42 QTCOMMERCIALCHART_END_NAMESPACE
43 43
44 44 #endif
45 45
@@ -1,92 +1,93
1 1 !include( ../common.pri ):error( Couldn't find the common.pri file! )
2 2 TARGET = QtCommercialChart
3 3 DESTDIR = $$CHART_BUILD_LIB_DIR
4 4 TEMPLATE = lib
5 5 QT += core \
6 6 gui
7 7 CONFIG += debug_and_release
8 8 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
9 9 SOURCES += \
10 10 axisitem.cpp \
11 11 chartdataset.cpp \
12 12 chartpresenter.cpp \
13 13 charttheme.cpp \
14 14 domain.cpp \
15 15 qchart.cpp \
16 16 qchartaxis.cpp \
17 17 qchartseries.cpp \
18 qchartview.cpp
18 qchartview.cpp
19 19 PRIVATE_HEADERS += \
20 20 axisitem_p.h \
21 21 chartdataset_p.h \
22 22 chartitem_p.h \
23 23 chartpresenter_p.h \
24 24 charttheme_p.h \
25 25 domain_p.h
26 26 PUBLIC_HEADERS += \
27 27 qchart.h \
28 28 qchartaxis.h \
29 29 qchartglobal.h \
30 30 qchartseries.h \
31 31 qchartview.h \
32 32
33 33 include(linechart/linechart.pri)
34 34 include(barchart/barchart.pri)
35 35 include(piechart/piechart.pri)
36 36 include(scatterseries/scatter.pri)
37 include(splinechart/splinechart.pri)
37 38
38 39 THEMES += themes/chartthemeicy_p.h \
39 40 themes/chartthemegrayscale_p.h \
40 41 themes/chartthemescientific_p.h \
41 42 themes/chartthemevanilla_p.h
42 43 HEADERS += $$PUBLIC_HEADERS
43 44 HEADERS += $$PRIVATE_HEADERS
44 45 HEADERS += $$THEMES
45 46 INCLUDEPATH += linechart \
46 47 barchart \
47 48 themes \
48 49 .
49 50 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
50 51 MOC_DIR = $$CHART_BUILD_DIR/lib
51 52 UI_DIR = $$CHART_BUILD_DIR/lib
52 53 RCC_DIR = $$CHART_BUILD_DIR/lib
53 54 DEFINES += QTCOMMERCIALCHART_LIBRARY
54 55 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
55 56 public_headers.files = $$PUBLIC_HEADERS
56 57 target.path = $$[QT_INSTALL_LIBS]
57 58 INSTALLS += target \
58 59 public_headers
59 60 install_build_public_headers.name = bild_public_headers
60 61 install_build_public_headers.output = $$CHART_BUILD_PUBLIC_HEADER_DIR/${QMAKE_FILE_BASE}.h
61 62 install_build_public_headers.input = PUBLIC_HEADERS
62 63 install_build_public_headers.commands = $$QMAKE_COPY \
63 64 ${QMAKE_FILE_NAME} \
64 65 $$CHART_BUILD_PUBLIC_HEADER_DIR
65 66 install_build_public_headers.CONFIG += target_predeps \
66 67 no_link
67 68 install_build_private_headers.name = bild_private_headers
68 69 install_build_private_headers.output = $$CHART_BUILD_PRIVATE_HEADER_DIR/${QMAKE_FILE_BASE}.h
69 70 install_build_private_headers.input = PRIVATE_HEADERS
70 71 install_build_private_headers.commands = $$QMAKE_COPY \
71 72 ${QMAKE_FILE_NAME} \
72 73 $$CHART_BUILD_PRIVATE_HEADER_DIR
73 74 install_build_private_headers.CONFIG += target_predeps \
74 75 no_link
75 76 QMAKE_EXTRA_COMPILERS += install_build_public_headers install_build_private_headers
76 77 chartversion.target = qchartversion_p.h
77 78 chartversion.commands = @echo \
78 79 "build_time" \
79 80 > \
80 81 $$chartversion.target;
81 82 chartversion.depends = $$HEADERS \
82 83 $$SOURCES
83 84 PRE_TARGETDEPS += qchartversion_p.h
84 85 QMAKE_CLEAN += qchartversion_p.h
85 86 QMAKE_EXTRA_TARGETS += chartversion
86 87 unix:QMAKE_DISTCLEAN += -r \
87 88 $$CHART_BUILD_HEADER_DIR \
88 89 $$CHART_BUILD_LIB_DIR
89 90 win32:QMAKE_DISTCLEAN += /Q \
90 91 $$CHART_BUILD_HEADER_DIR \
91 $$CHART_BUILD_LIB_DIR
92 $$CHART_BUILD_LIB_DIR
92 93
General Comments 0
You need to be logged in to leave comments. Login now