QGIS API Documentation 3.99.0-Master (a8f284845db)
Loading...
Searching...
No Matches
qgs3drendercontext.h
Go to the documentation of this file.
1/***************************************************************************
2 qgs3drendercontext.h
3 --------------------------------------
4 Date : August 2024
5 Copyright : (C) 2024 by Nyall Dawson
6 Email : nyall dot dawson 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 QGS3DRENDERCONTEXT_H
17#define QGS3DRENDERCONTEXT_H
18
19#include "qgis_3d.h"
24#include "qgsrange.h"
25#include "qgsrectangle.h"
26#include "qgsterraingenerator.h"
27#include "qgsvector3d.h"
28
29#include <QColor>
30
31#define SIP_NO_FILE
32
34
35
48class _3D_EXPORT Qgs3DRenderContext
49{
50 public:
51 Qgs3DRenderContext() = default;
55
59 static Qgs3DRenderContext fromMapSettings( const Qgs3DMapSettings *mapSettings );
60
64 QgsCoordinateReferenceSystem crs() const { return mCrs; }
65
71 QgsCoordinateTransformContext transformContext() const { return mTransformContext; }
72
78 QgsRectangle extent() const { return mExtent; }
79
83 QgsVector3D origin() const { return mOrigin; }
84
88 const QgsDateTimeRange &temporalRange() const { return mTemporalRange; }
89
93 QColor selectionColor() const { return mSelectionColor; }
94
99 double outputDpi() const { return mDpi; }
100
104 float fieldOfView() const { return mFieldOfView; }
105
111 QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
112
118 QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords ) const;
119
123 bool terrainRenderingEnabled() const { return mTerrainRenderingEnabled; }
124
128 const QgsAbstractTerrainSettings *terrainSettings() const;
129
133 QgsTerrainGenerator *terrainGenerator() const { return mTerrainGenerator; }
134
140 void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }
141
147 QgsExpressionContext &expressionContext() { return mExpressionContext; }
148
155 const QgsExpressionContext &expressionContext() const SIP_SKIP { return mExpressionContext; }
156
157 private:
160 QgsCoordinateTransformContext mTransformContext;
162 QgsVector3D mOrigin;
163 QgsRectangle mExtent;
164 QgsDateTimeRange mTemporalRange;
165 QColor mSelectionColor;
166 double mDpi = 96;
167 float mFieldOfView = 45.0f;
168 bool mTerrainRenderingEnabled = true;
169 std::unique_ptr<QgsAbstractTerrainSettings> mTerrainSettings;
171 QgsExpressionContext mExpressionContext;
172
173 // not owned, currently a pointer to the Qgs3DMapSettings terrain generator.
174 // TODO -- fix during implementation of https://github.com/qgis/QGIS-Enhancement-Proposals/issues/301
175 QPointer<QgsTerrainGenerator> mTerrainGenerator;
176};
177
178
179#endif // QGS3DRENDERCONTEXT_H
Definition of the world.
const QgsDateTimeRange & temporalRange() const
Returns the temporal range for the map.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system used in the 3D scene.
const QgsExpressionContext & expressionContext() const
Gets the expression context (const version).
QColor selectionColor() const
Returns color used for selected features.
QgsExpressionContext & expressionContext()
Gets the expression context.
float fieldOfView() const
Returns the camera lens' field of view.
static Qgs3DRenderContext fromMapSettings(const Qgs3DMapSettings *mapSettings)
Creates an initialized Qgs3DRenderContext instance from given Qgs3DMapSettings.
Qgs3DRenderContext()=default
QgsTerrainGenerator * terrainGenerator() const
Returns the terrain generator.
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0).
QgsRectangle extent() const
Returns the 3D scene's 2D extent in the 3D scene's CRS.
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
Qgs3DRenderContext & operator=(const Qgs3DRenderContext &other)
bool terrainRenderingEnabled() const
Returns whether the 2D terrain surface will be rendered.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Base class for all terrain settings classes.
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...
A rectangle specified with double values.
Base class for generators of terrain.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33
#define SIP_SKIP
Definition qgis_sip.h:133
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:764