QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
Viewer3DManager.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4#include <QtPositioning/QGeoCoordinate>
5#include <QtQmlIntegration/QtQmlIntegration>
6
7class QVariant;
8class Vehicle;
10
11class Viewer3DManager : public QObject
12{
13 Q_OBJECT
14 QML_NAMED_ELEMENT(QGCViewer3DManager)
15 QML_SINGLETON
16 Q_MOC_INCLUDE("Viewer3DMapProvider.h")
17
18 Q_PROPERTY(Viewer3DMapProvider *mapProvider READ mapProvider CONSTANT)
19 Q_PROPERTY(QGeoCoordinate gpsRef READ gpsRef NOTIFY gpsRefChanged)
22
23public:
28 Q_ENUM(DisplayMode)
29
30 explicit Viewer3DManager(QObject *parent = nullptr);
31
32 Viewer3DMapProvider *mapProvider() const { return _mapProvider; }
33 QGeoCoordinate gpsRef() const { return _gpsRef; }
34 DisplayMode displayMode() const { return _displayMode; }
35 bool vehicleOutsideMapRegion() const { return _vehicleOutsideMapRegion; }
36
38 static bool coordinateWithinRegion(const QGeoCoordinate &coordinate, const QGeoCoordinate &bbMin, const QGeoCoordinate &bbMax);
39
40 Q_INVOKABLE void setDisplayMode(DisplayMode mode);
41
42signals:
46
47private:
48 enum class GpsRefSource {
49 None,
50 Map,
51 Vehicle,
52 };
53
54 void _onGpsRefChanged(const QGeoCoordinate &newGpsRef, bool isRefSet);
55 void _onActiveVehicleChanged(Vehicle *vehicle);
56 void _onActiveVehicleCoordinateChanged(const QGeoCoordinate &newCoordinate);
57 void _onEnabledChanged(const QVariant &value);
58 void _updateVehicleOutsideMapRegion();
59
60 Viewer3DMapProvider *_mapProvider = nullptr;
61 Vehicle *_activeVehicle = nullptr;
62
63 QGeoCoordinate _gpsRef;
64 GpsRefSource _gpsRefSource = GpsRefSource::None;
65 DisplayMode _displayMode = DisplayMode::Map;
66 bool _vehicleOutsideMapRegion = false;
67};
static bool coordinateWithinRegion(const QGeoCoordinate &coordinate, const QGeoCoordinate &bbMin, const QGeoCoordinate &bbMax)
Returns true if the coordinate lies within the lat/lon bounding box. Invalid inputs return false.
bool vehicleOutsideMapRegion() const
DisplayMode displayMode() const
void gpsRefChanged()
void vehicleOutsideMapRegionChanged()
void displayModeChanged()
Viewer3DMapProvider * mapProvider() const
Q_INVOKABLE void setDisplayMode(DisplayMode mode)
QGeoCoordinate gpsRef() const