QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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,
72 qgis::down_cast< const QgsTiledSceneLayerElevationProperties * >( tsl->elevationProperties() )->zScale(),
73 qgis::down_cast< const QgsTiledSceneLayerElevationProperties * >( tsl->elevationProperties() )->zOffset() );
74}
75
76void QgsTiledSceneLayer3DRenderer::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
77{
78 Q_UNUSED( context )
79
80 QDomDocument doc = elem.ownerDocument();
81
82 elem.setAttribute( QStringLiteral( "layer" ), mLayerRef.layerId );
83 elem.setAttribute( QStringLiteral( "max-screen-error" ), maximumScreenError() );
84 elem.setAttribute( QStringLiteral( "show-bounding-boxes" ), showBoundingBoxes() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
85}
86
87void QgsTiledSceneLayer3DRenderer::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
88{
89 Q_UNUSED( context )
90
91 mLayerRef = QgsMapLayerRef( elem.attribute( QStringLiteral( "layer" ) ) );
92
93 mShowBoundingBoxes = elem.attribute( QStringLiteral( "show-bounding-boxes" ), QStringLiteral( "0" ) ).toInt();
94 mMaximumScreenError = elem.attribute( QStringLiteral( "max-screen-error" ), QStringLiteral( "16.0" ) ).toDouble();
95}
96
98{
99 mLayerRef.setLayer( project.mapLayer( mLayerRef.layerId ) );
100}
101
103{
104 return mMaximumScreenError;
105}
106
108{
109 mMaximumScreenError = error;
110}
111
113{
114 return mShowBoundingBoxes;
115}
116
118{
119 mShowBoundingBoxes = showBoundingBoxes;
120}
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 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 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.
virtual Qt3DCore::QEntity * createEntity(const Qgs3DMapSettings &map) const override
Returns a 3D entity that will be used to show renderer's data in 3D scene.
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.