QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
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 "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgscolorrampshader.h"
25
31class CORE_EXPORT QgsPointCloudCategory
32{
33 public:
34
36
46 QgsPointCloudCategory( int value, const QColor &color, const QString &label, bool render = true, double pointSize = 0 );
47
52 bool operator==( const QgsPointCloudCategory &other ) const;
53
59 int value() const { return mValue; }
60
65 QColor color() const { return mColor; }
66
72 double pointSize() const { return mPointSize; }
73
79 QString label() const { return mLabel; }
80
86 void setValue( int value ) { mValue = value; }
87
93 void setColor( const QColor &color ) { mColor = color; }
94
101 void setPointSize( double size ) { mPointSize = size; }
102
108 void setLabel( const QString &label ) { mLabel = label; }
109
114 bool renderState() const { return mRender; }
115
120 void setRenderState( bool render ) { mRender = render; }
121
122 protected:
123 int mValue = 0;
124 QColor mColor;
125 double mPointSize = 0; // Values <= 0 means "use default layer point size"
126 QString mLabel;
127 bool mRender = true;
128};
129
130typedef QList<QgsPointCloudCategory> QgsPointCloudCategoryList;
131
132#ifndef SIP_RUN
133
143{
144 public:
145
146 QSet< QString > usedAttributes() const override;
147 bool prepareBlock( const QgsPointCloudBlock *block ) override;
148 QColor pointColor( const QgsPointCloudBlock *block, int i, double z ) override SIP_SKIP;
149
151 QHash< int, QColor > colors;
154};
155#endif
156
164{
165 public:
166
170 QgsPointCloudClassifiedRenderer( const QString &attributeName = QString(), const QgsPointCloudCategoryList &categories = QgsPointCloudCategoryList() );
171
172 QString type() const override;
173 QgsPointCloudRenderer *clone() const override;
174 void renderBlock( const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context ) override;
175 bool willRenderPoint( const QVariantMap &pointAttributes ) override;
176 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
177 QSet< QString > usedAttributes( const QgsPointCloudRenderContext &context ) const override;
178 QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) override SIP_FACTORY;
179 QStringList legendRuleKeys() const override;
180 bool legendItemChecked( const QString &key ) override;
181 void checkLegendItem( const QString &key, bool state = true ) override;
182 std::unique_ptr< QgsPreparedPointCloudRendererData > prepare() override SIP_SKIP;
183
187 static QgsPointCloudRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
188
193
199 QString attribute() const;
200
206 void setAttribute( const QString &attribute );
207
214
221
227 void addCategory( const QgsPointCloudCategory &category );
228
229 private:
230
231 QString mAttribute = QStringLiteral( "Classification" );
232
233 QgsPointCloudCategoryList mCategories;
234};
235
236#endif // QGSPOINTCLOUDCLASSIFIEDRENDERER_H
Layer tree node points to a map layer.
DataType
Systems of unit measurement.
Base class for storing raw data from point cloud nodes.
Represents an individual category (class) from a QgsPointCloudClassifiedRenderer.
void setPointSize(double size)
Sets the point size for this category.
QgsPointCloudCategory()=default
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.
double pointSize() const
Returns the point size for 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...
Prepared data container for QgsPointCloudClassifiedRenderer.
QColor pointColor(const QgsPointCloudBlock *block, int i, double z) override
An optimised method of retrieving the color of a point from a point cloud block.
QSet< QString > usedAttributes() const override
Returns the set of attributes used by the prepared point cloud renderer.
bool prepareBlock(const QgsPointCloudBlock *block) override
Prepares the renderer for using the specified block.
void addCategory(const QgsPointCloudCategory &category)
Adds a category to the renderer.
QString attribute() const
Returns the attribute to use for the renderer.
QgsPointCloudClassifiedRenderer(const QString &attributeName=QString(), const QgsPointCloudCategoryList &categories=QgsPointCloudCategoryList())
Constructor for QgsPointCloudClassifiedRenderer.
bool willRenderPoint(const QVariantMap &pointAttributes) override
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Saves the renderer configuration to an XML element.
void checkLegendItem(const QString &key, bool state=true) override
Called when the check state of the legend item with the specified key is changed.
QSet< QString > usedAttributes(const QgsPointCloudRenderContext &context) const override
Returns a list of attributes required by this renderer.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an RGB renderer from an XML element.
QgsPointCloudCategoryList categories() const
Returns the classification categories used for rendering.
static QgsPointCloudCategoryList defaultCategories()
Returns the default list of categories.
bool legendItemChecked(const QString &key) override
Returns true if the legend item with the specified key is checked.
QgsPointCloudRenderer * clone() const override
Create a deep copy of this renderer.
void setCategories(const QgsPointCloudCategoryList &categories)
Sets the classification categories used for rendering.
QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer) override
Creates a set of legend nodes representing the renderer.
void renderBlock(const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context) override
Renders a block of point cloud data using the specified render context.
std::unique_ptr< QgsPreparedPointCloudRendererData > prepare() override
Returns prepared data container for bulk point color retrieval.
QStringList legendRuleKeys() const override
Returns a list of all rule keys for legend nodes created by the renderer.
void setAttribute(const QString &attribute)
Sets the attribute to use for the renderer.
QString type() const override
Returns the identifier of the renderer type.
Encapsulates the render context for a 2D point cloud rendering operation.
Base class for 2d point cloud renderer prepared data containers.
A container for the context for various read/write operations on objects.
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_FACTORY
Definition qgis_sip.h:84
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QList< QgsPointCloudCategory > QgsPointCloudCategoryList