QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgs3drendercontext.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgs3drendercontext.cpp
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#include "qgs3drendercontext.h"
17#include "qgs3dutils.h"
18#include "qgsthreadingutils.h"
20
22 : mCrs( other.mCrs )
23 , mTransformContext( other.mTransformContext )
24 , mOrigin( other.mOrigin )
25 , mExtent( other.mExtent )
26 , mTemporalRange( other.mTemporalRange )
27 , mSelectionColor( other.mSelectionColor )
28 , mDpi( other.mDpi )
29 , mFieldOfView( other.mFieldOfView )
30 , mTerrainRenderingEnabled( other.mTerrainRenderingEnabled )
31 , mTerrainSettings( std::unique_ptr<QgsAbstractTerrainSettings>( other.mTerrainSettings->clone() ) )
32 , mExpressionContext( other.mExpressionContext )
33 , mTerrainGenerator( other.mTerrainGenerator )
34{
35}
36
38
40{
41 if ( &other == this )
42 return *this;
43
44 mCrs = other.mCrs;
45 mTransformContext = other.mTransformContext;
46 mOrigin = other.mOrigin;
47 mExtent = other.mExtent;
48 mTemporalRange = other.mTemporalRange;
49 mSelectionColor = other.mSelectionColor;
50 mDpi = other.mDpi;
51 mFieldOfView = other.mFieldOfView;
52 mTerrainRenderingEnabled = other.mTerrainRenderingEnabled;
53 mTerrainSettings.reset( other.mTerrainSettings->clone() );
54 mExpressionContext = other.mExpressionContext;
55 mTerrainGenerator = other.mTerrainGenerator;
56 return *this;
57}
58
60{
62
64 res.mCrs = mapSettings->crs();
65 res.mTransformContext = mapSettings->transformContext();
66 res.mOrigin = mapSettings->origin();
67 res.mExtent = mapSettings->extent();
68 res.mTemporalRange = mapSettings->temporalRange();
69 res.mSelectionColor = mapSettings->selectionColor();
70 res.mDpi = mapSettings->outputDpi();
71 res.mFieldOfView = mapSettings->fieldOfView();
72 res.mTerrainRenderingEnabled = mapSettings->terrainRenderingEnabled();
73 res.mTerrainSettings = std::unique_ptr<QgsAbstractTerrainSettings>( mapSettings->terrainSettings()->clone() );
74 res.mTerrainGenerator = mapSettings->terrainGenerator();
75 return res;
76}
77
79{
80 return Qgs3DUtils::mapToWorldCoordinates( mapCoords, mOrigin );
81}
82
84{
85 return Qgs3DUtils::worldToMapCoordinates( worldCoords, mOrigin );
86}
87
89{
90 return mTerrainSettings.get();
91}
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
QColor selectionColor() const
Returns color used for selected features.
const QgsAbstractTerrainSettings * terrainSettings() const
Returns the terrain settings.
float fieldOfView() const
Returns the camera lens' field of view.
QgsRectangle extent() const
Returns the 3D scene's 2D extent in the 3D scene's CRS.
QgsTerrainGenerator * terrainGenerator() const
Returns the terrain generator.
bool terrainRenderingEnabled() const
Returns whether the 2D terrain surface will be rendered.
QgsCoordinateReferenceSystem crs() const
Returns coordinate reference system used in the 3D scene.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0).
const QgsAbstractTerrainSettings * terrainSettings() const
Returns the terrain settings.
static Qgs3DRenderContext fromMapSettings(const Qgs3DMapSettings *mapSettings)
Creates an initialized Qgs3DRenderContext instance from given Qgs3DMapSettings.
Qgs3DRenderContext()=default
QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords) const
Converts map coordinates to 3D world coordinates (applies offset and turns (x,y,z) into (x,...
QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords) const
Converts 3D world coordinates to map coordinates (applies offset and turns (x,y,z) into (x,...
Qgs3DRenderContext & operator=(const Qgs3DRenderContext &other)
static QgsVector3D worldToMapCoordinates(const QgsVector3D &worldCoords, const QgsVector3D &origin)
Converts 3D world coordinates to map coordinates (applies offset)
static QgsVector3D mapToWorldCoordinates(const QgsVector3D &mapCoords, const QgsVector3D &origin)
Converts map coordinates to 3D world coordinates (applies offset)
virtual QgsAbstractTerrainSettings * clone() const =0
Returns a copy of the terrain settings.
const QgsDateTimeRange & temporalRange() const
Returns the datetime range for the object.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
#define QGIS_CHECK_OTHER_QOBJECT_THREAD_ACCESS(other)