QGIS API Documentation 3.41.0-Master (af5edcb665c)
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"
27
28#include <QColor>
29
32
33#define SIP_NO_FILE
34
47class _3D_EXPORT Qgs3DRenderContext
48{
49 public:
50 Qgs3DRenderContext() = default;
53 Qgs3DRenderContext &operator=( const Qgs3DRenderContext &other );
54
58 static Qgs3DRenderContext fromMapSettings( const Qgs3DMapSettings *mapSettings );
59
63 QgsCoordinateReferenceSystem crs() const { return mCrs; }
64
70 QgsCoordinateTransformContext transformContext() const { return mTransformContext; }
71
77 QgsRectangle extent() const { return mExtent; }
78
82 QgsVector3D origin() const { return mOrigin; }
83
87 const QgsDateTimeRange &temporalRange() const { return mTemporalRange; }
88
92 QColor selectionColor() const { return mSelectionColor; }
93
98 double outputDpi() const { return mDpi; }
99
103 float fieldOfView() const { return mFieldOfView; }
104
110 QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
111
117 QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords ) const;
118
122 bool terrainRenderingEnabled() const { return mTerrainRenderingEnabled; }
123
127 const QgsAbstractTerrainSettings *terrainSettings() const;
128
132 QgsTerrainGenerator *terrainGenerator() const { return mTerrainGenerator; }
133
139 void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }
140
146 QgsExpressionContext &expressionContext() { return mExpressionContext; }
147
154 const QgsExpressionContext &expressionContext() const SIP_SKIP { return mExpressionContext; }
155
156 private:
159 QgsCoordinateTransformContext mTransformContext;
161 QgsVector3D mOrigin;
162 QgsRectangle mExtent;
163 QgsDateTimeRange mTemporalRange;
164 QColor mSelectionColor;
165 double mDpi = 96;
166 float mFieldOfView = 45.0f;
167 bool mTerrainRenderingEnabled = true;
168 std::unique_ptr<QgsAbstractTerrainSettings> mTerrainSettings;
170 QgsExpressionContext mExpressionContext;
171
172 // not owned, currently a pointer to the Qgs3DMapSettings terrain generator.
173 // TODO -- fix during implementation of https://github.com/qgis/QGIS-Enhancement-Proposals/issues/301
174 QgsTerrainGenerator *mTerrainGenerator = nullptr;
175};
176
177
178#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...
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