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

#include <SurfacePatchModel.h>

+ Inheritance diagram for SurfacePatchModel:
+ Collaboration diagram for SurfacePatchModel:

Public Types

enum  Roles {
  CenterXRole = Qt::UserRole + 1 , CenterYRole , SpanRole , ZoomRole ,
  HeightsRole , ReadyRole , CoveredRole , TileImageRole ,
  HasTileImageRole , EdgeLodDeltasRole , TileXRole , TileYRole
}
 

Signals

void sceneChanged ()
 
void terrainChanged ()
 
void debugHillsChanged ()
 
void mapTypeChanged ()
 
void statsChanged ()
 
void statsEnabledChanged ()
 
void statsTextChanged ()
 
void capturingChanged ()
 
void terrainHeightsChanged ()
 terrainHeightAt answers changed somewhere: consumers re-query
 
void terrainDataChanged ()
 terrainDataHeightAt / segmentBelowTerrain answers changed somewhere (not on patch churn)
 

Public Member Functions

 SurfacePatchModel (QObject *parent=nullptr)
 
 ~SurfacePatchModel () override
 
GeoScene * scene () const
 
void setScene (GeoScene *scene)
 
bool terrain () const
 
void setTerrain (bool terrain)
 
bool debugHills () const
 
void setDebugHills (bool debugHills)
 
QString mapType () const
 
void setMapType (const QString &mapType)
 
int gridSize () const
 
HeightField * heightField () const
 
Q_INVOKABLE double terrainHeightAt (const QGeoCoordinate &coordinate) const
 
Q_INVOKABLE double terrainDataHeightAt (const QGeoCoordinate &coordinate) const
 
Q_INVOKABLE bool segmentBelowTerrain (const QGeoCoordinate &from, const QGeoCoordinate &to, double ignoreStartMeters, double ignoreEndMeters) const
 
Q_INVOKABLE QGeoCoordinate surfaceCoordinateAtScreenPoint (const GeoMapCamera *camera, const QPointF &screenPos, double zScale) const
 
double maxRangeMultiplier () const
 
int patchCount () const
 
int pendingCount () const
 
int maxZoomLevel () const
 
int pendingImageCount () const
 Tile image requests awaiting delivery or failure.
 
void setTileImageNetworkManager (QNetworkAccessManager *networkManager)
 
bool statsEnabled () const
 
void setStatsEnabled (bool enabled)
 
QString statsText () const
 
bool capturing () const
 
Q_INVOKABLE void startCapture ()
 Starts recording the per-second perf samples (plus camera context)
 
Q_INVOKABLE QString stopCapture ()
 
Q_INVOKABLE void analyzeSurface () const
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
QHash< int, QByteArray > roleNames () const override
 

Detailed Description

QML bridge between SurfaceModel and the Repeater3D that renders the surface: one row per active patch, updated incrementally (no model resets on pan/zoom).

Patch positions are exposed in scene coordinates (see GeoScene): world mercator meters relative to the scene's re-anchorable origin.

Definition at line 43 of file SurfacePatchModel.h.

Member Enumeration Documentation

◆ Roles

Enumerator
CenterXRole 

patch center x in scene meters

CenterYRole 

patch center y in scene meters

SpanRole 

patch edge length (m)

ZoomRole 

quadtree zoom level

HeightsRole 

vertex height grid (empty = flat)

ReadyRole 
CoveredRole 

pending but overlapped by a ready patch: delegate suppresses rendering

TileImageRole 

drapable image: own tile, or ancestor/descendant fallback while loading

HasTileImageRole 

QImage is opaque to QML; bool validity for bindings.

EdgeLodDeltasRole 

{N,S,W,E} coarser-neighbor LOD deltas for edge stitching

TileXRole 

slippy tile x of the patch key

TileYRole 

slippy tile y of the patch key

Definition at line 64 of file SurfacePatchModel.h.

Constructor & Destructor Documentation

◆ SurfacePatchModel()

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

Definition at line 35 of file SurfacePatchModel.cc.

◆ ~SurfacePatchModel()

SurfacePatchModel::~SurfacePatchModel ( )
overridedefault

Member Function Documentation

◆ analyzeSurface()

◆ capturing()

bool SurfacePatchModel::capturing ( ) const
inline

Definition at line 162 of file SurfacePatchModel.h.

◆ capturingChanged

void SurfacePatchModel::capturingChanged ( )
signal

Referenced by startCapture(), and stopCapture().

◆ data()

◆ debugHills()

bool SurfacePatchModel::debugHills ( ) const
inline

Definition at line 90 of file SurfacePatchModel.h.

Referenced by setDebugHills().

◆ debugHillsChanged

void SurfacePatchModel::debugHillsChanged ( )
signal

Referenced by setDebugHills().

◆ gridSize()

int SurfacePatchModel::gridSize ( ) const

Definition at line 469 of file SurfacePatchModel.cc.

References SurfaceModel::kGridSize.

◆ heightField()

HeightField * SurfacePatchModel::heightField ( ) const
inline

The shared terrain field patches sample from. Owned here; replaced whenever the surface model is rebuilt.

Definition at line 104 of file SurfacePatchModel.h.

◆ mapType()

QString SurfacePatchModel::mapType ( ) const
inline

Definition at line 94 of file SurfacePatchModel.h.

Referenced by setMapType().

◆ mapTypeChanged

void SurfacePatchModel::mapTypeChanged ( )
signal

Referenced by setMapType().

◆ maxRangeMultiplier()

double SurfacePatchModel::maxRangeMultiplier ( ) const

SurfaceModel::kMaxRangeMultiplier, exposed so the scene camera's far clip plane can cover the full retained patch range

Definition at line 474 of file SurfacePatchModel.cc.

References SurfaceModel::kMaxRangeMultiplier.

◆ maxZoomLevel()

int SurfacePatchModel::maxZoomLevel ( ) const

Definition at line 484 of file SurfacePatchModel.cc.

References TileMath::TileKey::zoom.

◆ patchCount()

int SurfacePatchModel::patchCount ( ) const
inline

Definition at line 139 of file SurfacePatchModel.h.

◆ pendingCount()

int SurfacePatchModel::pendingCount ( ) const

Definition at line 479 of file SurfacePatchModel.cc.

References SurfaceModel::pendingCount().

◆ pendingImageCount()

int SurfacePatchModel::pendingImageCount ( ) const
inline

Tile image requests awaiting delivery or failure.

Definition at line 145 of file SurfacePatchModel.h.

◆ roleNames()

QHash< int, QByteArray > SurfacePatchModel::roleNames ( ) const
override

◆ rowCount()

int SurfacePatchModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 692 of file SurfacePatchModel.cc.

◆ scene()

GeoScene * SurfacePatchModel::scene ( ) const
inline

Definition at line 80 of file SurfacePatchModel.h.

Referenced by setScene().

◆ sceneChanged

void SurfacePatchModel::sceneChanged ( )
signal

Referenced by setScene().

◆ segmentBelowTerrain()

bool SurfacePatchModel::segmentBelowTerrain ( const QGeoCoordinate &  from,
const QGeoCoordinate &  to,
double  ignoreStartMeters,
double  ignoreEndMeters 
) const

True when the straight segment from -> to (altitude linear along it, in the field's frame) passes strictly below the field's estimate anywhere outside the first ignoreStartMeters and last ignoreEndMeters. False when either end has no altitude.

Definition at line 340 of file SurfacePatchModel.cc.

References TileMath::geoToWorld(), and HeightField::heightAt().

◆ setDebugHills()

void SurfacePatchModel::setDebugHills ( bool  debugHills)

Definition at line 102 of file SurfacePatchModel.cc.

References debugHills(), and debugHillsChanged().

◆ setMapType()

void SurfacePatchModel::setMapType ( const QString &  mapType)

Provider type string for tile imagery (see TileImageSource). Empty disables imagery: TileImageRole stays a null QImage for every patch.

Definition at line 113 of file SurfacePatchModel.cc.

References mapType(), mapTypeChanged(), TileImageSource::tileImageFailed(), and TileImageSource::tileImageReady().

◆ setScene()

void SurfacePatchModel::setScene ( GeoScene *  scene)

◆ setStatsEnabled()

void SurfacePatchModel::setStatsEnabled ( bool  enabled)

Enables the once-per-second perf counter sampling behind statsText: model update rate/duration, patch churn, and fallback composites

Definition at line 510 of file SurfacePatchModel.cc.

References statsEnabledChanged(), and statsTextChanged().

◆ setTerrain()

void SurfacePatchModel::setTerrain ( bool  terrain)

Real terrain elevations (see TerrariumTileFetcher); false gives a flat z=0 surface. debugHills overrides either.

Definition at line 91 of file SurfacePatchModel.cc.

References terrain(), and terrainChanged().

◆ setTileImageNetworkManager()

void SurfacePatchModel::setTileImageNetworkManager ( QNetworkAccessManager *  networkManager)
inline

Network manager for tile imagery fetches, applied at the next setMapType (test injection seam)

Definition at line 149 of file SurfacePatchModel.h.

◆ startCapture()

void SurfacePatchModel::startCapture ( )

Starts recording the per-second perf samples (plus camera context)

Definition at line 572 of file SurfacePatchModel.cc.

References capturingChanged().

◆ statsChanged

void SurfacePatchModel::statsChanged ( )
signal

◆ statsEnabled()

bool SurfacePatchModel::statsEnabled ( ) const
inline

Definition at line 154 of file SurfacePatchModel.h.

◆ statsEnabledChanged

void SurfacePatchModel::statsEnabledChanged ( )
signal

Referenced by setStatsEnabled().

◆ statsText()

QString SurfacePatchModel::statsText ( ) const
inline

Definition at line 160 of file SurfacePatchModel.h.

◆ statsTextChanged

void SurfacePatchModel::statsTextChanged ( )
signal

Referenced by setStatsEnabled(), and stopCapture().

◆ stopCapture()

QString SurfacePatchModel::stopCapture ( )

Stops recording and writes the samples as CSV; returns the file path (empty on write failure)

Definition at line 593 of file SurfacePatchModel.cc.

References capturingChanged(), data(), and statsTextChanged().

◆ surfaceCoordinateAtScreenPoint()

QGeoCoordinate SurfacePatchModel::surfaceCoordinateAtScreenPoint ( const GeoMapCamera *  camera,
const QPointF &  screenPos,
double  zScale 
) const

Coordinate of the rendered surface under screenPos: marches the camera's pick ray to its first crossing of z = terrain height(x, y) * zScale, so the pick lands on the visible front surface and ridges occlude the ground behind them. zScale is the height-to-scene-z factor (verticalScale * terrainScale, never negative); 0 reduces to a flat z=0 plane pick. The march is capped at the rendered range (maxRangeMultiplier * camera distance). Invalid coordinate when nothing is hit (sky pick) or camera is null.

Definition at line 376 of file SurfacePatchModel.cc.

References GeoMapCamera::PickRay::dirX, GeoMapCamera::PickRay::dirY, GeoMapCamera::PickRay::dirZ, GeoMapCamera::distance(), SurfaceModel::kMaxRangeMultiplier, GeoMapCamera::PickRay::originX, GeoMapCamera::PickRay::originY, GeoMapCamera::PickRay::originZ, GeoMapCamera::pickRayAt(), and TileMath::worldToGeo().

◆ terrain()

bool SurfacePatchModel::terrain ( ) const
inline

Definition at line 84 of file SurfacePatchModel.h.

Referenced by setTerrain().

◆ terrainChanged

void SurfacePatchModel::terrainChanged ( )
signal

Referenced by setTerrain().

◆ terrainDataChanged

void SurfacePatchModel::terrainDataChanged ( )
signal

terrainDataHeightAt / segmentBelowTerrain answers changed somewhere (not on patch churn)

◆ terrainDataHeightAt()

double SurfacePatchModel::terrainDataHeightAt ( const QGeoCoordinate &  coordinate) const

The field's estimate alone (see HeightField), independent of the drawn detail level: for the camera pivot and altitude datums, where following the mesh would couple them to patch churn. Emits terrainDataChanged when it changes.

Definition at line 332 of file SurfacePatchModel.cc.

References TileMath::geoToWorld(), and HeightField::heightAt().

◆ terrainHeightAt()

double SurfacePatchModel::terrainHeightAt ( const QGeoCoordinate &  coordinate) const

Terrain height (true meters) at a coordinate as rendered: the patch mesh where a patch draws, else the field's estimate (real data, coarser estimate, or 0; see HeightField). Emits terrainHeightsChanged when either changes.

Definition at line 323 of file SurfacePatchModel.cc.

References TileMath::geoToWorld().

◆ terrainHeightsChanged

void SurfacePatchModel::terrainHeightsChanged ( )
signal

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