iVS3D v2.0.9
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 <QMetaType>
10#include <QObject>
11#include <QPointF>
12#include <QPolygonF>
13#include <QQuickItem>
14#include <QVariantList>
15#include <QtGlobal>
16#include <cmath>
17#include <float.h>
18
19// Set to 1 to enable partial marker styling based on selected/total ratio.
20#ifndef GEOMAP_ENABLE_PARTIAL_SELECTION
21#define GEOMAP_ENABLE_PARTIAL_SELECTION 1
22#endif
23
24using GpsDataList = QList<QPair<QPointF, bool>>;
25Q_DECLARE_METATYPE(GpsDataList)
26
28 QPointF point;
29 bool used = false;
30 qreal ratio = 0.0;
31};
32
33using GpsPointStateList = QList<GpsPointState>;
34Q_DECLARE_METATYPE(GpsPointStateList)
35
36
47class MapHandler : public QObject
48{
49 Q_OBJECT
50
51 //--- METHOD DECLARATION ---//
52
53 public:
54 explicit MapHandler(QObject* parent = nullptr);
55
59 void addPoints(const GpsDataList& m_gpsData);
60
61 void updatePoints(const GpsPointStateList& changedPoints);
62
63 void setPolygon(const QPolygonF& poly);
64
65 void replaceData(const GpsDataList& gpsData, const QPolygonF& polygon);
66 void updatePointsAndPolygon(const GpsPointStateList& changedPoints,
67 const QPolygonF& polygon);
68
75 void emitCircleSignal(const QGeoCoordinate& coordinate, QString name,
76 bool used, qreal ratio)
77 {
78 Q_EMIT circleSignal(coordinate, name, used, ratio);
79 }
84 void emitAdjustMapCenter(const QGeoCoordinate& coordinate)
85 {
86 Q_EMIT adjustMap(coordinate);
87 }
92 void emitCreatePolyline(const QGeoCoordinate& coordinate)
93 {
94 Q_EMIT createPolyline(coordinate);
95 }
100 void emitSetTracePath(const QVariantList& coordinates)
101 {
102 Q_EMIT setTracePath(coordinates);
103 }
108 void emitSetMapSelect(const QGeoPath& path)
109 {
110 Q_EMIT setMapSelect(path);
111 }
112 void emitSetMapSelectCoordinates(const QVariantList& coordinates)
113 {
114 Q_EMIT setMapSelectCoordinates(coordinates);
115 }
121 void emitSetPoint(const int index, bool used)
122 {
123 Q_EMIT setPoint(index, used);
124 }
125
126 void emitSetPointState(const int index, bool used, qreal ratio)
127 {
128 Q_EMIT setPointState(index, used, ratio);
129 }
130
131 void emitSetPartialSelectionEnabled(bool enabled)
132 {
133 Q_EMIT setPartialSelectionEnabled(enabled);
134 }
139 {
140 Q_EMIT getMapItems();
141 }
142
144 void drawGpsDataOnMap();
145
146 Q_SIGNALS:
153 void circleSignal(const QGeoCoordinate& coordinate, QString name, bool used,
154 qreal ratio);
159 void adjustMap(const QGeoCoordinate& coordinate);
165 void createPolyline(const QGeoCoordinate& coordinate);
171 void setTracePath(const QVariantList& coordinates);
176 void setMapSelect(const QGeoPath& path);
177 void setMapSelectCoordinates(const QVariantList& coordinates);
183 void setPoint(const int index, bool used);
184 void setPointState(const int index, bool used, qreal ratio);
185 void setPartialSelectionEnabled(bool enabled);
186 void setPointHighlight(const int index, bool highlighted);
191 void clearMap();
192
193 signals:
199 void gpsClicked(QPointF gpsPoint, bool used);
200
205 void gpsSelected(QPolygonF polyF);
206
207 public slots:
208 // Slot to signal which is emitted when a gps point on the map is clicked
209 void onQmlGpsClicked(const QString& text);
210 // Slot to signal which is emitted when the map is right clicked
211 void onQmlMapClicked(const QString& text);
212 // Slot to signal which returns all items on the map
213 void onQmlMapItems(const QVariant& variant);
214
215 void onQmlDeleteSelection();
216
217 void onQmlSelectionBack();
218
219 void onQmlSelectionForward();
220
221 void setCurrentIndex(uint index);
222 void setPartialSelectionMode(bool enabled);
223
224 private:
227 void newMapItems();
228
230 QPolygonF geoPolyToPolyF();
231
234 QList<QLineF> geoPolyToLineList();
235
237 QPointF pointAtGeo(int index);
238
241 QPointF minDistance(QPointF A, QPointF B, QPointF newPoint);
242 void applyCurrentIndexHighlight();
243
244 //--- METHOD DECLARATION ---//
245
246 private:
248 QMap<QPointF, bool> mGpsMap;
250 QMap<QPointF, qreal> mPointSelectionRatio;
251
253 QList<QPointF> mOrderedGpsList;
255 QList<QPointF> mSourceIndexToPoint;
256
258 QGeoPolygon mPolygon;
259
261 QSet<QPointF> mChangedPoints;
262
264 QMap<QPointF, int> mMapItems;
265
266 QList<QGeoPolygon> mPolyStack;
267
268 int mCurrentStackPos = -1;
269 int mCurrentSourceIndex = -1;
270 int mCurrentMapItemIndex = -1;
271 bool mPartialSelectionEnabled = GEOMAP_ENABLE_PARTIAL_SELECTION != 0;
272};
273
274#endif // IVS3D_MAPHANDLER_H
The MapHandler is used to handel the qml map.
Definition maphandler.h:48
void emitCreatePolyline(const QGeoCoordinate &coordinate)
emitCreatePolyline method to emit the corresponding signal
Definition maphandler.h:92
void emitSetMapSelect(const QGeoPath &path)
emitSetMapSelect Method to emit the corresponding signal
Definition maphandler.h:108
QList< QPointF > mOrderedGpsList
List of GPS data in the order of acquisition.
Definition maphandler.h:253
QSet< QPointF > mChangedPoints
Save points that have been change with a new polygon.
Definition maphandler.h:261
QMap< QPointF, bool > mGpsMap
GPS points used or not.
Definition maphandler.h:248
void emitSetTracePath(const QVariantList &coordinates)
emitSetTracePath Sends the full ordered GPS trace path to the QML map in one shot.
Definition maphandler.h:100
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 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:264
QGeoPolygon mPolygon
The current polygon.
Definition maphandler.h:258
void createPolyline(const QGeoCoordinate &coordinate)
emitCreatePolyline Used to add points to the static polyline on the map (And will set the polyline vi...
void setPoint(const int index, bool used)
emitSetPoint Used to update a points oppacity
void adjustMap(const QGeoCoordinate &coordinate)
adjustMap Used to center the map at the given coordinate
void emitAdjustMapCenter(const QGeoCoordinate &coordinate)
emitAdjustMapCenter Method to emit the corresponding signal
Definition maphandler.h:84
void emitSetPoint(const int index, bool used)
emitSetPoint Method to emit the corresponding signal
Definition maphandler.h:121
QMap< QPointF, qreal > mPointSelectionRatio
Ratio of selected images for each unique GPS point.
Definition maphandler.h:250
void setTracePath(const QVariantList &coordinates)
setTracePath Replaces the entire GPS trace path on the map in one call. Coordinates are ordered by im...
QList< QPointF > mSourceIndexToPoint
Maps source frame index to GPS point (keeps duplicates).
Definition maphandler.h:255
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:138
void circleSignal(const QGeoCoordinate &coordinate, QString name, bool used, qreal ratio)
circleSignal Used to create points on the map at the given coordinate
void emitCircleSignal(const QGeoCoordinate &coordinate, QString name, bool used, qreal ratio)
emitCircleSignal Method to emit the corresponding signal
Definition maphandler.h:75
Definition maphandler.h:27