QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
18 #include <Qt3DRender/QGeometryRenderer>
19 #include <Qt3DCore/QTransform>
31 FlatTerrainChunkLoader::FlatTerrainChunkLoader( QgsTerrainEntity *terrain, QgsChunkNode *node )
32 : QgsTerrainTileLoader( terrain, node )
38 Qt3DCore::QEntity *FlatTerrainChunkLoader::createEntity( Qt3DCore::QEntity *parent )
40 QgsTerrainTileEntity *entity =
new QgsTerrainTileEntity( mNode->tileId() );
47 mTileGeometry =
new Qt3DExtras::QPlaneGeometry;
49 Qt3DRender::QGeometryRenderer *mesh =
new Qt3DRender::QGeometryRenderer;
50 mesh->setGeometry( mTileGeometry );
51 entity->addComponent( mesh );
60 Qt3DCore::QTransform *transform =
nullptr;
61 transform =
new Qt3DCore::QTransform();
62 entity->addComponent( transform );
65 const QgsAABB bbox = mNode->bbox();
66 const double side = bbox.
xMax - bbox.
xMin;
67 const double half = side / 2;
69 transform->setScale( side );
70 transform->setTranslation( QVector3D( bbox.
xMin + half, 0, bbox.
zMin + half ) );
72 entity->setEnabled(
false );
73 entity->setParent( parent );
83 return new FlatTerrainChunkLoader(
mTerrain, node );
90 cloned->mExtent = mExtent;
91 cloned->updateTilingScheme();
114 QDomElement elemExtent = elem.ownerDocument().createElement( QStringLiteral(
"extent" ) );
115 elemExtent.setAttribute( QStringLiteral(
"xmin" ), QString::number( r.
xMinimum() ) );
116 elemExtent.setAttribute( QStringLiteral(
"xmax" ), QString::number( r.
xMaximum() ) );
117 elemExtent.setAttribute( QStringLiteral(
"ymin" ), QString::number( r.
yMinimum() ) );
118 elemExtent.setAttribute( QStringLiteral(
"ymax" ), QString::number( r.
yMaximum() ) );
119 elem.appendChild( elemExtent );
126 const QDomElement elemExtent = elem.firstChildElement( QStringLiteral(
"extent" ) );
127 const double xmin = elemExtent.attribute( QStringLiteral(
"xmin" ) ).toDouble();
128 const double xmax = elemExtent.attribute( QStringLiteral(
"xmax" ) ).toDouble();
129 const double ymin = elemExtent.attribute( QStringLiteral(
"ymin" ) ).toDouble();
130 const double ymax = elemExtent.attribute( QStringLiteral(
"ymax" ) ).toDouble();
140 updateTilingScheme();
149 updateTilingScheme();
154 void QgsFlatTerrainGenerator::updateTilingScheme()
QgsFlatTerrainGenerator()=default
Creates flat terrain generator object.
QgsPhongMaterialSettings terrainShadingMaterial() const
Returns terrain shading material.
void setExtent(const QgsRectangle &extent) override
sets the extent of the terrain in terrain's CRS
void extentChanged()
Emitted when the terrain extent has changed.
const QgsCoordinateReferenceSystem & crs
QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
void rootChunkHeightRange(float &hMin, float &hMax) const override
Returns height range of the root chunk in world coordinates.
A rectangle specified with double values.
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
QgsTerrainEntity * mTerrain
QgsTilingScheme mTerrainTilingScheme
Tiling scheme of the terrain.
void readXml(const QDomElement &elem) override
Read terrain generator's configuration from XML.
Base class for generators of terrain.
QgsTerrainGenerator * clone() const override SIP_FACTORY
Makes a copy of the current instance.
@ Flat
The whole terrain is flat area.
Axis-aligned bounding box - in world coords.
Type
Enumeration of the available terrain generators.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
Terrain generator that creates a simple square flat area.
QgsRectangle tileToExtent(int x, int y, int z) const
Returns map coordinates of the extent of a tile.
This class represents a coordinate reference system (CRS).
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override SIP_FACTORY
Type type() const override
What texture generator implementation is this.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
QList< QgsMapLayer * > layers() const
Returns the list of 3D map layers to be rendered in the scene.
The class encapsulates tiling scheme (just like with WMTS / TMS / XYZ layers).
QgsRectangle extent() const override
extent of the terrain in terrain's CRS
void writeXml(QDomElement &elem) const override
Write terrain generator's configuration to XML.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
bool isTerrainShadingEnabled() const
Returns whether terrain shading is enabled.