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