##// END OF EJS Templates
Refactor xyplotdata...
Michal Klocek -
r25:9ee7e26e06fe
parent child
Show More
@@ -1,77 +1,78
1 #include "qchart.h"
1 #include "qchart.h"
2 #include "qchartseries.h"
2 #include "qchartseries.h"
3 #include "xylinechartitem_p.h"
3 #include "xylinechartitem_p.h"
4 #include "xyplotdata_p.h"
4 #include "xyplotdomain_p.h"
5 #include "axis_p.h"
5 #include "axis_p.h"
6 #include "xygrid_p.h"
6 #include "xygrid_p.h"
7 #include <QDebug>
7 #include <QDebug>
8
8
9 QCHART_BEGIN_NAMESPACE
9 QCHART_BEGIN_NAMESPACE
10
10
11 QChart::QChart(QGraphicsItem* parent):QGraphicsItem(parent),
11 QChart::QChart(QGraphicsItem* parent):QGraphicsItem(parent),
12 m_marginSize(0),
12 m_marginSize(0),
13 m_axisX(new Axis(this)),
13 m_axisX(new Axis(this)),
14 m_axisY(new Axis(this)),
14 m_axisY(new Axis(this)),
15 m_grid(new XYGrid(this)),
15 m_grid(new XYGrid(this)),
16 m_plotDataIndex(0)
16 m_plotDataIndex(0)
17 {
17 {
18 // setFlags(QGraphicsItem::ItemClipsChildrenToShape);
18 // setFlags(QGraphicsItem::ItemClipsChildrenToShape);
19 // set axis
19 // set axis
20 m_axisY->rotate(90);
20 m_axisY->rotate(90);
21
21
22
22
23 //TODO hardcoded values , to removed soon
23 //TODO hardcoded values , to removed soon
24 XYPlotData* data = new XYPlotData();
24 XYPlotDomain* data = new XYPlotDomain();
25 data->m_minX = 0.0;
25 data->m_minX = 0.0;
26 data->m_maxX = 100.0;
26 data->m_maxX = 100.0;
27 data->m_minY = 0.0;
27 data->m_minY = 0.0;
28 data->m_maxY = 100.0;
28 data->m_maxY = 100.0;
29 data->m_ticksX=4;
29 data->m_ticksX=4;
30 data->m_ticksY=4;
30 data->m_ticksY=4;
31
31
32 m_plotDataList.clear();
32 m_plotDataList.clear();
33 m_plotDataList << data;
33 m_plotDataList << data;
34
34
35 m_grid->setZValue(10);
35 m_grid->setZValue(10);
36 m_grid->setXYPlotData(*m_plotDataList.at(0));
36 m_grid->setXYPlotData(*m_plotDataList.at(0));
37 }
37 }
38
38
39 QChart::~QChart(){}
39 QChart::~QChart(){}
40
40
41 QRectF QChart::boundingRect() const
41 QRectF QChart::boundingRect() const
42 {
42 {
43 return m_rect;
43 return m_rect;
44 }
44 }
45
45
46 void QChart::addSeries(QChartSeries* series)
46 void QChart::addSeries(QChartSeries* series)
47 {
47 {
48 m_series<<series;
48 m_series<<series;
49
49
50 switch(series->type())
50 switch(series->type())
51 {
51 {
52 case QChartSeries::LINE:
52 case QChartSeries::LINE:
53 XYLineChartItem* item = new XYLineChartItem(reinterpret_cast<QXYChartSeries*>(series),this);
53 XYLineChartItem* item = new XYLineChartItem(reinterpret_cast<QXYChartSeries*>(series),this);
54 item->setXYPlotData(*m_plotDataList.at(0));
54 item->updateXYPlotData(*m_plotDataList.at(0));
55 m_items<<item;
55 m_items<<item;
56 break;
56 break;
57 }
57 }
58 }
58 }
59
59
60 void QChart::setSize(const QSizeF& size) {
60 void QChart::setSize(const QSizeF& size) {
61 //TODO refactor to setGeometry
61 //TODO refactor to setGeometry
62 m_rect = QRect(QPoint(0,0),size.toSize());
62 m_rect = QRect(QPoint(0,0),size.toSize());
63 m_rect.adjust(margin(),margin(),-margin(),-margin());
63 m_rect.adjust(margin(),margin(),-margin(),-margin());
64 m_grid->setPos(m_rect.topLeft());
64 m_grid->setPos(m_rect.topLeft());
65 m_grid->setSize(m_rect.size());
65 m_grid->setSize(m_rect.size());
66 m_plotDataList.at(0)->m_viewportRect = m_rect;
66 foreach(QGraphicsItem* item , m_items)
67 foreach(QGraphicsItem* item , m_items)
67 reinterpret_cast<XYLineChartItem*>(item)->setChartSize(m_rect);
68 reinterpret_cast<XYLineChartItem*>(item)->updateXYPlotData(*m_plotDataList.at(0));
68 update();
69 update();
69
70
70 }
71 }
71
72
72 void QChart::setMargin(int margin)
73 void QChart::setMargin(int margin)
73 {
74 {
74 m_marginSize = margin;
75 m_marginSize = margin;
75 }
76 }
76
77
77 QCHART_END_NAMESPACE
78 QCHART_END_NAMESPACE
@@ -1,45 +1,45
1 #ifndef CHART_H
1 #ifndef CHART_H
2 #define CHART_H
2 #define CHART_H
3
3
4 #include <qchartconfig.h>
4 #include <qchartconfig.h>
5 #include <QGraphicsItem>
5 #include <QGraphicsItem>
6
6
7 QCHART_BEGIN_NAMESPACE
7 QCHART_BEGIN_NAMESPACE
8
8
9 class Axis;
9 class Axis;
10 class XYGrid;
10 class XYGrid;
11 class QChartSeries;
11 class QChartSeries;
12 class XYPlotData;
12 class XYPlotDomain;
13
13
14 class QCHART_EXPORT QChart : public QGraphicsItem
14 class QCHART_EXPORT QChart : public QGraphicsItem
15 {
15 {
16
16
17 public:
17 public:
18 QChart(QGraphicsItem* parent = 0);
18 QChart(QGraphicsItem* parent = 0);
19 virtual ~QChart();
19 virtual ~QChart();
20
20
21 //from QGraphicsItem
21 //from QGraphicsItem
22 virtual QRectF boundingRect() const;
22 virtual QRectF boundingRect() const;
23 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){};
23 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){};
24
24
25 void addSeries(QChartSeries* series);
25 void addSeries(QChartSeries* series);
26
26
27 virtual void setSize(const QSizeF& rect);
27 virtual void setSize(const QSizeF& rect);
28 void setMargin(int margin);
28 void setMargin(int margin);
29 int margin() const { return m_marginSize;}
29 int margin() const { return m_marginSize;}
30
30
31 private:
31 private:
32 QRect m_rect;
32 QRect m_rect;
33 QList<const QChartSeries*> m_series;
33 QList<const QChartSeries*> m_series;
34 Axis* m_axisX;
34 Axis* m_axisX;
35 Axis* m_axisY;
35 Axis* m_axisY;
36 XYGrid* m_grid;
36 XYGrid* m_grid;
37 QList<XYPlotData*> m_plotDataList;
37 QList<XYPlotDomain*> m_plotDataList;
38 QList<QGraphicsItem*> m_items;
38 QList<QGraphicsItem*> m_items;
39 int m_plotDataIndex;
39 int m_plotDataIndex;
40 int m_marginSize;
40 int m_marginSize;
41 };
41 };
42
42
43 QCHART_END_NAMESPACE
43 QCHART_END_NAMESPACE
44
44
45 #endif
45 #endif
@@ -1,46 +1,46
1 TARGET = QChart
1 TARGET = QChart
2 TEMPLATE = lib
2 TEMPLATE = lib
3 QT += core \
3 QT += core \
4 gui
4 gui
5 CONFIG += debug_and_release
5 CONFIG += debug_and_release
6 CONFIG(debug, debug|release):TARGET = QChartd
6 CONFIG(debug, debug|release):TARGET = QChartd
7
7
8 SOURCES += \
8 SOURCES += \
9 xylinechart/qxychartseries.cpp \
9 xylinechart/qxychartseries.cpp \
10 xylinechart/xylinechartitem.cpp \
10 xylinechart/xylinechartitem.cpp \
11 xylinechart/xygrid.cpp \
11 xylinechart/xygrid.cpp \
12 xylinechart/xyplotdata.cpp \
12 xylinechart/xyplotdomain.cpp \
13 qchart.cpp \
13 qchart.cpp \
14 axis.cpp \
14 axis.cpp \
15 qchartwidget.cpp
15 qchartwidget.cpp
16
16
17 PRIVATE_HEADERS += \
17 PRIVATE_HEADERS += \
18 xylinechart/xylinechartitem_p.h \
18 xylinechart/xylinechartitem_p.h \
19 xylinechart/xyplotdata_p.h \# to be removed
19 xylinechart/xyplotdomain_p.h \
20 xylinechart/xygrid_p.h \
20 xylinechart/xygrid_p.h \
21 axis_p.h
21 axis_p.h
22
22
23 PUBLIC_HEADERS += \
23 PUBLIC_HEADERS += \
24 qchartseries.h \
24 qchartseries.h \
25 qchart.h \
25 qchart.h \
26 qchartwidget.h \
26 qchartwidget.h \
27 qchartconfig.h \
27 qchartconfig.h \
28 xylinechart/qxychartseries.h
28 xylinechart/qxychartseries.h
29
29
30 HEADERS += $$PUBLIC_HEADERS
30 HEADERS += $$PUBLIC_HEADERS
31 HEADERS += $$PRIVATE_HEADERS
31 HEADERS += $$PRIVATE_HEADERS
32
32
33 INCLUDEPATH += xylinechart \
33 INCLUDEPATH += xylinechart \
34 .
34 .
35
35
36 OBJECTS_DIR = ../build/lib
36 OBJECTS_DIR = ../build/lib
37 MOC_DIR = ../build/lib
37 MOC_DIR = ../build/lib
38 UI_DIR = ../build/lib
38 UI_DIR = ../build/lib
39 RCC_DIR = ../build/lib
39 RCC_DIR = ../build/lib
40 DEFINES += QCHART_LIBRARY
40 DEFINES += QCHART_LIBRARY
41
41
42 public_headers.path = $$[QT_INSTALL_HEADERS]/QCharts
42 public_headers.path = $$[QT_INSTALL_HEADERS]/QCharts
43 public_headers.files = $$PUBLIC_HEADERS
43 public_headers.files = $$PUBLIC_HEADERS
44 target.path = $$[QT_INSTALL_LIBS]
44 target.path = $$[QT_INSTALL_LIBS]
45 INSTALLS += target \
45 INSTALLS += target \
46 public_headers
46 public_headers
@@ -1,70 +1,70
1 #include "xygrid_p.h"
1 #include "xygrid_p.h"
2 #include <QPainter>
2 #include <QPainter>
3 #include <QDebug>
3 #include <QDebug>
4
4
5 QCHART_BEGIN_NAMESPACE
5 QCHART_BEGIN_NAMESPACE
6
6
7 XYGrid::XYGrid(QGraphicsItem* parent):QGraphicsItem(parent)
7 XYGrid::XYGrid(QGraphicsItem* parent):QGraphicsItem(parent)
8 {
8 {
9 }
9 }
10
10
11 XYGrid::~XYGrid()
11 XYGrid::~XYGrid()
12 {
12 {
13 // TODO Auto-generated destructor stub
13 // TODO Auto-generated destructor stub
14 }
14 }
15
15
16 void XYGrid::setSize(const QSizeF& size)
16 void XYGrid::setSize(const QSizeF& size)
17 {
17 {
18 m_rect.setSize(size.toSize());
18 m_rect.setSize(size.toSize());
19 }
19 }
20
20
21 void XYGrid::setXYPlotData(const XYPlotData& xyPlotData)
21 void XYGrid::setXYPlotData(const XYPlotDomain& xyPlotData)
22 {
22 {
23 m_xyPlotData = xyPlotData;
23 m_xyPlotData = xyPlotData;
24 }
24 }
25
25
26 QRectF XYGrid::boundingRect() const
26 QRectF XYGrid::boundingRect() const
27 {
27 {
28 return m_rect;
28 return m_rect;
29 }
29 }
30
30
31 void XYGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
31 void XYGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
32 {
32 {
33
33
34 if (!m_rect.isValid())
34 if (!m_rect.isValid())
35 return;
35 return;
36
36
37 const qreal deltaX = (m_rect.width() -1) / m_xyPlotData.ticksX();
37 const qreal deltaX = (m_rect.width() -1) / m_xyPlotData.ticksX();
38 const qreal deltaY = (m_rect.height() - 1) / m_xyPlotData.ticksY();
38 const qreal deltaY = (m_rect.height() - 1) / m_xyPlotData.ticksY();
39
39
40 for (int i = 0; i <= m_xyPlotData.ticksX(); ++i) {
40 for (int i = 0; i <= m_xyPlotData.ticksX(); ++i) {
41
41
42 int x = i * deltaX + m_rect.left();
42 int x = i * deltaX + m_rect.left();
43 qreal label = m_xyPlotData.m_minX + (i * m_xyPlotData.spanX()
43 qreal label = m_xyPlotData.m_minX + (i * m_xyPlotData.spanX()
44 / m_xyPlotData.ticksX());
44 / m_xyPlotData.ticksX());
45 painter->drawLine(x, m_rect.top()+1, x, m_rect.bottom());
45 painter->drawLine(x, m_rect.top()+1, x, m_rect.bottom());
46 //painter->drawLine(x, m_rect.bottom(), x, m_rect.bottom() + 5);
46 //painter->drawLine(x, m_rect.bottom(), x, m_rect.bottom() + 5);
47
47
48 painter->drawText(x - 50, m_rect.bottom() + 5, 100, 20,
48 painter->drawText(x - 50, m_rect.bottom() + 5, 100, 20,
49 Qt::AlignHCenter | Qt::AlignTop,
49 Qt::AlignHCenter | Qt::AlignTop,
50 QString::number(label));
50 QString::number(label));
51 }
51 }
52
52
53 for (int j = 0; j <= m_xyPlotData.ticksY(); ++j) {
53 for (int j = 0; j <= m_xyPlotData.ticksY(); ++j) {
54
54
55 int y = j * -deltaY + m_rect.bottom();
55 int y = j * -deltaY + m_rect.bottom();
56 qreal label = m_xyPlotData.m_minY + (j * m_xyPlotData.spanY()
56 qreal label = m_xyPlotData.m_minY + (j * m_xyPlotData.spanY()
57 / m_xyPlotData.ticksY());
57 / m_xyPlotData.ticksY());
58
58
59 painter->drawLine(m_rect.left(), y, m_rect.right()-1, y);
59 painter->drawLine(m_rect.left(), y, m_rect.right()-1, y);
60 //painter->drawLine(m_rect.left() - 5, y, m_rect.left(), y);
60 //painter->drawLine(m_rect.left() - 5, y, m_rect.left(), y);
61 //TODO : margin = 50 ;
61 //TODO : margin = 50 ;
62 painter->drawText(m_rect.left() - 50, y - 10, 50 - 5, 20,
62 painter->drawText(m_rect.left() - 50, y - 10, 50 - 5, 20,
63 Qt::AlignRight | Qt::AlignVCenter,
63 Qt::AlignRight | Qt::AlignVCenter,
64 QString::number(label));
64 QString::number(label));
65 }
65 }
66
66
67 //painter->drawRect(m_rect.adjusted(0, 0, -1, -1));
67 //painter->drawRect(m_rect.adjusted(0, 0, -1, -1));
68 }
68 }
69
69
70 QCHART_END_NAMESPACE
70 QCHART_END_NAMESPACE
@@ -1,31 +1,31
1 #ifndef XYGRID_H_
1 #ifndef XYGRID_H_
2 #define XYGRID_H_
2 #define XYGRID_H_
3
3
4 #include <qchartconfig.h>
4 #include <qchartconfig.h>
5 #include <xyplotdata_p.h>
5 #include <xyplotdomain_p.h>
6 #include <QGraphicsItem>
6 #include <QGraphicsItem>
7
7
8 QCHART_BEGIN_NAMESPACE
8 QCHART_BEGIN_NAMESPACE
9
9
10 class XYGrid : public QGraphicsItem
10 class XYGrid : public QGraphicsItem
11 {
11 {
12 public:
12 public:
13 XYGrid(QGraphicsItem* parent = 0);
13 XYGrid(QGraphicsItem* parent = 0);
14 virtual ~XYGrid();
14 virtual ~XYGrid();
15
15
16 //from QGraphicsItem
16 //from QGraphicsItem
17 virtual QRectF boundingRect() const;
17 virtual QRectF boundingRect() const;
18 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
18 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
19
19
20 //TODO: this is just temporary interface
20 //TODO: this is just temporary interface
21 void setXYPlotData(const XYPlotData& xyPlotData);
21 void setXYPlotData(const XYPlotDomain& xyPlotData);
22 void setSize(const QSizeF& rect);
22 void setSize(const QSizeF& rect);
23
23
24 private:
24 private:
25 QRectF m_rect;
25 QRectF m_rect;
26 XYPlotData m_xyPlotData;
26 XYPlotDomain m_xyPlotData;
27 };
27 };
28
28
29 QCHART_END_NAMESPACE
29 QCHART_END_NAMESPACE
30
30
31 #endif /* XYGRID_H_ */
31 #endif /* XYGRID_H_ */
@@ -1,69 +1,56
1 #include "xylinechartitem_p.h"
1 #include "xylinechartitem_p.h"
2 #include "axis_p.h"
2 #include "axis_p.h"
3 #include "xygrid_p.h"
3 #include "xygrid_p.h"
4 #include "qxychartseries.h"
4 #include "qxychartseries.h"
5 #include <QPainter>
5 #include <QPainter>
6 #include <QStyleOptionGraphicsItem>
6 #include <QStyleOptionGraphicsItem>
7 #include <QDebug>
7 #include <QDebug>
8
8
9 QCHART_BEGIN_NAMESPACE
9 QCHART_BEGIN_NAMESPACE
10
10
11 XYLineChartItem::XYLineChartItem(QXYChartSeries* series,QGraphicsItem *parent):QGraphicsItem(parent),
11 XYLineChartItem::XYLineChartItem(QXYChartSeries* series,QGraphicsItem *parent):QGraphicsItem(parent),
12 m_series(series),
12 m_series(series)
13 m_dirtyGeometry(true)
14 {
13 {
15
14
16 }
15 }
17
16
18 void XYLineChartItem::setChartSize(const QRectF& rect)
17 void XYLineChartItem::updateXYPlotData(const XYPlotDomain& data)
19 {
18 {
20 m_rect = rect;
21 m_dirtyGeometry = true;
22 }
23
24 void XYLineChartItem::setXYPlotData(const XYPlotData& data){
25 m_xyPlotData=data;
19 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
20
39 m_dirtyGeometry=false;
21 if (!m_xyPlotData.m_viewportRect.isValid())
40
41 if (!m_rect.isValid())
42 return;
22 return;
43
23
44 painter->setClipRect(m_rect.adjusted(+1, +1, -1, -1));
24 const QRect& rect = m_xyPlotData.m_viewportRect;
45
25
46 const qreal deltaX = (m_rect.width()-1)/m_xyPlotData.spanX();
26 const qreal deltaX = (rect.width()-1)/m_xyPlotData.spanX();
47 const qreal deltaY = (m_rect.height()-1)/m_xyPlotData.spanY();
27 const qreal deltaY = (rect.height()-1)/m_xyPlotData.spanY();
48
28
49 m_polyline.clear();
29 m_polyline.clear();
50 m_polyline.resize(m_series->count());
30 m_polyline.resize(m_series->count());
51
31
52 for (int j = 0; j < m_series->count(); ++j) {
32 for (int j = 0; j < m_series->count(); ++j) {
53 qreal dx = m_series->x(j) - m_xyPlotData.m_minX;
33 qreal dx = m_series->x(j) - m_xyPlotData.m_minX;
54 qreal dy = m_series->y(j) - m_xyPlotData.m_minY;
34 qreal dy = m_series->y(j) - m_xyPlotData.m_minY;
55 qreal x = (dx * deltaX) + m_rect.left();
35 qreal x = (dx * deltaX) + rect.left();
56 qreal y = - (dy * deltaY) + m_rect.bottom();
36 qreal y = - (dy * deltaY) + rect.bottom();
57 m_polyline[j] = QPointF(x, y);
37 m_polyline[j] = QPointF(x, y);
58 }
38 }
59 painter->setPen(m_series->color());
39
60 painter->drawPolyline(m_polyline);
40 }
41
42 QRectF XYLineChartItem::boundingRect() const
43 {
44 return m_polyline.boundingRect();
61 }
45 }
62
46
63 painter->setClipRect(m_rect.adjusted(+1, +1, -1, -1));
47
48 void XYLineChartItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget)
49 {
50 painter->setClipRect(m_xyPlotData.m_viewportRect.adjusted(+1, +1, -1, -1));
64 painter->setPen(m_series->color());
51 painter->setPen(m_series->color());
65 painter->drawPolyline(m_polyline);
52 painter->drawPolyline(m_polyline);
66
53
67 }
54 }
68
55
69 QCHART_END_NAMESPACE
56 QCHART_END_NAMESPACE
@@ -1,37 +1,33
1 #ifndef XYLINECHARTITEM_H
1 #ifndef XYLINECHARTITEM_H
2 #define XYLINECHARTITEM_H
2 #define XYLINECHARTITEM_H
3
3
4 #include "qchartconfig.h"
4 #include "qchartconfig.h"
5 #include "qchart.h"
5 #include "qchart.h"
6 #include "xyplotdata_p.h"
6 #include "xyplotdomain_p.h"
7
7
8 QCHART_BEGIN_NAMESPACE
8 QCHART_BEGIN_NAMESPACE
9
9
10 class QXYChartSeries;
10 class QXYChartSeries;
11
11
12 class XYLineChartItem : public QGraphicsItem
12 class XYLineChartItem : public QGraphicsItem
13 {
13 {
14
14
15 public:
15 public:
16 XYLineChartItem(QXYChartSeries* m_series,QGraphicsItem *parent = 0);
16 XYLineChartItem(QXYChartSeries* m_series,QGraphicsItem *parent = 0);
17 virtual ~ XYLineChartItem(){};
17 virtual ~ XYLineChartItem(){};
18
18
19 //from QGraphicsItem
19 //from QGraphicsItem
20 virtual QRectF boundingRect() const;
20 virtual QRectF boundingRect() const;
21 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
21 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
22
22
23 //TODO: this is just temporary interface
23 void updateXYPlotData(const XYPlotDomain& data);
24 void setChartSize(const QRectF& size);
25 void setXYPlotData(const XYPlotData& data);
26
24
27 private:
25 private:
28 QRectF m_rect;
29 QPolygonF m_polyline;
26 QPolygonF m_polyline;
30 QXYChartSeries* m_series;
27 QXYChartSeries* m_series;
31 XYPlotData m_xyPlotData;
28 XYPlotDomain m_xyPlotData;
32 bool m_dirtyGeometry;
33 };
29 };
34
30
35 QCHART_END_NAMESPACE
31 QCHART_END_NAMESPACE
36
32
37 #endif
33 #endif
@@ -1,27 +1,33
1 #include "xyplotdata_p.h"
1 #include "xyplotdomain_p.h"
2
2
3 QCHART_BEGIN_NAMESPACE
3 QCHART_BEGIN_NAMESPACE
4
4
5 XYPlotData::XYPlotData()
5 XYPlotDomain::XYPlotDomain():
6 m_ticksX(0),
7 m_ticksY(0),
8 m_minX(0),
9 m_maxX(0),
10 m_minY(0),
11 m_maxY(0)
6 {
12 {
7
13
8 }
14 }
9
15
10 XYPlotData::~XYPlotData()
16 XYPlotDomain::~XYPlotDomain()
11 {
17 {
12 // TODO Auto-generated destructor stub
18 // TODO Auto-generated destructor stub
13 }
19 }
14
20
15 qreal XYPlotData::spanX() const
21 qreal XYPlotDomain::spanX() const
16 {
22 {
17 Q_ASSERT(m_maxX >= m_minX);
23 Q_ASSERT(m_maxX >= m_minX);
18 return m_maxX - m_minX;
24 return m_maxX - m_minX;
19 }
25 }
20
26
21 qreal XYPlotData::spanY() const
27 qreal XYPlotDomain::spanY() const
22 {
28 {
23 Q_ASSERT(m_maxY >= m_minY);
29 Q_ASSERT(m_maxY >= m_minY);
24 return m_maxY - m_minY;
30 return m_maxY - m_minY;
25 }
31 }
26
32
27 QCHART_END_NAMESPACE
33 QCHART_END_NAMESPACE
@@ -1,31 +1,30
1 #ifndef PLOTTER_H_
1 #ifndef PLOTDOMAIN_H_
2 #define PLOTTER_H_
2 #define PLOTDOMAIN_H_
3 #include "qchartconfig.h"
3 #include "qchartconfig.h"
4 #include <QtGlobal>
4 #include <QRect>
5
5
6 QCHART_BEGIN_NAMESPACE
6 QCHART_BEGIN_NAMESPACE
7
7
8 class XYPlotData {
8 class XYPlotDomain {
9 public:
9 public:
10 XYPlotData();
10 XYPlotDomain();
11 virtual ~XYPlotData();
11 virtual ~XYPlotDomain();
12
12
13 qreal spanX() const;
13 qreal spanX() const;
14 qreal spanY() const;
14 qreal spanY() const;
15 int ticksX() const { return m_ticksX; }
15 int ticksX() const { return m_ticksX; }
16 int ticksY() const { return m_ticksY; }
16 int ticksY() const { return m_ticksY; }
17
17
18 public:
18 public:
19 int m_ticksX;
19 int m_ticksX;
20 int m_ticksY;
20 int m_ticksY;
21 qreal m_minX;
21 qreal m_minX;
22 qreal m_maxX;
22 qreal m_maxX;
23 qreal m_minY;
23 qreal m_minY;
24 qreal m_maxY;
24 qreal m_maxY;
25
25 QRect m_viewportRect;
26
27 };
26 };
28
27
29 QCHART_END_NAMESPACE
28 QCHART_END_NAMESPACE
30
29
31 #endif /* PLOTTER_H_ */
30 #endif /* PLOTTER_H_ */
General Comments 0
You need to be logged in to leave comments. Login now