QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgstiledscenerendererregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledscenerendererregistry.cpp
3 ---------------------
4 begin : August 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson 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 ***************************************************************************/
17
18// default renderers
21
23{
24 // add default renderers
25 addRenderer( new QgsTiledSceneRendererMetadata( QStringLiteral( "texture" ),
26 QObject::tr( "Textured" ),
28 addRenderer( new QgsTiledSceneRendererMetadata( QStringLiteral( "wireframe" ),
29 QObject::tr( "Wireframe" ),
31}
32
37
39{
40 if ( !metadata || mRenderers.contains( metadata->name() ) )
41 return false;
42
43 mRenderers[metadata->name()] = metadata;
44 mRenderersOrder << metadata->name();
45 return true;
46}
47
48bool QgsTiledSceneRendererRegistry::removeRenderer( const QString &rendererName )
49{
50 if ( !mRenderers.contains( rendererName ) )
51 return false;
52
53 delete mRenderers[rendererName];
54 mRenderers.remove( rendererName );
55 mRenderersOrder.removeAll( rendererName );
56 return true;
57}
58
60{
61 return mRenderers.value( rendererName );
62}
63
65{
66 QStringList renderers;
67 for ( const QString &renderer : mRenderersOrder )
68 {
69 QgsTiledSceneRendererAbstractMetadata *r = mRenderers.value( renderer );
70 if ( r )
71 renderers << renderer;
72 }
73 return renderers;
74}
75
80
Represents a map layer supporting display of tiled scene objects.
Stores metadata about one tiled scene renderer class.
QString name() const
Returns the unique name of the renderer.
Convenience metadata class that uses static functions to create tiled scene renderer and its widget.
QgsTiledSceneRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
bool removeRenderer(const QString &rendererName)
Removes a renderer from registry.
static QgsTiledSceneRenderer * defaultRenderer(const QgsTiledSceneLayer *layer)
Returns a new default tiled scene renderer for a specified layer.
QStringList renderersList() const
Returns a list of available renderers.
bool addRenderer(QgsTiledSceneRendererAbstractMetadata *metadata)
Adds a renderer to the registry.
Abstract base class for 2d tiled scene renderers.
Renders tiled scene layers using textures.
static QgsTiledSceneRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates a textured renderer from an XML element.
static QgsTiledSceneRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates a textured renderer from an XML element.