QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgstiledscenerendererregistry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledscenerendererregistry.h
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 ***************************************************************************/
15#ifndef QGSTILEDSCENERENDERERREGISTRY_H
16#define QGSTILEDSCENERENDERERREGISTRY_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
20#include <QIcon>
21#include <QMap>
22#include <QStringList>
23#include <QDomElement>
24
28class QgsStyle;
29#ifndef SIP_RUN
31#endif
32
33
44{
45 public:
46
54 QgsTiledSceneRendererAbstractMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon() )
55 : mName( name )
56 , mVisibleName( visibleName )
57 , mIcon( icon )
58 {}
60
65 QString name() const { return mName; }
66
71 QString visibleName() const { return mVisibleName; }
72
77 QIcon icon() const { return mIcon; }
78
83 void setIcon( const QIcon &icon ) { mIcon = icon; }
84
89 virtual QgsTiledSceneRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) = 0 SIP_FACTORY;
90
91#ifndef SIP_RUN
92
103 { Q_UNUSED( layer ) Q_UNUSED( style ); Q_UNUSED( oldRenderer ); return nullptr; }
104#endif
105
106 protected:
108 QString mName;
112 QIcon mIcon;
113};
114
115typedef QgsTiledSceneRenderer *( *QgsTiledSceneRendererCreateFunc )( QDomElement &, const QgsReadWriteContext & ) SIP_SKIP;
116typedef QgsTiledSceneRendererWidget *( *QgsTiledSceneRendererWidgetFunc )( QgsTiledSceneLayer *, QgsStyle *, QgsTiledSceneRenderer * ) SIP_SKIP;
117
124{
125 public:
126
131 QgsTiledSceneRendererMetadata( const QString &name,
132 const QString &visibleName,
134 const QIcon &icon = QIcon(),
135 QgsTiledSceneRendererWidgetFunc pfWidget = nullptr ) SIP_SKIP
136 : QgsTiledSceneRendererAbstractMetadata( name, visibleName, icon )
137 , mCreateFunc( pfCreate )
138 , mWidgetFunc( pfWidget )
139 {}
140
141 QgsTiledSceneRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY
142 { return mCreateFunc ? mCreateFunc( elem, context ) : nullptr; }
143
144#ifndef SIP_RUN
146 { return mWidgetFunc ? mWidgetFunc( layer, style, renderer ) : nullptr; }
147#endif
148
153
156
157 protected:
162
163 private:
164#ifdef SIP_RUN
166#endif
167
168};
169
170
182{
183 public:
184
187
190
197 bool addRenderer( QgsTiledSceneRendererAbstractMetadata *metadata SIP_TRANSFER );
198
205 bool removeRenderer( const QString &rendererName );
206
211 QgsTiledSceneRendererAbstractMetadata *rendererMetadata( const QString &rendererName );
212
216 QStringList renderersList() const;
217
223 static QgsTiledSceneRenderer *defaultRenderer( const QgsTiledSceneLayer *layer ) SIP_FACTORY;
224
225 private:
226#ifdef SIP_RUN
228#endif
229
231 QMap<QString, QgsTiledSceneRendererAbstractMetadata *> mRenderers;
232
234 QStringList mRenderersOrder;
235};
236
237#endif // QGSTILEDSCENERENDERERREGISTRY_H
The class is used as a container of context for various read/write operations on other objects.
Represents a map layer supporting display of tiled scene objects.
Stores metadata about one tiled scene renderer class.
void setIcon(const QIcon &icon)
Sets an icon representing the renderer.
QString mName
name used within QGIS for identification (the same what renderer's type() returns)
virtual QgsTiledSceneRendererWidget * createRendererWidget(QgsTiledSceneLayer *layer, QgsStyle *style, QgsTiledSceneRenderer *oldRenderer)
Returns new instance of settings widget for the renderer.
QIcon mIcon
icon to be shown in the renderer properties dialog
QgsTiledSceneRendererAbstractMetadata(const QString &name, const QString &visibleName, const QIcon &icon=QIcon())
Constructor for QgsTiledSceneRendererAbstractMetadata, with the specified name.
QIcon icon() const
Returns an icon representing the renderer.
QString name() const
Returns the unique name of the renderer.
QString visibleName() const
Returns a friendly display name of the renderer.
QString mVisibleName
name visible for users (translatable)
virtual QgsTiledSceneRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
virtual ~QgsTiledSceneRendererAbstractMetadata()=default
Convenience metadata class that uses static functions to create tiled scene renderer and its widget.
QgsTiledSceneRendererWidget * createRendererWidget(QgsTiledSceneLayer *layer, QgsStyle *style, QgsTiledSceneRenderer *renderer) override
Returns new instance of settings widget for the renderer.
QgsTiledSceneRendererCreateFunc createFunction() const
QgsTiledSceneRendererWidgetFunc widgetFunction() const
QgsTiledSceneRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context) override
Returns new instance of the renderer given the DOM element.
void setWidgetFunction(QgsTiledSceneRendererWidgetFunc f)
QgsTiledSceneRendererMetadata(const QString &name, const QString &visibleName, QgsTiledSceneRendererCreateFunc pfCreate, const QIcon &icon=QIcon(), QgsTiledSceneRendererWidgetFunc pfWidget=nullptr)
Construct metadata.
QgsTiledSceneRendererCreateFunc mCreateFunc
pointer to function that creates an instance of the renderer when loading project / style
QgsTiledSceneRendererWidgetFunc mWidgetFunc
pointer to function that creates a widget for configuration of renderer's params
Registry of 2D renderers for tiled scenes.
QgsTiledSceneRendererRegistry(const QgsTiledSceneRendererRegistry &rh)=delete
QgsTiledSceneRendererRegistry & operator=(const QgsTiledSceneRendererRegistry &rh)=delete
Base class for tiled scene 2D renderer settings widgets.
Abstract base class for 2d tiled scene renderers.
#define SIP_EXTERNAL
Definition qgis_sip.h:116
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
QgsTiledSceneRenderer *(* QgsTiledSceneRendererCreateFunc)(QDomElement &, const QgsReadWriteContext &)
QgsTiledSceneRendererWidget *(* QgsTiledSceneRendererWidgetFunc)(QgsTiledSceneLayer *, QgsStyle *, QgsTiledSceneRenderer *)