##// END OF EJS Templates
scatterchart: get rid of a warning...
Jani Honkonen -
r1232:8d7d8cb763e0
parent child
Show More
@@ -1,141 +1,142
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef SCATTERCHARTITEM_H
21 #ifndef SCATTERCHARTITEM_H
22 #define SCATTERCHARTITEM_H
22 #define SCATTERCHARTITEM_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "xychart_p.h"
25 #include "xychart_p.h"
26 #include <QGraphicsEllipseItem>
26 #include <QGraphicsEllipseItem>
27 #include <QPen>
27 #include <QPen>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QScatterSeries;
31 class QScatterSeries;
32 class Marker;
32 class Marker;
33
33
34 class ScatterChartItem : public XYChart, public QGraphicsItem
34 class ScatterChartItem : public XYChart, public QGraphicsItem
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37 Q_INTERFACES(QGraphicsItem)
37 public:
38 public:
38 explicit ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter);
39 explicit ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter);
39
40
40 public:
41 public:
41 //from QGraphicsItem
42 //from QGraphicsItem
42 QRectF boundingRect() const;
43 QRectF boundingRect() const;
43 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
44 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
44
45
45 void setPen(const QPen &pen);
46 void setPen(const QPen &pen);
46 void setBrush(const QBrush &brush);
47 void setBrush(const QBrush &brush);
47
48
48 void markerSelected(Marker *item);
49 void markerSelected(Marker *item);
49
50
50 public Q_SLOTS:
51 public Q_SLOTS:
51 void handleUpdated();
52 void handleUpdated();
52
53
53 private:
54 private:
54 void createPoints(int count);
55 void createPoints(int count);
55 void deletePoints(int count);
56 void deletePoints(int count);
56
57
57 protected:
58 protected:
58 void updateGeometry();
59 void updateGeometry();
59 void mousePressEvent(QGraphicsSceneMouseEvent *event);
60 void mousePressEvent(QGraphicsSceneMouseEvent *event);
60
61
61 private:
62 private:
62 QScatterSeries *m_series;
63 QScatterSeries *m_series;
63 QGraphicsItemGroup m_items;
64 QGraphicsItemGroup m_items;
64 int m_shape;
65 int m_shape;
65 int m_size;
66 int m_size;
66 QRectF m_rect;
67 QRectF m_rect;
67
68
68 };
69 };
69
70
70
71
71 class Marker: public QAbstractGraphicsShapeItem
72 class Marker: public QAbstractGraphicsShapeItem
72 {
73 {
73
74
74 public:
75 public:
75
76
76 Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent)
77 Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent)
77 {
78 {
78 }
79 }
79
80
80 ~Marker()
81 ~Marker()
81 {
82 {
82 delete m_item;
83 delete m_item;
83 }
84 }
84
85
85 void setPoint(const QPointF& point)
86 void setPoint(const QPointF& point)
86 {
87 {
87 m_point=point;
88 m_point=point;
88 }
89 }
89
90
90 QPointF point() const
91 QPointF point() const
91 {
92 {
92 return m_point;
93 return m_point;
93 }
94 }
94
95
95 QPainterPath shape() const
96 QPainterPath shape() const
96 {
97 {
97 return m_item->shape();
98 return m_item->shape();
98 }
99 }
99
100
100 QRectF boundingRect() const
101 QRectF boundingRect() const
101 {
102 {
102 return m_item->boundingRect();
103 return m_item->boundingRect();
103 }
104 }
104
105
105 bool contains(const QPointF &point) const
106 bool contains(const QPointF &point) const
106 {
107 {
107 return m_item->contains(point);
108 return m_item->contains(point);
108 }
109 }
109
110
110 void setPen(const QPen &pen)
111 void setPen(const QPen &pen)
111 {
112 {
112 m_item->setPen(pen);
113 m_item->setPen(pen);
113 }
114 }
114
115
115 void setBrush(const QBrush &brush)
116 void setBrush(const QBrush &brush)
116 {
117 {
117 m_item->setBrush(brush);
118 m_item->setBrush(brush);
118 }
119 }
119
120
120 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
121 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
121 {
122 {
122 m_item->paint(painter,option,widget);
123 m_item->paint(painter,option,widget);
123 }
124 }
124
125
125 protected:
126 protected:
126
127
127 void mousePressEvent(QGraphicsSceneMouseEvent *event)
128 void mousePressEvent(QGraphicsSceneMouseEvent *event)
128 {
129 {
129 Q_UNUSED(event)
130 Q_UNUSED(event)
130 m_parent->markerSelected(this);
131 m_parent->markerSelected(this);
131 }
132 }
132
133
133 private:
134 private:
134 QAbstractGraphicsShapeItem* m_item;
135 QAbstractGraphicsShapeItem* m_item;
135 ScatterChartItem* m_parent;
136 ScatterChartItem* m_parent;
136 QPointF m_point;
137 QPointF m_point;
137 };
138 };
138
139
139 QTCOMMERCIALCHART_END_NAMESPACE
140 QTCOMMERCIALCHART_END_NAMESPACE
140
141
141 #endif // SCATTERPRESENTER_H
142 #endif // SCATTERPRESENTER_H
General Comments 0
You need to be logged in to leave comments. Login now