iVS3D v2.0.0
Loading...
Searching...
No Matches
maphandler.h
1#ifndef IVS3D_MAPHANDLER_H
2#define IVS3D_MAPHANDLER_H
3
4#include <QGeoCoordinate>
5#include <QGeoPath>
6#include <QGeoPolygon>
7#include <QLineF>
8#include <QList>
9#include <QObject>
10#include <QPointF>
11#include <QPolygonF>
12#include <QQuickItem>
13#include <QtGlobal>
14#include <cmath>
15#include <float.h>
16
28class MapHandler : public QObject
29{
30 Q_OBJECT
31
32 //--- METHOD DECLARATION ---//
33
34 public:
35 explicit MapHandler();
36
40 void addPoints(const QList<QPair<QPointF, bool>>& m_gpsData);
41
42 void updatePoints(const QList<QPair<QPointF, bool>>& m_changedPoints);
43
44 void setPolygon(const QPolygonF& poly);
45
52 void emitCircleSignal(const QGeoCoordinate& coordinate, QString name, bool used)
53 {
54 Q_EMIT circleSignal(coordinate, name, used);
55 }
60 void emitAdjustMapCenter(const QGeoCoordinate& coordinate)
61 {
62 Q_EMIT adjustMap(coordinate);
63 }
68 void emitCreatePolyline(const QGeoCoordinate& coordinate)
69 {
70 Q_EMIT createPolyline(coordinate);
71 }
76 void emitSetMapSelect(const QGeoPath& path)
77 {
78 Q_EMIT setMapSelect(path);
79 }
85 void emitSetPoint(const int index, bool used)
86 {
87 Q_EMIT setPoint(index, used);
88 }
93 {
94 Q_EMIT getMapItems();
95 }
96
98 void drawGpsDataOnMap();
99
100 Q_SIGNALS:
107 void circleSignal(const QGeoCoordinate& coordinate, QString name, bool used);
112 void adjustMap(const QGeoCoordinate& coordinate);
118 void createPolyline(const QGeoCoordinate& coordinate);
123 void setMapSelect(const QGeoPath& path);
129 void setPoint(const int index, bool used);
134
135 signals:
141 void gpsClicked(QPointF gpsPoint, bool used);
142
147 void gpsSelected(QPolygonF polyF);
148
149 public slots:
150 // Slot to signal which is emitted when a gps point on the map is clicked
151 void onQmlGpsClicked(const QString& text);
152 // Slot to signal which is emitted when the map is right clicked
153 void onQmlMapClicked(const QString& text);
154 // Slot to signal which returns all items on the map
155 void onQmlMapItems(const QVariant& variant);
156
157 void onQmlDeleteSelection();
158
159 void onQmlSelectionBack();
160
161 void onQmlSelectionForward();
162
163 private:
166 void newMapItems();
167
169 QPolygonF geoPolyToPolyF();
170
173 QList<QLineF> geoPolyToLineList();
174
176 QPointF pointAtGeo(int index);
177
180 QPointF minDistance(QPointF A, QPointF B, QPointF newPoint);
181
182 //--- METHOD DECLARATION ---//
183
184 private:
186 QMap<QPointF, bool> mGpsMap;
187
189 QList<QPointF> mOrderedGpsList;
190
192 QGeoPolygon mPolygon;
193
195 QSet<QPointF> mChangedPoints;
196
198 QMap<QPointF, int> mMapItems;
199
200 QList<QGeoPolygon> mPolyStack;
201
202 int mCurrentStackPos = -1;
203};
204
205#endif // IVS3D_MAPHANDLER_H
The MapHandler is used to handel the qml map.
Definition maphandler.h:29
void emitCreatePolyline(const QGeoCoordinate &coordinate)
emitCreatePolyline method to emit the corresponding signal
Definition maphandler.h:68
void emitSetMapSelect(const QGeoPath &path)
emitSetMapSelect Method to emit the corresponding signal
Definition maphandler.h:76
QList< QPointF > mOrderedGpsList
List of GPS data in the order of acquisition.
Definition maphandler.h:189
QSet< QPointF > mChangedPoints
Save points that have been change with a new polygon.
Definition maphandler.h:195
void addPoints(const QList< QPair< QPointF, bool > > &m_gpsData)
addPoints Adds all given gps values as points on the map
Definition maphandler.cpp:22
QMap< QPointF, bool > mGpsMap
GPS points used or not.
Definition maphandler.h:186
QPolygonF geoPolyToPolyF()
Converts the current QGeoPolygon to QPolygonF.
Definition maphandler.cpp:198
void getMapItems()
getMapItems Used to signal that the map needs to return the current map items
void gpsClicked(QPointF gpsPoint, bool used)
gpsClicked Signal emitted when a gps points has been clicked
void newMapItems()
Definition maphandler.cpp:187
void gpsSelected(QPolygonF polyF)
gpsSelected Signal emitted when a new polygon has been selected
QMap< QPointF, int > mMapItems
Used to save the item list from the qml map.
Definition maphandler.h:198
QGeoPolygon mPolygon
The current polygon.
Definition maphandler.h:192
void createPolyline(const QGeoCoordinate &coordinate)
emitCreatePolyline Used to add points to the static polyline on the map (And will set the polyline vi...
void emitCircleSignal(const QGeoCoordinate &coordinate, QString name, bool used)
emitCircleSignal Method to emit the corresponding signal
Definition maphandler.h:52
void circleSignal(const QGeoCoordinate &coordinate, QString name, bool used)
circleSignal Used to create points on the map at the given coordinate
void setPoint(const int index, bool used)
emitSetPoint Used to update a points oppacity
QPointF pointAtGeo(int index)
Return the QPointF of the current QGeoPolygon at the given index.
Definition maphandler.cpp:227
void adjustMap(const QGeoCoordinate &coordinate)
adjustMap Used to center the map at the given coordinate
void drawGpsDataOnMap()
draw GPS data onto map.
Definition maphandler.cpp:72
void emitAdjustMapCenter(const QGeoCoordinate &coordinate)
emitAdjustMapCenter Method to emit the corresponding signal
Definition maphandler.h:60
void emitSetPoint(const int index, bool used)
emitSetPoint Method to emit the corresponding signal
Definition maphandler.h:85
QList< QLineF > geoPolyToLineList()
Definition maphandler.cpp:210
void setMapSelect(const QGeoPath &path)
emitSetMapSelect Used to updated the current user selected polygon on the map
void emitGetMapItems()
emitGetMapItems Method to emit the corresponding signal
Definition maphandler.h:92
QPointF minDistance(QPointF A, QPointF B, QPointF newPoint)
Definition maphandler.cpp:325