QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoScene.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/QObject>
13#include <QtCore/QPointF>
14#include <QtCore/QVariant>
15#include <QtCore/qnumeric.h>
16#include <QtGui/QVector3D>
17#include <QtPositioning/QGeoCoordinate>
18#include <QtQmlIntegration/QtQmlIntegration>
19
20class GeoMapCamera;
21
22Q_MOC_INCLUDE("GeoMapCamera.h")
23
24
34class GeoScene : public QObject
35{
36 Q_OBJECT
37 QML_ELEMENT
38 Q_PROPERTY(GeoMapCamera* camera READ camera WRITE setCamera NOTIFY cameraChanged)
39 Q_PROPERTY(QPointF sceneOrigin READ sceneOrigin NOTIFY sceneOriginChanged)
40 Q_PROPERTY(qreal verticalScale READ verticalScale NOTIFY sceneOriginChanged)
41 Q_PROPERTY(qreal terrainScale READ terrainScale WRITE setTerrainScale NOTIFY terrainScaleChanged)
42 Q_PROPERTY(QObject* content3D READ content3D WRITE setContent3D NOTIFY content3DChanged)
43
44public:
45 explicit GeoScene(QObject* parent = nullptr);
46
47 static constexpr double kReanchorDistance = 50000.0;
48
49 GeoMapCamera* camera() const { return _camera; }
50
51 void setCamera(GeoMapCamera* camera);
52
56 QPointF sceneOrigin() const { return _origin; }
57
62 qreal verticalScale() const;
63
67 qreal terrainScale() const { return _terrainScale; }
68
69 void setTerrainScale(qreal scale);
70
74 QObject* content3D() const { return _content3D; }
75
76 void setContent3D(QObject* node);
77
82 Q_INVOKABLE QVector3D scenePositionFor(const QGeoCoordinate& coordinate) const;
83
88 Q_INVOKABLE QVariant screenPositionFor(const QGeoCoordinate& coordinate) const;
89
98 Q_INVOKABLE QGeoCoordinate centerForCoordinateAtScreenPoint(const QGeoCoordinate& coordinate,
99 const QPointF& screenPos,
100 double centerElevation = qQNaN()) const;
101
102signals:
107
108private slots:
109 void _maybeReanchor();
110
111private:
112 GeoMapCamera* _camera = nullptr;
113 QPointF _origin;
114 bool _originSet = false;
115 qreal _terrainScale = 0.0;
116 QObject* _content3D = nullptr;
117};
qreal centerElevation() const
QPointF sceneOrigin() const
Q_INVOKABLE QGeoCoordinate centerForCoordinateAtScreenPoint(const QGeoCoordinate &coordinate, const QPointF &screenPos, double worldZ=0.0, double centerElevation=qQNaN()) const
void sceneOriginChanged()
qreal terrainScale() const
Definition GeoScene.h:67
void terrainScaleChanged()
void cameraChanged()
QObject * content3D() const
Definition GeoScene.h:74
GeoMapCamera * camera() const
Definition GeoScene.h:49
void content3DChanged()
QPointF sceneOrigin() const
Definition GeoScene.h:56