##// END OF EJS Templates
Remove PlotDomain , use Domain insted...
Michal Klocek -
r149:23a271e217e1
parent child
Show More
@@ -1,66 +1,62
1 #include "bar_p.h"
1 #include "bar_p.h"
2 #include <QDebug>
2 #include <QDebug>
3 #include <QPainter>
3 #include <QPainter>
4
4
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6
6
7 Bar::Bar(QGraphicsItem *parent)
7 Bar::Bar(QGraphicsItem *parent)
8 : ChartItem(parent)
8 : ChartItem(parent)
9 {
9 {
10 }
10 }
11
11
12 void Bar::setSize(const QSizeF& size)
12 void Bar::setSize(const QSizeF& size)
13 {
13 {
14 mWidth = size.width();
14 mWidth = size.width();
15 mHeight = size.height();
15 mHeight = size.height();
16 }
16 }
17
17
18 void Bar::setPlotDomain(const PlotDomain& data)
19 {
20 mPlotDomain = data;
21 }
22
18
23 void Bar::resize( qreal w, qreal h )
19 void Bar::resize( qreal w, qreal h )
24 {
20 {
25 // qDebug() << "bar::resize" << w << h;
21 // qDebug() << "bar::resize" << w << h;
26 mWidth = w;
22 mWidth = w;
27 mHeight = h;
23 mHeight = h;
28 }
24 }
29
25
30 void Bar::setColor( QColor col )
26 void Bar::setColor( QColor col )
31 {
27 {
32 mColor = col;
28 mColor = col;
33 }
29 }
34 void Bar::setPos(qreal x, qreal y)
30 void Bar::setPos(qreal x, qreal y)
35 {
31 {
36 // qDebug() << "Bar::setpos" << x << y;
32 // qDebug() << "Bar::setpos" << x << y;
37 mXpos = x;
33 mXpos = x;
38 mYpos = y;
34 mYpos = y;
39 }
35 }
40
36
41 void Bar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
37 void Bar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
42 {
38 {
43 if (0 == mHeight) {
39 if (0 == mHeight) {
44 return;
40 return;
45 }
41 }
46 // TODO: accept brush instead of color
42 // TODO: accept brush instead of color
47 QBrush brush(mColor);
43 QBrush brush(mColor);
48 painter->setBrush(brush);
44 painter->setBrush(brush);
49
45
50 // This compensates for rounding errors. drawRect takes ints and cumulative error of pos + size may be over 1.
46 // This compensates for rounding errors. drawRect takes ints and cumulative error of pos + size may be over 1.
51 int x0 = mXpos;
47 int x0 = mXpos;
52 int x1 = (mXpos + mWidth);
48 int x1 = (mXpos + mWidth);
53 int w = x1-x0;
49 int w = x1-x0;
54 int y0 = mYpos;
50 int y0 = mYpos;
55 int y1 = (mYpos + mHeight);
51 int y1 = (mYpos + mHeight);
56 int h = y1-y0;
52 int h = y1-y0;
57 painter->drawRect(x0, y0 ,w ,h);
53 painter->drawRect(x0, y0 ,w ,h);
58 }
54 }
59
55
60 QRectF Bar::boundingRect() const
56 QRectF Bar::boundingRect() const
61 {
57 {
62 QRectF r(mXpos, mYpos, mXpos + mWidth, mYpos + mHeight);
58 QRectF r(mXpos, mYpos, mXpos + mWidth, mYpos + mHeight);
63 return r;
59 return r;
64 }
60 }
65
61
66 QTCOMMERCIALCHART_END_NAMESPACE
62 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,44 +1,42
1 #ifndef BAR_H
1 #ifndef BAR_H
2 #define BAR_H
2 #define BAR_H
3
3
4 #include "chartitem_p.h"
4 #include "chartitem_p.h"
5 #include "qchartglobal.h"
5 #include "qchartglobal.h"
6 #include <QGraphicsItem>
6 #include <QGraphicsItem>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 // Single bar item of chart
10 // Single bar item of chart
11 class Bar : public ChartItem
11 class Bar : public ChartItem
12 {
12 {
13 public:
13 public:
14 Bar(QGraphicsItem *parent=0);
14 Bar(QGraphicsItem *parent=0);
15
15
16 public: // from ChartItem
16 public: // from ChartItem
17 void setSize(const QSizeF &size);
17 void setSize(const QSizeF &size);
18 void setPlotDomain(const PlotDomain& data);
19
18
20 // Layout Stuff
19 // Layout Stuff
21 void resize( qreal w, qreal h ); // Size of bar.
20 void resize( qreal w, qreal h ); // Size of bar.
22 void setColor( QColor col ); // Color of bar
21 void setColor( QColor col ); // Color of bar
23 void setPos(qreal x, qreal y);
22 void setPos(qreal x, qreal y);
24
23
25 public:
24 public:
26 // From QGraphicsItem
25 // From QGraphicsItem
27
26
28 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
27 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
29 QRectF boundingRect() const;
28 QRectF boundingRect() const;
30
29
31 private:
30 private:
32
31
33 qreal mHeight;
32 qreal mHeight;
34 qreal mWidth;
33 qreal mWidth;
35 qreal mXpos;
34 qreal mXpos;
36 qreal mYpos;
35 qreal mYpos;
37 QColor mColor;
36 QColor mColor;
38
37
39 PlotDomain mPlotDomain;
40 };
38 };
41
39
42 QTCOMMERCIALCHART_END_NAMESPACE
40 QTCOMMERCIALCHART_END_NAMESPACE
43
41
44 #endif // BAR_H
42 #endif // BAR_H
@@ -1,42 +1,37
1 #include "barlabel_p.h"
1 #include "barlabel_p.h"
2 #include <QPainter>
2 #include <QPainter>
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4
4
5 BarLabel::BarLabel(QGraphicsItem* parent) : ChartItem(parent)
5 BarLabel::BarLabel(QGraphicsItem* parent) : ChartItem(parent)
6 {
6 {
7 }
7 }
8
8
9
9
10 void BarLabel::set(QString label)
10 void BarLabel::set(QString label)
11 {
11 {
12 mLabel = label;
12 mLabel = label;
13 }
13 }
14
14
15 void BarLabel::setPos(qreal x, qreal y)
15 void BarLabel::setPos(qreal x, qreal y)
16 {
16 {
17 mXpos = x;
17 mXpos = x;
18 mYpos = y;
18 mYpos = y;
19 }
19 }
20
20
21 void BarLabel::setSize(const QSizeF &size)
21 void BarLabel::setSize(const QSizeF &size)
22 {
22 {
23 mSize = size;
23 mSize = size;
24 }
24 }
25
25
26 void BarLabel::setPlotDomain(const PlotDomain& data)
27 {
28 mDomain = data;
29 }
30
31 void BarLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
26 void BarLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
32 {
27 {
33 painter->drawText(boundingRect(),mLabel);
28 painter->drawText(boundingRect(),mLabel);
34 }
29 }
35
30
36 QRectF BarLabel::boundingRect() const
31 QRectF BarLabel::boundingRect() const
37 {
32 {
38 QRectF r(mXpos, mYpos, mXpos + mSize.width(), mYpos + mSize.height());
33 QRectF r(mXpos, mYpos, mXpos + mSize.width(), mYpos + mSize.height());
39 return r;
34 return r;
40 }
35 }
41
36
42 QTCOMMERCIALCHART_END_NAMESPACE
37 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,36 +1,34
1 #ifndef BARLABEL_H
1 #ifndef BARLABEL_H
2 #define BARLABEL_H
2 #define BARLABEL_H
3
3
4 #include "chartitem_p.h"
4 #include "chartitem_p.h"
5
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
8 class BarLabel : public ChartItem
8 class BarLabel : public ChartItem
9 {
9 {
10 public:
10 public:
11 BarLabel(QGraphicsItem* parent = 0);
11 BarLabel(QGraphicsItem* parent = 0);
12
12
13 void set(QString label);
13 void set(QString label);
14 void setPos(qreal x, qreal y);
14 void setPos(qreal x, qreal y);
15
15
16 // From ChartItem
16 // From ChartItem
17 void setSize(const QSizeF &size);
17 void setSize(const QSizeF &size);
18 void setPlotDomain(const PlotDomain& data);
19
18
20 // From QGraphicsItem
19 // From QGraphicsItem
21 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
20 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
22 QRectF boundingRect() const;
21 QRectF boundingRect() const;
23
22
24 private:
23 private:
25
24
26 PlotDomain mDomain;
27 QSizeF mSize;
25 QSizeF mSize;
28 QString mLabel;
26 QString mLabel;
29 qreal mXpos;
27 qreal mXpos;
30 qreal mYpos;
28 qreal mYpos;
31
29
32 };
30 };
33
31
34 QTCOMMERCIALCHART_END_NAMESPACE
32 QTCOMMERCIALCHART_END_NAMESPACE
35
33
36 #endif // BARLABEL_H
34 #endif // BARLABEL_H
@@ -1,49 +1,44
1 #include "separator_p.h"
1 #include "separator_p.h"
2 #include <QDebug>
2 #include <QDebug>
3 #include <QPainter>
3 #include <QPainter>
4
4
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6
6
7 Separator::Separator(QGraphicsItem *parent)
7 Separator::Separator(QGraphicsItem *parent)
8 : ChartItem(parent)
8 : ChartItem(parent)
9 {
9 {
10 }
10 }
11
11
12 void Separator::setPos(qreal x, qreal y)
12 void Separator::setPos(qreal x, qreal y)
13 {
13 {
14 mXpos = x;
14 mXpos = x;
15 mYpos = y;
15 mYpos = y;
16 }
16 }
17
17
18 void Separator::setColor(QColor color)
18 void Separator::setColor(QColor color)
19 {
19 {
20 mColor = color;
20 mColor = color;
21 }
21 }
22
22
23 void Separator::setSize(const QSizeF &size)
23 void Separator::setSize(const QSizeF &size)
24 {
24 {
25 mWidth = size.width();
25 mWidth = size.width();
26 mHeight = size.height();
26 mHeight = size.height();
27 }
27 }
28
28
29 void Separator::setPlotDomain(const PlotDomain& data)
30 {
31
32 }
33
34 void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
29 void Separator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
35 {
30 {
36 qDebug() << "separator::paint" << boundingRect();
31 qDebug() << "separator::paint" << boundingRect();
37 QPen pen(mColor);
32 QPen pen(mColor);
38 painter->setPen(pen);
33 painter->setPen(pen);
39 painter->drawLine(mXpos,mYpos,mXpos,mHeight);
34 painter->drawLine(mXpos,mYpos,mXpos,mHeight);
40 }
35 }
41
36
42 QRectF Separator::boundingRect() const
37 QRectF Separator::boundingRect() const
43 {
38 {
44 QRectF r(mXpos,mYpos,mWidth,mHeight);
39 QRectF r(mXpos,mYpos,mWidth,mHeight);
45 return r;
40 return r;
46 }
41 }
47
42
48
43
49 QTCOMMERCIALCHART_END_NAMESPACE
44 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,36 +1,35
1 #ifndef SEPARATOR_H
1 #ifndef SEPARATOR_H
2 #define SEPARATOR_H
2 #define SEPARATOR_H
3
3
4 #include "chartitem_p.h"
4 #include "chartitem_p.h"
5
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
8 class Separator : public ChartItem
8 class Separator : public ChartItem
9 {
9 {
10 public:
10 public:
11 Separator(QGraphicsItem *parent = 0);
11 Separator(QGraphicsItem *parent = 0);
12
12
13 void setPos(qreal x, qreal y);
13 void setPos(qreal x, qreal y);
14 void setColor(QColor color);
14 void setColor(QColor color);
15
15
16 // From ChartItem
16 // From ChartItem
17 void setSize(const QSizeF &size);
17 void setSize(const QSizeF &size);
18 void setPlotDomain(const PlotDomain& data);
19
18
20 // From QGraphicsItem
19 // From QGraphicsItem
21 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
20 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
22 QRectF boundingRect() const;
21 QRectF boundingRect() const;
23
22
24 private:
23 private:
25
24
26 QColor mColor;
25 QColor mColor;
27 qreal mXpos;
26 qreal mXpos;
28 qreal mYpos;
27 qreal mYpos;
29 qreal mHeight;
28 qreal mHeight;
30 qreal mWidth;
29 qreal mWidth;
31
30
32 };
31 };
33
32
34 QTCOMMERCIALCHART_END_NAMESPACE
33 QTCOMMERCIALCHART_END_NAMESPACE
35
34
36 #endif // SEPARATOR_H
35 #endif // SEPARATOR_H
@@ -1,22 +1,21
1 #ifndef CHARTITEM_H_
1 #ifndef CHARTITEM_H_
2 #define CHARTITEM_H_
2 #define CHARTITEM_H_
3
3
4 #include "plotdomain_p.h"
5 #include "domain_p.h"
4 #include "domain_p.h"
6 #include <QGraphicsItem>
5 #include <QGraphicsItem>
7
6
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
8
10 class ChartAnimationManager;
9 class ChartAnimationManager;
11
10
12 class ChartItem : public QGraphicsItem
11 class ChartItem : public QGraphicsItem
13 {
12 {
14 enum ChartItemTypes{ AXIS_ITEM = UserType+1, XYLINE_ITEM};
13 enum ChartItemTypes{ AXIS_ITEM = UserType+1, XYLINE_ITEM};
15 public:
14 public:
16 ChartItem(QGraphicsItem* parent = 0):QGraphicsItem(parent){};
15 ChartItem(QGraphicsItem* parent = 0):QGraphicsItem(parent){};
17 virtual ~ChartItem(){};
16 virtual ~ChartItem(){};
18 };
17 };
19
18
20 QTCOMMERCIALCHART_END_NAMESPACE
19 QTCOMMERCIALCHART_END_NAMESPACE
21
20
22 #endif /* CHARTITEM_H_ */
21 #endif /* CHARTITEM_H_ */
@@ -1,122 +1,112
1
1
2 #include "piepresenter.h"
2 #include "piepresenter.h"
3 #include "pieslice.h"
3 #include "pieslice.h"
4 #include <QDebug>
4 #include <QDebug>
5
5
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 QTCOMMERCIALCHART_BEGIN_NAMESPACE
7
7
8 PiePresenter::PiePresenter(QGraphicsItem *parent, QPieSeries *series) :
8 PiePresenter::PiePresenter(QGraphicsItem *parent, QPieSeries *series) :
9 ChartItem(parent),
9 ChartItem(parent),
10 m_pieSeries(series)
10 m_pieSeries(series)
11 {
11 {
12 Q_ASSERT(parent);
12 Q_ASSERT(parent);
13 Q_ASSERT(series);
13 Q_ASSERT(series);
14 m_rect = parentItem()->boundingRect();
14 m_rect = parentItem()->boundingRect();
15 setAcceptHoverEvents(true);
15 setAcceptHoverEvents(true);
16 }
16 }
17
17
18 PiePresenter::~PiePresenter()
18 PiePresenter::~PiePresenter()
19 {
19 {
20 while (m_slices.count())
20 while (m_slices.count())
21 delete m_slices.takeLast();
21 delete m_slices.takeLast();
22 }
22 }
23
23
24 void PiePresenter::seriesChanged()
24 void PiePresenter::seriesChanged()
25 {
25 {
26 const qreal fullPie = 360;
26 const qreal fullPie = 360;
27 qreal total = 0;
27 qreal total = 0;
28
28
29 // calculate total
29 // calculate total
30 foreach (QPieSlice sliceData, m_pieSeries->slices())
30 foreach (QPieSlice sliceData, m_pieSeries->slices())
31 total += sliceData.m_value;
31 total += sliceData.m_value;
32
32
33 // TODO: no need to create new slices in case size changed; we should re-use the existing ones
33 // TODO: no need to create new slices in case size changed; we should re-use the existing ones
34 while (m_slices.count())
34 while (m_slices.count())
35 delete m_slices.takeLast();
35 delete m_slices.takeLast();
36
36
37 // create slices
37 // create slices
38 qreal angle = 0;
38 qreal angle = 0;
39 for (int i=0; i<m_pieSeries->count(); i++) {
39 for (int i=0; i<m_pieSeries->count(); i++) {
40 QPieSlice sliceData = m_pieSeries->slice(i);
40 QPieSlice sliceData = m_pieSeries->slice(i);
41 qreal span = sliceData.m_value / total * fullPie;
41 qreal span = sliceData.m_value / total * fullPie;
42 PieSlice *slice = new PieSlice(this, i, angle, span);
42 PieSlice *slice = new PieSlice(this, i, angle, span);
43 m_slices.append(slice);
43 m_slices.append(slice);
44 angle += span;
44 angle += span;
45 }
45 }
46
46
47 resize();
47 resize();
48 }
48 }
49
49
50 void PiePresenter::setSize(const QSizeF &size)
51 {
52 // TODO: allow user setting the size?
53 // TODO: allow user defining the margins?
54 m_rect.setSize(size);
55 resize();
56 }
57
58 void PiePresenter::setPlotDomain(const PlotDomain& plotDomain)
59 {
60 // TODO
61 }
62
63 void PiePresenter::resize()
50 void PiePresenter::resize()
64 {
51 {
65 m_pieRect = m_rect;
52 m_pieRect = m_rect;
66
53
67 if (m_pieRect.width() < m_pieRect.height()) {
54 if (m_pieRect.width() < m_pieRect.height()) {
68 m_pieRect.setWidth(m_pieRect.width() * m_pieSeries->m_sizeFactor);
55 m_pieRect.setWidth(m_pieRect.width() * m_pieSeries->m_sizeFactor);
69 m_pieRect.setHeight(m_pieRect.width());
56 m_pieRect.setHeight(m_pieRect.width());
70 m_pieRect.moveCenter(m_rect.center());
57 m_pieRect.moveCenter(m_rect.center());
71 } else {
58 } else {
72 m_pieRect.setHeight(m_pieRect.height() * m_pieSeries->m_sizeFactor);
59 m_pieRect.setHeight(m_pieRect.height() * m_pieSeries->m_sizeFactor);
73 m_pieRect.setWidth(m_pieRect.height());
60 m_pieRect.setWidth(m_pieRect.height());
74 m_pieRect.moveCenter(m_rect.center());
61 m_pieRect.moveCenter(m_rect.center());
75 }
62 }
76
63
77 switch (m_pieSeries->m_position) {
64 switch (m_pieSeries->m_position) {
78 case QPieSeries::PiePositionTopLeft: {
65 case QPieSeries::PiePositionTopLeft: {
79 m_pieRect.setHeight(m_pieRect.height() / 2);
66 m_pieRect.setHeight(m_pieRect.height() / 2);
80 m_pieRect.setWidth(m_pieRect.height());
67 m_pieRect.setWidth(m_pieRect.height());
81 m_pieRect.moveCenter(QPointF(m_rect.center().x() / 2, m_rect.center().y() / 2));
68 m_pieRect.moveCenter(QPointF(m_rect.center().x() / 2, m_rect.center().y() / 2));
82 break;
69 break;
83 }
70 }
84 case QPieSeries::PiePositionTopRight: {
71 case QPieSeries::PiePositionTopRight: {
85 m_pieRect.setHeight(m_pieRect.height() / 2);
72 m_pieRect.setHeight(m_pieRect.height() / 2);
86 m_pieRect.setWidth(m_pieRect.height());
73 m_pieRect.setWidth(m_pieRect.height());
87 m_pieRect.moveCenter(QPointF((m_rect.center().x() / 2) * 3, m_rect.center().y() / 2));
74 m_pieRect.moveCenter(QPointF((m_rect.center().x() / 2) * 3, m_rect.center().y() / 2));
88 break;
75 break;
89 }
76 }
90 case QPieSeries::PiePositionBottomLeft: {
77 case QPieSeries::PiePositionBottomLeft: {
91 m_pieRect.setHeight(m_pieRect.height() / 2);
78 m_pieRect.setHeight(m_pieRect.height() / 2);
92 m_pieRect.setWidth(m_pieRect.height());
79 m_pieRect.setWidth(m_pieRect.height());
93 m_pieRect.moveCenter(QPointF(m_rect.center().x() / 2, (m_rect.center().y() / 2) * 3));
80 m_pieRect.moveCenter(QPointF(m_rect.center().x() / 2, (m_rect.center().y() / 2) * 3));
94 break;
81 break;
95 }
82 }
96 case QPieSeries::PiePositionBottomRight: {
83 case QPieSeries::PiePositionBottomRight: {
97 m_pieRect.setHeight(m_pieRect.height() / 2);
84 m_pieRect.setHeight(m_pieRect.height() / 2);
98 m_pieRect.setWidth(m_pieRect.height());
85 m_pieRect.setWidth(m_pieRect.height());
99 m_pieRect.moveCenter(QPointF((m_rect.center().x() / 2) * 3, (m_rect.center().y() / 2) * 3));
86 m_pieRect.moveCenter(QPointF((m_rect.center().x() / 2) * 3, (m_rect.center().y() / 2) * 3));
100 break;
87 break;
101 }
88 }
102 default:
89 default:
103 break;
90 break;
104 }
91 }
105
92
106 qDebug() << "presentation rect:" << m_rect;
93 qDebug() << "presentation rect:" << m_rect;
107 qDebug() << "pie rect:" << m_pieRect;
94 qDebug() << "pie rect:" << m_pieRect;
108 }
95 }
109
96
110 void PiePresenter::handleDomainChanged(const Domain& domain)
97 void PiePresenter::handleDomainChanged(const Domain& domain)
111 {
98 {
112 // TODO
99 // TODO
113 }
100 }
114
101
115 void PiePresenter::handleGeometryChanged(const QRectF& rect)
102 void PiePresenter::handleGeometryChanged(const QRectF& rect)
116 {
103 {
117 setSize(rect.size());
104 // TODO: allow user setting the size?
105 // TODO: allow user defining the margins?
106 m_rect.setSize(rect.size());
107 resize();
118 }
108 }
119
109
120 #include "moc_piepresenter.cpp"
110 #include "moc_piepresenter.cpp"
121
111
122 QTCOMMERCIALCHART_END_NAMESPACE
112 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,45 +1,43
1 #ifndef PIEPRESENTER_H
1 #ifndef PIEPRESENTER_H
2 #define PIEPRESENTER_H
2 #define PIEPRESENTER_H
3
3
4 #include "chartitem_p.h"
4 #include "chartitem_p.h"
5 #include "qpieseries.h"
5 #include "qpieseries.h"
6
6
7 class QGraphicsItem;
7 class QGraphicsItem;
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 class PieSlice;
9 class PieSlice;
10
10
11 class PiePresenter : public QObject, public ChartItem
11 class PiePresenter : public QObject, public ChartItem
12 {
12 {
13 Q_OBJECT
13 Q_OBJECT
14
14
15 public:
15 public:
16 // TODO: use a generic data class instead of x and y
16 // TODO: use a generic data class instead of x and y
17 PiePresenter(QGraphicsItem *parent, QPieSeries *series);
17 PiePresenter(QGraphicsItem *parent, QPieSeries *series);
18 ~PiePresenter();
18 ~PiePresenter();
19
19
20 public: // from ChartItem
20 public: // from ChartItem
21 void setSize(const QSizeF &size);
22 void setPlotDomain(const PlotDomain& data);
23 QRectF boundingRect() const { return m_rect; }
21 QRectF boundingRect() const { return m_rect; }
24 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
22 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
25
23
26 public:
24 public:
27 void seriesChanged();
25 void seriesChanged();
28 void resize();
26 void resize();
29 QRectF pieRect() const { return m_pieRect; }
27 QRectF pieRect() const { return m_pieRect; }
30
28
31 public Q_SLOTS:
29 public Q_SLOTS:
32 void handleDomainChanged(const Domain& domain);
30 void handleDomainChanged(const Domain& domain);
33 void handleGeometryChanged(const QRectF& rect);
31 void handleGeometryChanged(const QRectF& rect);
34
32
35 private:
33 private:
36 friend class PieSlice;
34 friend class PieSlice;
37 QList<PieSlice*> m_slices;
35 QList<PieSlice*> m_slices;
38 QPieSeries *m_pieSeries;
36 QPieSeries *m_pieSeries;
39 QRectF m_rect;
37 QRectF m_rect;
40 QRectF m_pieRect;
38 QRectF m_pieRect;
41 };
39 };
42
40
43 QTCOMMERCIALCHART_END_NAMESPACE
41 QTCOMMERCIALCHART_END_NAMESPACE
44
42
45 #endif // PIEPRESENTER_H
43 #endif // PIEPRESENTER_H
@@ -1,195 +1,190
1 #include "qchart.h"
1 #include "qchart.h"
2 #include "qchartseries.h"
3 #include "qscatterseries.h"
2 #include "qscatterseries.h"
4 #include "qscatterseries_p.h"
3 #include "qscatterseries_p.h"
5 #include "qpieseries.h"
4 #include "qpieseries.h"
6 #include "qchartaxis.h"
5 #include "qchartaxis.h"
7 #include "charttheme_p.h"
8 #include "chartitem_p.h"
9 #include "plotdomain_p.h"
10 #include "axisitem_p.h"
11 #include "chartpresenter_p.h"
6 #include "chartpresenter_p.h"
12 #include "chartdataset_p.h"
7 #include "chartdataset_p.h"
13
8
14 //series
9 //series
15 #include "barchartseries.h"
10 #include "barchartseries.h"
16 #include "stackedbarchartseries.h"
11 #include "stackedbarchartseries.h"
17 #include "percentbarchartseries.h"
12 #include "percentbarchartseries.h"
18 #include "qlinechartseries.h"
13 #include "qlinechartseries.h"
19
14
20 #include <QGraphicsScene>
15 #include <QGraphicsScene>
21 #include <QGraphicsSceneResizeEvent>
16 #include <QGraphicsSceneResizeEvent>
22 #include <QDebug>
17 #include <QDebug>
23
18
24 QTCOMMERCIALCHART_BEGIN_NAMESPACE
19 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25
20
26 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
21 QChart::QChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) : QGraphicsWidget(parent,wFlags),
27 m_backgroundItem(0),
22 m_backgroundItem(0),
28 m_titleItem(0),
23 m_titleItem(0),
29 m_dataset(new ChartDataSet(this)),
24 m_dataset(new ChartDataSet(this)),
30 m_presenter(new ChartPresenter(this,m_dataset))
25 m_presenter(new ChartPresenter(this,m_dataset))
31 {
26 {
32 }
27 }
33
28
34 QChart::~QChart() {}
29 QChart::~QChart() {}
35
30
36 void QChart::addSeries(QChartSeries* series)
31 void QChart::addSeries(QChartSeries* series)
37 {
32 {
38 m_dataset->addSeries(series);
33 m_dataset->addSeries(series);
39 }
34 }
40
35
41 //TODO on review, is it really needed ??
36 //TODO on review, is it really needed ??
42 QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type)
37 QChartSeries* QChart::createSeries(QChartSeries::QChartSeriesType type)
43 {
38 {
44 // TODO: support also other types; not only scatter and pie
39 // TODO: support also other types; not only scatter and pie
45
40
46 QChartSeries *series(0);
41 QChartSeries *series(0);
47
42
48 switch (type) {
43 switch (type) {
49 case QChartSeries::SeriesTypeLine: {
44 case QChartSeries::SeriesTypeLine: {
50 series = QLineChartSeries::create();
45 series = QLineChartSeries::create();
51 break;
46 break;
52 }
47 }
53 case QChartSeries::SeriesTypeBar: {
48 case QChartSeries::SeriesTypeBar: {
54 series = new BarChartSeries(this);
49 series = new BarChartSeries(this);
55 break;
50 break;
56 }
51 }
57 case QChartSeries::SeriesTypeStackedBar: {
52 case QChartSeries::SeriesTypeStackedBar: {
58 series = new StackedBarChartSeries(this);
53 series = new StackedBarChartSeries(this);
59 break;
54 break;
60 }
55 }
61 case QChartSeries::SeriesTypePercentBar: {
56 case QChartSeries::SeriesTypePercentBar: {
62 series = new PercentBarChartSeries(this);
57 series = new PercentBarChartSeries(this);
63 break;
58 break;
64 }
59 }
65 case QChartSeries::SeriesTypeScatter: {
60 case QChartSeries::SeriesTypeScatter: {
66 series = new QScatterSeries(this);
61 series = new QScatterSeries(this);
67 break;
62 break;
68 }
63 }
69 case QChartSeries::SeriesTypePie: {
64 case QChartSeries::SeriesTypePie: {
70 series = new QPieSeries(this);
65 series = new QPieSeries(this);
71 break;
66 break;
72 }
67 }
73 default:
68 default:
74 Q_ASSERT(false);
69 Q_ASSERT(false);
75 break;
70 break;
76 }
71 }
77
72
78 addSeries(series);
73 addSeries(series);
79 return series;
74 return series;
80 }
75 }
81
76
82 void QChart::setChartBackgroundBrush(const QBrush& brush)
77 void QChart::setChartBackgroundBrush(const QBrush& brush)
83 {
78 {
84
79
85 if(!m_backgroundItem) {
80 if(!m_backgroundItem) {
86 m_backgroundItem = new QGraphicsRectItem(this);
81 m_backgroundItem = new QGraphicsRectItem(this);
87 m_backgroundItem->setZValue(-1);
82 m_backgroundItem->setZValue(-1);
88 }
83 }
89
84
90 m_backgroundItem->setBrush(brush);
85 m_backgroundItem->setBrush(brush);
91 m_backgroundItem->update();
86 m_backgroundItem->update();
92 }
87 }
93
88
94 void QChart::setChartBackgroundPen(const QPen& pen)
89 void QChart::setChartBackgroundPen(const QPen& pen)
95 {
90 {
96
91
97 if(!m_backgroundItem) {
92 if(!m_backgroundItem) {
98 m_backgroundItem = new QGraphicsRectItem(this);
93 m_backgroundItem = new QGraphicsRectItem(this);
99 m_backgroundItem->setZValue(-1);
94 m_backgroundItem->setZValue(-1);
100 }
95 }
101
96
102 m_backgroundItem->setPen(pen);
97 m_backgroundItem->setPen(pen);
103 m_backgroundItem->update();
98 m_backgroundItem->update();
104 }
99 }
105
100
106 void QChart::setTitle(const QString& title,const QFont& font)
101 void QChart::setTitle(const QString& title,const QFont& font)
107 {
102 {
108 if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
103 if(!m_titleItem) m_titleItem = new QGraphicsTextItem(this);
109 m_titleItem->setPlainText(title);
104 m_titleItem->setPlainText(title);
110 m_titleItem->setFont(font);
105 m_titleItem->setFont(font);
111 }
106 }
112
107
113 int QChart::margin() const
108 int QChart::margin() const
114 {
109 {
115 return m_presenter->margin();
110 return m_presenter->margin();
116 }
111 }
117
112
118 void QChart::setMargin(int margin)
113 void QChart::setMargin(int margin)
119 {
114 {
120 m_presenter->setMargin(margin);
115 m_presenter->setMargin(margin);
121 }
116 }
122
117
123 void QChart::setTheme(QChart::ChartThemeId theme)
118 void QChart::setTheme(QChart::ChartThemeId theme)
124 {
119 {
125 m_presenter->setTheme(theme);
120 m_presenter->setTheme(theme);
126 }
121 }
127
122
128 QChart::ChartThemeId QChart::theme()
123 QChart::ChartThemeId QChart::theme()
129 {
124 {
130 return (QChart::ChartThemeId) m_presenter->theme();
125 return (QChart::ChartThemeId) m_presenter->theme();
131 }
126 }
132
127
133 void QChart::zoomInToRect(const QRectF& rectangle)
128 void QChart::zoomInToRect(const QRectF& rectangle)
134 {
129 {
135 m_presenter->zoomInToRect(rectangle);
130 m_presenter->zoomInToRect(rectangle);
136 }
131 }
137
132
138 void QChart::zoomIn()
133 void QChart::zoomIn()
139 {
134 {
140 m_presenter->zoomIn();
135 m_presenter->zoomIn();
141 }
136 }
142
137
143 void QChart::zoomOut()
138 void QChart::zoomOut()
144 {
139 {
145 m_presenter->zoomOut();
140 m_presenter->zoomOut();
146 }
141 }
147
142
148 void QChart::zoomReset()
143 void QChart::zoomReset()
149 {
144 {
150 m_presenter->zoomReset();
145 m_presenter->zoomReset();
151 }
146 }
152
147
153 void QChart::setAxisX(const QChartAxis& axis)
148 void QChart::setAxisX(const QChartAxis& axis)
154 {
149 {
155
150
156 }
151 }
157 void QChart::setAxisY(const QChartAxis& axis)
152 void QChart::setAxisY(const QChartAxis& axis)
158 {
153 {
159
154
160 }
155 }
161
156
162 void QChart::setAxisY(const QList<QChartAxis>& axis)
157 void QChart::setAxisY(const QList<QChartAxis>& axis)
163 {
158 {
164 //TODO not implemented
159 //TODO not implemented
165 }
160 }
166
161
167 void QChart::setAxis(AxisItem *item, const QChartAxis& axis)
162 void QChart::setAxis(AxisItem *item, const QChartAxis& axis)
168 {
163 {
169
164
170 }
165 }
171
166
172 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
167 void QChart::resizeEvent(QGraphicsSceneResizeEvent *event)
173 {
168 {
174
169
175 m_rect = QRectF(QPoint(0,0),event->newSize());
170 m_rect = QRectF(QPoint(0,0),event->newSize());
176 QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
171 QRectF rect = m_rect.adjusted(margin(),margin(), -margin(), -margin());
177
172
178 // recalculate title position
173 // recalculate title position
179 if (m_titleItem) {
174 if (m_titleItem) {
180 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
175 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
181 m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
176 m_titleItem->setPos(center.x(),m_rect.top()/2 + margin()/2);
182 }
177 }
183
178
184 //recalculate background gradient
179 //recalculate background gradient
185 if (m_backgroundItem) {
180 if (m_backgroundItem) {
186 m_backgroundItem->setRect(rect);
181 m_backgroundItem->setRect(rect);
187 }
182 }
188
183
189 QGraphicsWidget::resizeEvent(event);
184 QGraphicsWidget::resizeEvent(event);
190 update();
185 update();
191 }
186 }
192
187
193 #include "moc_qchart.cpp"
188 #include "moc_qchart.cpp"
194
189
195 QTCOMMERCIALCHART_END_NAMESPACE
190 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,140 +1,140
1 #include "qscatterseries.h"
1 #include "qscatterseries.h"
2 #include "qscatterseries_p.h"
2 #include "qscatterseries_p.h"
3 #include "qchart.h"
3 #include "qchart.h"
4 #include <QPainter>
4 #include <QPainter>
5 #include <QGraphicsScene>
5 #include <QGraphicsScene>
6 #include <QDebug>
6 #include <QDebug>
7
7
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9
9
10 //#define QSeriesData QList<qreal>
10 //#define QSeriesData QList<qreal>
11
11
12 QScatterSeriesPrivate::QScatterSeriesPrivate(QGraphicsItem *parent) :
12 QScatterSeriesPrivate::QScatterSeriesPrivate(QGraphicsItem *parent) :
13 ChartItem(parent),
13 ChartItem(parent),
14 m_boundingRect(),
14 m_boundingRect(),
15 m_markerColor(QColor()),
15 m_markerColor(QColor()),
16 m_visibleChartArea()
16 m_visibleChartArea()
17 {
17 {
18 if (parent)
18 if (parent)
19 m_boundingRect = parent->boundingRect();
19 m_boundingRect = parent->boundingRect();
20 }
20 }
21
21
22 void QScatterSeriesPrivate::changeGeometry()
22 void QScatterSeriesPrivate::changeGeometry()
23 {
23 {
24 if (m_boundingRect.isValid()) {
24 if (m_boundingRect.isValid()) {
25 prepareGeometryChange();
25 prepareGeometryChange();
26 qreal scalex = m_boundingRect.width() / m_visibleChartArea.spanX();
26 qreal scalex = m_boundingRect.width() / m_visibleChartArea.spanX();
27 qreal scaley = m_boundingRect.height() / m_visibleChartArea.spanY();
27 qreal scaley = m_boundingRect.height() / m_visibleChartArea.spanY();
28 m_scenex.clear();
28 m_scenex.clear();
29 m_sceney.clear();
29 m_sceney.clear();
30
30
31 // Convert relative coordinates to absolute pixel coordinates that can be used for drawing
31 // Convert relative coordinates to absolute pixel coordinates that can be used for drawing
32 foreach(qreal x, m_x)
32 foreach(qreal x, m_x)
33 m_scenex.append(m_boundingRect.left() + x * scalex - m_visibleChartArea.m_minX * scalex);
33 m_scenex.append(m_boundingRect.left() + x * scalex - m_visibleChartArea.m_minX * scalex);
34
34
35 foreach(qreal y, m_y)
35 foreach(qreal y, m_y)
36 m_sceney.append(m_boundingRect.bottom() - y * scaley + m_visibleChartArea.m_minY * scaley);
36 m_sceney.append(m_boundingRect.bottom() - y * scaley + m_visibleChartArea.m_minY * scaley);
37 }
37 }
38 }
38 }
39
39
40 void QScatterSeriesPrivate::setSize(const QSizeF &size)
40 void QScatterSeriesPrivate::setSize(const QSizeF &size)
41 {
41 {
42 // m_boundingRect = QRectF(pos().x(), pos().y(), size.width(), size.height());
42 // m_boundingRect = QRectF(pos().x(), pos().y(), size.width(), size.height());
43 m_boundingRect = QRectF(0, 0, size.width(), size.height());
43 m_boundingRect = QRectF(0, 0, size.width(), size.height());
44 changeGeometry();
44 changeGeometry();
45 }
45 }
46
46
47 void QScatterSeriesPrivate::themeChanged(ChartTheme *theme)
47 void QScatterSeriesPrivate::themeChanged(ChartTheme *theme)
48 {
48 {
49 //m_theme = theme->themeForSeries();
49 //m_theme = theme->themeForSeries();
50 }
50 }
51
51
52 void QScatterSeriesPrivate::setPlotDomain(const PlotDomain& plotDomain)
52 void QScatterSeriesPrivate::setPlotDomain(const Domain& plotDomain)
53 {
53 {
54 m_visibleChartArea = plotDomain;
54 //m_visibleChartArea = plotDomain;
55 changeGeometry();
55 changeGeometry();
56 }
56 }
57
57
58 QRectF QScatterSeriesPrivate::boundingRect() const
58 QRectF QScatterSeriesPrivate::boundingRect() const
59 {
59 {
60 return m_boundingRect;
60 return m_boundingRect;
61 }
61 }
62
62
63 void QScatterSeriesPrivate::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
63 void QScatterSeriesPrivate::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
64 {
64 {
65 // TODO: The opacity should be user definable?
65 // TODO: The opacity should be user definable?
66 //brush.setColor(QColor(255, 82, 0, 100));
66 //brush.setColor(QColor(255, 82, 0, 100));
67 if (m_markerColor.isValid()) {
67 if (m_markerColor.isValid()) {
68 QPen pen = painter->pen();
68 QPen pen = painter->pen();
69 QBrush brush = pen.brush();
69 QBrush brush = pen.brush();
70 brush.setColor(m_markerColor);
70 brush.setColor(m_markerColor);
71 pen.setBrush(brush);
71 pen.setBrush(brush);
72 pen.setWidth(4);
72 pen.setWidth(4);
73 painter->setPen(pen);
73 painter->setPen(pen);
74 }
74 }
75 else
75 else
76 //painter->setPen(m_theme.markerPen);
76 //painter->setPen(m_theme.markerPen);
77 // brush.setColor(m_theme..lineColor);
77 // brush.setColor(m_theme..lineColor);
78
78
79 // TODO: m_scenex and m_sceny are left empty during construction -> we would need a resize
79 // TODO: m_scenex and m_sceny are left empty during construction -> we would need a resize
80 // event right after construction or maybe given a size during initialization
80 // event right after construction or maybe given a size during initialization
81 for (int i(0); i < m_scenex.count() && i < m_sceney.count(); i++) {
81 for (int i(0); i < m_scenex.count() && i < m_sceney.count(); i++) {
82 if (scene()->width() > m_scenex.at(i) && scene()->height() > m_sceney.at(i))
82 if (scene()->width() > m_scenex.at(i) && scene()->height() > m_sceney.at(i))
83 //painter->drawArc(m_scenex.at(i), m_sceney.at(i), 2, 2, 0, 5760);
83 //painter->drawArc(m_scenex.at(i), m_sceney.at(i), 2, 2, 0, 5760);
84 painter->drawPoint(m_scenex.at(i), m_sceney.at(i));
84 painter->drawPoint(m_scenex.at(i), m_sceney.at(i));
85 }
85 }
86 }
86 }
87
87
88 QScatterSeries::QScatterSeries(QObject *parent) :
88 QScatterSeries::QScatterSeries(QObject *parent) :
89 QChartSeries(parent),
89 QChartSeries(parent),
90 d(new QScatterSeriesPrivate(qobject_cast<QGraphicsItem *> (parent)))
90 d(new QScatterSeriesPrivate(qobject_cast<QGraphicsItem *> (parent)))
91 {
91 {
92 }
92 }
93
93
94 bool QScatterSeries::setData(QList<qreal> xlist, QList<qreal> ylist)
94 bool QScatterSeries::setData(QList<qreal> xlist, QList<qreal> ylist)
95 {
95 {
96 // TODO: validate data
96 // TODO: validate data
97 d->m_x = xlist;
97 d->m_x = xlist;
98 d->m_y = ylist;
98 d->m_y = ylist;
99
99
100 // TODO: the following updates the visible chart area setting of the series, we would instead
100 // TODO: the following updates the visible chart area setting of the series, we would instead
101 // need to update the _chart's_ visible area... this would require a callback or
101 // need to update the _chart's_ visible area... this would require a callback or
102 // similar to the parenting QChart object...
102 // similar to the parenting QChart object...
103 foreach (qreal x, d->m_x) {
103 foreach (qreal x, d->m_x) {
104 d->m_visibleChartArea.m_minX = qMin(d->m_visibleChartArea.m_minX, x);
104 d->m_visibleChartArea.m_minX = qMin(d->m_visibleChartArea.m_minX, x);
105 d->m_visibleChartArea.m_maxX = qMax(d->m_visibleChartArea.m_maxX, x);
105 d->m_visibleChartArea.m_maxX = qMax(d->m_visibleChartArea.m_maxX, x);
106 }
106 }
107 foreach (qreal y, d->m_y) {
107 foreach (qreal y, d->m_y) {
108 d->m_visibleChartArea.m_minY = qMin(d->m_visibleChartArea.m_minY, y);
108 d->m_visibleChartArea.m_minY = qMin(d->m_visibleChartArea.m_minY, y);
109 d->m_visibleChartArea.m_maxY = qMax(d->m_visibleChartArea.m_maxY, y);
109 d->m_visibleChartArea.m_maxY = qMax(d->m_visibleChartArea.m_maxY, y);
110 }
110 }
111
111
112 d->changeGeometry();
112 d->changeGeometry();
113
113
114 return true;
114 return true;
115 }
115 }
116
116
117 void QScatterSeries::setMarkerColor(QColor color)
117 void QScatterSeries::setMarkerColor(QColor color)
118 {
118 {
119 d->m_markerColor = color;
119 d->m_markerColor = color;
120 }
120 }
121
121
122 QColor QScatterSeries::markerColor()
122 QColor QScatterSeries::markerColor()
123 {
123 {
124 return d->m_markerColor;
124 return d->m_markerColor;
125 }
125 }
126
126
127 // TODO:
127 // TODO:
128 //void QScatterSeries::chartScaleChanged(qreal xscale, qreal yscale)
128 //void QScatterSeries::chartScaleChanged(qreal xscale, qreal yscale)
129 //{
129 //{
130 // d->rescale(xscale, yscale);
130 // d->rescale(xscale, yscale);
131 //}
131 //}
132
132
133 QScatterSeries::~QScatterSeries()
133 QScatterSeries::~QScatterSeries()
134 {
134 {
135 delete d;
135 delete d;
136 }
136 }
137
137
138 #include "moc_qscatterseries.cpp"
138 #include "moc_qscatterseries.cpp"
139
139
140 QTCOMMERCIALCHART_END_NAMESPACE
140 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,47 +1,47
1 #ifndef QSCATTERSERIESPRIVATE_H
1 #ifndef QSCATTERSERIESPRIVATE_H
2 #define QSCATTERSERIESPRIVATE_H
2 #define QSCATTERSERIESPRIVATE_H
3
3
4 #include "qchartseries.h"
4 #include "qchartseries.h"
5 #include "charttheme_p.h"
5 #include "charttheme_p.h"
6 #include "chartitem_p.h"
6 #include "chartitem_p.h"
7 #include "plotdomain_p.h"
7 #include "domain_p.h"
8 #include <QGraphicsItem>
8 #include <QGraphicsItem>
9
9
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 QTCOMMERCIALCHART_BEGIN_NAMESPACE
11
11
12 /*!
12 /*!
13 * The PIMPL class of QScatterSeries.
13 * The PIMPL class of QScatterSeries.
14 */
14 */
15 class QScatterSeriesPrivate : public ChartItem
15 class QScatterSeriesPrivate : public ChartItem
16 {
16 {
17 public:
17 public:
18 QScatterSeriesPrivate(QGraphicsItem *parent);
18 QScatterSeriesPrivate(QGraphicsItem *parent);
19
19
20 public: // from ChartObjectInterface
20 public: // from ChartObjectInterface
21 void setSize(const QSizeF &size);
21 void setSize(const QSizeF &size);
22 void setPlotDomain(const PlotDomain& data);
22 void setPlotDomain(const Domain& data);
23
23
24 public: // from ChartThemeObserver
24 public: // from ChartThemeObserver
25 void themeChanged(ChartTheme *theme);
25 void themeChanged(ChartTheme *theme);
26
26
27 public: // from QGraphicsItem
27 public: // from QGraphicsItem
28 QRectF boundingRect() const;
28 QRectF boundingRect() const;
29 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
29 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
30
30
31 public:
31 public:
32 void changeGeometry();
32 void changeGeometry();
33
33
34 QRectF m_boundingRect;
34 QRectF m_boundingRect;
35 // TODO: use the chart data class instead of list of x and y values?
35 // TODO: use the chart data class instead of list of x and y values?
36 QList<qreal> m_x;
36 QList<qreal> m_x;
37 QList<qreal> m_y;
37 QList<qreal> m_y;
38 QList<qreal> m_scenex;
38 QList<qreal> m_scenex;
39 QList<qreal> m_sceney;
39 QList<qreal> m_sceney;
40 QColor m_markerColor;
40 QColor m_markerColor;
41 //SeriesTheme m_theme;
41 //SeriesTheme m_theme;
42 PlotDomain m_visibleChartArea;
42 Domain m_visibleChartArea;
43 };
43 };
44
44
45 QTCOMMERCIALCHART_END_NAMESPACE
45 QTCOMMERCIALCHART_END_NAMESPACE
46
46
47 #endif // QSCATTERSERIESPRIVATE_H
47 #endif // QSCATTERSERIESPRIVATE_H
@@ -1,110 +1,108
1 !include( ../common.pri ):error( Couldn't find the common.pri file! )
1 !include( ../common.pri ):error( Couldn't find the common.pri file! )
2 TARGET = QtCommercialChart
2 TARGET = QtCommercialChart
3 DESTDIR = $$CHART_BUILD_LIB_DIR
3 DESTDIR = $$CHART_BUILD_LIB_DIR
4 TEMPLATE = lib
4 TEMPLATE = lib
5 QT += core \
5 QT += core \
6 gui
6 gui
7 CONFIG += debug_and_release
7 CONFIG += debug_and_release
8 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
8 CONFIG(debug, debug|release):TARGET = QtCommercialChartd
9 SOURCES += barchart/barchartseries.cpp \
9 SOURCES += barchart/barchartseries.cpp \
10 barchart/bargroup.cpp \
10 barchart/bargroup.cpp \
11 barchart/bar.cpp \
11 barchart/bar.cpp \
12 barchart/stackedbarchartseries.cpp \
12 barchart/stackedbarchartseries.cpp \
13 barchart/stackedbargroup.cpp \
13 barchart/stackedbargroup.cpp \
14 barchart/percentbarchartseries.cpp \
14 barchart/percentbarchartseries.cpp \
15 barchart/percentbargroup.cpp \
15 barchart/percentbargroup.cpp \
16 barchart/barlabel.cpp \
16 barchart/barlabel.cpp \
17 linechart/linechartanimationitem.cpp \
17 linechart/linechartanimationitem.cpp \
18 linechart/linechartitem.cpp \
18 linechart/linechartitem.cpp \
19 linechart/qlinechartseries.cpp \
19 linechart/qlinechartseries.cpp \
20 barchart/separator.cpp \
20 barchart/separator.cpp \
21 barchart/bargroupbase.cpp \
21 barchart/bargroupbase.cpp \
22 barchart/barchartseriesbase.cpp \
22 barchart/barchartseriesbase.cpp \
23 plotdomain.cpp \
24 qscatterseries.cpp \
23 qscatterseries.cpp \
25 qchart.cpp \
24 qchart.cpp \
26 axisitem.cpp \
25 axisitem.cpp \
27 qchartview.cpp \
26 qchartview.cpp \
28 qchartseries.cpp \
27 qchartseries.cpp \
29 qchartaxis.cpp \
28 qchartaxis.cpp \
30 charttheme.cpp \
29 charttheme.cpp \
31 chartdataset.cpp \
30 chartdataset.cpp \
32 chartpresenter.cpp \
31 chartpresenter.cpp \
33 domain.cpp
32 domain.cpp
34 PRIVATE_HEADERS += linechart/linechartitem_p.h \
33 PRIVATE_HEADERS += linechart/linechartitem_p.h \
35 linechart/linechartanimationitem_p.h \
34 linechart/linechartanimationitem_p.h \
36 barchart/barlabel_p.h \
35 barchart/barlabel_p.h \
37 barchart/bar_p.h \
36 barchart/bar_p.h \
38 barchart/separator_p.h \
37 barchart/separator_p.h \
39 plotdomain_p.h \
40 qscatterseries_p.h \
38 qscatterseries_p.h \
41 axisitem_p.h \
39 axisitem_p.h \
42 chartitem_p.h \
40 chartitem_p.h \
43 charttheme_p.h \
41 charttheme_p.h \
44 chartdataset_p.h \
42 chartdataset_p.h \
45 chartpresenter_p.h \
43 chartpresenter_p.h \
46 domain_p.h
44 domain_p.h
47 PUBLIC_HEADERS += linechart/qlinechartseries.h \
45 PUBLIC_HEADERS += linechart/qlinechartseries.h \
48 barchart/barchartseries.h \
46 barchart/barchartseries.h \
49 barchart/bargroup.h \
47 barchart/bargroup.h \
50 barchart/stackedbarchartseries.h \
48 barchart/stackedbarchartseries.h \
51 barchart/stackedbargroup.h \
49 barchart/stackedbargroup.h \
52 barchart/percentbarchartseries.h \
50 barchart/percentbarchartseries.h \
53 barchart/percentbargroup.h \
51 barchart/percentbargroup.h \
54 barchart/barchartseriesbase.h \
52 barchart/barchartseriesbase.h \
55 barchart/bargroupbase.h \
53 barchart/bargroupbase.h \
56 qchartseries.h \
54 qchartseries.h \
57 qscatterseries.h \
55 qscatterseries.h \
58 qchart.h \
56 qchart.h \
59 qchartglobal.h \
57 qchartglobal.h \
60 qchartview.h \
58 qchartview.h \
61 qchartaxis.h
59 qchartaxis.h
62
60
63 include(piechart/piechart.pri)
61 include(piechart/piechart.pri)
64
62
65 THEMES += themes/chartthemeicy_p.h \
63 THEMES += themes/chartthemeicy_p.h \
66 themes/chartthemegrayscale_p.h \
64 themes/chartthemegrayscale_p.h \
67 themes/chartthemescientific_p.h \
65 themes/chartthemescientific_p.h \
68 themes/chartthemevanilla_p.h
66 themes/chartthemevanilla_p.h
69 HEADERS += $$PUBLIC_HEADERS
67 HEADERS += $$PUBLIC_HEADERS
70 HEADERS += $$PRIVATE_HEADERS
68 HEADERS += $$PRIVATE_HEADERS
71 HEADERS += $$THEMES
69 HEADERS += $$THEMES
72 INCLUDEPATH += linechart \
70 INCLUDEPATH += linechart \
73 barchart \
71 barchart \
74 themes \
72 themes \
75 .
73 .
76 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
74 OBJECTS_DIR = $$CHART_BUILD_DIR/lib
77 MOC_DIR = $$CHART_BUILD_DIR/lib
75 MOC_DIR = $$CHART_BUILD_DIR/lib
78 UI_DIR = $$CHART_BUILD_DIR/lib
76 UI_DIR = $$CHART_BUILD_DIR/lib
79 RCC_DIR = $$CHART_BUILD_DIR/lib
77 RCC_DIR = $$CHART_BUILD_DIR/lib
80 DEFINES += QTCOMMERCIALCHART_LIBRARY
78 DEFINES += QTCOMMERCIALCHART_LIBRARY
81 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
79 public_headers.path = $$[QT_INSTALL_HEADERS]/QtCommercialChart
82 public_headers.files = $$PUBLIC_HEADERS
80 public_headers.files = $$PUBLIC_HEADERS
83 target.path = $$[QT_INSTALL_LIBS]
81 target.path = $$[QT_INSTALL_LIBS]
84 INSTALLS += target \
82 INSTALLS += target \
85 public_headers
83 public_headers
86 install_build_headers.name = bild_headers
84 install_build_headers.name = bild_headers
87 install_build_headers.output = $$CHART_BUILD_HEADER_DIR/${QMAKE_FILE_BASE}.h
85 install_build_headers.output = $$CHART_BUILD_HEADER_DIR/${QMAKE_FILE_BASE}.h
88 install_build_headers.input = PUBLIC_HEADERS
86 install_build_headers.input = PUBLIC_HEADERS
89 install_build_headers.commands = $$QMAKE_COPY \
87 install_build_headers.commands = $$QMAKE_COPY \
90 ${QMAKE_FILE_NAME} \
88 ${QMAKE_FILE_NAME} \
91 $$CHART_BUILD_HEADER_DIR
89 $$CHART_BUILD_HEADER_DIR
92 install_build_headers.CONFIG += target_predeps \
90 install_build_headers.CONFIG += target_predeps \
93 no_link
91 no_link
94 QMAKE_EXTRA_COMPILERS += install_build_headers
92 QMAKE_EXTRA_COMPILERS += install_build_headers
95 chartversion.target = qchartversion_p.h
93 chartversion.target = qchartversion_p.h
96 chartversion.commands = @echo \
94 chartversion.commands = @echo \
97 "build_time" \
95 "build_time" \
98 > \
96 > \
99 $$chartversion.target;
97 $$chartversion.target;
100 chartversion.depends = $$HEADERS \
98 chartversion.depends = $$HEADERS \
101 $$SOURCES
99 $$SOURCES
102 PRE_TARGETDEPS += qchartversion_p.h
100 PRE_TARGETDEPS += qchartversion_p.h
103 QMAKE_CLEAN += qchartversion_p.h
101 QMAKE_CLEAN += qchartversion_p.h
104 QMAKE_EXTRA_TARGETS += chartversion
102 QMAKE_EXTRA_TARGETS += chartversion
105 unix:QMAKE_DISTCLEAN += -r \
103 unix:QMAKE_DISTCLEAN += -r \
106 $$CHART_BUILD_HEADER_DIR \
104 $$CHART_BUILD_HEADER_DIR \
107 $$CHART_BUILD_LIB_DIR
105 $$CHART_BUILD_LIB_DIR
108 win32:QMAKE_DISTCLEAN += /Q \
106 win32:QMAKE_DISTCLEAN += /Q \
109 $$CHART_BUILD_HEADER_DIR \
107 $$CHART_BUILD_HEADER_DIR \
110 $$CHART_BUILD_LIB_DIR
108 $$CHART_BUILD_LIB_DIR
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now