QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FlightPathGeometry.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 *
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
7 *
8 ****************************************************************************/
9
10#pragma once
11
12#include <QtCore/QByteArray>
13#include <QtCore/QList>
14#include <QtCore/QVariant>
15#include <QtGui/QVector3D>
16#include <QtPositioning/QGeoCoordinate>
17#include <QtQmlIntegration/QtQmlIntegration>
18#include <QtQuick3D/QQuick3DGeometry>
19
20class GeoScene;
21
22Q_MOC_INCLUDE("GeoScene.h")
23
24
42class FlightPathGeometry : public QQuick3DGeometry
43{
44 Q_OBJECT
45 QML_ELEMENT
46 Q_PROPERTY(GeoScene* scene READ scene WRITE setScene NOTIFY sceneChanged)
47 Q_PROPERTY(QGeoCoordinate anchorCoordinate READ anchorCoordinate NOTIFY anchorCoordinateChanged)
48 Q_PROPERTY(int pointCount READ pointCount NOTIFY pointCountChanged)
49
50public:
51 explicit FlightPathGeometry(QQuick3DObject* parent = nullptr);
52
53 static constexpr int kFloatsPerVertex = 8;
54
55 GeoScene* scene() const { return _scene; }
56
57 void setScene(GeoScene* scene);
58
62 QGeoCoordinate anchorCoordinate() const { return _points.isEmpty() ? QGeoCoordinate() : _points.first(); }
63
64 int pointCount() const { return static_cast<int>(_points.size()); }
65
69 Q_INVOKABLE void setPath(const QVariantList& coordinates, const QVariantList& highlights = QVariantList());
70
71 Q_INVOKABLE void appendPoint(const QGeoCoordinate& coordinate);
72
74 Q_INVOKABLE void updateLastPoint(const QGeoCoordinate& coordinate);
75
76 Q_INVOKABLE void clearPath();
77
78signals:
82
83private:
84 void _rebuild();
85 QVector3D _positionFor(const QGeoCoordinate& coordinate) const;
86 QVector3D _segmentDirection(qsizetype index) const;
87 QVector3D _tangentAt(qsizetype index) const;
88 void _writeVertexPair(qsizetype index, const QVector3D& tangent);
89 void _growBounds(const QVector3D& position);
90
91 GeoScene* _scene = nullptr;
92 QList<QGeoCoordinate> _points;
93 QList<bool> _highlights;
94
95 // Incremental mirrors of the GPU buffer so mutations avoid full rebuilds
96 QList<QVector3D> _positions;
97 QList<QVector3D> _segmentDirections;
98 QByteArray _vertexData;
99 QVector3D _minBounds;
100 QVector3D _maxBounds;
101};
GeoScene * scene() const
void anchorCoordinateChanged()
QGeoCoordinate anchorCoordinate() const