QGIS API Documentation 3.43.0-Master (37eec98dbf6)
Static Public Member Functions | List of all members
Qgs3DUtils Class Reference

Miscellaneous utility functions used from 3D code. More...

#include <qgs3dutils.h>

Static Public Member Functions

static QByteArray addDefinesToShaderCode (const QByteArray &shaderCode, const QStringList &defines)
 Inserts some define macros into a shader source code.
 
static Qgis::AltitudeBinding altBindingFromString (const QString &str)
 Converts a string to a value from AltitudeBinding enum.
 
static QString altBindingToString (Qgis::AltitudeBinding altBind)
 Converts a value from AltitudeBinding enum to a string.
 
static Qgis::AltitudeClamping altClampingFromString (const QString &str)
 Converts a string to a value from AltitudeClamping enum.
 
static QString altClampingToString (Qgis::AltitudeClamping altClamp)
 Converts a value from AltitudeClamping enum to a string.
 
static double calculateEntityGpuMemorySize (Qt3DCore::QEntity *entity)
 Calculates approximate usage of GPU memory by an entity.
 
static void calculateViewExtent (const Qt3DRender::QCamera *camera, float maxRenderingDistance, float z, float &minX, float &maxX, float &minY, float &maxY, float &minZ, float &maxZ)
 Computes the portion of the Y=y plane the camera is looking at.
 
static QImage captureSceneDepthBuffer (QgsAbstract3DEngine &engine, Qgs3DMapScene *scene)
 Captures the depth buffer of the current 3D scene of a 3D engine.
 
static QImage captureSceneImage (QgsAbstract3DEngine &engine, Qgs3DMapScene *scene)
 Captures image of the current 3D scene of a 3D engine.
 
static QHash< QgsMapLayer *, QVector< QgsRayCastingUtils::RayHit > > castRay (Qgs3DMapScene *scene, const QgsRay3D &ray, const QgsRayCastingUtils::RayCastContext &context)
 Casts a ray through the scene and returns information about the intersecting entities (ray uses World coordinates).
 
static float clampAltitude (const QgsPoint &p, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float offset, const QgsPoint &centroid, const Qgs3DRenderContext &context)
 Clamps altitude of a vertex according to the settings, returns Z value.
 
static void clampAltitudes (QgsLineString *lineString, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, const QgsPoint &centroid, float offset, const Qgs3DRenderContext &context)
 Clamps altitude of vertices of a linestring according to the settings.
 
static bool clampAltitudes (QgsPolygon *polygon, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, float offset, const Qgs3DRenderContext &context)
 Clamps altitude of vertices of a polygon according to the settings.
 
static void computeBoundingBoxNearFarPlanes (const QgsAABB &bbox, const QMatrix4x4 &viewMatrix, float &fnear, float &ffar)
 This routine computes nearPlane farPlane from the closest and farthest corners point of bounding box bbox.
 
static std::unique_ptr< QgsPointCloudLayer3DRendererconvert2DPointCloudRendererTo3D (QgsPointCloudRenderer *renderer)
 Creates a QgsPointCloudLayer3DRenderer matching the symbol settings of a given QgsPointCloudRenderer.
 
static Qgs3DTypes::CullingMode cullingModeFromString (const QString &str)
 Converts a string to a value from CullingMode enum.
 
static QString cullingModeToString (Qgs3DTypes::CullingMode mode)
 Converts a value from CullingMode enum to a string.
 
static double decodeDepth (const QRgb &pixel)
 Decodes the depth value from the pixel's color value The depth value is encoded from OpenGL side (the depth render pass) into the 3 RGB channels to preserve precision.
 
static void decomposeTransformMatrix (const QMatrix4x4 &matrix, QVector3D &translation, QQuaternion &rotation, QVector3D &scale)
 Tries to decompose a 4x4 transform matrix into translation, rotation and scale components.
 
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.
 
static bool exportAnimation (const Qgs3DAnimationSettings &animationSettings, 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.
 
static void extractPointPositions (const QgsFeature &f, const Qgs3DRenderContext &context, const QgsVector3D &chunkOrigin, Qgis::AltitudeClamping altClamp, QVector< QVector3D > &positions)
 Calculates (x,y,z) positions of (multi)point from the given feature.
 
static QgsExpressionContext globalProjectLayerExpressionContext (QgsVectorLayer *layer)
 Returns expression context for use in preparation of 3D data of a layer.
 
static bool isCullable (const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix)
 Returns true if bbox is completely outside the current viewing volume.
 
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.
 
static QgsCameraPose lineSegmentToCameraPose (const QgsVector3D &startPoint, const QgsVector3D &endPoint, const QgsDoubleRange &elevationRange, float fieldOfView, const QgsVector3D &worldOrigin)
 Returns the camera pose for a camera looking at mid-point between startPoint and endPoint.
 
static QList< QVector4D > lineSegmentToClippingPlanes (const QgsVector3D &startPoint, const QgsVector3D &endPoint, double distance, const QgsVector3D &origin)
 Returns a list of 4 planes derived from a line extending from startPoint to endPoint.
 
static QgsVector3D mapToWorldCoordinates (const QgsVector3D &mapCoords, const QgsVector3D &origin)
 Converts map coordinates to 3D world coordinates (applies offset)
 
static QgsAABB mapToWorldExtent (const QgsBox3D &box3D, const QgsVector3D &mapOrigin)
 Converts 3D box in map coordinates to AABB in world coordinates.
 
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.
 
static QString matrix4x4toString (const QMatrix4x4 &m)
 Converts a 4x4 transform matrix to a string.
 
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.
 
static int openGlMaxClipPlanes (QSurface *surface)
 Gets the maximum number of clip planes that can be used.
 
static QgsPhongMaterialSettings phongMaterialFromQt3DComponent (Qt3DExtras::QPhongMaterial *material)
 Returns phong material settings object based on the Qt3D material.
 
static void pitchAndYawFromViewVector (QVector3D vect, double &pitch, double &yaw)
 Function used to extract the pitch and yaw (also known as heading) angles in degrees from the view vector of the camera [cameraViewCenter - cameraPosition].
 
static Qt3DRender::QCullFace::CullingMode qt3DcullingMode (Qgs3DTypes::CullingMode mode)
 Converts Qgs3DTypes::CullingMode mode into its Qt3D equivalent.
 
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.
 
static QByteArray removeDefinesFromShaderCode (const QByteArray &shaderCode, const QStringList &defines)
 Removes some define macros from a shader source code.
 
static QQuaternion rotationFromPitchHeadingAngles (float pitchAngle, float headingAngle)
 Returns rotation quaternion that performs rotation around X axis by pitchAngle, followed by rotation around Z axis by headingAngle (both angles in degrees).
 
static QgsPoint screenPointToMapCoordinates (const QPoint &screenPoint, QSize size, const QgsCameraController *cameraController, const Qgs3DMapSettings *mapSettings)
 Transform the given screen point to QgsPoint in map coordinates.
 
static QVector3D screenPointToWorldPos (const QPoint &screenPoint, double depth, const QSize &screenSize, Qt3DRender::QCamera *camera)
 Converts the clicked mouse position to the corresponding 3D world coordinates.
 
static float screenSpaceError (float epsilon, float distance, int screenSize, float fov)
 This routine approximately calculates how an error (epsilon) of an object in world coordinates at given distance (between camera and the object) will look like in screen coordinates.
 
static QVector2D screenToTextureCoordinates (QVector2D screenXY, QSize winSize)
 Converts from screen coordinates to texture coordinates.
 
static QMatrix4x4 stringToMatrix4x4 (const QString &str)
 Convert a string to a 4x4 transform matrix.
 
static QVector2D textureToScreenCoordinates (QVector2D textureXY, QSize winSize)
 Converts from texture coordinates coordinates to screen coordinates.
 
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)
 
static QgsRectangle tryReprojectExtent2D (const QgsRectangle &extent, const QgsCoordinateReferenceSystem &crs1, const QgsCoordinateReferenceSystem &crs2, const QgsCoordinateTransformContext &context)
 Reprojects extent from crs1 to crs2 coordinate reference system with context context.
 
static void waitForFrame (QgsAbstract3DEngine &engine, Qgs3DMapScene *scene)
 Waits for a frame to be rendered.
 
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.
 
static QgsVector3D worldToMapCoordinates (const QgsVector3D &worldCoords, const QgsVector3D &origin)
 Converts 3D world coordinates to map coordinates (applies offset)
 
static QgsRectangle worldToMapExtent (const QgsAABB &bbox, const QgsVector3D &mapOrigin)
 Converts axis aligned bounding box in 3D world coordinates to extent in map coordinates.
 

Detailed Description

Miscellaneous utility functions used from 3D code.

Note
Not available in Python bindings

Definition at line 58 of file qgs3dutils.h.

Member Function Documentation

◆ addDefinesToShaderCode()

QByteArray Qgs3DUtils::addDefinesToShaderCode ( const QByteArray &  shaderCode,
const QStringList &  defines 
)
static

Inserts some define macros into a shader source code.

Parameters
shaderCodeshader code
defineslist of defines to add
Since
QGIS 3.40

Definition at line 939 of file qgs3dutils.cpp.

◆ altBindingFromString()

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

Converts a string to a value from AltitudeBinding enum.

Definition at line 329 of file qgs3dutils.cpp.

◆ altBindingToString()

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

Converts a value from AltitudeBinding enum to a string.

Definition at line 316 of file qgs3dutils.cpp.

◆ altClampingFromString()

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

Converts a string to a value from AltitudeClamping enum.

Definition at line 305 of file qgs3dutils.cpp.

◆ altClampingToString()

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

Converts a value from AltitudeClamping enum to a string.

Definition at line 290 of file qgs3dutils.cpp.

◆ calculateEntityGpuMemorySize()

double Qgs3DUtils::calculateEntityGpuMemorySize ( Qt3DCore::QEntity *  entity)
static

Calculates approximate usage of GPU memory by an entity.

Returns
GPU memory usage in megabytes
Since
QGIS 3.34

Definition at line 175 of file qgs3dutils.cpp.

◆ calculateViewExtent()

void Qgs3DUtils::calculateViewExtent ( const Qt3DRender::QCamera *  camera,
float  maxRenderingDistance,
float  z,
float &  minX,
float &  maxX,
float &  minY,
float &  maxY,
float &  minZ,
float &  maxZ 
)
static

Computes the portion of the Y=y plane the camera is looking at.

Since
QGIS 3.44

Definition at line 1038 of file qgs3dutils.cpp.

◆ captureSceneDepthBuffer()

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

Captures the depth buffer of the current 3D scene of a 3D engine.

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

Note
In order to get more precision, the depth values are encoded into RGB colors, use Qgs3DUtils::decodeDepth() to get the correct depth value.
Since
QGIS 3.24

Definition at line 128 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 82 of file qgs3dutils.cpp.

◆ castRay()

QHash< QgsMapLayer *, QVector< QgsRayCastingUtils::RayHit > > Qgs3DUtils::castRay ( Qgs3DMapScene scene,
const QgsRay3D ray,
const QgsRayCastingUtils::RayCastContext context 
)
static

Casts a ray through the scene and returns information about the intersecting entities (ray uses World coordinates).

The resulting hits are grouped by layer in a QHash.

Note
Hits on the terrain have nullptr as their key in the returning QHash.
Since
QGIS 3.32

Definition at line 848 of file qgs3dutils.cpp.

◆ clampAltitude()

float Qgs3DUtils::clampAltitude ( const QgsPoint p,
Qgis::AltitudeClamping  altClamp,
Qgis::AltitudeBinding  altBind,
float  offset,
const QgsPoint centroid,
const Qgs3DRenderContext context 
)
static

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

Definition at line 365 of file qgs3dutils.cpp.

◆ clampAltitudes() [1/2]

void Qgs3DUtils::clampAltitudes ( QgsLineString lineString,
Qgis::AltitudeClamping  altClamp,
Qgis::AltitudeBinding  altBind,
const QgsPoint centroid,
float  offset,
const Qgs3DRenderContext context 
)
static

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

Definition at line 401 of file qgs3dutils.cpp.

◆ clampAltitudes() [2/2]

bool Qgs3DUtils::clampAltitudes ( QgsPolygon polygon,
Qgis::AltitudeClamping  altClamp,
Qgis::AltitudeBinding  altBind,
float  offset,
const Qgs3DRenderContext context 
)
static

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

Definition at line 451 of file qgs3dutils.cpp.

◆ computeBoundingBoxNearFarPlanes()

void Qgs3DUtils::computeBoundingBoxNearFarPlanes ( const QgsAABB bbox,
const QMatrix4x4 &  viewMatrix,
float &  fnear,
float &  ffar 
)
static

This routine computes nearPlane farPlane from the closest and farthest corners point of bounding box bbox.

In case of error, fnear will equal 1e9 and ffar 0.

Parameters
bboxin world coordinates
viewMatrixcamera view matrix
fnearnear plane
ffarfar plane
Since
QGIS 3.34

Definition at line 905 of file qgs3dutils.cpp.

◆ convert2DPointCloudRendererTo3D()

std::unique_ptr< QgsPointCloudLayer3DRenderer > Qgs3DUtils::convert2DPointCloudRendererTo3D ( QgsPointCloudRenderer renderer)
static

Creates a QgsPointCloudLayer3DRenderer matching the symbol settings of a given QgsPointCloudRenderer.

Note
This function was formerly in Qgs3DAppUtils
Since
QGIS 3.26

Definition at line 802 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 353 of file qgs3dutils.cpp.

◆ cullingModeToString()

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

Converts a value from CullingMode enum to a string.

Definition at line 337 of file qgs3dutils.cpp.

◆ decodeDepth()

static double Qgs3DUtils::decodeDepth ( const QRgb &  pixel)
inlinestatic

Decodes the depth value from the pixel's color value The depth value is encoded from OpenGL side (the depth render pass) into the 3 RGB channels to preserve precision.

Since
QGIS 3.24

Definition at line 243 of file qgs3dutils.h.

◆ decomposeTransformMatrix()

void Qgs3DUtils::decomposeTransformMatrix ( const QMatrix4x4 &  matrix,
QVector3D &  translation,
QQuaternion &  rotation,
QVector3D &  scale 
)
static

Tries to decompose a 4x4 transform matrix into translation, rotation and scale components.

It is expected that the matrix has been created by only applying these transforms, otherwise the results are undefined.

Since
QGIS 3.42

Definition at line 975 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 692 of file qgs3dutils.cpp.

◆ exportAnimation()

bool Qgs3DUtils::exportAnimation ( const Qgs3DAnimationSettings animationSettings,
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 191 of file qgs3dutils.cpp.

◆ extractPointPositions()

void Qgs3DUtils::extractPointPositions ( const QgsFeature f,
const Qgs3DRenderContext context,
const QgsVector3D chunkOrigin,
Qgis::AltitudeClamping  altClamp,
QVector< QVector3D > &  positions 
)
static

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

Definition at line 507 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 726 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 582 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 629 of file qgs3dutils.cpp.

◆ lineSegmentToCameraPose()

QgsCameraPose Qgs3DUtils::lineSegmentToCameraPose ( const QgsVector3D startPoint,
const QgsVector3D endPoint,
const QgsDoubleRange elevationRange,
float  fieldOfView,
const QgsVector3D worldOrigin 
)
static

Returns the camera pose for a camera looking at mid-point between startPoint and endPoint.

The camera is angled to provide a profile view and the heading angle is calculated to look from the right side of the line. The middle of elevationRange sets the z attribute of mid-point.

Since
QGIS 3.44

Definition at line 1135 of file qgs3dutils.cpp.

◆ lineSegmentToClippingPlanes()

QList< QVector4D > Qgs3DUtils::lineSegmentToClippingPlanes ( const QgsVector3D startPoint,
const QgsVector3D endPoint,
double  distance,
const QgsVector3D origin 
)
static

Returns a list of 4 planes derived from a line extending from startPoint to endPoint.

The parameter distance defines the distance between the parallel clipping planes and the line. Each clipping plane is represented as a 4D vector, where the first three components correspond to the normalized normal of the plane, and the fourth component represents its distance from the origin of the scene.

Note
distance is expected to be positive
Since
QGIS 3.44

back clip plane

left clip plane

front clip plane

right clip plane

Definition at line 1096 of file qgs3dutils.cpp.

◆ mapToWorldCoordinates()

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

Converts map coordinates to 3D world coordinates (applies offset)

Definition at line 598 of file qgs3dutils.cpp.

◆ mapToWorldExtent() [1/2]

QgsAABB Qgs3DUtils::mapToWorldExtent ( const QgsBox3D box3D,
const QgsVector3D mapOrigin 
)
static

Converts 3D box in map coordinates to AABB in world coordinates.

Since
QGIS 3.42

Definition at line 651 of file qgs3dutils.cpp.

◆ mapToWorldExtent() [2/2]

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 641 of file qgs3dutils.cpp.

◆ matrix4x4toString()

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

Converts a 4x4 transform matrix to a string.

Definition at line 487 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 277 of file qgs3dutils.cpp.

◆ openGlMaxClipPlanes()

int Qgs3DUtils::openGlMaxClipPlanes ( QSurface *  surface)
static

Gets the maximum number of clip planes that can be used.

This value depends on the OpenGL implementation. It should be at least 6.

Since
QGIS 3.42

Definition at line 1002 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 735 of file qgs3dutils.cpp.

◆ pitchAndYawFromViewVector()

void Qgs3DUtils::pitchAndYawFromViewVector ( QVector3D  vect,
double &  pitch,
double &  yaw 
)
static

Function used to extract the pitch and yaw (also known as heading) angles in degrees from the view vector of the camera [cameraViewCenter - cameraPosition].

Since
QGIS 3.24

Definition at line 784 of file qgs3dutils.cpp.

◆ qt3DcullingMode()

Qt3DRender::QCullFace::CullingMode Qgs3DUtils::qt3DcullingMode ( Qgs3DTypes::CullingMode  mode)
static

Converts Qgs3DTypes::CullingMode mode into its Qt3D equivalent.

Parameters
modeculling mode
Since
QGIS 3.34

Definition at line 922 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 745 of file qgs3dutils.cpp.

◆ removeDefinesFromShaderCode()

QByteArray Qgs3DUtils::removeDefinesFromShaderCode ( const QByteArray &  shaderCode,
const QStringList &  defines 
)
static

Removes some define macros from a shader source code.

Parameters
shaderCodeshader code
defineslist of defines to remove
Since
QGIS 3.40

Definition at line 958 of file qgs3dutils.cpp.

◆ rotationFromPitchHeadingAngles()

QQuaternion Qgs3DUtils::rotationFromPitchHeadingAngles ( float  pitchAngle,
float  headingAngle 
)
static

Returns rotation quaternion that performs rotation around X axis by pitchAngle, followed by rotation around Z axis by headingAngle (both angles in degrees).

Since
QGIS 3.42

Definition at line 1020 of file qgs3dutils.cpp.

◆ screenPointToMapCoordinates()

QgsPoint Qgs3DUtils::screenPointToMapCoordinates ( const QPoint &  screenPoint,
QSize  size,
const QgsCameraController cameraController,
const Qgs3DMapSettings mapSettings 
)
static

Transform the given screen point to QgsPoint in map coordinates.

Note
This transformation is not unique as we pick point halfway between near and far plane on the ray from the camera.
Parameters
sizesize of canvas
screenPointpoint in screen coordinates
cameraControllercamera controller attached to the scene
mapSettings3D map settings of the scene
Since
QGIS 3.44

Definition at line 1025 of file qgs3dutils.cpp.

◆ screenPointToWorldPos()

QVector3D Qgs3DUtils::screenPointToWorldPos ( const QPoint &  screenPoint,
double  depth,
const QSize &  screenSize,
Qt3DRender::QCamera *  camera 
)
static

Converts the clicked mouse position to the corresponding 3D world coordinates.

Since
QGIS 3.24

Definition at line 771 of file qgs3dutils.cpp.

◆ screenSpaceError()

float Qgs3DUtils::screenSpaceError ( float  epsilon,
float  distance,
int  screenSize,
float  fov 
)
static

This routine approximately calculates how an error (epsilon) of an object in world coordinates at given distance (between camera and the object) will look like in screen coordinates.

Parameters
epsilonerror in world coordinates
distancedistance between camera and object
screenSizescreen width or height in pixels
fovcamera's field of view in degrees
Since
QGIS 3.32

Definition at line 879 of file qgs3dutils.cpp.

◆ screenToTextureCoordinates()

QVector2D Qgs3DUtils::screenToTextureCoordinates ( QVector2D  screenXY,
QSize  winSize 
)
static

Converts from screen coordinates to texture coordinates.

Note
Expected return values are in [0, 1] range
See also
textureToScreenCoordinates()
Since
QGIS 3.24

Definition at line 792 of file qgs3dutils.cpp.

◆ stringToMatrix4x4()

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

Convert a string to a 4x4 transform matrix.

Definition at line 497 of file qgs3dutils.cpp.

◆ textureToScreenCoordinates()

QVector2D Qgs3DUtils::textureToScreenCoordinates ( QVector2D  textureXY,
QSize  winSize 
)
static

Converts from texture coordinates coordinates to screen coordinates.

Note
Expected return values are in [0, winSize.width], [0, winSize.height] range
See also
screenToTextureCoordinates()
Since
QGIS 3.24

Definition at line 797 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 671 of file qgs3dutils.cpp.

◆ tryReprojectExtent2D()

QgsRectangle Qgs3DUtils::tryReprojectExtent2D ( const QgsRectangle extent,
const QgsCoordinateReferenceSystem crs1,
const QgsCoordinateReferenceSystem crs2,
const QgsCoordinateTransformContext context 
)
static

Reprojects extent from crs1 to crs2 coordinate reference system with context context.

If crs1 and crs2 are identical, extent is returned.

Parameters
extentextent to reproject
crs1source coordinate reference system
crs2destination coordinate reference system
contextthe context under which the transform is applied
Returns
reprojected extent. In case of failure, extent is returned
Since
QGIS 3.32

Definition at line 608 of file qgs3dutils.cpp.

◆ waitForFrame()

void Qgs3DUtils::waitForFrame ( QgsAbstract3DEngine engine,
Qgs3DMapScene scene 
)
static

Waits for a frame to be rendered.

Useful to trigger once-per-frame updates

Since
QGIS 3.42

Definition at line 64 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 635 of file qgs3dutils.cpp.

◆ worldToMapCoordinates()

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

Converts 3D world coordinates to map coordinates (applies offset)

Definition at line 603 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 661 of file qgs3dutils.cpp.


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