QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapItem.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/QPointF>
13#include <QtGui/QVector3D>
14#include <QtPositioning/QGeoCoordinate>
15#include <QtQmlIntegration/QtQmlIntegration>
16#include <QtQuick/QQuickItem>
17
18class GeoMapCamera;
19class GeoScene;
20class QQmlComponent;
22
23Q_MOC_INCLUDE("GeoScene.h")
24Q_MOC_INCLUDE("SurfacePatchModel.h")
25Q_MOC_INCLUDE("QtQml/QQmlComponent")
26
38class GeoMapItem : public QQuickItem
39{
40 Q_OBJECT
41 QML_ELEMENT
42 Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
43 Q_PROPERTY(QPointF anchorPoint READ anchorPoint WRITE setAnchorPoint NOTIFY anchorPointChanged)
44 Q_PROPERTY(GeoScene* scene READ scene WRITE setScene NOTIFY sceneChanged)
45 Q_PROPERTY(SurfacePatchModel* surfaceModel READ surfaceModel WRITE setSurfaceModel NOTIFY surfaceModelChanged)
46 Q_PROPERTY(AltitudeMode altitudeMode READ altitudeMode WRITE setAltitudeMode NOTIFY altitudeModeChanged)
47 Q_PROPERTY(bool projected READ projected NOTIFY projectedChanged)
48 Q_PROPERTY(QVector3D scenePosition READ scenePosition NOTIFY scenePositionChanged)
49 Q_PROPERTY(QQmlComponent* delegate3D READ delegate3D WRITE setDelegate3D NOTIFY delegate3DChanged)
50 Q_PROPERTY(QObject* node3D READ node3D NOTIFY node3DChanged)
51 Q_PROPERTY(bool crossfade3D READ crossfade3D WRITE setCrossfade3D NOTIFY crossfade3DChanged)
52 Q_PROPERTY(qreal contentOpacity2D READ contentOpacity2D NOTIFY contentOpacity2DChanged)
53
54public:
55 explicit GeoMapItem(QQuickItem* parent = nullptr);
56 ~GeoMapItem() override;
57
59 enum class AltitudeMode
60 {
61 ClampToGround,
62 Absolute
63 };
64 Q_ENUM(AltitudeMode)
65
66 QGeoCoordinate coordinate() const { return _coordinate; }
67
68 void setCoordinate(const QGeoCoordinate& coordinate);
69
72 QPointF anchorPoint() const { return _anchorPoint; }
73
74 void setAnchorPoint(const QPointF& anchorPoint);
75
76 GeoScene* scene() const { return _scene; }
77
78 void setScene(GeoScene* scene);
79
80 SurfacePatchModel* surfaceModel() const { return _surfaceModel; }
81
82 void setSurfaceModel(SurfacePatchModel* surfaceModel);
83
84 AltitudeMode altitudeMode() const { return _altitudeMode; }
85
86 void setAltitudeMode(AltitudeMode mode);
87
90 bool projected() const { return _projected; }
91
95 QVector3D scenePosition() const { return _scenePosition; }
96
102 QQmlComponent* delegate3D() const { return _delegate3D; }
103
104 void setDelegate3D(QQmlComponent* delegate3D);
105
108 QObject* node3D() const { return _node3D; }
109
113 bool crossfade3D() const { return _crossfade3D; }
114
115 void setCrossfade3D(bool crossfade3D);
116
120 qreal contentOpacity2D() const { return _contentOpacity2D; }
121
122signals:
134
135private slots:
136 void _updatePosition();
137 void _terrainHeightsChanged();
138
139private:
140 void _connectCamera();
141 void _setProjected(bool projected);
142 void _setScenePosition(const QVector3D& scenePosition);
143 void _rebuildNode3D();
144 void _updateCrossfade();
145 void _updateNode3DVisibility();
146
147 QGeoCoordinate _coordinate;
148 QPointF _anchorPoint;
149 GeoScene* _scene = nullptr;
150 SurfacePatchModel* _surfaceModel = nullptr;
151 GeoMapCamera* _connectedCamera = nullptr;
152 AltitudeMode _altitudeMode = AltitudeMode::ClampToGround;
153 bool _projected = false;
154 QVector3D _scenePosition;
155 QQmlComponent* _delegate3D = nullptr;
156 QObject* _node3D = nullptr;
157 bool _crossfade3D = true;
158 qreal _contentOpacity2D = 1.0;
159};
SurfacePatchModel * surfaceModel() const
Definition GeoMapItem.h:80
void crossfade3DChanged()
void surfaceModelChanged()
QObject * node3D() const
Definition GeoMapItem.h:108
qreal contentOpacity2D() const
Definition GeoMapItem.h:120
AltitudeMode
How the coordinate's vertical position is resolved.
Definition GeoMapItem.h:60
void projectedChanged()
void node3DChanged()
QVector3D scenePosition() const
Definition GeoMapItem.h:95
void scenePositionChanged()
void coordinateChanged()
AltitudeMode altitudeMode() const
Definition GeoMapItem.h:84
QPointF anchorPoint() const
Definition GeoMapItem.h:72
bool projected() const
Definition GeoMapItem.h:90
void anchorPointChanged()
void delegate3DChanged()
void sceneChanged()
bool crossfade3D() const
Definition GeoMapItem.h:113
GeoScene * scene() const
Definition GeoMapItem.h:76
void altitudeModeChanged()
QQmlComponent * delegate3D() const
Definition GeoMapItem.h:102
void contentOpacity2DChanged()
void setScene(GeoScene *scene)
GeoScene * scene() const