-
Notifications
You must be signed in to change notification settings - Fork 17
/
mapoperator.h
255 lines (214 loc) · 6.69 KB
/
mapoperator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#ifndef MAPOPERATOR_H
#define MAPOPERATOR_H
#include "interactivemap.h"
class MapOperator;
class MapEllipseItem;
class MapPolygonItem;
class MapRouteItem;
class MapObjectItem;
class MapRangeRingItem;
class MapTrailItem;
class MapLineItem;
class MapRectItem;
class MapTableItem;
/*!
* \brief 圆形创建操作器
* \details 左键双击完成创建
*/
class GRAPHICSMAPLIB_EXPORT MapEllipseOperator : public MapOperator
{
Q_OBJECT
public:
MapEllipseOperator(QObject *parent = nullptr);
/// 接管已经创建的圆形(请确保被应用为操作器后再调用)
void takeOver(MapEllipseItem *item);
signals:
void created(MapEllipseItem *item);
void deleted(MapEllipseItem *item);
protected:
virtual void ready() override;
virtual void end() override;
virtual bool keyPressEvent(QKeyEvent *event) override;
virtual bool mouseDoubleClickEvent(QMouseEvent *) override;
virtual bool mousePressEvent(QMouseEvent *event) override;
virtual bool mouseReleaseEvent(QMouseEvent *event) override;
virtual bool mouseMoveEvent(QMouseEvent *event) override;
private:
void detach();
private:
QGeoCoordinate m_first;
MapEllipseItem *m_ellipse;
};
/*!
* \brief 多边形创建操作器
* \details 左键双击结束编辑
*/
class GRAPHICSMAPLIB_EXPORT MapPolygonOperator : public MapOperator
{
Q_OBJECT
public:
MapPolygonOperator(QObject *parent = nullptr);
/// 接管已经创建的多边行(请确保被应用为操作器后再调用)
void takeOver(MapPolygonItem *item);
signals:
void created(MapPolygonItem *item);
void deleted(MapPolygonItem *item);
protected:
virtual void ready() override;
virtual void end() override;
virtual bool keyPressEvent(QKeyEvent *event) override;
virtual bool mouseDoubleClickEvent(QMouseEvent *event) override;
virtual bool mousePressEvent(QMouseEvent *event) override;
virtual bool mouseReleaseEvent(QMouseEvent *event) override;
private:
void detach();
private:
QPoint m_pressPos;
MapPolygonItem *m_polygon;
};
/*!
* \brief 图标对象创建操作器
* \details 左键单击完成单图标对象的创建,右键双击结束编辑
*/
class GRAPHICSMAPLIB_EXPORT MapObjectOperator : public MapOperator
{
Q_OBJECT
public:
MapObjectOperator(QObject *parent = nullptr);
/// 接管已经创建的对象
void takeOver(MapObjectItem *item);
signals:
void created(MapObjectItem *item);
void deleted(MapObjectItem *item);
protected:
virtual void ready() override;
virtual void end() override;
virtual bool keyPressEvent(QKeyEvent *event) override;
virtual bool mousePressEvent(QMouseEvent *event) override;
virtual bool mouseReleaseEvent(QMouseEvent *event) override;
virtual bool mouseDoubleClickEvent(QMouseEvent *event) override;
private:
void detach();
private:
QPoint m_pressPos;
MapObjectItem *m_obj = nullptr;
};
/*!
* \brief 图标对象标签创建操作器
* \details
*/
class GRAPHICSMAPLIB_EXPORT MapScutcheonOperator : public MapOperator
{
Q_OBJECT
public:
MapScutcheonOperator(QObject *parent = nullptr);
/// 接管已经创建的对象
void takeOver(MapTableItem *item);
/// 设置是否忽略鼠标事件
void setIgnoreMouseEvent(bool bIgnore);
void setOffset(const QPoint &offset);
QPoint GetOffset() const {return m_Offset; }
signals:
void changeOffset();
protected:
virtual void ready() override;
virtual void end() override;
virtual bool keyPressEvent(QKeyEvent *event) override;
virtual bool mouseMoveEvent(QMouseEvent * event) override;
virtual bool mousePressEvent(QMouseEvent *event) override;
virtual bool mouseReleaseEvent(QMouseEvent *event) override;
virtual bool mouseDoubleClickEvent(QMouseEvent *event) override;
private:
bool m_bMousePress;
QPoint m_PressPosition;
QPoint m_Offset;
MapTableItem *m_toolTip;
bool m_bIgnoreEvent; // 鼠标忽略
};
/*!
* \brief 航路创建操作器
* \details 双击和右键完成单航路的创建,多次点击实现新增航点
*/
class GRAPHICSMAPLIB_EXPORT MapRouteOperator : public MapOperator
{
Q_OBJECT
public:
MapRouteOperator(QObject *parent = nullptr);
/// 接管已经创建的航路(请确保被应用为操作器后再调用)
void takeOver(MapRouteItem *item);
/// 设置航点的默认图标
void setWaypointIcon(const QPixmap &pixmap);
signals:
///< 创建信号
void created(MapRouteItem *item);
void deleted(MapRouteItem *item);
protected:
virtual void ready() override;
virtual void end() override;
virtual bool keyPressEvent(QKeyEvent *event) override;
virtual bool mouseDoubleClickEvent(QMouseEvent *event) override;
virtual bool mousePressEvent(QMouseEvent *event) override;
virtual bool mouseReleaseEvent(QMouseEvent *event) override;
private:
QPoint m_pressPos;
//
MapRouteItem *m_route = nullptr;
//
QPixmap m_waypointIcon;
};
/*!
* \brief 测距线段操作器
* \details 完成测距线段的创建及修改
*/
class GRAPHICSMAPLIB_EXPORT MapRangeLineOperator : public MapOperator
{
Q_OBJECT
public:
MapRangeLineOperator(QObject *parent = nullptr);
signals:
///< 创建信号
void created(MapLineItem *item);
void deleted(MapLineItem *item);
protected:
virtual void ready() override;
virtual void end() override;
virtual bool keyPressEvent(QKeyEvent *event) override;
virtual bool mousePressEvent(QMouseEvent *event) override;
virtual bool mouseReleaseEvent(QMouseEvent *event) override;
virtual bool mouseMoveEvent(QMouseEvent *event) override;
private:
QPoint m_pressEndPos;
QPoint m_pressFirstPos;
//
MapLineItem *m_line;
};
/*!
* \brief 矩形创建操作器
* \details 左键双击完成编辑
*/
class GRAPHICSMAPLIB_EXPORT MapRectOperator : public MapOperator
{
Q_OBJECT
public:
MapRectOperator(QObject *parent = nullptr);
/// 接管已经创建的矩形(请确保被应用为操作器后再调用)
void takeOver(MapRectItem *item);
signals:
void created(MapRectItem *item);
void deleted(MapRectItem *item);
protected:
virtual void ready() override;
virtual void end() override;
virtual bool keyPressEvent(QKeyEvent *event) override;
virtual bool mousePressEvent(QMouseEvent *event) override;
virtual bool mouseDoubleClickEvent(QMouseEvent *event) override;
virtual bool mouseReleaseEvent(QMouseEvent *event) override;
virtual bool mouseMoveEvent(QMouseEvent *event) override;
private:
void detach();
private:
bool m_ignoreEvent;
QGeoCoordinate m_first;
MapRectItem *m_rect;
};
#endif // MAPOPERATOR_H