QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCMapPolyline.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4#include <QtCore/QVariantList>
5#include <QtPositioning/QGeoCoordinate>
6
8
9class QGCMapPolyline : public QObject
10{
11 Q_OBJECT
12
13public:
14 QGCMapPolyline(QObject* parent = nullptr);
15 QGCMapPolyline(const QGCMapPolyline& other, QObject* parent = nullptr);
16
17 ~QGCMapPolyline() override;
18
19 const QGCMapPolyline& operator=(const QGCMapPolyline& other);
20
21 Q_PROPERTY(int count READ count NOTIFY countChanged)
22 Q_PROPERTY(QVariantList path READ path NOTIFY pathChanged)
23 Q_PROPERTY(QmlObjectListModel* pathModel READ qmlPathModel CONSTANT)
24 Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged)
25 Q_PROPERTY(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged)
26 Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged)
27 Q_PROPERTY(bool empty READ empty NOTIFY isEmptyChanged)
28 Q_PROPERTY(bool traceMode READ traceMode WRITE setTraceMode NOTIFY traceModeChanged)
29 Q_PROPERTY(int selectedVertex READ selectedVertex WRITE selectVertex NOTIFY selectedVertexChanged)
30
31 Q_INVOKABLE void clear(void);
32 Q_INVOKABLE void appendVertex(const QGeoCoordinate& coordinate);
33 Q_INVOKABLE void removeVertex(int vertexIndex);
34 Q_INVOKABLE void appendVertices(const QList<QGeoCoordinate>& coordinates);
35
39 Q_INVOKABLE void adjustVertex(int vertexIndex, const QGeoCoordinate coordinate);
40
42 Q_INVOKABLE void splitSegment(int vertexIndex);
43
46 QList<QGeoCoordinate> offsetPolyline(double distance);
47
50 Q_INVOKABLE bool loadKMLOrSHPFile(const QString &file);
51
52 Q_INVOKABLE void beginReset (void);
53 Q_INVOKABLE void endReset (void);
54
56 QList<QGeoCoordinate> coordinateList(void) const;
57
59 Q_INVOKABLE QGeoCoordinate vertexCoordinate(int vertex) const;
60
63 void saveToJson(QJsonObject& json);
64
70 bool loadFromJson(const QJsonObject& json, bool required, QString& errorString);
71
73 QList<QPointF> nedPolyline(void);
74
76 double length(void) const;
77
78 // Property methods
79 int count (void) const { return _polylinePath.count(); }
80 bool dirty (void) const { return _dirty; }
81 void setDirty (bool dirty);
82 bool interactive (void) const { return _interactive; }
83 QVariantList path (void) const { return _polylinePath; }
84 bool isValid (void) const { return _polylineModel.count() >= 2; }
85 bool empty (void) const { return _polylineModel.count() == 0; }
86 bool traceMode (void) const { return _traceMode; }
87 int selectedVertex() const { return _selectedVertexIndex; }
88
89 QmlObjectListModel* qmlPathModel(void) { return &_polylineModel; }
90 QmlObjectListModel& pathModel (void) { return _polylineModel; }
91
92 void setPath (const QList<QGeoCoordinate>& path);
93 void setPath (const QVariantList& path);
94 void setInteractive (bool interactive);
95 void setTraceMode (bool traceMode);
96 void selectVertex (int index);
97
98 static constexpr const char* jsonPolylineKey = "polyline";
99
100signals:
101 void countChanged (int count);
102 void pathChanged (void);
103 void dirtyChanged (bool dirty);
104 void cleared (void);
106 void isValidChanged (void);
107 void isEmptyChanged (void);
109 void selectedVertexChanged(int index);
110
111private slots:
112 void _polylineModelCountChanged(int count);
113 void _polylineModelDirtyChanged(bool dirty);
114
115private:
116 void _init (void);
117 QGeoCoordinate _coordFromPointF (const QPointF& point) const;
118 QPointF _pointFFromCoord (const QGeoCoordinate& coordinate) const;
119
120 QVariantList _polylinePath;
121 QmlObjectListModel _polylineModel;
122 bool _deferredPathChanged = false;
123 bool _dirty;
124 bool _interactive;
125 bool _traceMode = false;
126 int _selectedVertexIndex = -1;
127};
QString errorString
void beginReset(void)
QList< QGeoCoordinate > offsetPolyline(double distance)
void dirtyChanged(bool dirty)
static constexpr const char * jsonPolylineKey
QList< QPointF > nedPolyline(void)
Convert polyline to NED and return (D is ignored)
bool loadKMLOrSHPFile(const QString &file)
void cleared(void)
void splitSegment(int vertexIndex)
Splits the line segment comprised of vertexIndex -> vertexIndex + 1.
void pathChanged(void)
void removeVertex(int vertexIndex)
void interactiveChanged(bool interactive)
QmlObjectListModel & pathModel(void)
void traceModeChanged(bool traceMode)
void adjustVertex(int vertexIndex, const QGeoCoordinate coordinate)
bool isValid(void) const
void setTraceMode(bool traceMode)
void isEmptyChanged(void)
int count READ count NOTIFY countChanged(QVariantList path READ path NOTIFY pathChanged) 1(QmlObjectListModel *pathModel READ qmlPathModel CONSTANT) 1(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) 1(bool interactive READ interactive WRITE setInteractive NOTIFY interactiveChanged) 1(bool isValid READ isValid NOTIFY isValidChanged) 1(bool empty READ empty NOTIFY isEmptyChanged) 1(bool traceMode READ traceMode WRITE setTraceMode NOTIFY traceModeChanged) 1(int selectedVertex READ selectedVertex WRITE selectVertex NOTIFY selectedVertexChanged) 1 void clear(void)
bool empty(void) const
bool dirty(void) const
QGeoCoordinate vertexCoordinate(int vertex) const
Returns the QGeoCoordinate for the vertex specified.
void selectVertex(int index)
void setPath(const QList< QGeoCoordinate > &path)
void setDirty(bool dirty)
bool interactive(void) const
void appendVertex(const QGeoCoordinate &coordinate)
int count(void) const
~QGCMapPolyline() override
void saveToJson(QJsonObject &json)
QmlObjectListModel * qmlPathModel(void)
QList< QGeoCoordinate > coordinateList(void) const
Returns the path in a list of QGeoCoordinate's format.
const QGCMapPolyline & operator=(const QGCMapPolyline &other)
void endReset(void)
void appendVertices(const QList< QGeoCoordinate > &coordinates)
int selectedVertex() const
QVariantList path(void) const
void isValidChanged(void)
bool loadFromJson(const QJsonObject &json, bool required, QString &errorString)
double length(void) const
Returns the length of the polyline in meters.
void countChanged(int count)
bool traceMode(void) const
void selectedVertexChanged(int index)
void setInteractive(bool interactive)
int count() const override final