@@ -1,146 +1,146 | |||
|
1 | 1 | /**************************************************************************** |
|
2 | 2 | ** |
|
3 | 3 | ** Copyright (C) 2013 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 Enterprise Charts Add-on. |
|
8 | 8 | ** |
|
9 | 9 | ** $QT_BEGIN_LICENSE$ |
|
10 | 10 | ** Licensees holding valid Qt Enterprise licenses may use this file in |
|
11 | 11 | ** accordance with the Qt Enterprise 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 | // W A R N I N G |
|
22 | 22 | // ------------- |
|
23 | 23 | // |
|
24 | 24 | // This file is not part of the Qt Enterprise Chart API. It exists purely as an |
|
25 | 25 | // implementation detail. This header file may change from version to |
|
26 | 26 | // version without notice, or even be removed. |
|
27 | 27 | // |
|
28 | 28 | // We mean it. |
|
29 | 29 | |
|
30 | 30 | #ifndef SCATTERCHARTITEM_H |
|
31 | 31 | #define SCATTERCHARTITEM_H |
|
32 | 32 | |
|
33 | 33 | #include "qchartglobal.h" |
|
34 | 34 | #include "xychart_p.h" |
|
35 | 35 | #include <QGraphicsEllipseItem> |
|
36 | 36 | #include <QPen> |
|
37 | 37 | |
|
38 | 38 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
39 | 39 | |
|
40 | 40 | class QScatterSeries; |
|
41 | 41 | |
|
42 | 42 | class ScatterChartItem : public XYChart |
|
43 | 43 | { |
|
44 | 44 | Q_OBJECT |
|
45 | 45 | Q_INTERFACES(QGraphicsItem) |
|
46 | 46 | public: |
|
47 | 47 | explicit ScatterChartItem(QScatterSeries *series, QGraphicsItem *item = 0); |
|
48 | 48 | |
|
49 | 49 | public: |
|
50 | 50 | //from QGraphicsItem |
|
51 | 51 | QRectF boundingRect() const; |
|
52 | 52 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
53 | 53 | |
|
54 | 54 | void setPen(const QPen &pen); |
|
55 | 55 | void setBrush(const QBrush &brush); |
|
56 | 56 | |
|
57 | 57 | void markerSelected(QGraphicsItem *item); |
|
58 | 58 | void markerHovered(QGraphicsItem *item, bool state); |
|
59 | 59 | |
|
60 | 60 | public Q_SLOTS: |
|
61 | 61 | void handleUpdated(); |
|
62 | 62 | |
|
63 | 63 | private: |
|
64 | 64 | void createPoints(int count); |
|
65 | 65 | void deletePoints(int count); |
|
66 | 66 | |
|
67 | 67 | protected: |
|
68 | 68 | void updateGeometry(); |
|
69 | 69 | |
|
70 | 70 | private: |
|
71 | 71 | QScatterSeries *m_series; |
|
72 | 72 | QGraphicsItemGroup m_items; |
|
73 | 73 | bool m_visible; |
|
74 | 74 | int m_shape; |
|
75 | 75 | int m_size; |
|
76 | 76 | QRectF m_rect; |
|
77 | 77 | QMap<QGraphicsItem *, QPointF> m_markerMap; |
|
78 | 78 | }; |
|
79 | 79 | |
|
80 | 80 | class CircleMarker: public QGraphicsEllipseItem |
|
81 | 81 | { |
|
82 | 82 | |
|
83 | 83 | public: |
|
84 | 84 | CircleMarker(qreal x, qreal y, qreal w, qreal h, ScatterChartItem *parent) |
|
85 | 85 | : QGraphicsEllipseItem(x, y, w, h, parent), |
|
86 | 86 | m_parent(parent) |
|
87 | 87 | { |
|
88 | 88 | setAcceptHoverEvents(true); |
|
89 | 89 | } |
|
90 | 90 | |
|
91 | 91 | protected: |
|
92 | 92 | void mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
93 | 93 | { |
|
94 | m_parent->markerSelected(this); | |
|
95 | 94 | QGraphicsEllipseItem::mousePressEvent(event); |
|
95 | m_parent->markerSelected(this); | |
|
96 | 96 | } |
|
97 | 97 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
98 | 98 | { |
|
99 | m_parent->markerHovered(this, true); | |
|
100 | 99 | QGraphicsEllipseItem::hoverEnterEvent(event); |
|
100 | m_parent->markerHovered(this, true); | |
|
101 | 101 | } |
|
102 | 102 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
103 | 103 | { |
|
104 | m_parent->markerHovered(this, false); | |
|
105 | 104 | QGraphicsEllipseItem::hoverLeaveEvent(event); |
|
105 | m_parent->markerHovered(this, false); | |
|
106 | 106 | } |
|
107 | 107 | |
|
108 | 108 | private: |
|
109 | 109 | ScatterChartItem *m_parent; |
|
110 | 110 | }; |
|
111 | 111 | |
|
112 | 112 | class RectangleMarker: public QGraphicsRectItem |
|
113 | 113 | { |
|
114 | 114 | |
|
115 | 115 | public: |
|
116 | 116 | RectangleMarker(qreal x, qreal y, qreal w, qreal h, ScatterChartItem *parent) |
|
117 | 117 | : QGraphicsRectItem(x, y, w, h, parent), |
|
118 | 118 | m_parent(parent) |
|
119 | 119 | { |
|
120 | 120 | setAcceptHoverEvents(true); |
|
121 | 121 | } |
|
122 | 122 | |
|
123 | 123 | protected: |
|
124 | 124 | void mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
125 | 125 | { |
|
126 | m_parent->markerSelected(this); | |
|
127 | 126 | QGraphicsRectItem::mousePressEvent(event); |
|
127 | m_parent->markerSelected(this); | |
|
128 | 128 | } |
|
129 | 129 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
|
130 | 130 | { |
|
131 | m_parent->markerHovered(this, true); | |
|
132 | 131 | QGraphicsRectItem::hoverEnterEvent(event); |
|
132 | m_parent->markerHovered(this, true); | |
|
133 | 133 | } |
|
134 | 134 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) |
|
135 | 135 | { |
|
136 | m_parent->markerHovered(this, false); | |
|
137 | 136 | QGraphicsRectItem::hoverLeaveEvent(event); |
|
137 | m_parent->markerHovered(this, false); | |
|
138 | 138 | } |
|
139 | 139 | |
|
140 | 140 | private: |
|
141 | 141 | ScatterChartItem *m_parent; |
|
142 | 142 | }; |
|
143 | 143 | |
|
144 | 144 | QTCOMMERCIALCHART_END_NAMESPACE |
|
145 | 145 | |
|
146 | 146 | #endif // SCATTERPRESENTER_H |
General Comments 0
You need to be logged in to leave comments.
Login now