QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Static Public Member Functions | List of all members
Qgs3DUtils Class Reference

3 More...

#include <qgs3dutils.h>

Static Public Member Functions

static Qgs3DTypes::AltitudeBinding altBindingFromString (const QString &str)
 Converts a string to a value from AltitudeBinding enum. More...
 
static QString altBindingToString (Qgs3DTypes::AltitudeBinding altBind)
 Converts a value from AltitudeBinding enum to a string. More...
 
static Qgs3DTypes::AltitudeClamping altClampingFromString (const QString &str)
 Converts a string to a value from AltitudeClamping enum. More...
 
static QString altClampingToString (Qgs3DTypes::AltitudeClamping altClamp)
 Converts a value from AltitudeClamping enum to a string. More...
 
static QImage captureSceneImage (QgsAbstract3DEngine &engine, Qgs3DMapScene *scene)
 Captures image of the current 3D scene of a 3D engine. More...
 
static float clampAltitude (const QgsPoint &p, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const QgsPoint &centroid, const Qgs3DMapSettings &map)
 Clamps altitude of a vertex according to the settings, returns Z value. More...
 
static void clampAltitudes (QgsLineString *lineString, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, const QgsPoint &centroid, float height, const Qgs3DMapSettings &map)
 Clamps altitude of vertices of a linestring according to the settings. More...
 
static bool clampAltitudes (QgsPolygon *polygon, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map)
 Clamps altitude of vertices of a polygon according to the settings. More...
 
static Qgs3DTypes::CullingMode cullingModeFromString (const QString &str)
 Converts a string to a value from CullingMode enum. More...
 
static QString cullingModeToString (Qgs3DTypes::CullingMode mode)
 Converts a value from CullingMode enum to a string. More...
 
static void estimateVectorLayerZRange (QgsVectorLayer *layer, double &zMin, double &zMax)
 Try to estimate range of Z values used in the given vector layer and store that in zMin and zMax. More...
 
static bool exportAnimation (const Qgs3DAnimationSettings &animationSettings, const Qgs3DMapSettings &mapSettings, int framesPerSecond, const QString &outputDirectory, const QString &fileNameTemplate, const QSize &outputSize, QString &error, QgsFeedback *feedback=nullptr)
 Captures 3D animation frames to the selected folder. More...
 
static void extractPointPositions (const QgsFeature &f, const Qgs3DMapSettings &map, Qgs3DTypes::AltitudeClamping altClamp, QVector< QVector3D > &positions)
 Calculates (x,y,z) positions of (multi)point from the given feature. More...
 
static QgsExpressionContext globalProjectLayerExpressionContext (QgsVectorLayer *layer)
 Returns expression context for use in preparation of 3D data of a layer. More...
 
static bool isCullable (const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix)
 Returns true if bbox is completely outside the current viewing volume. More...
 
static QgsAABB layerToWorldExtent (const QgsRectangle &extent, double zMin, double zMax, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context)
 Converts extent (in map layer's CRS) to axis aligned bounding box in 3D world coordinates. More...
 
static QgsVector3D mapToWorldCoordinates (const QgsVector3D &mapCoords, const QgsVector3D &origin)
 Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,-z,y)) More...
 
static QgsAABB mapToWorldExtent (const QgsRectangle &extent, double zMin, double zMax, const QgsVector3D &mapOrigin)
 Converts map extent to axis aligned bounding box in 3D world coordinates. More...
 
static QString matrix4x4toString (const QMatrix4x4 &m)
 Converts a 4x4 transform matrix to a string. More...
 
static int maxZoomLevel (double tile0width, double tileResolution, double maxError)
 Calculates the highest needed zoom level for tiles in quad-tree given width of the base tile (zoom level 0) in map units, resolution of the tile (e.g. More...
 
static QgsPhongMaterialSettings phongMaterialFromQt3DComponent (Qt3DExtras::QPhongMaterial *material)
 Returns phong material settings object based on the Qt3D material. More...
 
static QgsRay3D rayFromScreenPoint (const QPoint &point, const QSize &windowSize, Qt3DRender::QCamera *camera)
 Convert from clicked point on the screen to a ray in world coordinates. More...
 
static QMatrix4x4 stringToMatrix4x4 (const QString &str)
 Convert a string to a 4x4 transform matrix. More...
 
static QgsVector3D transformWorldCoordinates (const QgsVector3D &worldPoint1, const QgsVector3D &origin1, const QgsCoordinateReferenceSystem &crs1, const QgsVector3D &origin2, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context)
 Transforms a world point from (origin1, crs1) to (origin2, crs2) More...
 
static QgsRectangle worldToLayerExtent (const QgsAABB &bbox, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context)
 Converts axis aligned bounding box in 3D world coordinates to extent in map layer CRS. More...
 
static QgsVector3D worldToMapCoordinates (const QgsVector3D &worldCoords, const QgsVector3D &origin)
 Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,-z,y)) More...
 
static QgsRectangle worldToMapExtent (const QgsAABB &bbox, const QgsVector3D &mapOrigin)
 Converts axis aligned bounding box in 3D world coordinates to extent in map coordinates. More...
 

Detailed Description

3

Miscellaneous utility functions used from 3D code.

Note
Not available in Python bindings
Since
QGIS 3.0

Definition at line 52 of file qgs3dutils.h.

Member Function Documentation

◆ altBindingFromString()

Qgs3DTypes::AltitudeBinding Qgs3DUtils::altBindingFromString ( const QString &  str)
static

Converts a string to a value from AltitudeBinding enum.

Definition at line 214 of file qgs3dutils.cpp.

◆ altBindingToString()

QString Qgs3DUtils::altBindingToString ( Qgs3DTypes::AltitudeBinding  altBind)
static

Converts a value from AltitudeBinding enum to a string.

Definition at line 203 of file qgs3dutils.cpp.

◆ altClampingFromString()

Qgs3DTypes::AltitudeClamping Qgs3DUtils::altClampingFromString ( const QString &  str)
static

Converts a string to a value from AltitudeClamping enum.

Definition at line 192 of file qgs3dutils.cpp.

◆ altClampingToString()

QString Qgs3DUtils::altClampingToString ( Qgs3DTypes::AltitudeClamping  altClamp)
static

Converts a value from AltitudeClamping enum to a string.

Definition at line 180 of file qgs3dutils.cpp.

◆ captureSceneImage()

QImage Qgs3DUtils::captureSceneImage ( QgsAbstract3DEngine engine,
Qgs3DMapScene scene 
)
static

Captures image of the current 3D scene of a 3D engine.

The function waits until the scene is not fully loaded/updated before capturing the image.

Since
QGIS 3.4

Definition at line 42 of file qgs3dutils.cpp.

◆ clampAltitude()

float Qgs3DUtils::clampAltitude ( const QgsPoint p,
Qgs3DTypes::AltitudeClamping  altClamp,
Qgs3DTypes::AltitudeBinding  altBind,
float  height,
const QgsPoint centroid,
const Qgs3DMapSettings map 
)
static

Clamps altitude of a vertex according to the settings, returns Z value.

Definition at line 246 of file qgs3dutils.cpp.

◆ clampAltitudes() [1/2]

void Qgs3DUtils::clampAltitudes ( QgsLineString lineString,
Qgs3DTypes::AltitudeClamping  altClamp,
Qgs3DTypes::AltitudeBinding  altBind,
const QgsPoint centroid,
float  height,
const Qgs3DMapSettings map 
)
static

Clamps altitude of vertices of a linestring according to the settings.

Definition at line 263 of file qgs3dutils.cpp.

◆ clampAltitudes() [2/2]

bool Qgs3DUtils::clampAltitudes ( QgsPolygon polygon,
Qgs3DTypes::AltitudeClamping  altClamp,
Qgs3DTypes::AltitudeBinding  altBind,
float  height,
const Qgs3DMapSettings map 
)
static

Clamps altitude of vertices of a polygon according to the settings.

Definition at line 293 of file qgs3dutils.cpp.

◆ cullingModeFromString()

Qgs3DTypes::CullingMode Qgs3DUtils::cullingModeFromString ( const QString &  str)
static

Converts a string to a value from CullingMode enum.

Definition at line 234 of file qgs3dutils.cpp.

◆ cullingModeToString()

QString Qgs3DUtils::cullingModeToString ( Qgs3DTypes::CullingMode  mode)
static

Converts a value from CullingMode enum to a string.

Definition at line 222 of file qgs3dutils.cpp.

◆ estimateVectorLayerZRange()

void Qgs3DUtils::estimateVectorLayerZRange ( QgsVectorLayer layer,
double &  zMin,
double &  zMax 
)
static

Try to estimate range of Z values used in the given vector layer and store that in zMin and zMax.

The implementation scans a small amount of features and looks at the Z values of geometries (we don't need exact range, just a rough estimate is fine to know where to expect the data to be). For layers with geometries without Z values, the returned range will be [0, 0].

Since
QGIS 3.12

Definition at line 515 of file qgs3dutils.cpp.

◆ exportAnimation()

bool Qgs3DUtils::exportAnimation ( const Qgs3DAnimationSettings animationSettings,
const Qgs3DMapSettings mapSettings,
int  framesPerSecond,
const QString &  outputDirectory,
const QString &  fileNameTemplate,
const QSize &  outputSize,
QString &  error,
QgsFeedback feedback = nullptr 
)
static

Captures 3D animation frames to the selected folder.

Parameters
animationSettingsSettings for keyframes and camera
mapSettings3d map settings
framesPerSecondnumber of frames per second to export
outputDirectoryoutput directory where to export frames
fileNameTemplatetemplate for exporting the frames. Must be in format prefix####.format, where number of

represents how many 0 should be left-padded to the frame number

e.g. my###.jpg will create frames my001.jpg, my002.jpg, etc

Parameters
outputSizesize of the frame in pixels
errorerror string in case of failure
feedbackoptional feedback object used to cancel export or report progress
Returns
whether export succeeded. In case of failure, see error argument
Since
QGIS 3.8

Definition at line 83 of file qgs3dutils.cpp.

◆ extractPointPositions()

void Qgs3DUtils::extractPointPositions ( const QgsFeature f,
const Qgs3DMapSettings map,
Qgs3DTypes::AltitudeClamping  altClamp,
QVector< QVector3D > &  positions 
)
static

Calculates (x,y,z) positions of (multi)point from the given feature.

Definition at line 342 of file qgs3dutils.cpp.

◆ globalProjectLayerExpressionContext()

QgsExpressionContext Qgs3DUtils::globalProjectLayerExpressionContext ( QgsVectorLayer layer)
static

Returns expression context for use in preparation of 3D data of a layer.

Definition at line 547 of file qgs3dutils.cpp.

◆ isCullable()

bool Qgs3DUtils::isCullable ( const QgsAABB bbox,
const QMatrix4x4 &  viewProjectionMatrix 
)
static

Returns true if bbox is completely outside the current viewing volume.

coarse box vs frustum test for culling.

This is used to perform object culling checks.

corners of oriented box are transformed to clip space and there is a test that all points are on the wrong side of the same plane see http://www.lighthouse3d.com/tutorials/view-frustum-culling/geometric-approach-testing-boxes/

should be equivalent to https://searchcode.com/codesearch/view/35195518/ qt3d /src/threed/painting/qglpainter.cpp bool QGLPainter::isCullable(const QBox3D& box) const

Definition at line 408 of file qgs3dutils.cpp.

◆ layerToWorldExtent()

QgsAABB Qgs3DUtils::layerToWorldExtent ( const QgsRectangle extent,
double  zMin,
double  zMax,
const QgsCoordinateReferenceSystem layerCrs,
const QgsVector3D mapOrigin,
const QgsCoordinateReferenceSystem mapCrs,
const QgsCoordinateTransformContext context 
)
static

Converts extent (in map layer's CRS) to axis aligned bounding box in 3D world coordinates.

Since
QGIS 3.12

Definition at line 461 of file qgs3dutils.cpp.

◆ mapToWorldCoordinates()

QgsVector3D Qgs3DUtils::mapToWorldCoordinates ( const QgsVector3D mapCoords,
const QgsVector3D origin 
)
static

Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,-z,y))

Definition at line 426 of file qgs3dutils.cpp.

◆ mapToWorldExtent()

QgsAABB Qgs3DUtils::mapToWorldExtent ( const QgsRectangle extent,
double  zMin,
double  zMax,
const QgsVector3D mapOrigin 
)
static

Converts map extent to axis aligned bounding box in 3D world coordinates.

Since
QGIS 3.12

Definition at line 473 of file qgs3dutils.cpp.

◆ matrix4x4toString()

QString Qgs3DUtils::matrix4x4toString ( const QMatrix4x4 &  m)
static

Converts a 4x4 transform matrix to a string.

Definition at line 322 of file qgs3dutils.cpp.

◆ maxZoomLevel()

int Qgs3DUtils::maxZoomLevel ( double  tile0width,
double  tileResolution,
double  maxError 
)
static

Calculates the highest needed zoom level for tiles in quad-tree given width of the base tile (zoom level 0) in map units, resolution of the tile (e.g.

tile's texture width) and desired maximum error in map units.

Definition at line 167 of file qgs3dutils.cpp.

◆ phongMaterialFromQt3DComponent()

QgsPhongMaterialSettings Qgs3DUtils::phongMaterialFromQt3DComponent ( Qt3DExtras::QPhongMaterial *  material)
static

Returns phong material settings object based on the Qt3D material.

Definition at line 556 of file qgs3dutils.cpp.

◆ rayFromScreenPoint()

QgsRay3D Qgs3DUtils::rayFromScreenPoint ( const QPoint &  point,
const QSize &  windowSize,
Qt3DRender::QCamera *  camera 
)
static

Convert from clicked point on the screen to a ray in world coordinates.

Definition at line 566 of file qgs3dutils.cpp.

◆ stringToMatrix4x4()

QMatrix4x4 Qgs3DUtils::stringToMatrix4x4 ( const QString &  str)
static

Convert a string to a 4x4 transform matrix.

Definition at line 332 of file qgs3dutils.cpp.

◆ transformWorldCoordinates()

QgsVector3D Qgs3DUtils::transformWorldCoordinates ( const QgsVector3D worldPoint1,
const QgsVector3D origin1,
const QgsCoordinateReferenceSystem crs1,
const QgsVector3D origin2,
const QgsCoordinateReferenceSystem crs2,
const QgsCoordinateTransformContext context 
)
static

Transforms a world point from (origin1, crs1) to (origin2, crs2)

Definition at line 494 of file qgs3dutils.cpp.

◆ worldToLayerExtent()

QgsRectangle Qgs3DUtils::worldToLayerExtent ( const QgsAABB bbox,
const QgsCoordinateReferenceSystem layerCrs,
const QgsVector3D mapOrigin,
const QgsCoordinateReferenceSystem mapCrs,
const QgsCoordinateTransformContext context 
)
static

Converts axis aligned bounding box in 3D world coordinates to extent in map layer CRS.

Since
QGIS 3.12

Definition at line 467 of file qgs3dutils.cpp.

◆ worldToMapCoordinates()

QgsVector3D Qgs3DUtils::worldToMapCoordinates ( const QgsVector3D worldCoords,
const QgsVector3D origin 
)
static

Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,-z,y))

Definition at line 434 of file qgs3dutils.cpp.

◆ worldToMapExtent()

QgsRectangle Qgs3DUtils::worldToMapExtent ( const QgsAABB bbox,
const QgsVector3D mapOrigin 
)
static

Converts axis aligned bounding box in 3D world coordinates to extent in map coordinates.

Since
QGIS 3.12

Definition at line 484 of file qgs3dutils.cpp.


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