QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoScene Class Reference

#include <GeoScene.h>

+ Inheritance diagram for GeoScene:
+ Collaboration diagram for GeoScene:

Signals

void cameraChanged ()
 
void sceneOriginChanged ()
 
void terrainScaleChanged ()
 
void content3DChanged ()
 

Public Member Functions

 GeoScene (QObject *parent=nullptr)
 
GeoMapCameracamera () const
 
void setCamera (GeoMapCamera *camera)
 
QPointF sceneOrigin () const
 
qreal verticalScale () const
 
qreal terrainScale () const
 
void setTerrainScale (qreal scale)
 
QObject * content3D () const
 
void setContent3D (QObject *node)
 
Q_INVOKABLE QVector3D scenePositionFor (const QGeoCoordinate &coordinate) const
 
Q_INVOKABLE QVariant screenPositionFor (const QGeoCoordinate &coordinate) const
 
Q_INVOKABLE QGeoCoordinate centerForCoordinateAtScreenPoint (const QGeoCoordinate &coordinate, const QPointF &screenPos, double centerElevation=qQNaN()) const
 

Static Public Attributes

static constexpr double kReanchorDistance = 50000.0
 scene-origin re-anchor threshold (m)
 

Detailed Description

Owns the scene-space definition shared by everything GeoMap renders.

Scene coordinates are world mercator meters relative to sceneOrigin. The origin re-anchors to the camera center whenever the camera strays more than kReanchorDistance from it, keeping scene coordinates small enough for the renderer's float precision.

All renderable content (surface patches, and later map items such as vehicles, flight paths, and mission markers) must place itself through this one origin so everything shifts consistently on re-anchor.

Definition at line 34 of file GeoScene.h.

Constructor & Destructor Documentation

◆ GeoScene()

GeoScene::GeoScene ( QObject *  parent = nullptr)
explicit

Definition at line 20 of file GeoScene.cc.

Member Function Documentation

◆ camera()

GeoMapCamera * GeoScene::camera ( ) const
inline

Definition at line 49 of file GeoScene.h.

Referenced by setCamera().

◆ cameraChanged

void GeoScene::cameraChanged ( )
signal

◆ centerForCoordinateAtScreenPoint()

QGeoCoordinate GeoScene::centerForCoordinateAtScreenPoint ( const QGeoCoordinate &  coordinate,
const QPointF &  screenPos,
double  centerElevation = qQNaN() 
) const

Camera center that places coordinate at screenPos, solved at the coordinate's rendered height (altitude scaled to scene units and the terrain scale, NaN treated as 0) — the inverse of screenPositionFor. centerElevation (true meters, scaled to rendered height internally like altitude) overrides the camera pivot elevation for the solve — pass the terrain elevation at the destination center when the pivot follows terrain; NaN keeps the camera's current value. Invalid coordinate when there is no camera.

Definition at line 100 of file GeoScene.cc.

References GeoMapCamera::centerForCoordinateAtScreenPoint(), and verticalScale().

◆ content3D()

QObject * GeoScene::content3D ( ) const
inline

Container node inside the View3D for map item 3D content (a QQuick3DNode, typed QObject* to keep QtQuick3D out of this header). Items parent their delegate3D instances here.

Definition at line 74 of file GeoScene.h.

◆ content3DChanged

void GeoScene::content3DChanged ( )
signal

◆ sceneOrigin()

QPointF GeoScene::sceneOrigin ( ) const
inline

Until a camera anchors the scene, the origin is the mercator origin (0, 0): results stay well-defined but are not precision-safe far from it. If the camera goes away, the origin retains its last anchor.

Definition at line 56 of file GeoScene.h.

Referenced by SurfacePatchModel::data().

◆ sceneOriginChanged

void GeoScene::sceneOriginChanged ( )
signal

◆ scenePositionFor()

QVector3D GeoScene::scenePositionFor ( const QGeoCoordinate &  coordinate) const

Scene position for a geographic coordinate (double math internally; once a camera has anchored the origin the result is origin-relative and small enough for floats). Altitude (true meters, NaN treated as 0) lands on z scaled to scene units.

Definition at line 81 of file GeoScene.cc.

References TileMath::geoToWorld(), and verticalScale().

◆ screenPositionFor()

QVariant GeoScene::screenPositionFor ( const QGeoCoordinate &  coordinate) const

Screen position (pixels) of a geographic coordinate through the camera, at its rendered height (altitude scaled to scene units and the terrain scale, matching GeoMapItem placement). Invalid QVariant when there is no camera or the point is at or behind the camera plane.

Definition at line 89 of file GeoScene.cc.

References TileMath::geoToWorld(), verticalScale(), and GeoMapCamera::worldToScreen().

◆ setCamera()

void GeoScene::setCamera ( GeoMapCamera camera)

Definition at line 22 of file GeoScene.cc.

References camera(), cameraChanged(), and GeoMapCamera::centerChanged().

◆ setContent3D()

void GeoScene::setContent3D ( QObject *  node)

Definition at line 62 of file GeoScene.cc.

References content3DChanged().

◆ setTerrainScale()

void GeoScene::setTerrainScale ( qreal  scale)

Definition at line 53 of file GeoScene.cc.

References terrainScaleChanged().

◆ terrainScale()

qreal GeoScene::terrainScale ( ) const
inline

Terrain displacement factor: 1 in 3D, 0 in 2D (map stays flat). Everything placing content by altitude must scale z by it to stay on the rendered surface. Startup mode is 2D, so it starts at 0.

Definition at line 67 of file GeoScene.h.

◆ terrainScaleChanged

void GeoScene::terrainScaleChanged ( )
signal

◆ verticalScale()

qreal GeoScene::verticalScale ( ) const

Mercator scale factor at the scene origin: heights and altitudes are true meters, but scene x/y are mercator meters (stretched by 1/cos(lat)). Rendering must scale z by this factor or geometry appears vertically squashed away from the equator.

Definition at line 48 of file GeoScene.cc.

References TileMath::mercatorScale(), and TileMath::worldToGeo().

Referenced by SurfacePatchModel::analyzeSurface(), centerForCoordinateAtScreenPoint(), scenePositionFor(), and screenPositionFor().

Member Data Documentation

◆ kReanchorDistance

constexpr double GeoScene::kReanchorDistance = 50000.0
staticconstexpr

scene-origin re-anchor threshold (m)

Definition at line 47 of file GeoScene.h.


The documentation for this class was generated from the following files: