@@ -1,171 +1,151 | |||||
1 | #include "qchart.h" |
|
1 | #include "qchart.h" | |
2 | #include "qchartseries.h" |
|
2 | #include "qchartseries.h" | |
3 | #include "qscatterseries.h" |
|
3 | #include "qscatterseries.h" | |
4 | #include "qscatterseries_p.h" |
|
4 | #include "qscatterseries_p.h" | |
5 | #include "qpieseries.h" |
|
5 | #include "qpieseries.h" | |
6 | #include "qxychartseries.h" |
|
6 | #include "qxychartseries.h" | |
7 | #include "xylinechartitem_p.h" |
|
7 | #include "xylinechartitem_p.h" | |
8 | #include "xyplotdomain_p.h" |
|
8 | #include "xyplotdomain_p.h" | |
9 | #include "axis_p.h" |
|
9 | #include "axis_p.h" | |
10 | #include "xygrid_p.h" |
|
10 | #include "xygrid_p.h" | |
11 | #include <QGraphicsScene> |
|
11 | #include <QGraphicsScene> | |
12 | #include <QDebug> |
|
12 | #include <QDebug> | |
13 |
|
13 | |||
14 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
14 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
15 |
|
15 | |||
16 | class QChartPrivate |
|
|||
17 | { |
|
|||
18 | public: |
|
|||
19 |
|
||||
20 | QChartPrivate(QChart* parent): |
|
|||
21 | m_axisX(new Axis(parent)), |
|
|||
22 | m_axisY(new Axis(parent)), |
|
|||
23 | m_grid(new XYGrid(parent)), |
|
|||
24 | m_plotDataIndex(0), |
|
|||
25 | m_marginSize(0){} |
|
|||
26 |
|
||||
27 | Axis* m_axisX; |
|
|||
28 | Axis* m_axisY; |
|
|||
29 | XYGrid* m_grid; |
|
|||
30 | QRect m_rect; |
|
|||
31 | QList<const QChartSeries*> m_series; |
|
|||
32 | QList<XYPlotDomain> m_plotDomainList; |
|
|||
33 | QList<XYLineChartItem*> m_xyLineChartItems; |
|
|||
34 | QList<QGraphicsItem*> m_items; |
|
|||
35 | int m_plotDataIndex; |
|
|||
36 | int m_marginSize; |
|
|||
37 |
|
||||
38 | }; |
|
|||
39 |
|
||||
40 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|||
41 |
|
||||
42 | QChart::QChart(QGraphicsObject* parent) : QGraphicsObject(parent), |
|
16 | QChart::QChart(QGraphicsObject* parent) : QGraphicsObject(parent), | |
43 | d(new QChartPrivate(this)) |
|
17 | m_axisX(new Axis(this)), | |
|
18 | m_axisY(new Axis(this)), | |||
|
19 | m_grid(new XYGrid(this)), | |||
|
20 | m_plotDataIndex(0), | |||
|
21 | m_marginSize(0) | |||
44 | { |
|
22 | { | |
45 | // setFlags(QGraphicsItem::ItemClipsChildrenToShape); |
|
23 | // setFlags(QGraphicsItem::ItemClipsChildrenToShape); | |
46 | // set axis |
|
24 | // set axis | |
47 |
|
|
25 | m_axisY->rotate(90); | |
48 | } |
|
26 | } | |
49 |
|
27 | |||
50 | QChart::~QChart(){} |
|
28 | QChart::~QChart(){} | |
51 |
|
29 | |||
52 | QRectF QChart::boundingRect() const |
|
30 | QRectF QChart::boundingRect() const | |
53 | { |
|
31 | { | |
54 |
return |
|
32 | return m_rect; | |
55 | } |
|
33 | } | |
56 |
|
34 | |||
57 | void QChart::addSeries(QChartSeries* series) |
|
35 | void QChart::addSeries(QChartSeries* series) | |
58 | { |
|
36 | { | |
59 | // TODO: we should check the series not already added |
|
37 | // TODO: we should check the series not already added | |
60 |
|
38 | |||
61 |
|
|
39 | m_series<<series; | |
62 |
|
40 | |||
63 | switch(series->type()) |
|
41 | switch(series->type()) | |
64 | { |
|
42 | { | |
65 | case QChartSeries::SeriesTypeLine: { |
|
43 | case QChartSeries::SeriesTypeLine: { | |
66 |
|
44 | |||
67 | QXYChartSeries* xyseries = static_cast<QXYChartSeries*>(series); |
|
45 | QXYChartSeries* xyseries = static_cast<QXYChartSeries*>(series); | |
68 |
|
46 | |||
69 | XYPlotDomain domain; |
|
47 | XYPlotDomain domain; | |
70 | //TODO "nice numbers algorithm" |
|
48 | //TODO "nice numbers algorithm" | |
71 | domain.m_ticksX=4; |
|
49 | domain.m_ticksX=4; | |
72 | domain.m_ticksY=4; |
|
50 | domain.m_ticksY=4; | |
73 |
|
51 | |||
74 | for (int i = 0 ; i < xyseries->count() ; i++) |
|
52 | for (int i = 0 ; i < xyseries->count() ; i++) | |
75 | { |
|
53 | { | |
76 | qreal x = xyseries->x(i); |
|
54 | qreal x = xyseries->x(i); | |
77 | qreal y = xyseries->y(i); |
|
55 | qreal y = xyseries->y(i); | |
78 | domain.m_minX = qMin(domain.m_minX,x); |
|
56 | domain.m_minX = qMin(domain.m_minX,x); | |
79 | domain.m_minY = qMin(domain.m_minY,y); |
|
57 | domain.m_minY = qMin(domain.m_minY,y); | |
80 | domain.m_maxX = qMax(domain.m_maxX,x); |
|
58 | domain.m_maxX = qMax(domain.m_maxX,x); | |
81 | domain.m_maxY = qMax(domain.m_maxY,y); |
|
59 | domain.m_maxY = qMax(domain.m_maxY,y); | |
82 | } |
|
60 | } | |
83 |
|
61 | |||
84 | XYLineChartItem* item = new XYLineChartItem(xyseries,this); |
|
62 | XYLineChartItem* item = new XYLineChartItem(xyseries,this); | |
85 | item->updateXYPlotDomain(domain); |
|
63 | item->updateXYPlotDomain(domain); | |
86 |
|
|
64 | m_plotDomainList<<domain; | |
87 |
|
|
65 | m_xyLineChartItems<<item; | |
88 | break; |
|
66 | break; | |
89 | } |
|
67 | } | |
90 | // TODO: Not tested: |
|
68 | // TODO: Not tested: | |
91 | // case QChartSeries::SeriesTypeScatter: { |
|
69 | // case QChartSeries::SeriesTypeScatter: { | |
92 | // QScatterSeries *scatter = qobject_cast<QScatterSeries *>(series); |
|
70 | // QScatterSeries *scatter = qobject_cast<QScatterSeries *>(series); | |
93 | // if (scatter) { |
|
71 | // if (scatter) { | |
94 | // scatter->d->setParentItem(this); |
|
72 | // scatter->d->setParentItem(this); | |
95 | // scene()->addItem(scatter->d); |
|
73 | // scene()->addItem(scatter->d); | |
96 | // } |
|
74 | // } | |
97 | // break; |
|
75 | // break; | |
98 | // } |
|
76 | // } | |
99 | } |
|
77 | } | |
100 | } |
|
78 | } | |
101 |
|
79 | |||
102 | QChartSeries* QChart::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type) |
|
80 | QChartSeries* QChart::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type) | |
103 | { |
|
81 | { | |
104 | // TODO: support also other types; not only scatter and pie |
|
82 | // TODO: support also other types; not only scatter and pie | |
105 | Q_ASSERT(type == QChartSeries::SeriesTypeScatter |
|
83 | Q_ASSERT(type == QChartSeries::SeriesTypeScatter | |
106 | || type == QChartSeries::SeriesTypePie); |
|
84 | || type == QChartSeries::SeriesTypePie); | |
107 |
|
85 | |||
108 | switch (type) { |
|
86 | switch (type) { | |
109 | case QChartSeries::SeriesTypeScatter: { |
|
87 | case QChartSeries::SeriesTypeScatter: { | |
110 | QScatterSeries *scatterSeries = new QScatterSeries(x, y, this); |
|
88 | QScatterSeries *scatterSeries = new QScatterSeries(x, y, this); | |
111 | connect(this, SIGNAL(sizeChanged(QRectF, qreal, qreal)), |
|
89 | connect(this, SIGNAL(sizeChanged(QRectF, qreal, qreal)), | |
112 | scatterSeries, SLOT(chartSizeChanged(QRectF, qreal, qreal))); |
|
90 | scatterSeries, SLOT(chartSizeChanged(QRectF, qreal, qreal))); | |
113 | scatterSeries->d->setParentItem(this); |
|
91 | scatterSeries->d->setParentItem(this); | |
114 | return scatterSeries; |
|
92 | return scatterSeries; | |
115 | } |
|
93 | } | |
116 | case QChartSeries::SeriesTypePie: { |
|
94 | case QChartSeries::SeriesTypePie: { | |
117 | // TODO: we now have also a list of y values as a parameter, it is ignored |
|
95 | // TODO: we now have also a list of y values as a parameter, it is ignored | |
118 | // we should use a generic data class instead of list of x and y values |
|
96 | // we should use a generic data class instead of list of x and y values | |
119 | QPieSeries *pieSeries = new QPieSeries(x, this); |
|
97 | QPieSeries *pieSeries = new QPieSeries(x, this); | |
120 | connect(this, SIGNAL(sizeChanged(QRectF, qreal, qreal)), |
|
98 | connect(this, SIGNAL(sizeChanged(QRectF, qreal, qreal)), | |
121 | pieSeries, SLOT(chartSizeChanged(QRectF, qreal, qreal))); |
|
99 | pieSeries, SLOT(chartSizeChanged(QRectF, qreal, qreal))); | |
122 | return pieSeries; |
|
100 | return pieSeries; | |
123 | } |
|
101 | } | |
124 | default: |
|
102 | default: | |
125 | break; |
|
103 | break; | |
126 | } |
|
104 | } | |
127 |
|
105 | |||
128 | return 0; |
|
106 | return 0; | |
129 | } |
|
107 | } | |
130 |
|
108 | |||
131 | void QChart::setSize(const QSizeF& size) |
|
109 | void QChart::setSize(const QSizeF& size) | |
132 | { |
|
110 | { | |
133 |
|
|
111 | m_rect = QRect(QPoint(0,0),size.toSize()); | |
134 |
|
|
112 | m_rect.adjust(margin(),margin(), -margin(), -margin()); | |
135 |
|
|
113 | m_grid->setPos(m_rect.topLeft()); | |
136 |
|
|
114 | m_grid->setSize(m_rect.size()); | |
137 |
|
115 | |||
138 | // TODO: calculate the scale |
|
116 | // TODO: calculate the scale | |
139 | // TODO: calculate the origo |
|
117 | // TODO: calculate the origo | |
140 | // TODO: not sure if emitting a signal here is the best from performance point of view |
|
118 | // TODO: not sure if emitting a signal here is the best from performance point of view | |
141 | const qreal xscale = size.width() / 100; |
|
119 | const qreal xscale = size.width() / 100; | |
142 | const qreal yscale = size.height() / 100; |
|
120 | const qreal yscale = size.height() / 100; | |
143 | emit sizeChanged(QRectF(0, 0, size.width(), size.height()), xscale, yscale); |
|
121 | emit sizeChanged(QRectF(0, 0, size.width(), size.height()), xscale, yscale); | |
144 |
|
122 | |||
145 |
for (int i(0); i < |
|
123 | for (int i(0); i < m_plotDomainList.size(); i++) | |
146 |
|
|
124 | m_plotDomainList[i].m_viewportRect = m_rect; | |
147 |
|
125 | |||
148 | // TODO: line chart items are updated separately as they don't support update |
|
126 | // TODO: line chart items are updated separately as they don't support update | |
149 | // via sizeChanged signal |
|
127 | // via sizeChanged signal | |
150 |
foreach(XYLineChartItem* item , |
|
128 | foreach(XYLineChartItem* item ,m_xyLineChartItems) | |
151 |
item->updateXYPlotDomain( |
|
129 | item->updateXYPlotDomain(m_plotDomainList.at(m_plotDataIndex)); | |
|
130 | ||||
|
131 | ||||
|
132 | if (m_plotDomainList.count()) | |||
|
133 | m_grid->setXYPlotData(m_plotDomainList.at(m_plotDataIndex)); | |||
152 |
|
134 | |||
153 | if (d->m_plotDomainList.count()) |
|
|||
154 | d->m_grid->setXYPlotData(d->m_plotDomainList.at(d->m_plotDataIndex)); |
|
|||
155 | update(); |
|
135 | update(); | |
156 | } |
|
136 | } | |
157 |
|
137 | |||
158 | int QChart::margin() const |
|
138 | int QChart::margin() const | |
159 | { |
|
139 | { | |
160 |
return |
|
140 | return m_marginSize; | |
161 | } |
|
141 | } | |
162 |
|
142 | |||
163 | void QChart::setMargin(int margin) |
|
143 | void QChart::setMargin(int margin) | |
164 | { |
|
144 | { | |
165 |
|
|
145 | m_marginSize = margin; | |
166 | } |
|
146 | } | |
167 |
|
147 | |||
168 | #include "moc_qchart.cpp" |
|
148 | #include "moc_qchart.cpp" | |
169 |
|
149 | |||
170 |
|
150 | |||
171 | QTCOMMERCIALCHART_END_NAMESPACE |
|
151 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,55 +1,63 | |||||
1 | #ifndef CHART_H |
|
1 | #ifndef CHART_H | |
2 | #define CHART_H |
|
2 | #define CHART_H | |
3 |
|
3 | |||
4 | #include <qchartglobal.h> |
|
4 | #include <qchartglobal.h> | |
5 | #include <qchartseries.h> |
|
5 | #include <qchartseries.h> | |
6 | #include <QGraphicsObject> |
|
6 | #include <QGraphicsObject> | |
7 |
|
7 | |||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
9 | |||
10 | class Axis; |
|
10 | class Axis; | |
11 | class XYGrid; |
|
11 | class XYGrid; | |
12 | class QChartSeries; |
|
12 | class QChartSeries; | |
13 | class XYPlotDomain; |
|
13 | class XYPlotDomain; | |
14 |
class |
|
14 | class XYLineChartItem; | |
15 |
|
15 | |||
16 | // TODO: We don't need to have QChart tied to QGraphicsItem: |
|
16 | // TODO: We don't need to have QChart tied to QGraphicsItem: | |
17 | //class QTCOMMERCIALCHART_EXPORT QChart |
|
17 | //class QTCOMMERCIALCHART_EXPORT QChart | |
18 | //class QTCOMMERCIALCHART_EXPORT QChartGraphicsItem : public QGraphicsItem { |
|
18 | //class QTCOMMERCIALCHART_EXPORT QChartGraphicsItem : public QGraphicsItem { | |
19 | // public: QChartGraphicsItem(QChart &chart); |
|
19 | // public: QChartGraphicsItem(QChart &chart); | |
20 |
|
20 | |||
21 | /*! |
|
21 | /*! | |
22 | * TODO: define the responsibilities |
|
22 | * TODO: define the responsibilities | |
23 | */ |
|
23 | */ | |
24 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsObject |
|
24 | class QTCOMMERCIALCHART_EXPORT QChart : public QGraphicsObject | |
25 | { |
|
25 | { | |
26 | Q_OBJECT |
|
26 | Q_OBJECT | |
27 | public: |
|
27 | public: | |
28 | QChart(QGraphicsObject* parent = 0); |
|
28 | QChart(QGraphicsObject* parent = 0); | |
29 | ~QChart(); |
|
29 | ~QChart(); | |
30 |
|
30 | |||
31 | //from QGraphicsItem |
|
31 | //from QGraphicsItem | |
32 | QRectF boundingRect() const; |
|
32 | QRectF boundingRect() const; | |
33 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){}; |
|
33 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){}; | |
34 |
|
34 | |||
35 | void addSeries(QChartSeries* series); |
|
35 | void addSeries(QChartSeries* series); | |
36 | //TODO: QChartSeries* createSeries(QSeriesData *data, QChartSeries::QChartSeriesType type); |
|
36 | //TODO: QChartSeries* createSeries(QSeriesData *data, QChartSeries::QChartSeriesType type); | |
37 | // TODO: who owns the series now? maybe owned by chart and returned a reference instead... |
|
37 | // TODO: who owns the series now? maybe owned by chart and returned a reference instead... | |
38 | QChartSeries* createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type); |
|
38 | QChartSeries* createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type); | |
39 |
|
39 | |||
40 | virtual void setSize(const QSizeF& rect); |
|
40 | virtual void setSize(const QSizeF& rect); | |
41 | void setMargin(int margin); |
|
41 | void setMargin(int margin); | |
42 | int margin() const; |
|
42 | int margin() const; | |
43 |
|
43 | |||
44 | signals: |
|
44 | signals: | |
45 | void sizeChanged(QRectF rect, qreal xscale, qreal yscale); |
|
45 | void sizeChanged(QRectF rect, qreal xscale, qreal yscale); | |
46 |
|
46 | |||
47 | private: |
|
47 | private: | |
48 | // Q_DECLARE_PRIVATE(QChart) |
|
|||
49 | Q_DISABLE_COPY(QChart) |
|
48 | Q_DISABLE_COPY(QChart) | |
50 | QChartPrivate *d; |
|
49 | Axis* m_axisX; | |
|
50 | Axis* m_axisY; | |||
|
51 | XYGrid* m_grid; | |||
|
52 | QRect m_rect; | |||
|
53 | QList<const QChartSeries*> m_series; | |||
|
54 | QList<XYPlotDomain> m_plotDomainList; | |||
|
55 | QList<XYLineChartItem*> m_xyLineChartItems; | |||
|
56 | QList<QGraphicsItem*> m_items; | |||
|
57 | int m_plotDataIndex; | |||
|
58 | int m_marginSize; | |||
51 | }; |
|
59 | }; | |
52 |
|
60 | |||
53 | QTCOMMERCIALCHART_END_NAMESPACE |
|
61 | QTCOMMERCIALCHART_END_NAMESPACE | |
54 |
|
62 | |||
55 | #endif |
|
63 | #endif |
@@ -1,77 +1,51 | |||||
1 | #include "qchartwidget.h" |
|
1 | #include "qchartwidget.h" | |
2 | #include "qchartseries.h" |
|
2 | #include "qchartseries.h" | |
3 | #include <QGraphicsView> |
|
3 | #include <QGraphicsView> | |
4 | #include <QGraphicsScene> |
|
4 | #include <QGraphicsScene> | |
5 | #include <QResizeEvent> |
|
5 | #include <QResizeEvent> | |
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
8 |
|
8 | |||
9 | class QChartWidgetPrivate |
|
9 | QChartWidget::QChartWidget(QWidget *parent) : | |
10 | { |
|
10 | QWidget(parent) | |
11 | public: |
|
|||
12 | QChartWidgetPrivate(QChartWidget *parent) : |
|
|||
13 | m_view(0), |
|
|||
14 | m_scene(0), |
|
|||
15 | m_chart(0) |
|
|||
16 | { |
|
11 | { | |
|
12 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |||
17 |
|
|
13 | m_scene = new QGraphicsScene(); | |
18 |
|
|
14 | m_view = new QGraphicsView(parent); | |
19 |
|
|
15 | m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
20 | m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
|||
21 |
|
|
16 | m_view->setScene(m_scene); | |
22 |
|
|
17 | m_chart = new QChart(); | |
23 |
|
|
18 | m_scene->addItem(m_chart); | |
24 |
|
|
19 | m_view->show(); | |
25 | } |
|
20 | } | |
26 |
|
21 | |||
27 | ~QChartWidgetPrivate() { |
|
|||
28 | } |
|
|||
29 |
|
||||
30 | QGraphicsView *m_view; |
|
|||
31 | QGraphicsScene *m_scene; |
|
|||
32 | QChart* m_chart; |
|
|||
33 | }; |
|
|||
34 |
|
||||
35 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|||
36 |
|
||||
37 | QChartWidget::QChartWidget(QWidget *parent) : |
|
|||
38 | QWidget(parent), |
|
|||
39 | d_ptr(new QChartWidgetPrivate(this)) |
|
|||
40 | { |
|
|||
41 | setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
|||
42 | } |
|
|||
43 |
|
||||
44 | QChartWidget::~QChartWidget() |
|
22 | QChartWidget::~QChartWidget() | |
45 | { |
|
23 | { | |
46 | delete d_ptr; |
|
|||
47 | } |
|
24 | } | |
48 |
|
25 | |||
49 | void QChartWidget::resizeEvent(QResizeEvent *event) |
|
26 | void QChartWidget::resizeEvent(QResizeEvent *event) | |
50 | { |
|
27 | { | |
51 | Q_D(QChartWidget); |
|
28 | m_view->resize(size().width(),size().height()); | |
52 |
|
|
29 | m_scene->setSceneRect(0,0,size().width(),size().height()); | |
53 | d->m_scene->setSceneRect(0,0,size().width(),size().height()); |
|
30 | m_chart->setSize(size()); | |
54 | d->m_chart->setSize(size()); |
|
|||
55 | QWidget::resizeEvent(event); |
|
31 | QWidget::resizeEvent(event); | |
56 | } |
|
32 | } | |
57 |
|
33 | |||
58 | QSize QChartWidget::sizeHint() const |
|
34 | QSize QChartWidget::sizeHint() const | |
59 | { |
|
35 | { | |
60 | // TODO: calculate size hint based on contents? |
|
36 | // TODO: calculate size hint based on contents? | |
61 | return QSize(100, 100); |
|
37 | return QSize(100, 100); | |
62 | } |
|
38 | } | |
63 |
|
39 | |||
64 | void QChartWidget::addSeries(QChartSeries* series) |
|
40 | void QChartWidget::addSeries(QChartSeries* series) | |
65 | { |
|
41 | { | |
66 | Q_D(QChartWidget); |
|
42 | m_chart->addSeries(series); | |
67 | d->m_chart->addSeries(series); |
|
|||
68 | } |
|
43 | } | |
69 |
|
44 | |||
70 | QChartSeries* QChartWidget::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type) |
|
45 | QChartSeries* QChartWidget::createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type) | |
71 | { |
|
46 | { | |
72 | Q_D(QChartWidget); |
|
47 | return m_chart->createSeries(x, y, type); | |
73 | return d->m_chart->createSeries(x, y, type); |
|
|||
74 | } |
|
48 | } | |
75 | #include "moc_qchartwidget.cpp" |
|
49 | #include "moc_qchartwidget.cpp" | |
76 |
|
50 | |||
77 | QTCOMMERCIALCHART_END_NAMESPACE |
|
51 | QTCOMMERCIALCHART_END_NAMESPACE |
@@ -1,38 +1,41 | |||||
1 | #ifndef QCHARTWIDGET_H |
|
1 | #ifndef QCHARTWIDGET_H | |
2 | #define QCHARTWIDGET_H |
|
2 | #define QCHARTWIDGET_H | |
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include "qchart.h" |
|
5 | #include "qchart.h" | |
6 | #include <QWidget> |
|
6 | #include <QWidget> | |
7 |
|
7 | |||
|
8 | class QGraphicsView; | |||
|
9 | class QGraphicsScene; | |||
|
10 | ||||
8 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
11 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
9 |
|
12 | |||
10 | class QChartSeries; |
|
13 | class QChartSeries; | |
11 | class QChartWidgetPrivate; |
|
14 | class QChartWidgetPrivate; | |
12 |
|
15 | |||
13 | class QTCOMMERCIALCHART_EXPORT QChartWidget : public QWidget |
|
16 | class QTCOMMERCIALCHART_EXPORT QChartWidget : public QWidget | |
14 | { |
|
17 | { | |
15 | Q_OBJECT |
|
18 | Q_OBJECT | |
16 | public: |
|
19 | public: | |
17 | explicit QChartWidget(QWidget *parent = 0); |
|
20 | explicit QChartWidget(QWidget *parent = 0); | |
18 | ~QChartWidget(); |
|
21 | ~QChartWidget(); | |
19 |
|
22 | |||
20 | //implement from QWidget |
|
23 | //implement from QWidget | |
21 | void resizeEvent(QResizeEvent *event); |
|
24 | void resizeEvent(QResizeEvent *event); | |
22 | QSize sizeHint() const; |
|
25 | QSize sizeHint() const; | |
23 |
|
26 | |||
24 | // TODO: addSeries and createSeries are optional solutions |
|
27 | // TODO: addSeries and createSeries are optional solutions | |
25 | void addSeries(QChartSeries* series); |
|
28 | void addSeries(QChartSeries* series); | |
26 | QChartSeries* createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type); |
|
29 | QChartSeries* createSeries(QList<qreal> x, QList<qreal> y, QChartSeries::QChartSeriesType type); | |
27 | protected: |
|
|||
28 | QChartWidgetPrivate * const d_ptr; |
|
|||
29 |
|
30 | |||
30 | private: |
|
31 | private: | |
31 | Q_DISABLE_COPY(QChartWidget) |
|
32 | Q_DISABLE_COPY(QChartWidget) | |
32 | Q_DECLARE_PRIVATE(QChartWidget) |
|
33 | QGraphicsView *m_view; | |
|
34 | QGraphicsScene *m_scene; | |||
|
35 | QChart* m_chart; | |||
33 |
|
36 | |||
34 | }; |
|
37 | }; | |
35 |
|
38 | |||
36 | QTCOMMERCIALCHART_END_NAMESPACE |
|
39 | QTCOMMERCIALCHART_END_NAMESPACE | |
37 |
|
40 | |||
38 | #endif // QCHARTWIDGET_H |
|
41 | #endif // QCHARTWIDGET_H |
General Comments 0
You need to be logged in to leave comments.
Login now