##// END OF EJS Templates
Refactor current draft to fit int current design specs...
Michal Klocek -
r21:f4dbcb0551ab
parent child
Show More
@@ -0,0 +1,69
1 #include "xylinechartitem_p.h"
2 #include "axis_p.h"
3 #include "xygrid_p.h"
4 #include "qxychartseries.h"
5 #include <QPainter>
6 #include <QStyleOptionGraphicsItem>
7 #include <QDebug>
8
9 QCHART_BEGIN_NAMESPACE
10
11 XYLineChartItem::XYLineChartItem(QXYChartSeries* series,QGraphicsItem *parent):QGraphicsItem(parent),
12 m_series(series),
13 m_dirtyGeometry(true)
14 {
15
16 }
17
18 void XYLineChartItem::setChartSize(const QRectF& rect)
19 {
20 m_rect = rect;
21 m_dirtyGeometry = true;
22 }
23
24 void XYLineChartItem::setXYPlotData(const XYPlotData& data){
25 m_xyPlotData=data;
26 m_dirtyGeometry = true;
27 }
28
29 QRectF XYLineChartItem::boundingRect() const
30 {
31 return m_polyline.boundingRect();
32 }
33
34
35 void XYLineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
36 {
37 if(m_dirtyGeometry) {
38
39 m_dirtyGeometry=false;
40
41 if (!m_rect.isValid())
42 return;
43
44 painter->setClipRect(m_rect.adjusted(+1, +1, -1, -1));
45
46 const qreal deltaX = (m_rect.width()-1)/m_xyPlotData.spanX();
47 const qreal deltaY = (m_rect.height()-1)/m_xyPlotData.spanY();
48
49 m_polyline.clear();
50 m_polyline.resize(m_series->count());
51
52 for (int j = 0; j < m_series->count(); ++j) {
53 qreal dx = m_series->x(j) - m_xyPlotData.m_minX;
54 qreal dy = m_series->y(j) - m_xyPlotData.m_minY;
55 qreal x = (dx * deltaX) + m_rect.left();
56 qreal y = - (dy * deltaY) + m_rect.bottom();
57 m_polyline[j] = QPointF(x, y);
58 }
59 painter->setPen(m_series->color());
60 painter->drawPolyline(m_polyline);
61 }
62
63 painter->setClipRect(m_rect.adjusted(+1, +1, -1, -1));
64 painter->setPen(m_series->color());
65 painter->drawPolyline(m_polyline);
66
67 }
68
69 QCHART_END_NAMESPACE
@@ -0,0 +1,37
1 #ifndef XYLINECHARTITEM_H
2 #define XYLINECHARTITEM_H
3
4 #include "qchartconfig.h"
5 #include "qchart.h"
6 #include "xyplotdata_p.h"
7
8 QCHART_BEGIN_NAMESPACE
9
10 class QXYChartSeries;
11
12 class XYLineChartItem : public QGraphicsItem
13 {
14
15 public:
16 XYLineChartItem(QXYChartSeries* m_series,QGraphicsItem *parent = 0);
17 virtual ~ XYLineChartItem(){};
18
19 //from QGraphicsItem
20 virtual QRectF boundingRect() const;
21 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
22
23 //TODO: this is just temporary interface
24 void setChartSize(const QRectF& size);
25 void setXYPlotData(const XYPlotData& data);
26
27 private:
28 QRectF m_rect;
29 QPolygonF m_polyline;
30 QXYChartSeries* m_series;
31 XYPlotData m_xyPlotData;
32 bool m_dirtyGeometry;
33 };
34
35 QCHART_END_NAMESPACE
36
37 #endif
@@ -5,5 +5,4 QT += core gui
5 5
6 6 CONFIG += charts
7 7
8 HEADERS += chartview.h
9 SOURCES += main.cpp chartview.cpp
8 SOURCES += main.cpp
@@ -1,6 +1,7
1 1 #include <QApplication>
2 2 #include <QMainWindow>
3 3 #include <qchartwidget.h>
4 #include <qxychartseries.h>
4 5 #include <qchart.h>
5 6 #include "chartview.h"
6 7 #include <cmath>
@@ -15,13 +16,13 int main(int argc, char *argv[])
15 16
16 17 QMainWindow window;
17 18
18 QXYSeries* series0 = new QXYSeries();
19 QXYChartSeries* series0 = QXYChartSeries::create();
19 20 series0->setColor(Qt::blue);
20 QXYSeries* series1 = new QXYSeries();
21 QXYChartSeries* series1 = QXYChartSeries::create();
21 22 series1->setColor(Qt::red);
22 QXYSeries* series2 = new QXYSeries();
23 QXYChartSeries* series2 = QXYChartSeries::create();
23 24 series2->setColor(Qt::gray);
24 QXYSeries* series3 = new QXYSeries();
25 QXYChartSeries* series3 = QXYChartSeries::create();
25 26 series3->setColor(Qt::green);
26 27
27 28 int numPoints = 100;
@@ -33,23 +34,21 int main(int argc, char *argv[])
33 34 series3->add(x,100);
34 35 }
35 36
36 QList<QXYSeries*> dataset;
37 QList<QXYChartSeries*> dataset;
37 38
38 qDebug()<<"Series 1:" << *series1;
39 qDebug()<<"Series 2:" << *series2;
39 //qDebug()<<"Series 1:" << *series1;
40 //qDebug()<<"Series 2:" << *series2;
40 41
41 42 dataset << series0;
42 43 dataset << series1;
43 44 dataset << series2;
44 45 dataset << series3;
45 46
46 QChart* chart = QChart::createXYLineChart(dataset);
47 chart->setMargin(50);
48 QChartWidget* chartWidget = new QChartWidget();
49 chartWidget->addChart(chart);
47 QChartWidget* chartWidget = new QChartWidget(&window);
48 chartWidget->addSeries(series1);
49 chartWidget->addSeries(series2);
50 50
51 ChartView* view = new ChartView(chartWidget,&window);
52 window.setCentralWidget(view);
51 window.setCentralWidget(chartWidget);
53 52 window.resize(400, 300);
54 53 window.show();
55 54
@@ -1,24 +1,70
1 1 #include "qchart.h"
2 #include "xylinechart_p.h"
2 #include "qchartseries.h"
3 #include "xylinechartitem_p.h"
4 #include "axis_p.h"
5 #include "xygrid_p.h"
6 #include <QDebug>
3 7
4 8 QCHART_BEGIN_NAMESPACE
5 9
6 10 QChart::QChart(QGraphicsItem* parent):QGraphicsItem(parent),
7 m_marginSize(0)
11 m_marginSize(0),
12 m_axisX(new Axis(this)),
13 m_axisY(new Axis(this)),
14 m_grid(new XYGrid(this)),
15 m_plotDataIndex(0)
8 16 {
9 17 // setFlags(QGraphicsItem::ItemClipsChildrenToShape);
18 // set axis
19 m_axisY->rotate(90);
20
21 XYPlotData data;
22 data.m_minX = 0.0;
23 data.m_maxX = 100.0;
24 data.m_minY = 0.0;
25 data.m_maxY = 100.0;
26 data.m_ticksX=4;
27 data.m_ticksY=4;
28
29 m_plotDataList.clear();
30 m_plotDataList << data;
31
32 m_grid->setZValue(10);
33 m_grid->setXYPlotData(m_plotDataList.at(0));
10 34 }
11 35
12 36 QChart::~QChart(){}
13 37
38 QRectF QChart::boundingRect() const
39 {
40 return m_rect;
41 }
14 42
15 QChart* QChart::createXYLineChart(const QList<QXYSeries*>& dataset)
43 void QChart::addSeries(QChartSeries* series)
16 44 {
17 XYLineChart* chart = new XYLineChart();
18 foreach (const QXYSeries* series,dataset) {
19 chart->addXYSeries(series);
45 m_series<<series;
46
47 switch(series->type())
48 {
49 case QChartSeries::LINE:
50 qDebug()<<"xyline added";
51 XYLineChartItem* item = new XYLineChartItem(reinterpret_cast<QXYChartSeries*>(series),this);
52 item->setXYPlotData(m_plotDataList.at(0));
53 m_items<<item;
54 break;
20 55 }
21 return chart;
56 }
57
58 void QChart::setSize(const QSizeF& size) {
59 //TODO refactor to setGeometry
60 m_rect = QRect(QPoint(0,0),size.toSize());
61 m_rect.adjust(margin(),margin(),-margin(),-margin());
62 m_grid->setPos(m_rect.topLeft());
63 m_grid->setSize(m_rect.size());
64 foreach(QGraphicsItem* item , m_items)
65 reinterpret_cast<XYLineChartItem*>(item)->setChartSize(m_rect);
66 update();
67
22 68 }
23 69
24 70 void QChart::setMargin(int margin)
@@ -2,36 +2,42
2 2 #define CHART_H
3 3
4 4 #include <qchartconfig.h>
5 #include <qxyseries.h>
5 //TODO: temporary class
6 #include <xyplotdata_p.h>
6 7 #include <QGraphicsItem>
7 8
8 9 QCHART_BEGIN_NAMESPACE
9 10
11 class Axis;
12 class XYGrid;
13 class QChartSeries;
14
10 15 class QCHART_EXPORT QChart : public QGraphicsItem
11 16 {
12 public:
13 enum DataSeriesType {
14 DataSeriesTypeLine = 0,
15 DataSeriesTypeArea,
16 DataSeriesTypeBar,
17 DataSeriesTypePie,
18 DataSeriesTypeScatter,
19 DataSeriesTypeSpline
20 };
21
22 protected:
23 QChart(QGraphicsItem* parent =0);
24 17
25 18 public:
19 QChart(QGraphicsItem* parent = 0);
26 20 virtual ~QChart();
27 21
28 static QChart* createXYLineChart(const QList<QXYSeries*>& dataset);
22 //from QGraphicsItem
23 virtual QRectF boundingRect() const;
24 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){};
25
26 void addSeries(QChartSeries* series);
29 27
30 virtual void setSize(const QSizeF& rect)=0;
28 virtual void setSize(const QSizeF& rect);
31 29 void setMargin(int margin);
32 30 int margin() const { return m_marginSize;}
33 31
34 32 private:
33 QRect m_rect;
34 QList<const QChartSeries*> m_series;
35 Axis* m_axisX;
36 Axis* m_axisY;
37 XYGrid* m_grid;
38 QList<XYPlotData> m_plotDataList;
39 QList<QGraphicsItem*> m_items;
40 int m_plotDataIndex;
35 41 int m_marginSize;
36 42 };
37 43
@@ -1,51 +1,63
1 1 #include "qchartwidget.h"
2 #include "qxyseries.h"
3 #include "xylinechart_p.h"
2 #include "qchartseries.h"
4 3 #include <QGraphicsView>
5 4 #include <QGraphicsScene>
5 #include <QResizeEvent>
6 6
7 7 QCHART_BEGIN_NAMESPACE
8 8
9 9 class QChartWidgetPrivate
10 10 {
11 11 public:
12 QChartWidgetPrivate(QWidget *parent) : m_view(0), m_scene(0), m_chart(0) {
12 QChartWidgetPrivate(QChartWidget *parent) :
13 m_view(0),
14 m_scene(0),
15 m_chart(0),
16 q_ptr( parent )
17 {
13 18 m_scene = new QGraphicsScene();
14 m_view = new QGraphicsView(m_scene, parent);
15 m_view->resize(490, 300);
16 m_view->show();
19 m_view = new QGraphicsView(parent);
20 m_view->setScene(m_scene);
21 m_chart = new QChart();
22 m_scene->addItem(m_chart);
17 23 }
24
18 25 ~QChartWidgetPrivate() {
19 delete m_view;
20 delete m_scene;
21 26 }
22 27
23 28 QGraphicsView *m_view;
24 29 QGraphicsScene *m_scene;
25 30 QChart* m_chart;
31 QChartWidget * const q_ptr;
32 Q_DECLARE_PUBLIC(QChartWidget);
26 33 };
27 34
28 35 QChartWidget::QChartWidget(QWidget *parent) :
29 36 QWidget(parent),
30 d(new QChartWidgetPrivate(this))
37 d_ptr(new QChartWidgetPrivate(this))
31 38 {
32 setMinimumSize(d->m_view->size());
39
33 40 }
34 41
35 42 QChartWidget::~QChartWidget()
36 43 {
37 delete d;
44 delete d_ptr;
38 45 }
39 46
40 void QChartWidget::addDataSeries(
41 QChart::DataSeriesType dataSeriesType,
42 QList<QXYSeries*> dataset)
47 void QChartWidget::resizeEvent(QResizeEvent *event)
43 48 {
44 // TODO: implement management of several data series of different types
49 Q_D(QChartWidget);
50 d->m_view->resize(size().width(),size().height());
51 d->m_scene->setSceneRect(0,0,size().width(),size().height());
52 d->m_chart->setSize(size());
53 QWidget::resizeEvent(event);
54 }
45 55
46 d->m_chart = QChart::createXYLineChart(dataset);
47 d->m_scene->addItem(d->m_chart);
48 d->m_chart->setSize(this->size());
56
57 void QChartWidget::addSeries(QChartSeries* series)
58 {
59 Q_D(QChartWidget);
60 d->m_chart->addSeries(series);
49 61 }
50 62
51 63 #include "moc_qchartwidget.cpp"
@@ -7,7 +7,7
7 7
8 8 QCHART_BEGIN_NAMESPACE
9 9
10 class QXYSeries;
10 class QChartSeries;
11 11 class QChartWidgetPrivate;
12 12
13 13 class QCHART_EXPORT QChartWidget : public QWidget
@@ -16,19 +16,18 class QCHART_EXPORT QChartWidget : public QWidget
16 16 public:
17 17 explicit QChartWidget(QWidget *parent = 0);
18 18 ~QChartWidget();
19 // TODO: replace QXYSeries list with a charts data API
20 // TODO: return QChartDataSeries
21 void addDataSeries(QChart::DataSeriesType dataSeriesType, QList<QXYSeries*> dataset);
22 19
23 signals:
20 //implement from QWidget
21 void resizeEvent(QResizeEvent *event);
24 22
25 public slots:
23 void addSeries(QChartSeries* series);
24 protected:
25 QChartWidgetPrivate * const d_ptr;
26 26
27 27 private:
28 friend class QChartWidgetPrivate;
29 28 Q_DISABLE_COPY(QChartWidget)
30 // Q_DECLARE_PRIVATE(QChartWidget)
31 QChartWidgetPrivate * const d;
29 Q_DECLARE_PRIVATE(QChartWidget)
30
32 31 };
33 32
34 33 QCHART_END_NAMESPACE
@@ -6,9 +6,8 CONFIG += debug_and_release
6 6 CONFIG(debug, debug|release):TARGET = QChartd
7 7
8 8 SOURCES += \
9 xylinechart/qchartgraphicswidget.cpp \
10 xylinechart/qxyseries.cpp \
11 xylinechart/xylinechart.cpp \
9 xylinechart/qxychartseries.cpp \
10 xylinechart/xylinechartitem.cpp \
12 11 xylinechart/xygrid.cpp \
13 12 xylinechart/xyplotdata.cpp \
14 13 qchart.cpp \
@@ -16,16 +15,18 SOURCES += \
16 15 qchartwidget.cpp
17 16
18 17 PRIVATE_HEADERS += \
19 xylinechart/xylinechart_p.h \
18 xylinechart/xylinechartitem_p.h \
20 19 xylinechart/xygrid_p.h \
21 xylinechart/xyplotdata_p.h \
22 20 axis_p.h
21
23 22 PUBLIC_HEADERS += \
24 xylinechart/qxyseries.h \
25 xylinechart/qchartgraphicswidget.h \
23 qchartseries.h \
26 24 qchart.h \
27 25 qchartwidget.h \
28 qchartconfig.h
26 qchartconfig.h \
27 xylinechart/qxychartseries.h \
28 xylinechart/xyplotdata_p.h # to be removed
29
29 30 HEADERS += $$PUBLIC_HEADERS
30 31 HEADERS += $$PRIVATE_HEADERS
31 32
@@ -1,46 +1,51
1 #include "qxyseries.h"
1 #include "qxychartseries.h"
2 2
3 3 QCHART_BEGIN_NAMESPACE
4 4
5 QXYSeries::QXYSeries():
5 QXYChartSeries::QXYChartSeries(QObject* parent):QChartSeries(parent),
6 6 m_color(Qt::black)
7 7 {
8 8 }
9 9
10 QXYSeries::~QXYSeries()
10 QXYChartSeries::~QXYChartSeries()
11 11 {
12 12 }
13 13
14 QXYChartSeries* QXYChartSeries::create(QObject* parent)
15 {
16 //TODO: here we take QChartData when it is ready
17 // return null if malformed;
18 return new QXYChartSeries(parent);
19 }
14 20
15 void QXYSeries::setColor(const QColor& color)
21 void QXYChartSeries::setColor(const QColor& color)
16 22 {
17 23 m_color = color;
18 24 }
19 25
20
21 void QXYSeries::add(qreal x,qreal y)
26 void QXYChartSeries::add(qreal x,qreal y)
22 27 {
23 28 m_x<<x;
24 29 m_y<<y;
25 30 }
26 31
27 void QXYSeries::clear()
32 void QXYChartSeries::clear()
28 33 {
29 34 m_x.clear();
30 35 m_y.clear();
31 36 }
32 37
33 qreal QXYSeries::x(int pos) const
38 qreal QXYChartSeries::x(int pos) const
34 39 {
35 40 return m_x.at(pos);
36 41 }
37 42
38 qreal QXYSeries::y(int pos) const
43 qreal QXYChartSeries::y(int pos) const
39 44 {
40 45 return m_y.at(pos);
41 46 }
42 47
43 int QXYSeries::count() const
48 int QXYChartSeries::count() const
44 49 {
45 50 Q_ASSERT(m_x.size() == m_y.size());
46 51
@@ -48,7 +53,7 int QXYSeries::count() const
48 53
49 54 }
50 55
51 QDebug operator<< (QDebug debug, const QXYSeries series)
56 QDebug operator<< (QDebug debug, const QXYChartSeries series)
52 57 {
53 58 Q_ASSERT(series.m_x.size() == series.m_y.size());
54 59
@@ -2,16 +2,23
2 2 #define QXYSERIES_H_
3 3
4 4 #include "qchartconfig.h"
5 #include "qchartseries.h"
5 6 #include <QDebug>
6 7 #include <QColor>
7 8
8 9 QCHART_BEGIN_NAMESPACE
9 10
10 class QCHART_EXPORT QXYSeries
11 class QCHART_EXPORT QXYChartSeries : public QChartSeries
11 12 {
13 private:
14 QXYChartSeries(QObject* parent=0);
12 15 public:
13 QXYSeries();
14 virtual ~QXYSeries();
16 virtual ~QXYChartSeries();
17
18 //implemented from QChartSeries
19 static QXYChartSeries* create(QObject* parent=0);
20 virtual QChartSeriesType type() const { return QChartSeries::LINE;};
21
15 22 void add(qreal x, qreal y);
16 23 void clear();
17 24 void setColor(const QColor& color);
@@ -19,7 +26,7 public:
19 26 int count() const;
20 27 qreal x(int pos) const;
21 28 qreal y(int pos) const;
22 friend QDebug operator<< (QDebug d, const QXYSeries series);
29 friend QDebug operator<< (QDebug d, const QXYChartSeries series);
23 30
24 31 private:
25 32 QColor m_color;
@@ -1,11 +1,10
1 1 #include "xygrid_p.h"
2 #include "xylinechart_p.h"
3 2 #include <QPainter>
3 #include <QDebug>
4 4
5 5 QCHART_BEGIN_NAMESPACE
6 6
7 XYGrid::XYGrid(const XYLineChart* const chart, QGraphicsItem* parent):QGraphicsItem(parent),
8 m_chart(chart)
7 XYGrid::XYGrid(QGraphicsItem* parent):QGraphicsItem(parent)
9 8 {
10 9 }
11 10
@@ -14,10 +13,15 XYGrid::~XYGrid()
14 13 // TODO Auto-generated destructor stub
15 14 }
16 15
17 void XYGrid::setSize(const QSizeF& size) {
16 void XYGrid::setSize(const QSizeF& size)
17 {
18 18 m_rect.setSize(size.toSize());
19 19 }
20 20
21 void XYGrid::setXYPlotData(const XYPlotData& xyPlotData)
22 {
23 m_xyPlotData = xyPlotData;
24 }
21 25
22 26 QRectF XYGrid::boundingRect() const
23 27 {
@@ -26,42 +30,41 QRectF XYGrid::boundingRect() const
26 30
27 31 void XYGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
28 32 {
29 if (!m_rect.isValid())
30 return;
31 33
32 const XYPlotData& plotData = m_chart->xyPlotData();
34 if (!m_rect.isValid())
35 return;
33 36
34 const qreal deltaX = (m_rect.width() -1) / plotData.ticksX();
35 const qreal deltaY = (m_rect.height() - 1) / plotData.ticksY();
37 const qreal deltaX = (m_rect.width() -1) / m_xyPlotData.ticksX();
38 const qreal deltaY = (m_rect.height() - 1) / m_xyPlotData.ticksY();
36 39
37 for (int i = 0; i <= plotData.ticksX(); ++i) {
40 for (int i = 0; i <= m_xyPlotData.ticksX(); ++i) {
38 41
39 int x = i * deltaX + m_rect.left();
40 qreal label = plotData.m_minX + (i * plotData.spanX()
41 / plotData.ticksX());
42 painter->drawLine(x, m_rect.top()+1, x, m_rect.bottom());
43 //painter->drawLine(x, m_rect.bottom(), x, m_rect.bottom() + 5);
42 int x = i * deltaX + m_rect.left();
43 qreal label = m_xyPlotData.m_minX + (i * m_xyPlotData.spanX()
44 / m_xyPlotData.ticksX());
45 painter->drawLine(x, m_rect.top()+1, x, m_rect.bottom());
46 //painter->drawLine(x, m_rect.bottom(), x, m_rect.bottom() + 5);
44 47
45 painter->drawText(x - 50, m_rect.bottom() + 5, 100, 20,
46 Qt::AlignHCenter | Qt::AlignTop,
47 QString::number(label));
48 }
48 painter->drawText(x - 50, m_rect.bottom() + 5, 100, 20,
49 Qt::AlignHCenter | Qt::AlignTop,
50 QString::number(label));
51 }
49 52
50 for (int j = 0; j <= plotData.ticksY(); ++j) {
53 for (int j = 0; j <= m_xyPlotData.ticksY(); ++j) {
51 54
52 int y = j * -deltaY + m_rect.bottom();
53 qreal label = plotData.m_minY + (j * plotData.spanY()
54 / plotData.ticksY());
55 int y = j * -deltaY + m_rect.bottom();
56 qreal label = m_xyPlotData.m_minY + (j * m_xyPlotData.spanY()
57 / m_xyPlotData.ticksY());
55 58
56 painter->drawLine(m_rect.left(), y, m_rect.right()-1, y);
57 //painter->drawLine(m_rect.left() - 5, y, m_rect.left(), y);
58 //TODO : margin = 50 ;
59 painter->drawText(m_rect.left() - 50, y - 10, 50 - 5, 20,
60 Qt::AlignRight | Qt::AlignVCenter,
61 QString::number(label));
62 }
59 painter->drawLine(m_rect.left(), y, m_rect.right()-1, y);
60 //painter->drawLine(m_rect.left() - 5, y, m_rect.left(), y);
61 //TODO : margin = 50 ;
62 painter->drawText(m_rect.left() - 50, y - 10, 50 - 5, 20,
63 Qt::AlignRight | Qt::AlignVCenter,
64 QString::number(label));
65 }
63 66
64 //painter->drawRect(m_rect.adjusted(0, 0, -1, -1));
67 //painter->drawRect(m_rect.adjusted(0, 0, -1, -1));
65 68 }
66 69
67 70 QCHART_END_NAMESPACE
@@ -2,28 +2,28
2 2 #define XYGRID_H_
3 3
4 4 #include <qchartconfig.h>
5 #include <xyplotdata_p.h>
5 6 #include <QGraphicsItem>
6 7
7 8 QCHART_BEGIN_NAMESPACE
8 9
9 class XYPlotData;
10 class XYLineChart;
11
12 10 class XYGrid : public QGraphicsItem
13 11 {
14 12 public:
15 XYGrid(const XYLineChart* const chart,QGraphicsItem* parent = 0);
13 XYGrid(QGraphicsItem* parent = 0);
16 14 virtual ~XYGrid();
17 15
18 16 //from QGraphicsItem
19 17 virtual QRectF boundingRect() const;
20 18 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
21 19
20 //TODO: this is just temporary interface
21 void setXYPlotData(const XYPlotData& xyPlotData);
22 22 void setSize(const QSizeF& rect);
23 23
24 24 private:
25 25 QRectF m_rect;
26 const XYLineChart* const m_chart;
26 XYPlotData m_xyPlotData;
27 27 };
28 28
29 29 QCHART_END_NAMESPACE
@@ -100,7 +100,7 void MainWidget::addSeries(QString series, QString data)
100 100 {
101 101 qDebug() << "addSeries: " << series << " data: " << data;
102 102
103 QXYSeries* series0 = new QXYSeries();
103 QXYChartSeries* series0 = new QXYChartSeries();
104 104
105 105 if (data == "linear") {
106 106 // TODO
@@ -108,7 +108,7 void MainWidget::addSeries(QString series, QString data)
108 108 series0->setColor(Qt::blue);
109 109 for (int x = 0; x < 100; x++)
110 110 series0->add(x, abs(sin(3.14159265358979 / 50 * x) * 100));
111 QList<QXYSeries*> dataset;
111 QList<QXYChartSeries*> dataset;
112 112 dataset << series0;
113 113 } else if (data == "SIN + random") {
114 114 series0->setColor(Qt::blue);
@@ -120,7 +120,7 void MainWidget::addSeries(QString series, QString data)
120 120 // TODO: check if data has a valid file name
121 121 }
122 122
123 QList<QXYSeries*> dataset;
123 QList<QXYChartSeries*> dataset;
124 124 dataset << series0;
125 125
126 126 if (series == "Scatter") {
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now