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