-
Notifications
You must be signed in to change notification settings - Fork 2
/
MapView.h
71 lines (57 loc) · 1.73 KB
/
MapView.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
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include <QGraphicsView>
#include "MapItem.h"
#include "PointItem.h"
#include "PathItem.h"
#include <QGeoCoordinate>
class QWheelEvent;
class QKeyEvent;
class QGestureEvent;
class MapView : public QGraphicsView, public IItemMoving
{
Q_OBJECT
signals:
void GeoCoordinateOnMap(QGeoCoordinate);
void pathBuildFinished(QList<QPointF>);
public:
explicit MapView(QWidget *parent = 0);
void setTranslateSpeed(qreal speed);
qreal translateSpeed() const;
void setZoomDelta(qreal delta);
qreal zoomDelta() const;
public:
virtual bool event(QEvent *event) override;
public Q_SLOTS:
void zoomIn();
void zoomOut();
void zoom(float scaleFactor);
void translateF(QPointF delta);
void resloveView();
void removePathPointAt(int idx);
void removeAllPathPoint();
protected:
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
virtual void wheelEvent(QWheelEvent *event) override;
virtual void onItemMoving() override;
protected:
void gestureEvent(QGestureEvent *event);
private:
void makePointItem(QPoint pos);
void reBuildPath();
void showToolTip(const QGeoCoordinate &);
private:
qreal _translateSpeed;
qreal _zoomDelta;
bool _bMouseTranslate;
QPoint _lastMousePos;
QPointF _lastImgPos;
qreal _scale;
QGraphicsScene _scene;
MapItem *_map;
PathItem *_pathitem;
QList<PointItem*> _pointItems;
};
#endif // MAPVIEW_H