QGIS API Documentation  3.21.0-Master (909859188c)
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"
20 #include <QIcon>
21 #include <QMap>
22 #include <QStringList>
23 #include <QDomElement>
24 
27 class QgsPointCloudLayer;
28 class QgsStyle;
29 #ifndef SIP_RUN
31 #endif
32 
35 
46 {
47  public:
48 
56  QgsPointCloudRendererAbstractMetadata( const QString &name, const QString &visibleName, const QIcon &icon = QIcon() )
57  : mName( name )
58  , mVisibleName( visibleName )
59  , mIcon( icon )
60  {}
62 
67  QString name() const { return mName; }
68 
73  QString visibleName() const { return mVisibleName; }
74 
79  QIcon icon() const { return mIcon; }
80 
85  void setIcon( const QIcon &icon ) { mIcon = icon; }
86 
91  virtual QgsPointCloudRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) = 0 SIP_FACTORY;
92 
93 #ifndef SIP_RUN
94 
105  { Q_UNUSED( layer ) Q_UNUSED( style ); Q_UNUSED( oldRenderer ); return nullptr; }
106 #endif
107 
108  protected:
110  QString mName;
112  QString mVisibleName;
114  QIcon mIcon;
115 };
116 
117 typedef QgsPointCloudRenderer *( *QgsPointCloudRendererCreateFunc )( QDomElement &, const QgsReadWriteContext & ) SIP_SKIP;
118 typedef QgsPointCloudRendererWidget *( *QgsPointCloudRendererWidgetFunc )( QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer * ) SIP_SKIP;
119 
126 {
127  public:
128 
133  QgsPointCloudRendererMetadata( const QString &name,
134  const QString &visibleName,
136  const QIcon &icon = QIcon(),
137  QgsPointCloudRendererWidgetFunc pfWidget = nullptr ) SIP_SKIP
138  : QgsPointCloudRendererAbstractMetadata( name, visibleName, icon )
139  , mCreateFunc( pfCreate )
140  , mWidgetFunc( pfWidget )
141  {}
142 
143  QgsPointCloudRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY
144  { return mCreateFunc ? mCreateFunc( elem, context ) : nullptr; }
145 
146 #ifndef SIP_RUN
148  { return mWidgetFunc ? mWidgetFunc( layer, style, renderer ) : nullptr; }
149 #endif
150 
155 
158 
159  protected:
164 
165  private:
166 #ifdef SIP_RUN
168 #endif
169 
170 };
171 
172 
184 {
185  public:
186 
189 
194 
201  bool addRenderer( QgsPointCloudRendererAbstractMetadata *metadata SIP_TRANSFER );
202 
209  bool removeRenderer( const QString &rendererName );
210 
215  QgsPointCloudRendererAbstractMetadata *rendererMetadata( const QString &rendererName );
216 
220  QStringList renderersList() const;
221 
227  static QgsPointCloudRenderer *defaultRenderer( const QgsPointCloudDataProvider *provider ) SIP_FACTORY;
228 
229  private:
230 #ifdef SIP_RUN
232 #endif
233 
235  QMap<QString, QgsPointCloudRendererAbstractMetadata *> mRenderers;
236 
238  QStringList mRenderersOrder;
239 };
240 
241 #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.
virtual QgsPointCloudRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
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 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.
QgsPointCloudRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context) override
Returns new instance of the renderer given the DOM element.
QgsPointCloudRendererWidgetFunc mWidgetFunc
pointer to function that creates a widget for configuration of renderer's params
QgsPointCloudRendererWidget * createRendererWidget(QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer *renderer) override
Returns new instance of settings widget for the renderer.
QgsPointCloudRendererCreateFunc mCreateFunc
pointer to function that creates an instance of the renderer when loading project / style
QgsPointCloudRendererWidgetFunc widgetFunction() const
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
QgsPointCloudRendererWidget *(* QgsPointCloudRendererWidgetFunc)(QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer *)
QgsPointCloudRenderer *(* QgsPointCloudRendererCreateFunc)(QDomElement &, const QgsReadWriteContext &)