QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgsabstractterrainsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsabstractterrainsettings.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 QGSABSTRACTTERRAINSETTINGS_H
17#define QGSABSTRACTTERRAINSETTINGS_H
18
19#include <memory>
20
21#include "qgis_3d.h"
22#include "qgis_sip.h"
23
24#include <QString>
25
26class QDomElement;
28class QgsProject;
31
45{
46#ifdef SIP_RUN
48 if ( sipCpp->type() == "flat" )
49 sipType = sipType_QgsFlatTerrainSettings;
50 else if ( sipCpp->type() == "dem" )
51 sipType = sipType_QgsDemTerrainSettings;
52 else if ( sipCpp->type() == "online" )
53 sipType = sipType_QgsOnlineDemTerrainSettings;
54 else if ( sipCpp->type() == "mesh" )
55 sipType = sipType_QgsMeshTerrainSettings;
56 else if ( sipCpp->type() == "quantizedmesh" )
57 sipType = sipType_QgsQuantizedMeshTerrainSettings;
58 else
59 sipType = 0;
61#endif
62
63 public:
65
70
74 virtual QString type() const = 0;
75
79 virtual bool equals( const QgsAbstractTerrainSettings *other ) const = 0;
80
89 virtual void readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
90
98 virtual void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const = 0;
99
105 virtual void resolveReferences( const QgsProject *project );
106
112 virtual std::unique_ptr<QgsTerrainGenerator> createTerrainGenerator( const Qgs3DRenderContext &context ) const = 0 SIP_SKIP;
113
114 // common settings
115
123 void setVerticalScale( double scale ) { mTerrainVerticalScale = scale; }
124
132 double verticalScale() const { return mTerrainVerticalScale; }
133
138 void setMapTileResolution( int resolution ) { mMapTileResolution = resolution; }
139
147 int mapTileResolution() const { return mMapTileResolution; }
148
154 void setMaximumScreenError( double error ) { mMaxTerrainScreenError = error; }
155
166 double maximumScreenError() const { return mMaxTerrainScreenError; }
167
173 void setMaximumGroundError( double error ) { mMaxTerrainGroundError = error; }
174
184 double maximumGroundError() const { return mMaxTerrainGroundError; }
185
191 void setElevationOffset( double offset ) { mTerrainElevationOffset = offset; }
192
198 double elevationOffset() const { return mTerrainElevationOffset; }
199
200 protected:
201
207 void writeCommonProperties( QDomElement &element, const QgsReadWriteContext &context ) const;
208
214 void readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
215
219 void copyCommonProperties( const QgsAbstractTerrainSettings *source );
220
224 bool equalsCommon( const QgsAbstractTerrainSettings *other ) const;
225
226 private:
227 double mTerrainVerticalScale = 1;
228 int mMapTileResolution = 512;
229 double mMaxTerrainScreenError = 3.0;
230 double mMaxTerrainGroundError = 1.0;
231 double mTerrainElevationOffset = 0.0;
232};
233
234
235#endif // QGSABSTRACTTERRAINSETTINGS_H
Rendering context for preparation of 3D entities.
Base class for all terrain settings classes.
double maximumGroundError() const
Returns the maximum ground error of terrain tiles in world units.
int mapTileResolution() const
Returns the resolution (in pixels) of the texture of a terrain tile.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &context)=0
Reads settings from a DOM element.
double elevationOffset() const
Returns the elevation offset of the terrain (used to move the terrain up or down).
double verticalScale() const
Returns the vertical scale (exaggeration) for terrain.
void setMaximumGroundError(double error)
Sets the maximum ground error of terrain tiles in world units.
void setMapTileResolution(int resolution)
Sets the resolution (in pixels) of the texture of a terrain tile.
virtual void resolveReferences(const QgsProject *project)
After reading settings from XML, resolves references to any layers in a project that have been read a...
double maximumScreenError() const
Returns the maximum allowed screen error of terrain tiles in pixels.
virtual std::unique_ptr< QgsTerrainGenerator > createTerrainGenerator(const Qgs3DRenderContext &context) const =0
Creates a new instance of a terrain generator which matches the terrain settings.
void setElevationOffset(double offset)
Sets the terrain elevation offset (used to move the terrain up or down).
virtual ~QgsAbstractTerrainSettings()
void setVerticalScale(double scale)
Sets the vertical scale (exaggeration) for terrain.
virtual QgsAbstractTerrainSettings * clone() const =0
Returns a copy of the terrain settings.
virtual bool equals(const QgsAbstractTerrainSettings *other) const =0
Returns true if this settings is exactly equal to another other settings.
void setMaximumScreenError(double error)
Sets the maximum allowed screen error of terrain tiles in pixels.
virtual QString type() const =0
Returns the unique type name for the terrain generator.
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &context) const =0
Writes settings to a DOM element.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
A container for the context for various read/write operations on objects.
Base class for generators of terrain.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_ABSTRACT
Definition qgis_sip.h:221
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216