QGIS API Documentation 3.27.0-Master (9c08adf5ef)
qgspointcloudrendererregistry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudrendererregistry.h
3 ---------------------
4 begin : November 2020
5 copyright : (C) 2020 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 QGSPOINTCLOUDRENDERERREGISTRY_H
16#define QGSPOINTCLOUDRENDERERREGISTRY_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
21#include <QIcon>
22#include <QMap>
23#include <QStringList>
24#include <QDomElement>
25
29class QgsStyle;
30#ifndef SIP_RUN
32#endif
33
36
47{
48 public:
49
57 QgsPointCloudRendererAbstractMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon() )
58 : mName( name )
59 , mVisibleName( visibleName )
60 , mIcon( icon )
61 {}
63
68 QString name() const { return mName; }
69
74 QString visibleName() const { return mVisibleName; }
75
80 QIcon icon() const { return mIcon; }
81
86 void setIcon( const QIcon &icon ) { mIcon = icon; }
87
92 virtual QgsPointCloudRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) = 0 SIP_FACTORY;
93
94#ifndef SIP_RUN
95
106 { Q_UNUSED( layer ) Q_UNUSED( style ); Q_UNUSED( oldRenderer ); return nullptr; }
107#endif
108
109 protected:
111 QString mName;
115 QIcon mIcon;
116};
117
118typedef QgsPointCloudRenderer *( *QgsPointCloudRendererCreateFunc )( QDomElement &, const QgsReadWriteContext & ) SIP_SKIP;
119typedef QgsPointCloudRendererWidget *( *QgsPointCloudRendererWidgetFunc )( QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer * ) SIP_SKIP;
120
127{
128 public:
129
134 QgsPointCloudRendererMetadata( const QString &name,
135 const QString &visibleName,
137 const QIcon &icon = QIcon(),
138 QgsPointCloudRendererWidgetFunc pfWidget = nullptr ) SIP_SKIP
139 : QgsPointCloudRendererAbstractMetadata( name, visibleName, icon )
140 , mCreateFunc( pfCreate )
141 , mWidgetFunc( pfWidget )
142 {}
143
144 QgsPointCloudRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY
145 { return mCreateFunc ? mCreateFunc( elem, context ) : nullptr; }
146
147#ifndef SIP_RUN
149 { return mWidgetFunc ? mWidgetFunc( layer, style, renderer ) : nullptr; }
150#endif
151
156
159
160 protected:
165
166 private:
167#ifdef SIP_RUN
169#endif
170
171};
172
173
185{
186 public:
187
190
195
202 bool addRenderer( QgsPointCloudRendererAbstractMetadata *metadata SIP_TRANSFER );
203
210 bool removeRenderer( const QString &rendererName );
211
216 QgsPointCloudRendererAbstractMetadata *rendererMetadata( const QString &rendererName );
217
221 QStringList renderersList() const;
222
228 static QgsPointCloudRenderer *defaultRenderer( const QgsPointCloudLayer *layer ) SIP_FACTORY;
229
234 static QgsPointCloudCategoryList classificationAttributeCategories( const QgsPointCloudLayer *layer );
235 private:
236#ifdef SIP_RUN
238#endif
239
241 QMap<QString, QgsPointCloudRendererAbstractMetadata *> mRenderers;
242
244 QStringList mRenderersOrder;
245};
246
247#endif // QGSPOINTCLOUDRENDERERREGISTRY_H
Collection of point cloud attributes.
Base class for providing data for QgsPointCloudLayer.
Represents a map layer supporting display of point clouds.
Stores metadata about one point cloud renderer class.
QgsPointCloudRendererAbstractMetadata(const QString &name, const QString &visibleName, const QIcon &icon=QIcon())
Constructor for QgsPointCloudRendererAbstractMetadata, with the specified name.
QIcon icon() const
Returns an icon representing the renderer.
QString visibleName() const
Returns a friendly display name of the renderer.
virtual ~QgsPointCloudRendererAbstractMetadata()=default
void setIcon(const QIcon &icon)
Sets an icon representing the renderer.
virtual QgsPointCloudRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
virtual QgsPointCloudRendererWidget * createRendererWidget(QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer *oldRenderer)
Returns new instance of settings widget for the renderer.
QString name() const
Returns the unique name of the renderer.
QIcon mIcon
icon to be shown in the renderer properties dialog
QString mName
name used within QGIS for identification (the same what renderer's type() returns)
QString mVisibleName
name visible for users (translatable)
Convenience metadata class that uses static functions to create point cloud renderer and its widget.
void setWidgetFunction(QgsPointCloudRendererWidgetFunc f)
QgsPointCloudRendererMetadata(const QString &name, const QString &visibleName, QgsPointCloudRendererCreateFunc pfCreate, const QIcon &icon=QIcon(), QgsPointCloudRendererWidgetFunc pfWidget=nullptr)
Construct metadata.
QgsPointCloudRendererWidgetFunc mWidgetFunc
pointer to function that creates a widget for configuration of renderer's params
QgsPointCloudRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context) override
Returns new instance of the renderer given the DOM element.
QgsPointCloudRendererCreateFunc mCreateFunc
pointer to function that creates an instance of the renderer when loading project / style
QgsPointCloudRendererWidgetFunc widgetFunction() const
QgsPointCloudRendererWidget * createRendererWidget(QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer *renderer) override
Returns new instance of settings widget for the renderer.
QgsPointCloudRendererCreateFunc createFunction() const
Registry of 2D renderers for point clouds.
QgsPointCloudRendererRegistry(const QgsPointCloudRendererRegistry &rh)=delete
QgsPointCloudRendererRegistry cannot be copied.
QgsPointCloudRendererRegistry & operator=(const QgsPointCloudRendererRegistry &rh)=delete
QgsPointCloudRendererRegistry cannot be copied.
Base class for point cloud 2D renderer settings widgets.
Abstract base class for 2d point cloud renderers.
The class is used as a container of context for various read/write operations on other objects.
#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
QList< QgsPointCloudCategory > QgsPointCloudCategoryList
QgsPointCloudRendererWidget *(* QgsPointCloudRendererWidgetFunc)(QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer *)
QgsPointCloudRenderer *(* QgsPointCloudRendererCreateFunc)(QDomElement &, const QgsReadWriteContext &)