QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
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
22#include <QDomElement>
23#include <QIcon>
24#include <QMap>
25#include <QStringList>
26
30class QgsStyle;
31#ifndef SIP_RUN
33#endif
34
37
48{
49 public:
50
58 QgsPointCloudRendererAbstractMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon() )
59 : mName( name )
61 , mIcon( icon )
62 {}
64
69 QString name() const { return mName; }
70
75 QString visibleName() const { return mVisibleName; }
76
81 QIcon icon() const { return mIcon; }
82
87 void setIcon( const QIcon &icon ) { mIcon = icon; }
88
93 virtual QgsPointCloudRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) = 0 SIP_FACTORY;
94
95#ifndef SIP_RUN
96
107 { Q_UNUSED( layer ) Q_UNUSED( style ); Q_UNUSED( oldRenderer ); return nullptr; }
108#endif
109
110 protected:
112 QString mName;
116 QIcon mIcon;
117};
118
119typedef QgsPointCloudRenderer *( *QgsPointCloudRendererCreateFunc )( QDomElement &, const QgsReadWriteContext & ) SIP_SKIP;
120typedef QgsPointCloudRendererWidget *( *QgsPointCloudRendererWidgetFunc )( QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer * ) SIP_SKIP;
121
128{
129 public:
130
136 const QString &visibleName,
138 const QIcon &icon = QIcon(),
139 QgsPointCloudRendererWidgetFunc pfWidget = nullptr ) SIP_SKIP
141 , mCreateFunc( pfCreate )
142 , mWidgetFunc( pfWidget )
143 {}
144
145 QgsPointCloudRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY
146 { return mCreateFunc ? mCreateFunc( elem, context ) : nullptr; }
147
148#ifndef SIP_RUN
150 { return mWidgetFunc ? mWidgetFunc( layer, style, renderer ) : nullptr; }
151#endif
152
157
160
161 protected:
166
167 private:
168#ifdef SIP_RUN
170#endif
171
172};
173
174
186{
187 public:
188
191
194
202
209 bool removeRenderer( const QString &rendererName );
210
215 QgsPointCloudRendererAbstractMetadata *rendererMetadata( const QString &rendererName );
216
220 QStringList renderersList() const;
221
228
234 private:
235#ifdef SIP_RUN
237#endif
238
240 QMap<QString, QgsPointCloudRendererAbstractMetadata *> mRenderers;
241
243 QStringList mRenderersOrder;
244};
245
246#endif // QGSPOINTCLOUDRENDERERREGISTRY_H
A 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)
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
static QgsPointCloudCategoryList classificationAttributeCategories(const QgsPointCloudLayer *layer)
Returns a list of categories using the available Classification classes of a specified layer,...
QgsPointCloudRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
QgsPointCloudRendererRegistry(const QgsPointCloudRendererRegistry &rh)=delete
static QgsPointCloudRenderer * defaultRenderer(const QgsPointCloudLayer *layer)
Returns a new default point cloud renderer for a specified layer.
QgsPointCloudRendererRegistry & operator=(const QgsPointCloudRendererRegistry &rh)=delete
bool addRenderer(QgsPointCloudRendererAbstractMetadata *metadata)
Adds a renderer to the registry.
bool removeRenderer(const QString &rendererName)
Removes a renderer from registry.
QStringList renderersList() const
Returns a list of available renderers.
Base class for point cloud 2D renderer settings widgets.
Abstract base class for 2d point cloud renderers.
A container for the context for various read/write operations on objects.
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:88
#define SIP_EXTERNAL
Definition qgis_sip.h:124
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84
QList< QgsPointCloudCategory > QgsPointCloudCategoryList
QgsPointCloudRendererWidget *(* QgsPointCloudRendererWidgetFunc)(QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer *)
QgsPointCloudRenderer *(* QgsPointCloudRendererCreateFunc)(QDomElement &, const QgsReadWriteContext &)