QGIS API Documentation 4.3.0-Master (0cfde48c85b)
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
80 QgsRectangle extent() const { return mExtent; }
81
85 QgsVector3D origin() const { return mOrigin; }
86
90 const QgsDateTimeRange &temporalRange() const { return mTemporalRange; }
91
95 QColor selectionColor() const { return mSelectionColor; }
96
101 double outputDpi() const { return mDpi; }
102
106 float fieldOfView() const { return mFieldOfView; }
107
113 QgsVector3D mapToWorldCoordinates( const QgsVector3D &mapCoords ) const;
114
120 QgsVector3D worldToMapCoordinates( const QgsVector3D &worldCoords ) const;
121
125 bool terrainRenderingEnabled() const { return mTerrainRenderingEnabled; }
126
130 const QgsAbstractTerrainSettings *terrainSettings() const;
131
135 QgsTerrainGenerator *terrainGenerator() const { return mTerrainGenerator; }
136
142 void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }
143
149 QgsExpressionContext &expressionContext() { return mExpressionContext; }
150
157 const QgsExpressionContext &expressionContext() const SIP_SKIP { return mExpressionContext; }
158
165 Qgis::TextureFilterQuality textureFilterQuality() const { return mTextureFilterQuality; }
166
173 void setTextureFilterQuality( Qgis::TextureFilterQuality quality ) { mTextureFilterQuality = quality; }
174
175 private:
178 QgsCoordinateTransformContext mTransformContext;
180 QgsVector3D mOrigin;
181 QgsRectangle mExtent;
182 QgsDateTimeRange mTemporalRange;
183 QColor mSelectionColor;
184 double mDpi = 96;
185 float mFieldOfView = 45.0f;
186 bool mTerrainRenderingEnabled = true;
187 std::unique_ptr<QgsAbstractTerrainSettings> mTerrainSettings;
189 QgsExpressionContext mExpressionContext;
190
192
193 // not owned, currently a pointer to the Qgs3DMapSettings terrain generator.
194 // TODO -- fix during implementation of https://github.com/qgis/QGIS-Enhancement-Proposals/issues/301
195 QPointer<QgsTerrainGenerator> mTerrainGenerator;
196};
197
198
199#endif // QGS3DRENDERCONTEXT_H
TextureFilterQuality
Texture filtering qualities.
Definition qgis.h:4509
@ Trilinear
Trilinear (LinearMipmapLinear).
Definition qgis.h:4510
Definition of the world.
void setTextureFilterQuality(Qgis::TextureFilterQuality quality)
Sets the texture filtering quality.
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.
Qgis::TextureFilterQuality textureFilterQuality() const
Returns the texture filtering quality.
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:138
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:764