QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
28 class QgsPointCloudLayer;
29 class 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  {}
62  virtual ~QgsPointCloudRendererAbstractMetadata() = default;
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;
113  QString mVisibleName;
115  QIcon mIcon;
116 };
117 
118 typedef QgsPointCloudRenderer *( *QgsPointCloudRendererCreateFunc )( QDomElement &, const QgsReadWriteContext & ) SIP_SKIP;
119 typedef 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 
194  QgsPointCloudRendererRegistry &operator=( const QgsPointCloudRendererRegistry &rh ) = delete;
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
QgsPointCloudRendererWidget
Base class for point cloud 2D renderer settings widgets.
Definition: qgspointcloudrendererwidget.h:36
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsPointCloudLayer
Represents a map layer supporting display of point clouds.
Definition: qgspointcloudlayer.h:45
QgsPointCloudRendererMetadata
Convenience metadata class that uses static functions to create point cloud renderer and its widget.
Definition: qgspointcloudrendererregistry.h:126
QgsPointCloudCategoryList
QList< QgsPointCloudCategory > QgsPointCloudCategoryList
Definition: qgspointcloudclassifiedrenderer.h:116
QgsPointCloudRendererMetadata::widgetFunction
QgsPointCloudRendererWidgetFunc widgetFunction() const
Definition: qgspointcloudrendererregistry.h:155
QgsPointCloudRendererMetadata::setWidgetFunction
void setWidgetFunction(QgsPointCloudRendererWidgetFunc f)
Definition: qgspointcloudrendererregistry.h:158
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsPointCloudRendererAbstractMetadata::visibleName
QString visibleName() const
Returns a friendly display name of the renderer.
Definition: qgspointcloudrendererregistry.h:74
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsPointCloudRendererWidgetFunc
QgsPointCloudRendererWidget *(* QgsPointCloudRendererWidgetFunc)(QgsPointCloudLayer *, QgsStyle *, QgsPointCloudRenderer *)
Definition: qgspointcloudrendererregistry.h:119
QgsPointCloudRendererAbstractMetadata::createRendererWidget
virtual QgsPointCloudRendererWidget * createRendererWidget(QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer *oldRenderer)
Returns new instance of settings widget for the renderer.
Definition: qgspointcloudrendererregistry.h:105
qgspointcloudclassifiedrenderer.h
QgsPointCloudRendererMetadata::QgsPointCloudRendererMetadata
QgsPointCloudRendererMetadata(const QString &name, const QString &visibleName, QgsPointCloudRendererCreateFunc pfCreate, const QIcon &icon=QIcon(), QgsPointCloudRendererWidgetFunc pfWidget=nullptr)
Construct metadata.
Definition: qgspointcloudrendererregistry.h:134
QgsPointCloudAttributeCollection
Collection of point cloud attributes.
Definition: qgspointcloudattribute.h:141
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsPointCloudRendererMetadata::createRendererWidget
QgsPointCloudRendererWidget * createRendererWidget(QgsPointCloudLayer *layer, QgsStyle *style, QgsPointCloudRenderer *renderer) override
Returns new instance of settings widget for the renderer.
Definition: qgspointcloudrendererregistry.h:148
QgsPointCloudRendererAbstractMetadata
Stores metadata about one point cloud renderer class.
Definition: qgspointcloudrendererregistry.h:46
QgsPointCloudDataProvider
Base class for providing data for QgsPointCloudLayer.
Definition: qgspointclouddataprovider.h:46
QgsPointCloudRendererMetadata::createFunction
QgsPointCloudRendererCreateFunc createFunction() const
Definition: qgspointcloudrendererregistry.h:153
QgsPointCloudRendererCreateFunc
QgsPointCloudRenderer *(* QgsPointCloudRendererCreateFunc)(QDomElement &, const QgsReadWriteContext &)
Definition: qgspointcloudrendererregistry.h:118
QgsPointCloudRendererMetadata::mCreateFunc
QgsPointCloudRendererCreateFunc mCreateFunc
pointer to function that creates an instance of the renderer when loading project / style
Definition: qgspointcloudrendererregistry.h:162
QgsStyle
Definition: qgsstyle.h:159
QgsPointCloudRendererAbstractMetadata::name
QString name() const
Returns the unique name of the renderer.
Definition: qgspointcloudrendererregistry.h:68
QgsPointCloudRenderer
Abstract base class for 2d point cloud renderers.
Definition: qgspointcloudrenderer.h:296
QgsPointCloudRendererAbstractMetadata::mIcon
QIcon mIcon
icon to be shown in the renderer properties dialog
Definition: qgspointcloudrendererregistry.h:115
QgsPointCloudRendererAbstractMetadata::mVisibleName
QString mVisibleName
name visible for users (translatable)
Definition: qgspointcloudrendererregistry.h:113
SIP_EXTERNAL
#define SIP_EXTERNAL
Definition: qgis_sip.h:116
QgsPointCloudRendererAbstractMetadata::setIcon
void setIcon(const QIcon &icon)
Sets an icon representing the renderer.
Definition: qgspointcloudrendererregistry.h:86
QgsPointCloudRendererMetadata::createRenderer
QgsPointCloudRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context) override
Returns new instance of the renderer given the DOM element.
Definition: qgspointcloudrendererregistry.h:144
QgsPointCloudRendererRegistry
Registry of 2D renderers for point clouds.
Definition: qgspointcloudrendererregistry.h:184
QgsPointCloudRendererAbstractMetadata::QgsPointCloudRendererAbstractMetadata
QgsPointCloudRendererAbstractMetadata(const QString &name, const QString &visibleName, const QIcon &icon=QIcon())
Constructor for QgsPointCloudRendererAbstractMetadata, with the specified name.
Definition: qgspointcloudrendererregistry.h:57
QgsPointCloudRendererAbstractMetadata::mName
QString mName
name used within QGIS for identification (the same what renderer's type() returns)
Definition: qgspointcloudrendererregistry.h:111
QgsPointCloudRendererAbstractMetadata::icon
QIcon icon() const
Returns an icon representing the renderer.
Definition: qgspointcloudrendererregistry.h:80
QgsPointCloudRendererMetadata::mWidgetFunc
QgsPointCloudRendererWidgetFunc mWidgetFunc
pointer to function that creates a widget for configuration of renderer's params
Definition: qgspointcloudrendererregistry.h:164