##// END OF EJS Templates
Fix private header dependency...
Michal Klocek -
r22:780f6083c9a1
parent child
Show More
@@ -1,75 +1,77
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 "axis_p.h"
5 #include "axis_p.h"
5 #include "xygrid_p.h"
6 #include "xygrid_p.h"
6 #include <QDebug>
7 #include <QDebug>
7
8
8 QCHART_BEGIN_NAMESPACE
9 QCHART_BEGIN_NAMESPACE
9
10
10 QChart::QChart(QGraphicsItem* parent):QGraphicsItem(parent),
11 QChart::QChart(QGraphicsItem* parent):QGraphicsItem(parent),
11 m_marginSize(0),
12 m_marginSize(0),
12 m_axisX(new Axis(this)),
13 m_axisX(new Axis(this)),
13 m_axisY(new Axis(this)),
14 m_axisY(new Axis(this)),
14 m_grid(new XYGrid(this)),
15 m_grid(new XYGrid(this)),
15 m_plotDataIndex(0)
16 m_plotDataIndex(0)
16 {
17 {
17 // setFlags(QGraphicsItem::ItemClipsChildrenToShape);
18 // setFlags(QGraphicsItem::ItemClipsChildrenToShape);
18 // set axis
19 // set axis
19 m_axisY->rotate(90);
20 m_axisY->rotate(90);
20
21
21 XYPlotData data;
22
22 data.m_minX = 0.0;
23 //TODO hardcoded values , to removed soon
23 data.m_maxX = 100.0;
24 XYPlotData* data = new XYPlotData();
24 data.m_minY = 0.0;
25 data->m_minX = 0.0;
25 data.m_maxY = 100.0;
26 data->m_maxX = 100.0;
26 data.m_ticksX=4;
27 data->m_minY = 0.0;
27 data.m_ticksY=4;
28 data->m_maxY = 100.0;
29 data->m_ticksX=4;
30 data->m_ticksY=4;
28
31
29 m_plotDataList.clear();
32 m_plotDataList.clear();
30 m_plotDataList << data;
33 m_plotDataList << data;
31
34
32 m_grid->setZValue(10);
35 m_grid->setZValue(10);
33 m_grid->setXYPlotData(m_plotDataList.at(0));
36 m_grid->setXYPlotData(*m_plotDataList.at(0));
34 }
37 }
35
38
36 QChart::~QChart(){}
39 QChart::~QChart(){}
37
40
38 QRectF QChart::boundingRect() const
41 QRectF QChart::boundingRect() const
39 {
42 {
40 return m_rect;
43 return m_rect;
41 }
44 }
42
45
43 void QChart::addSeries(QChartSeries* series)
46 void QChart::addSeries(QChartSeries* series)
44 {
47 {
45 m_series<<series;
48 m_series<<series;
46
49
47 switch(series->type())
50 switch(series->type())
48 {
51 {
49 case QChartSeries::LINE:
52 case QChartSeries::LINE:
50 qDebug()<<"xyline added";
51 XYLineChartItem* item = new XYLineChartItem(reinterpret_cast<QXYChartSeries*>(series),this);
53 XYLineChartItem* item = new XYLineChartItem(reinterpret_cast<QXYChartSeries*>(series),this);
52 item->setXYPlotData(m_plotDataList.at(0));
54 item->setXYPlotData(*m_plotDataList.at(0));
53 m_items<<item;
55 m_items<<item;
54 break;
56 break;
55 }
57 }
56 }
58 }
57
59
58 void QChart::setSize(const QSizeF& size) {
60 void QChart::setSize(const QSizeF& size) {
59 //TODO refactor to setGeometry
61 //TODO refactor to setGeometry
60 m_rect = QRect(QPoint(0,0),size.toSize());
62 m_rect = QRect(QPoint(0,0),size.toSize());
61 m_rect.adjust(margin(),margin(),-margin(),-margin());
63 m_rect.adjust(margin(),margin(),-margin(),-margin());
62 m_grid->setPos(m_rect.topLeft());
64 m_grid->setPos(m_rect.topLeft());
63 m_grid->setSize(m_rect.size());
65 m_grid->setSize(m_rect.size());
64 foreach(QGraphicsItem* item , m_items)
66 foreach(QGraphicsItem* item , m_items)
65 reinterpret_cast<XYLineChartItem*>(item)->setChartSize(m_rect);
67 reinterpret_cast<XYLineChartItem*>(item)->setChartSize(m_rect);
66 update();
68 update();
67
69
68 }
70 }
69
71
70 void QChart::setMargin(int margin)
72 void QChart::setMargin(int margin)
71 {
73 {
72 m_marginSize = margin;
74 m_marginSize = margin;
73 }
75 }
74
76
75 QCHART_END_NAMESPACE
77 QCHART_END_NAMESPACE
@@ -1,46 +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 //TODO: temporary class
6 #include <xyplotdata_p.h>
7 #include <QGraphicsItem>
5 #include <QGraphicsItem>
8
6
9 QCHART_BEGIN_NAMESPACE
7 QCHART_BEGIN_NAMESPACE
10
8
11 class Axis;
9 class Axis;
12 class XYGrid;
10 class XYGrid;
13 class QChartSeries;
11 class QChartSeries;
12 class XYPlotData;
14
13
15 class QCHART_EXPORT QChart : public QGraphicsItem
14 class QCHART_EXPORT QChart : public QGraphicsItem
16 {
15 {
17
16
18 public:
17 public:
19 QChart(QGraphicsItem* parent = 0);
18 QChart(QGraphicsItem* parent = 0);
20 virtual ~QChart();
19 virtual ~QChart();
21
20
22 //from QGraphicsItem
21 //from QGraphicsItem
23 virtual QRectF boundingRect() const;
22 virtual QRectF boundingRect() const;
24 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){};
23 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){};
25
24
26 void addSeries(QChartSeries* series);
25 void addSeries(QChartSeries* series);
27
26
28 virtual void setSize(const QSizeF& rect);
27 virtual void setSize(const QSizeF& rect);
29 void setMargin(int margin);
28 void setMargin(int margin);
30 int margin() const { return m_marginSize;}
29 int margin() const { return m_marginSize;}
31
30
32 private:
31 private:
33 QRect m_rect;
32 QRect m_rect;
34 QList<const QChartSeries*> m_series;
33 QList<const QChartSeries*> m_series;
35 Axis* m_axisX;
34 Axis* m_axisX;
36 Axis* m_axisY;
35 Axis* m_axisY;
37 XYGrid* m_grid;
36 XYGrid* m_grid;
38 QList<XYPlotData> m_plotDataList;
37 QList<XYPlotData*> m_plotDataList;
39 QList<QGraphicsItem*> m_items;
38 QList<QGraphicsItem*> m_items;
40 int m_plotDataIndex;
39 int m_plotDataIndex;
41 int m_marginSize;
40 int m_marginSize;
42 };
41 };
43
42
44 QCHART_END_NAMESPACE
43 QCHART_END_NAMESPACE
45
44
46 #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/xyplotdata.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/xygrid_p.h \
20 xylinechart/xygrid_p.h \
20 axis_p.h
21 axis_p.h
21
22
22 PUBLIC_HEADERS += \
23 PUBLIC_HEADERS += \
23 qchartseries.h \
24 qchartseries.h \
24 qchart.h \
25 qchart.h \
25 qchartwidget.h \
26 qchartwidget.h \
26 qchartconfig.h \
27 qchartconfig.h \
27 xylinechart/qxychartseries.h \
28 xylinechart/qxychartseries.h
28 xylinechart/xyplotdata_p.h # to be removed
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
General Comments 0
You need to be logged in to leave comments. Login now