QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 "qgis_3d.h"
20#include "qgis_sip.h"
21#include <QString>
22#include <memory>
23
24class QDomElement;
26class QgsProject;
29
43{
44#ifdef SIP_RUN
46 if ( sipCpp->type() == "flat" )
47 sipType = sipType_QgsFlatTerrainSettings;
48 else if ( sipCpp->type() == "dem" )
49 sipType = sipType_QgsDemTerrainSettings;
50 else if ( sipCpp->type() == "online" )
51 sipType = sipType_QgsOnlineDemTerrainSettings;
52 else if ( sipCpp->type() == "mesh" )
53 sipType = sipType_QgsMeshTerrainSettings;
54 else if ( sipCpp->type() == "quantizedmesh" )
55 sipType = sipType_QgsQuantizedMeshTerrainSettings;
56 else
57 sipType = 0;
59#endif
60
61 public:
63
68
72 virtual QString type() const = 0;
73
77 virtual bool equals( const QgsAbstractTerrainSettings *other ) const = 0;
78
87 virtual void readXml( const QDomElement &element, const QgsReadWriteContext &context ) = 0;
88
96 virtual void writeXml( QDomElement &element, const QgsReadWriteContext &context ) const = 0;
97
103 virtual void resolveReferences( const QgsProject *project );
104
110 virtual std::unique_ptr<QgsTerrainGenerator> createTerrainGenerator( const Qgs3DRenderContext &context ) const = 0 SIP_SKIP;
111
112 // common settings
113
121 void setVerticalScale( double scale ) { mTerrainVerticalScale = scale; }
122
130 double verticalScale() const { return mTerrainVerticalScale; }
131
136 void setMapTileResolution( int resolution ) { mMapTileResolution = resolution; }
137
145 int mapTileResolution() const { return mMapTileResolution; }
146
152 void setMaximumScreenError( double error ) { mMaxTerrainScreenError = error; }
153
164 double maximumScreenError() const { return mMaxTerrainScreenError; }
165
171 void setMaximumGroundError( double error ) { mMaxTerrainGroundError = error; }
172
182 double maximumGroundError() const { return mMaxTerrainGroundError; }
183
189 void setElevationOffset( double offset ) { mTerrainElevationOffset = offset; }
190
196 double elevationOffset() const { return mTerrainElevationOffset; }
197
198 protected:
204 void writeCommonProperties( QDomElement &element, const QgsReadWriteContext &context ) const;
205
211 void readCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
212
216 void copyCommonProperties( const QgsAbstractTerrainSettings *source );
217
221 bool equalsCommon( const QgsAbstractTerrainSettings *other ) const;
222
223 private:
224 double mTerrainVerticalScale = 1;
225 int mMapTileResolution = 512;
226 double mMaxTerrainScreenError = 3.0;
227 double mMaxTerrainGroundError = 1.0;
228 double mTerrainElevationOffset = 0.0;
229};
230
231
232#endif // QGSABSTRACTTERRAINSETTINGS_H
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.
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:107
The class is used as a container of context for various read/write operations on other objects.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_ABSTRACT
Definition qgis_sip.h:213
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208