QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 #include "qgsray3d.h"
39 
40 #include <Qt3DRender/QCamera>
41 
42 #include <memory>
43 
44 #define SIP_NO_FILE
45 
52 class _3D_EXPORT Qgs3DUtils
53 {
54  public:
55 
61  static QImage captureSceneImage( QgsAbstract3DEngine &engine, Qgs3DMapScene *scene );
62 
81  static bool exportAnimation( const Qgs3DAnimationSettings &animationSettings,
82  const Qgs3DMapSettings &mapSettings,
83  int framesPerSecond,
84  const QString &outputDirectory,
85  const QString &fileNameTemplate,
86  const QSize &outputSize,
87  QString &error,
88  QgsFeedback *feedback = nullptr
89  );
90 
95  static int maxZoomLevel( double tile0width, double tileResolution, double maxError );
96 
98  static QString altClampingToString( Qgs3DTypes::AltitudeClamping altClamp );
100  static Qgs3DTypes::AltitudeClamping altClampingFromString( const QString &str );
101 
103  static QString altBindingToString( Qgs3DTypes::AltitudeBinding altBind );
105  static Qgs3DTypes::AltitudeBinding altBindingFromString( const QString &str );
106 
108  static QString cullingModeToString( Qgs3DTypes::CullingMode mode );
110  static Qgs3DTypes::CullingMode cullingModeFromString( const QString &str );
111 
113  static float clampAltitude( const QgsPoint &p, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const QgsPoint &centroid, const Qgs3DMapSettings &map );
115  static void clampAltitudes( QgsLineString *lineString, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, const QgsPoint &centroid, float height, const Qgs3DMapSettings &map );
117  static bool clampAltitudes( QgsPolygon *polygon, Qgs3DTypes::AltitudeClamping altClamp, Qgs3DTypes::AltitudeBinding altBind, float height, const Qgs3DMapSettings &map );
118 
120  static QString matrix4x4toString( const QMatrix4x4 &m );
122  static QMatrix4x4 stringToMatrix4x4( const QString &str );
123 
125  static void extractPointPositions( const QgsFeature &f, const Qgs3DMapSettings &map, Qgs3DTypes::AltitudeClamping altClamp, QVector<QVector3D> &positions );
126 
131  static bool isCullable( const QgsAABB &bbox, const QMatrix4x4 &viewProjectionMatrix );
132 
134  static QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords, const QgsVector3D &origin );
136  static QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords, const QgsVector3D &origin );
137 
142  static QgsAABB layerToWorldExtent( const QgsRectangle &extent, double zMin, double zMax, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context );
143 
148  static QgsRectangle worldToLayerExtent( const QgsAABB &bbox, const QgsCoordinateReferenceSystem &layerCrs, const QgsVector3D &mapOrigin, const QgsCoordinateReferenceSystem &mapCrs, const QgsCoordinateTransformContext &context );
149 
154  static QgsAABB mapToWorldExtent( const QgsRectangle &extent, double zMin, double zMax, const QgsVector3D &mapOrigin );
155 
160  static QgsRectangle worldToMapExtent( const QgsAABB &bbox, const QgsVector3D &mapOrigin );
161 
163  static QgsVector3D transformWorldCoordinates( const QgsVector3D &worldPoint1, const QgsVector3D &origin1, const QgsCoordinateReferenceSystem &crs1, const QgsVector3D &origin2, const QgsCoordinateReferenceSystem &crs2,
164  const QgsCoordinateTransformContext &context );
165 
173  static void estimateVectorLayerZRange( QgsVectorLayer *layer, double &zMin, double &zMax );
174 
176  static QgsExpressionContext globalProjectLayerExpressionContext( QgsVectorLayer *layer );
177 
179  static QgsPhongMaterialSettings phongMaterialFromQt3DComponent( Qt3DExtras::QPhongMaterial *material );
180 
182  static QgsRay3D rayFromScreenPoint( const QPoint &point, const QSize &windowSize, Qt3DRender::QCamera *camera );
183 };
184 
185 #endif // QGS3DUTILS_H
AltitudeClamping
how to handle altitude of vector features
Definition: qgs3dtypes.h:35
AltitudeBinding
how to handle clamping of vertices of individual features
Definition: qgs3dtypes.h:43
CullingMode
Triangle culling mode.
Definition: qgs3dtypes.h:50
3
Definition: qgsaabb.h:34
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:44
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
Polygon geometry type.
Definition: qgspolygon.h:34
A representation of a ray in 3D.
Definition: qgsray3d.h:31
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Represents a vector layer which manages a vector based data sets.