QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgs3dutils.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgs3dutils.h
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGS3DUTILS_H
17 #define QGS3DUTILS_H
18 
19 #include "qgis_sip.h"
20 
21 class QgsLineString;
22 class QgsPolygon;
23 class QgsFeedback;
24 
27 class Qgs3DMapScene;
28 
29 namespace Qt3DExtras
30 {
31  class QPhongMaterial;
32 }
33 
34 #include "qgs3dmapsettings.h"
35 #include "qgs3danimationsettings.h"
36 #include "qgs3dtypes.h"
37 #include "qgsaabb.h"
38 
39 #include <memory>
40 
41 #define SIP_NO_FILE
42 
49 class _3D_EXPORT Qgs3DUtils
50 {
51  public:
52 
58  static QImage captureSceneImage( QgsAbstract3DEngine &engine, Qgs3DMapScene *scene );
59 
78  static bool exportAnimation( const Qgs3DAnimationSettings &animationSettings,
79  const Qgs3DMapSettings &mapSettings,
80  int framesPerSecond,
81  const QString &outputDirectory,
82  const QString &fileNameTemplate,
83  const QSize &outputSize,
84  QString &error,
85  QgsFeedback *feedback = nullptr
86  );
87 
92  static int maxZoomLevel( double tile0width, double tileResolution, double maxError );
93 
95  static QString altClampingToString( Qgs3DTypes::AltitudeClamping altClamp );
97  static Qgs3DTypes::AltitudeClamping altClampingFromString( const QString &str );
98 
100  static QString altBindingToString( Qgs3DTypes::AltitudeBinding altBind );
102  static Qgs3DTypes::AltitudeBinding altBindingFromString( const QString &str );
103 
105  static QString cullingModeToString( Qgs3DTypes::CullingMode mode );
107  static Qgs3DTypes::CullingMode cullingModeFromString( const QString &str );
108 
110  static float clampAltitude( const QgsPoint &p, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const QgsPoint &centroid, const Qgs3DMapSettings &map );
112  static void clampAltitudes( QgsLineString *lineString, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, const QgsPoint &centroid, float height, const Qgs3DMapSettings &map );
114  static bool clampAltitudes( QgsPolygon *polygon, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map );
115 
117  static QString matrix4x4toString( const QMatrix4x4 &m );
119  static QMatrix4x4 stringToMatrix4x4( const QString &str );
120 
122  static void extractPointPositions( QgsFeature &f, const Qgs3DMapSettings &map, Qgs3DTypes::AltitudeClamping altClamp, QVector<QVector3D> &positions );
123 
128  static bool isCullable( const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix );
129 
131  static QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords, const QgsVector3D &origin );
133  static QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords, const QgsVector3D &origin );
134 
139  static QgsAABB layerToWorldExtent( const QgsRectangle &extent, double zMin, double zMax, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context );
140 
145  static QgsRectangle worldToLayerExtent( const QgsAABB &bbox, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context );
146 
151  static QgsAABB mapToWorldExtent( const QgsRectangle &extent, double zMin, double zMax, const QgsVector3D &mapOrigin );
152 
157  static QgsRectangle worldToMapExtent( const QgsAABB &bbox, const QgsVector3D &mapOrigin );
158 
160  static QgsVector3D transformWorldCoordinates( const QgsVector3D &worldPoint1, const QgsVector3D &origin1, const QgsCoordinateReferenceSystem &crs1, const QgsVector3D &origin2, const QgsCoordinateReferenceSystem &crs2,
161  const QgsCoordinateTransformContext &context );
162 
170  static void estimateVectorLayerZRange( QgsVectorLayer *layer, double &zMin, double &zMax );
171 
173  static QgsExpressionContext globalProjectLayerExpressionContext( QgsVectorLayer *layer );
174 
176  static QgsPhongMaterialSettings phongMaterialFromQt3DComponent( Qt3DExtras::QPhongMaterial *material );
177 };
178 
179 #endif // QGS3DUTILS_H
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
Qgs3DTypes::AltitudeBinding
AltitudeBinding
how to handle clamping of vertices of individual features
Definition: qgs3dtypes.h:43
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:58
qgs3danimationsettings.h
QgsPolygon
Polygon geometry type.
Definition: qgspolygon.h:34
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
qgsaabb.h
QgsVector3D
3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
Definition: qgsvector3d.h:32
QgsLineString
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:44
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsPhongMaterialSettings
3 Basic shading material used for rendering based on the Phong shading model with three color compone...
Definition: qgsphongmaterialsettings.h:37
QgsAbstract3DSymbol
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Definition: qgsabstract3dsymbol.h:46
Qgs3DTypes::CullingMode
CullingMode
Triangle culling mode.
Definition: qgs3dtypes.h:50
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
qgis_sip.h
QgsAABB
3 Axis-aligned bounding box - in world coords.
Definition: qgsaabb.h:34
qgs3dtypes.h
Qgs3DMapSettings
3 Definition of the world
Definition: qgs3dmapsettings.h:54
QgsAbstract3DEngine
3 Base class for 3D engine implementation.
Definition: qgsabstract3dengine.h:58
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:206
Qgs3DMapScene
3 Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children.
Definition: qgs3dmapscene.h:69
Qgs3DTypes::AltitudeClamping
AltitudeClamping
how to handle altitude of vector features
Definition: qgs3dtypes.h:35
qgs3dmapsettings.h
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
Qgs3DUtils
3 Miscellaneous utility functions used from 3D code.
Definition: qgs3dutils.h:50
Qgs3DAnimationSettings
3 Class that holds information about animation in 3D view.
Definition: qgs3danimationsettings.h:39
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
Qt3DExtras
Definition: qgs3dmapscene.h:40