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)
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 node3DOpacity READ node3DOpacity WRITE setNode3DOpacity NOTIFY node3DOpacityChanged)
54
55public:
56 explicit GeoMapItem(QQuickItem* parent = nullptr);
57 ~GeoMapItem() override;
58
60 enum class AltitudeMode
61 {
62 ClampToGround,
63 Absolute
64 };
65 Q_ENUM(AltitudeMode)
66
67 QGeoCoordinate coordinate() const { return _coordinate; }
68
69 void setCoordinate(const QGeoCoordinate& coordinate);
70
73 QPointF anchorPoint() const { return _anchorPoint; }
74
75 void setAnchorPoint(const QPointF& anchorPoint);
76
77 GeoScene* scene() const { return _scene; }
78
79 void setScene(GeoScene* scene);
80
81 SurfacePatchModel* surfaceModel() const { return _surfaceModel; }
82
83 void setSurfaceModel(SurfacePatchModel* surfaceModel);
84
85 AltitudeMode altitudeMode() const { return _altitudeMode; }
86
87 void setAltitudeMode(AltitudeMode mode);
88
91 bool projected() const { return _projected; }
92
96 QVector3D scenePosition() const { return _scenePosition; }
97
103 QQmlComponent* delegate3D() const { return _delegate3D; }
104
105 void setDelegate3D(QQmlComponent* delegate3D);
106
109 QObject* node3D() const { return _node3D; }
110
114 bool crossfade3D() const { return _crossfade3D; }
115
116 void setCrossfade3D(bool crossfade3D);
117
120 qreal node3DOpacity() const { return _node3DOpacity; }
121
122 void setNode3DOpacity(qreal node3DOpacity);
123
127 qreal contentOpacity2D() const { return _contentOpacity2D; }
128
129signals:
142
143private slots:
144 void _updatePosition();
145 void _terrainHeightsChanged();
146
147private:
148 void _connectCamera();
149 void _setProjected(bool projected);
150 void _setScenePosition(const QVector3D& scenePosition);
151 void _rebuildNode3D();
152 void _updateCrossfade();
153 void _updateNode3DVisibility();
154
155 QGeoCoordinate _coordinate;
156 QPointF _anchorPoint;
157 GeoScene* _scene = nullptr;
158 SurfacePatchModel* _surfaceModel = nullptr;
159 GeoMapCamera* _connectedCamera = nullptr;
161 bool _projected = false;
162 QVector3D _scenePosition;
163 QQmlComponent* _delegate3D = nullptr;
164 QObject* _node3D = nullptr;
165 bool _crossfade3D = true;
166 qreal _node3DOpacity = 1.0;
167 qreal _contentOpacity2D = 1.0;
168};
SurfacePatchModel * surfaceModel() const
Definition GeoMapItem.h:81
void crossfade3DChanged()
void setAnchorPoint(const QPointF &anchorPoint)
Definition GeoMapItem.cc:50
void setNode3DOpacity(qreal node3DOpacity)
void setCrossfade3D(bool crossfade3D)
void surfaceModelChanged()
QObject * node3D() const
Definition GeoMapItem.h:109
qreal contentOpacity2D() const
Definition GeoMapItem.h:127
AltitudeMode
How the coordinate's vertical position is resolved.
Definition GeoMapItem.h:61
@ ClampToGround
sit on the rendered terrain surface (default)
Definition GeoMapItem.h:62
void projectedChanged()
void setAltitudeMode(AltitudeMode mode)
void setDelegate3D(QQmlComponent *delegate3D)
void node3DChanged()
QVector3D scenePosition() const
Definition GeoMapItem.h:96
void scenePositionChanged()
GeoMapItem(QQuickItem *parent=nullptr)
Definition GeoMapItem.cc:29
void setScene(GeoScene *scene)
Definition GeoMapItem.cc:60
void coordinateChanged()
AltitudeMode altitudeMode() const
Definition GeoMapItem.h:85
QPointF anchorPoint() const
Definition GeoMapItem.h:73
bool projected() const
Definition GeoMapItem.h:91
void anchorPointChanged()
void setSurfaceModel(SurfacePatchModel *surfaceModel)
Definition GeoMapItem.cc:88
void delegate3DChanged()
void sceneChanged()
bool crossfade3D() const
Definition GeoMapItem.h:114
GeoScene * scene() const
Definition GeoMapItem.h:77
void node3DOpacityChanged()
QGeoCoordinate coordinate() const
Definition GeoMapItem.h:67
void altitudeModeChanged()
QQmlComponent * delegate3D() const
Definition GeoMapItem.h:103
void setCoordinate(const QGeoCoordinate &coordinate)
Definition GeoMapItem.cc:39
void contentOpacity2DChanged()
qreal node3DOpacity() const
Definition GeoMapItem.h:120
void setScene(GeoScene *scene)
GeoScene * scene() const