QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgspointcloudclassifiedrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspointcloudclassifiedrenderer.h
3  --------------------
4  begin : October 2020
5  copyright : (C) 2020 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSPOINTCLOUDCLASSIFIEDRENDERER_H
19 #define QGSPOINTCLOUDCLASSIFIEDRENDERER_H
20 
21 #include "qgspointcloudrenderer.h"
22 #include "qgis_core.h"
23 #include "qgis_sip.h"
24 #include "qgscolorrampshader.h"
25 
26 
32 class CORE_EXPORT QgsPointCloudCategory
33 {
34  public:
35 
39  QgsPointCloudCategory() = default;
40 
48  QgsPointCloudCategory( int value, const QColor &color, const QString &label, bool render = true );
49 
54  bool operator==( const QgsPointCloudCategory &other ) const;
55 
61  int value() const { return mValue; }
62 
67  QColor color() const { return mColor; }
68 
74  QString label() const { return mLabel; }
75 
81  void setValue( int value ) { mValue = value; }
82 
88  void setColor( const QColor &color ) { mColor = color; }
89 
95  void setLabel( const QString &label ) { mLabel = label; }
96 
101  bool renderState() const { return mRender; }
102 
107  void setRenderState( bool render ) { mRender = render; }
108 
109  protected:
110  int mValue = 0;
111  QColor mColor;
112  QString mLabel;
113  bool mRender = true;
114 };
115 
116 typedef QList<QgsPointCloudCategory> QgsPointCloudCategoryList;
117 
118 #ifndef SIP_RUN
119 
129 {
130  public:
131 
132  QSet< QString > usedAttributes() const override;
133  bool prepareBlock( const QgsPointCloudBlock *block ) override;
134  QColor pointColor( const QgsPointCloudBlock *block, int i, double z ) override SIP_SKIP;
135 
137  QHash< int, QColor > colors;
138  QString attributeName;
139  int attributeOffset = 0;
140 };
141 #endif
142 
150 {
151  public:
152 
156  QgsPointCloudClassifiedRenderer( const QString &attributeName = QString(), const QgsPointCloudCategoryList &categories = QgsPointCloudCategoryList() );
157 
158  QString type() const override;
159  QgsPointCloudRenderer *clone() const override;
160  void renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context ) override;
161  bool willRenderPoint( const QVariantMap &pointAttributes ) override;
162  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
163  QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const override;
164  QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) override SIP_FACTORY;
165  QStringList legendRuleKeys() const override;
166  bool legendItemChecked( const QString &key ) override;
167  void checkLegendItem( const QString &key, bool state = true ) override;
168  std::unique_ptr< QgsPreparedPointCloudRendererData > prepare() override SIP_SKIP;
169 
173  static QgsPointCloudRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
174 
178  static QgsPointCloudCategoryList defaultCategories();
179 
185  QString attribute() const;
186 
192  void setAttribute( const QString &attribute );
193 
199  QgsPointCloudCategoryList categories() const;
200 
206  void setCategories( const QgsPointCloudCategoryList &categories );
207 
213  void addCategory( const QgsPointCloudCategory &category );
214 
215  private:
216 
217  QString mAttribute = QStringLiteral( "Classification" );
218 
219  QgsPointCloudCategoryList mCategories;
220 };
221 
222 #endif // QGSPOINTCLOUDCLASSIFIEDRENDERER_H
QgsPointCloudAttribute::DataType
DataType
Systems of unit measurement.
Definition: qgspointcloudattribute.h:44
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
QgsPointCloudCategoryList
QList< QgsPointCloudCategory > QgsPointCloudCategoryList
Definition: qgspointcloudclassifiedrenderer.h:116
QgsPointCloudRenderer::usedAttributes
virtual QSet< QString > usedAttributes(const QgsPointCloudRenderContext &context) const
Returns a list of attributes required by this renderer.
Definition: qgspointcloudrenderer.cpp:78
QgsPointCloudClassifiedRendererPreparedData::attributeName
QString attributeName
Definition: qgspointcloudclassifiedrenderer.h:138
QgsPointCloudRenderer::createLegendNodes
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer)
Creates a set of legend nodes representing the renderer.
Definition: qgspointcloudrenderer.cpp:152
QgsPointCloudRenderer::checkLegendItem
virtual void checkLegendItem(const QString &key, bool state=true)
Called when the check state of the legend item with the specified key is changed.
Definition: qgspointcloudrenderer.cpp:127
QgsPointCloudRenderer::prepare
virtual std::unique_ptr< QgsPreparedPointCloudRendererData > prepare()
Returns prepared data container for bulk point color retrieval.
Definition: qgspointcloudrenderer.cpp:83
QgsPreparedPointCloudRendererData
Base class for 2d point cloud renderer prepared data containers.
Definition: qgspointcloudrenderer.h:256
qgscolorrampshader.h
QgsPointCloudRenderer::clone
virtual QgsPointCloudRenderer * clone() const =0
Create a deep copy of this renderer.
QgsPointCloudCategory
Represents an individual category (class) from a QgsPointCloudClassifiedRenderer.
Definition: qgspointcloudclassifiedrenderer.h:32
QgsPointCloudBlock
Base class for storing raw data from point cloud nodes.
Definition: qgspointcloudblock.h:38
QgsPreparedPointCloudRendererData::pointColor
virtual QColor pointColor(const QgsPointCloudBlock *block, int i, double z)=0
An optimised method of retrieving the color of a point from a point cloud block.
QgsPointCloudClassifiedRendererPreparedData::attributeType
QgsPointCloudAttribute::DataType attributeType
Definition: qgspointcloudclassifiedrenderer.h:136
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsPreparedPointCloudRendererData::prepareBlock
virtual bool prepareBlock(const QgsPointCloudBlock *block)=0
Prepares the renderer for using the specified block.
QgsPointCloudRenderer::save
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Saves the renderer configuration to an XML element.
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsPointCloudRenderer::renderBlock
virtual void renderBlock(const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context)=0
Renders a block of point cloud data using the specified render context.
QgsPointCloudRenderContext
Encapsulates the render context for a 2D point cloud rendering operation.
Definition: qgspointcloudrenderer.h:41
QgsPointCloudClassifiedRenderer
Renders point clouds by a classification attribute.
Definition: qgspointcloudclassifiedrenderer.h:149
QgsLayerTreeLayer
Layer tree node points to a map layer.
Definition: qgslayertreelayer.h:43
qgis_sip.h
QgsPointCloudClassifiedRendererPreparedData
Prepared data container for QgsPointCloudClassifiedRenderer.
Definition: qgspointcloudclassifiedrenderer.h:128
QgsPointCloudRenderer::willRenderPoint
virtual bool willRenderPoint(const QMap< QString, QVariant > &pointAttributes)
Checks whether the point holding pointAttributes attributes will be rendered By default if not overri...
Definition: qgspointcloudrenderer.h:364
QgsPreparedPointCloudRendererData::usedAttributes
virtual QSet< QString > usedAttributes() const =0
Returns the set of attributes used by the prepared point cloud renderer.
QgsPointCloudRenderer::type
virtual QString type() const =0
Returns the identifier of the renderer type.
QgsPointCloudRenderer
Abstract base class for 2d point cloud renderers.
Definition: qgspointcloudrenderer.h:296
QgsPointCloudClassifiedRendererPreparedData::colors
QHash< int, QColor > colors
Definition: qgspointcloudclassifiedrenderer.h:137
QgsPointCloudRenderer::legendRuleKeys
virtual QStringList legendRuleKeys() const
Returns a list of all rule keys for legend nodes created by the renderer.
Definition: qgspointcloudrenderer.cpp:157
QgsPointCloudRenderer::legendItemChecked
virtual bool legendItemChecked(const QString &key)
Returns true if the legend item with the specified key is checked.
Definition: qgspointcloudrenderer.cpp:122
qgspointcloudrenderer.h