forked from OlivierDelbeke/MapGraphics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapGraphicsView.h
More file actions
116 lines (90 loc) · 2.9 KB
/
Copy pathMapGraphicsView.h
File metadata and controls
116 lines (90 loc) · 2.9 KB
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
#ifndef MAPGRAPHICSVIEW_H
#define MAPGRAPHICSVIEW_H
#include <QWidget>
#include <QPointer>
#include <QSharedPointer>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QList>
#include <QContextMenuEvent>
#include <QVector3D>
#include <QStringBuilder>
#include <QHash>
#include "MapGraphicsScene.h"
#include "MapGraphicsObject.h"
#include "MapTileSource.h"
#include "MapGraphics_global.h"
#include "guts/MapTileGraphicsObject.h"
#include "guts/PrivateQGraphicsInfoSource.h"
class MAPGRAPHICSSHARED_EXPORT MapGraphicsView : public QWidget, public PrivateQGraphicsInfoSource
{
Q_OBJECT
public:
enum DragMode
{
NoDrag,
ScrollHandDrag,
RubberBandDrag
};
enum ZoomMode
{
CenterZoom,
MouseZoom
};
public:
explicit MapGraphicsView(MapGraphicsScene * scene=0, QWidget * parent = 0);
virtual ~MapGraphicsView();
QPointF center() const;
void centerOn(const QPointF& pos);
void centerOn(qreal longitude, qreal latitude);
void centerOn(const MapGraphicsObject * item);
QPointF mapToScene(const QPoint viewPos) const;
MapGraphicsView::DragMode dragMode() const;
void setDragMode(MapGraphicsView::DragMode);
MapGraphicsScene * scene() const;
void setScene(MapGraphicsScene *);
//pure-virtual from PrivateQGraphicsInfoSource
QSharedPointer<MapTileSource> tileSource() const;
/**
* @brief Sets the tile source that this view will pull from.
* MapGraphicsView does NOT take ownership of the tile source.
*
* @param tSource
*/
void setTileSource(QSharedPointer<MapTileSource> tSource);
//pure-virtual from PrivateQGraphicsInfoSource
quint8 zoomLevel() const;
void setZoomLevel(quint8 nZoom, ZoomMode zMode = CenterZoom);
void zoomIn(ZoomMode zMode = CenterZoom);
void zoomOut(ZoomMode zMode = CenterZoom);
void rotate(qreal rotation);
signals:
void zoomLevelChanged(quint8 nZoom);
public slots:
protected slots:
virtual void handleChildMouseDoubleClick(QMouseEvent * event);
virtual void handleChildMouseMove(QMouseEvent * event);
virtual void handleChildMousePress(QMouseEvent * event);
virtual void handleChildMouseRelease(QMouseEvent * event);
virtual void handleChildViewContextMenu(QContextMenuEvent * event);
virtual void handleChildViewScrollWheel(QWheelEvent * event);
private slots:
void renderTiles();
protected:
void doTileLayout();
void resetQGSSceneSize();
private:
QPointer<MapGraphicsScene> _scene;
QPointer<QGraphicsView> _childView;
QPointer<QGraphicsScene> _childScene;
QSharedPointer<MapTileSource> _tileSource;
QSet<MapTileGraphicsObject *> _tileObjects;
quint8 _zoomLevel;
DragMode _dragMode;
};
inline uint qHash(const QPointF& key)
{
const QString temp = QString::number(key.x()) % "," % QString::number(key.y());
return qHash(temp);
}
#endif // MAPGRAPHICSVIEW_H