QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgstiledscenelayer3drenderer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledscenelayer3drenderer.cpp
3 --------------------------------------
4 Date : July 2023
5 Copyright : (C) 2023 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
17
18#include "qgstiledsceneindex.h"
19#include "qgstiledscenelayer.h"
22
23#include "qgs3dmapsettings.h"
24
25
30
37
39
43
48
50{
51 return qobject_cast<QgsTiledSceneLayer *>( mLayerRef.layer );
52}
53
60
62{
64 if ( !tsl || !tsl->dataProvider() )
65 return nullptr;
66
67 QgsTiledSceneIndex index = tsl->dataProvider()->index();
68
69 return new QgsTiledSceneLayerChunkedEntity( map, index, tsl->dataProvider()->sceneCrs(), maximumScreenError(), showBoundingBoxes(), qgis::down_cast<const QgsTiledSceneLayerElevationProperties *>( tsl->elevationProperties() )->zScale(), qgis::down_cast<const QgsTiledSceneLayerElevationProperties *>( tsl->elevationProperties() )->zOffset() );
70}
71
72void QgsTiledSceneLayer3DRenderer::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
73{
74 Q_UNUSED( context )
75
76 QDomDocument doc = elem.ownerDocument();
77
78 elem.setAttribute( QStringLiteral( "layer" ), mLayerRef.layerId );
79 elem.setAttribute( QStringLiteral( "max-screen-error" ), maximumScreenError() );
80 elem.setAttribute( QStringLiteral( "show-bounding-boxes" ), showBoundingBoxes() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
81}
82
83void QgsTiledSceneLayer3DRenderer::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
84{
85 Q_UNUSED( context )
86
87 mLayerRef = QgsMapLayerRef( elem.attribute( QStringLiteral( "layer" ) ) );
88
89 mShowBoundingBoxes = elem.attribute( QStringLiteral( "show-bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
90 mMaximumScreenError = elem.attribute( QStringLiteral( "max-screen-error" ), QStringLiteral( "16.0" ) ).toDouble();
91}
92
94{
95 mLayerRef.setLayer( project.mapLayer( mLayerRef.layerId ) );
96}
97
99{
100 return mMaximumScreenError;
101}
102
104{
105 mMaximumScreenError = error;
106}
107
109{
110 return mShowBoundingBoxes;
111}
112
114{
115 mShowBoundingBoxes = showBoundingBoxes;
116}
Base metadata class for 3D renderers.
Base class for all renderers that may to participate in 3D view.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
The class is used as a container of context for various read/write operations on other objects.
virtual const QgsCoordinateReferenceSystem sceneCrs() const =0
Returns the original coordinate reference system for the tiled scene data.
virtual QgsTiledSceneIndex index() const =0
Returns the provider's tile index.
An index for tiled scene data providers.
QgsAbstract3DRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context) override
Creates an instance of a 3D renderer based on a DOM element with renderer configuration.
QgsTiledSceneLayer * layer() const
Returns tiled scene layer associated with the renderer.
void setLayer(QgsTiledSceneLayer *layer)
Sets tiled scene layer associated with the renderer.
virtual void resolveReferences(const QgsProject &project) override
Resolves references to other objects - second phase of loading - after readXml()
virtual Qt3DCore::QEntity * createEntity(Qgs3DMapSettings *map) const override
Returns a 3D entity that will be used to show renderer's data in 3D scene.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads renderer's properties from given XML element.
bool showBoundingBoxes() const
Returns whether bounding boxes will be visible when rendering the tiled scene.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the tiled scene.
virtual QgsAbstract3DRenderer * clone() const override
Returns a cloned instance.
void setShowBoundingBoxes(bool showBoundingBoxes)
Sets whether bounding boxes will be visible when rendering the tiled scene.
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when rendering the tiled scene.
virtual void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes renderer's properties to given XML element.
Represents a map layer supporting display of tiled scene objects.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
QgsTiledSceneDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
_LayerRef< QgsMapLayer > QgsMapLayerRef
QPointer< TYPE > layer
Weak pointer to map layer.
void setLayer(TYPE *l)
Sets the reference to point to a specified layer.
QString layerId
Original layer ID.