QGIS API Documentation  3.6.0-Noosa (5873452)
qgsdemterraingenerator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdemterraingenerator.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 QGSDEMTERRAINGENERATOR_H
17 #define QGSDEMTERRAINGENERATOR_H
18 
19 #include "qgis_3d.h"
20 
21 #include "qgsterraingenerator.h"
22 
23 
24 #include <memory>
25 
26 class QgsRasterLayer;
27 class QgsDemHeightMapGenerator;
28 
29 #include "qgsmaplayerref.h"
30 
37 {
38  public:
40  QgsDemTerrainGenerator() = default;
41  ~QgsDemTerrainGenerator() override;
42 
44  void setLayer( QgsRasterLayer *layer );
46  QgsRasterLayer *layer() const;
47 
49  void setCrs( const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context );
50 
52  void setResolution( int resolution ) { mResolution = resolution; updateGenerator(); }
54  int resolution() const { return mResolution; }
55 
57  void setSkirtHeight( float skirtHeight ) { mSkirtHeight = skirtHeight; }
59  float skirtHeight() const { return mSkirtHeight; }
60 
62  QgsDemHeightMapGenerator *heightMapGenerator() { return mHeightMapGenerator; }
63 
64  QgsTerrainGenerator *clone() const override SIP_FACTORY;
65  Type type() const override;
66  QgsRectangle extent() const override;
67  float heightAt( double x, double y, const Qgs3DMapSettings &map ) const override;
68  void writeXml( QDomElement &elem ) const override;
69  void readXml( const QDomElement &elem ) override;
70  void resolveReferences( const QgsProject &project ) override;
71 
72  QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override SIP_FACTORY;
73 
74  private:
75  void updateGenerator();
76 
77  QgsDemHeightMapGenerator *mHeightMapGenerator = nullptr;
78 
80 
81  QgsCoordinateTransformContext mTransformContext;
82 
84  QgsMapLayerRef mLayer;
86  int mResolution = 16;
88  float mSkirtHeight = 10.f;
89 };
90 
91 
92 #endif // QGSDEMTERRAINGENERATOR_H
virtual void resolveReferences(const QgsProject &project)
After read of XML, resolve references to any layers that have been read as layer IDs.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
virtual float heightAt(double x, double y, const Qgs3DMapSettings &map) const
Returns height at (x,y) in terrain&#39;s CRS.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
virtual Type type() const =0
What texture generator implementation is this.
int resolution() const
Returns resolution of the generator (how many elevation samples on one side of a terrain tile) ...
const QgsCoordinateReferenceSystem & crs
3 Definition of the world
virtual void readXml(const QDomElement &elem)=0
Read terrain generator&#39;s configuration from XML.
virtual QgsTerrainGenerator * clone() const =0SIP_FACTORY
Makes a copy of the current instance.
void setSkirtHeight(float skirtHeight)
Sets skirt height (in world units). Skirts at the edges of terrain tiles help hide cracks between adj...
float skirtHeight() const
Returns skirt height (in world units). Skirts at the edges of terrain tiles help hide cracks between ...
Reads and writes project states.
Definition: qgsproject.h:89
#define SIP_FACTORY
Definition: qgis_sip.h:69
Contains information about the context in which a coordinate transform is executed.
Type
Enumeration of the available terrain generators.
3 Base class for generators of terrain.
QgsDemHeightMapGenerator * heightMapGenerator()
Returns height map generator object - takes care of extraction of elevations from the layer) ...
3 Implementation of terrain generator that uses a raster layer with DEM to build terrain.
virtual void writeXml(QDomElement &elem) const =0
Write terrain generator&#39;s configuration to XML.
This class represents a coordinate reference system (CRS).
virtual QgsRectangle extent() const =0
extent of the terrain in terrain&#39;s CRS
void setResolution(int resolution)
Sets resolution of the generator (how many elevation samples on one side of a terrain tile) ...