QGIS API Documentation 4.3.0-Master (52aa6503bed)
Loading...
Searching...
No Matches
qgsterraingenerator.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsterraingenerator.h
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk 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 QGSTERRAINGENERATOR_H
17#define QGSTERRAINGENERATOR_H
18
19#include "qgis_3d.h"
20#include "qgschunkloader.h"
23#include "qgstilingscheme.h"
24
25#include <QTexture>
26
27#define SIP_NO_FILE
28
31class QgsAABB;
33class QgsRectangle;
34class QgsTerrainEntity;
35class QgsTerrainTextureGenerator;
36class QgsTerrainTileEntity;
37
38class QDomElement;
39class QDomDocument;
40class QgsProject;
41
42
55class _3D_EXPORT QgsTerrainGenerator : public QgsQuadtreeChunkLoader
56{
57 Q_OBJECT
58 public:
68
74 enum class Capability : int
75 {
76 NoCapabilities = 1 << 0,
77 SupportsTileResolution = 1 << 1,
78 };
79
80 Q_ENUM( Capability )
81 Q_DECLARE_FLAGS( Capabilities, Capability )
82 Q_FLAG( Capabilities )
83
87
94
96 virtual void setTerrain( QgsTerrainEntity *t ) { mTerrain = t; }
97
100
102 virtual Type type() const = 0;
103
105 virtual void setExtent( const QgsRectangle &extent ) { Q_UNUSED( extent ) }
106
108 virtual QgsRectangle rootChunkExtent() const = 0;
109
111 virtual QgsBox3D rootChunkBox3D( const Qgs3DMapSettings &map ) const;
112
114 virtual float rootChunkError( const Qgs3DMapSettings &map ) const;
115
117 virtual void rootChunkHeightRange( float &hMin, float &hMax ) const;
118
120 virtual float heightAt( double x, double y, const Qgs3DRenderContext &context ) const = 0;
121
123 static QString typeToString( Type type );
124
127
133 virtual void setCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context );
134
136 virtual QgsCoordinateReferenceSystem crs() const { return mTerrainTilingScheme.crs(); }
137
139 bool isValid() const;
140
141 QFuture<QgsChunkLoaderResult> updateChunk( QgsChunkNode *node ) override;
142
143 signals:
144
147
148 protected:
156
158 QFuture<TerrainTextureResources> loadTextureResources( QgsChunkNode *node );
160 Qt3DRender::QTexture2D *applyTexture( QgsTerrainTileEntity *entity, const QgsMaterialContext &context, const TerrainTextureResources &resources ) const;
162 void applyMaterial(
163 const TerrainTextureResources &resources, QgsTerrainTileEntity *entity, bool isShadingEnabled, const QgsPhongMaterialSettings &shadingMaterial, bool useTexture, const Qgs3DRenderContext &context
164 );
165
167 QgsTerrainEntity *mTerrain = nullptr;
169
170 bool mIsValid = true;
171};
172
173
174#endif // QGSTERRAINGENERATOR_H
Definition of the world.
Rendering context for preparation of 3D entities.
Axis-aligned bounding box - in world coords.
Definition qgsaabb.h:33
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:45
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Context settings for a material.
Basic shading material used for rendering based on the Phong shading model with three color component...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:114
A rectangle specified with double values.
Type
Enumeration of the available terrain generators.
@ QuantizedMesh
Terrain is built from quantized mesh tiles.
@ Dem
Terrain is built from raster layer with digital elevation model.
@ Online
Terrain is built from downloaded tiles with digital elevation model.
@ Mesh
Terrain is built from mesh layer with z value on vertices.
@ Flat
The whole terrain is flat area.
QgsTilingScheme mTerrainTilingScheme
Tiling scheme of the terrain.
QgsTerrainGenerator()
Create new terrain generator.
void terrainChanged()
Emitted when the terrain changed (for example, raster DEM or mesh have data changed).
virtual Type type() const =0
What texture generator implementation is this.
virtual QgsBox3D rootChunkBox3D(const Qgs3DMapSettings &map) const
Returns 3D box (in map coordinates) of the root chunk.
virtual float rootChunkError(const Qgs3DMapSettings &map) const
Returns error of the root chunk in world coordinates.
virtual float heightAt(double x, double y, const Qgs3DRenderContext &context) const =0
Returns height at (x,y) in map's CRS.
virtual void setExtent(const QgsRectangle &extent)
sets the extent of the terrain in terrain's CRS
void applyMaterial(const TerrainTextureResources &resources, QgsTerrainTileEntity *entity, bool isShadingEnabled, const QgsPhongMaterialSettings &shadingMaterial, bool useTexture, const Qgs3DRenderContext &context)
Creates material component for the entity with the rendered map as a texture.
static QString typeToString(Type type)
Converts terrain generator type enumeration into a string.
virtual QgsRectangle rootChunkExtent() const =0
extent of the terrain's root chunk in terrain's CRS
QgsTerrainEntity * mTerrain
QFuture< TerrainTextureResources > loadTextureResources(QgsChunkNode *node)
Asynchronously loads resources for creating texture.
virtual void rootChunkHeightRange(float &hMin, float &hMax) const
Returns height range of the root chunk in world coordinates.
QFlags< Capability > Capabilities
Qt3DRender::QTexture2D * applyTexture(QgsTerrainTileEntity *entity, const QgsMaterialContext &context, const TerrainTextureResources &resources) const
Creates a new texture that is linked to the entity.
Capability
Specific capabilities of the terrain generator.
virtual void setTerrain(QgsTerrainEntity *t)
Sets terrain entity for the generator (does not transfer ownership).
virtual QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
const QgsTilingScheme & tilingScheme() const
Returns tiling scheme of the terrain.
virtual QgsTerrainGenerator::Capabilities capabilities() const
Returns flags containing the supported capabilities.
virtual QgsTerrainGenerator * clone() const =0SIP_FACTORY
Makes a copy of the current instance.
Encapsulates tiling schemes (just like with WMTS / TMS / XYZ layers).
#define SIP_FACTORY
Definition qgis_sip.h:83