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
41class FlightPathGeometry : public QQuick3DGeometry
42{
43 Q_OBJECT
44 QML_ELEMENT
45 Q_PROPERTY(GeoScene* scene READ scene WRITE setScene NOTIFY sceneChanged)
46 Q_PROPERTY(QGeoCoordinate anchorCoordinate READ anchorCoordinate NOTIFY anchorCoordinateChanged)
47 Q_PROPERTY(int pointCount READ pointCount NOTIFY pointCountChanged)
48
49public:
50 explicit FlightPathGeometry(QQuick3DObject* parent = nullptr);
51
52 static constexpr int kFloatsPerVertex = 8;
53
54 GeoScene* scene() const { return _scene; }
55
56 void setScene(GeoScene* scene);
57
61 QGeoCoordinate anchorCoordinate() const { return _points.isEmpty() ? QGeoCoordinate() : _points.first(); }
62
63 int pointCount() const { return static_cast<int>(_points.size()); }
64
66 Q_INVOKABLE void setPath(const QVariantList& coordinates);
67
68 Q_INVOKABLE void appendPoint(const QGeoCoordinate& coordinate);
69
71 Q_INVOKABLE void updateLastPoint(const QGeoCoordinate& coordinate);
72
73 Q_INVOKABLE void clearPath();
74
75signals:
79
80private:
81 void _rebuild();
82 QVector3D _positionFor(const QGeoCoordinate& coordinate) const;
83 QVector3D _segmentDirection(qsizetype index) const;
84 QVector3D _tangentAt(qsizetype index) const;
85 void _writeVertexPair(qsizetype index, const QVector3D& tangent);
86 void _growBounds(const QVector3D& position);
87
88 GeoScene* _scene = nullptr;
89 QList<QGeoCoordinate> _points;
90
91 // Incremental mirrors of the GPU buffer so mutations avoid full rebuilds
92 QList<QVector3D> _positions;
93 QList<QVector3D> _segmentDirections;
94 QByteArray _vertexData;
95 QVector3D _minBounds;
96 QVector3D _maxBounds;
97};
GeoScene * scene() const
void anchorCoordinateChanged()
QGeoCoordinate anchorCoordinate() const