QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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"
24
25#include <QString>
26
27using namespace Qt::StringLiterals;
28
34class CORE_EXPORT QgsPointCloudCategory
35{
36 public:
38
48 QgsPointCloudCategory( int value, const QColor &color, const QString &label, bool render = true, double pointSize = 0 );
49
54 bool operator==( const QgsPointCloudCategory &other ) const;
55
61 int value() const { return mValue; }
62
67 QColor color() const { return mColor; }
68
74 double pointSize() const { return mPointSize; }
75
81 QString label() const { return mLabel; }
82
88 void setValue( int value ) { mValue = value; }
89
95 void setColor( const QColor &color ) { mColor = color; }
96
103 void setPointSize( double size ) { mPointSize = size; }
104
110 void setLabel( const QString &label ) { mLabel = label; }
111
116 bool renderState() const { return mRender; }
117
122 void setRenderState( bool render ) { mRender = render; }
123
124 protected:
125 int mValue = 0;
126 QColor mColor;
127 double mPointSize = 0; // Values <= 0 means "use default layer point size"
128 QString mLabel;
129 bool mRender = true;
130};
131
132typedef QList<QgsPointCloudCategory> QgsPointCloudCategoryList;
133
134#ifndef SIP_RUN
135
145{
146 public:
147 QSet< QString > usedAttributes() const override;
148 bool prepareBlock( const QgsPointCloudBlock *block ) override;
149 QColor pointColor( const QgsPointCloudBlock *block, int i, double z ) override SIP_SKIP;
150
152 QHash< int, QColor > colors;
155};
156#endif
157
165{
166 public:
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 QString mAttribute = u"Classification"_s;
231
232 QgsPointCloudCategoryList mCategories;
233};
234
235#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:133
#define SIP_FACTORY
Definition qgis_sip.h:83
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QList< QgsPointCloudCategory > QgsPointCloudCategoryList