QGIS API Documentation 3.41.0-Master (3440c17df1d)
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"
20#include "qgsvector3d.h"
21#include "qgsrectangle.h"
22#include "qgsrange.h"
26
27#include <QColor>
28
31
32#define SIP_NO_FILE
33
46class _3D_EXPORT Qgs3DRenderContext
47{
48
49 public:
50
51 Qgs3DRenderContext() = default;
52
56 static Qgs3DRenderContext fromMapSettings( const Qgs3DMapSettings *mapSettings );
57
61 QgsCoordinateReferenceSystem crs() const { return mCrs; }
62
68 QgsCoordinateTransformContext transformContext() const { return mTransformContext; }
69
75 QgsRectangle extent() const { return mExtent; }
76
80 QgsVector3D origin() const { return mOrigin; }
81
85 const QgsDateTimeRange &temporalRange() const { return mTemporalRange; }
86
90 QColor selectionColor() const { return mSelectionColor; }
91
96 double outputDpi() const { return mDpi; }
97
101 float fieldOfView() const { return mFieldOfView; }
102
108 QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
109
115 QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords ) const;
116
120 bool terrainRenderingEnabled() const { return mTerrainRenderingEnabled; }
121
125 double terrainVerticalScale() const { return mTerrainVerticalScale; }
126
130 QgsTerrainGenerator *terrainGenerator() const { return mTerrainGenerator; }
131
137 void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }
138
144 QgsExpressionContext &expressionContext() { return mExpressionContext; }
145
152 const QgsExpressionContext &expressionContext() const { return mExpressionContext; } SIP_SKIP
153
154 private:
157 QgsCoordinateTransformContext mTransformContext;
159 QgsVector3D mOrigin;
160 QgsRectangle mExtent;
161 QgsDateTimeRange mTemporalRange;
162 QColor mSelectionColor;
163 double mDpi = 96;
164 float mFieldOfView = 45.0f;
165 bool mTerrainRenderingEnabled = true;
166 double mTerrainVerticalScale = 1;
167
169 QgsExpressionContext mExpressionContext;
170
171 // not owned, currently a pointer to the Qgs3DMapSettings terrain generator.
172 // TODO -- fix during implementation of https://github.com/qgis/QGIS-Enhancement-Proposals/issues/301
173 QgsTerrainGenerator *mTerrainGenerator = nullptr;
174};
175
176
177#endif // QGS3DRENDERCONTEXT_H
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.
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.
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...
double terrainVerticalScale() const
Returns vertical scale (exaggeration) of terrain.
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...
A rectangle specified with double values.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
#define SIP_SKIP
Definition qgis_sip.h:126