QGIS API Documentation 4.1.0-Master (60fea48833c)
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:
57 QgsPointCloudRendererAbstractMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon() )
58 : mName( name )
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 {
107 Q_UNUSED( layer )
108 Q_UNUSED( style );
109 Q_UNUSED( oldRenderer );
110 return nullptr;
111 }
112#endif
113
114 protected:
116 QString mName;
120 QIcon mIcon;
121};
122
123typedef QgsPointCloudRenderer *( *QgsPointCloudRendererCreateFunc )( QDomElement &, const QgsReadWriteContext & ) SIP_SKIP;
124typedef QgsPointCloudRendererWidget *( *QgsPointCloudRendererWidgetFunc )( QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer * ) SIP_SKIP;
125
132{
133 public:
138 QgsPointCloudRendererMetadata( const QString &name, const QString &visibleName, QgsPointCloudRendererCreateFunc pfCreate, const QIcon &icon = QIcon(), QgsPointCloudRendererWidgetFunc pfWidget = nullptr )
140 mCreateFunc( pfCreate ),
141 mWidgetFunc( pfWidget )
142 {}
143
144 QgsPointCloudRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY { return mCreateFunc ? mCreateFunc( elem, context ) : nullptr; }
145
146#ifndef SIP_RUN
148 {
149 return mWidgetFunc ? mWidgetFunc( layer, style, renderer ) : nullptr;
150 }
151#endif
152
157
160
161 protected:
166
167 private:
168#ifdef SIP_RUN
170#endif
171};
172
173
185{
186 public:
189
192
200
207 bool removeRenderer( const QString &rendererName );
208
213 QgsPointCloudRendererAbstractMetadata *rendererMetadata( const QString &rendererName );
214
218 QStringList renderersList() const;
219
226
232
233 private:
234#ifdef SIP_RUN
236#endif
237
239 QMap<QString, QgsPointCloudRendererAbstractMetadata *> mRenderers;
240
242 QStringList mRenderersOrder;
243};
244
245#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:89
#define SIP_EXTERNAL
Definition qgis_sip.h:123
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
QList< QgsPointCloudCategory > QgsPointCloudCategoryList
QgsPointCloudRendererWidget *(* QgsPointCloudRendererWidgetFunc)(QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer *)
QgsPointCloudRenderer *(* QgsPointCloudRendererCreateFunc)(QDomElement &, const QgsReadWriteContext &)