QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
55  int value() const { return mValue; }
56 
61  QColor color() const { return mColor; }
62 
68  QString label() const { return mLabel; }
69 
75  void setValue( int value ) { mValue = value; }
76 
82  void setColor( const QColor &color ) { mColor = color; }
83 
89  void setLabel( const QString &label ) { mLabel = label; }
90 
95  bool renderState() const { return mRender; }
96 
101  void setRenderState( bool render ) { mRender = render; }
102 
103  protected:
104  int mValue = 0;
105  QColor mColor;
106  QString mLabel;
107  bool mRender = true;
108 };
109 
110 typedef QList<QgsPointCloudCategory> QgsPointCloudCategoryList;
111 
112 
120 {
121  public:
122 
127 
128  QString type() const override;
129  QgsPointCloudRenderer *clone() const override;
130  void renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context ) override;
131  bool willRenderPoint( const QVariantMap &pointAttributes ) override;
132  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
133  QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const override;
134  QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) override SIP_FACTORY;
135  QStringList legendRuleKeys() const override;
136  bool legendItemChecked( const QString &key ) override;
137  void checkLegendItem( const QString &key, bool state = true ) override;
138 
142  static QgsPointCloudRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
143 
147  static QgsPointCloudCategoryList defaultCategories();
148 
154  QString attribute() const;
155 
161  void setAttribute( const QString &attribute );
162 
168  QgsPointCloudCategoryList categories() const;
169 
175  void setCategories( const QgsPointCloudCategoryList &categories );
176 
182  void addCategory( const QgsPointCloudCategory &category );
183 
184  private:
185 
186  QString mAttribute = QStringLiteral( "Classification" );
187 
188  QgsPointCloudCategoryList mCategories;
189 };
190 
191 #endif // QGSPOINTCLOUDCLASSIFIEDRENDERER_H
Layer tree node points to a map layer.
Base class for storing raw data from point cloud nodes.
Represents an individual category (class) from a QgsPointCloudClassifiedRenderer.
QgsPointCloudCategory()=default
Constructor for QgsPointCloudCategory.
int value() const
Returns the value corresponding to this category.
void setValue(int value)
Sets the value corresponding to this category.
bool renderState() const
Returns true if the category is currently enabled and should be rendered.
void setRenderState(bool render)
Sets whether the category is currently enabled and should be rendered.
QColor color() const
Returns the color which will be used to render this category.
void setColor(const QColor &color)
Sets the color which will be used to render this category.
QString label() const
Returns the label for this category, which is used to represent the category within legends and the l...
void setLabel(const QString &label)
Sets the label for this category, which is used to represent the category within legends and the laye...
Renders point clouds by a classification attribute.
Encapsulates the render context for a 2D point cloud rendering operation.
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_FACTORY
Definition: qgis_sip.h:76
QList< QgsPointCloudCategory > QgsPointCloudCategoryList