QGeoView  1.0
QGeoView documentation
QGVMapQGView.h
1 /***************************************************************************
2  * QGeoView is a Qt / C ++ widget for visualizing geographic data.
3  * Copyright (C) 2018-2025 Andrey Yaroshenko.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program; if not, see https://www.gnu.org/licenses.
17  ****************************************************************************/
18 
19 #pragma once
20 
21 #include "QGVCamera.h"
22 #include "QGVGlobal.h"
23 #include "QGVMapQGItem.h"
24 #include "QGVMapRubberBand.h"
25 
26 #include <QDragEnterEvent>
27 #include <QDragLeaveEvent>
28 #include <QDragMoveEvent>
29 #include <QDropEvent>
30 #include <QGraphicsView>
31 #include <QMenu>
32 #include <QMimeData>
33 
34 class QGVMap;
35 
36 class QGV_LIB_DECL QGVMapQGView : public QGraphicsView
37 {
38  Q_OBJECT
39 
40 public:
41  explicit QGVMapQGView(QGVMap* geoMap);
42 
43  void setMouseActions(QGV::MouseActions actions);
44  QGV::MouseActions getMouseActions() const;
45 
46  QGVCameraState getCamera() const;
47  void cameraTo(const QGVCameraActions& actions, bool animation);
48  double getMinScale() const;
49  double getMaxScale() const;
50  void setScaleLimits(double minScale, double maxScale);
51  void cleanState();
52 
53 Q_SIGNALS:
54  void dropData(QPointF position, const QMimeData* dropData);
55 
56 private:
57  QRectF viewRect() const;
58  void changeState(QGV::MapState state);
59  void cameraScale(double scale);
60  void cameraScale(const QRectF& projRect);
61  void cameraRotate(double azimuth);
62  void cameraMove(const QPointF& projPos);
63  void blockCameraUpdate();
64  void unblockCameraUpdate();
65  void applyCameraUpdate(const QGVCameraState& oldState);
66 
67  void showTooltip(QHelpEvent* helpEvent);
68  void zoomByWheel(QWheelEvent* event);
69  void startMoving(QMouseEvent* event);
70  void startMovingObject(QMouseEvent* event);
71  void startSelectionRect(QMouseEvent* event);
72  void stopSelectionRect(QMouseEvent* event);
73  void stopMovingObject(QMouseEvent* event);
74  void zoomArea(QMouseEvent* event, QRect areaRect);
75  void selectObjectsByRect(QMouseEvent* event, QRect selRect);
76  void objectClick(QMouseEvent* event);
77  void objectDoubleClick(QMouseEvent* event);
78  void moveForWheel(QMouseEvent* event);
79  void moveForRect(QMouseEvent* event);
80  void moveMap(QMouseEvent* event);
81  void moveObject(QMouseEvent* event);
82  void unselectAll(QMouseEvent* event);
83  void showMenu(QMouseEvent* event);
84 
85  bool event(QEvent* event) override final;
86  void wheelEvent(QWheelEvent* event) override final;
87  void mousePressEvent(QMouseEvent* event) override final;
88  void mouseReleaseEvent(QMouseEvent* event) override final;
89  void mouseMoveEvent(QMouseEvent* event) override final;
90  void mouseDoubleClickEvent(QMouseEvent* event) override final;
91  void resizeEvent(QResizeEvent* event) override final;
92  void showEvent(QShowEvent* event) override final;
93  void keyPressEvent(QKeyEvent* event) override final;
94  void dragEnterEvent(QDragEnterEvent* event) override final;
95  void dragMoveEvent(QDragMoveEvent* event) override final;
96  void dropEvent(QDropEvent* event) override final;
97  void dragLeaveEvent(QDragLeaveEvent* event) override final;
98 
99 private:
100  QGVMap* mGeoMap;
101  unsigned int mBlockUpdateCount;
102  double mMinScale;
103  double mMaxScale;
104  double mScale;
105  double mAzimuth;
106  QGV::MouseActions mMouseActions;
107  QRect mViewRect;
108  QGV::MapState mState;
109  QRect mWheelMouseArea;
110  QPointF mWheelProjAnchor;
111  double mWheelBestFactor;
112  QPointF mMoveProjAnchor;
113  QGVDrawItem* mMovingObject;
114  QScopedPointer<QGraphicsScene> mQGScene;
115  QScopedPointer<QGVMapRubberBand> mSelectionRect;
116  QScopedPointer<QMenu> mContextMenu;
117 };
Definition: QGVCamera.h:59
Definition: QGVCamera.h:30
Definition: QGVDrawItem.h:27
Definition: QGVMapQGView.h:37
Definition: QGVMap.h:35