40 : mCategories( defaultCategories() )
46 return QStringLiteral(
"classified" );
51 std::unique_ptr< QgsPointCloudClassifiedRenderer > res = std::make_unique< QgsPointCloudClassifiedRenderer >();
52 res->mAttribute = mAttribute;
53 res->mCategories = mCategories;
64 const char *ptr = block->
data();
69 int attributeOffset = 0;
83 const bool reproject = ct.
isValid();
85 QHash< int, QColor > colors;
88 if ( !category.renderState() )
91 colors.insert( category.value(), category.color() );
94 for (
int i = 0; i < count; ++i )
104 z =
pointZ( context, ptr, i );
109 int attributeValue = 0;
110 context.
getAttribute( ptr, i * recordSize + attributeOffset, attributeType, attributeValue );
111 const QColor color = colors.value( attributeValue );
112 if ( !color.isValid() )
115 pointXY( context, ptr, i, x, y );
116 if ( visibleExtent.
contains( x, y ) )
139 if ( !pointAttributes.contains( mAttribute ) )
141 bool parsedCorrectly;
142 int attributeInt = pointAttributes[ mAttribute ].toInt( &parsedCorrectly );
143 if ( !parsedCorrectly )
147 if ( category.value() == attributeInt )
148 return category.renderState();
155 std::unique_ptr< QgsPointCloudClassifiedRenderer > r = std::make_unique< QgsPointCloudClassifiedRenderer >();
157 r->setAttribute( element.attribute( QStringLiteral(
"attribute" ), QStringLiteral(
"Classification" ) ) );
160 const QDomElement catsElem = element.firstChildElement( QStringLiteral(
"categories" ) );
161 if ( !catsElem.isNull() )
163 QDomElement catElem = catsElem.firstChildElement();
164 while ( !catElem.isNull() )
166 if ( catElem.tagName() == QLatin1String(
"category" ) )
168 const int value = catElem.attribute( QStringLiteral(
"value" ) ).toInt();
169 const QString label = catElem.attribute( QStringLiteral(
"label" ) );
170 const bool render = catElem.attribute( QStringLiteral(
"render" ) ) != QLatin1String(
"false" );
174 catElem = catElem.nextSiblingElement();
179 r->restoreCommonProperties( element, context );
208 QDomElement rendererElem = doc.createElement( QStringLiteral(
"renderer" ) );
210 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"classified" ) );
211 rendererElem.setAttribute( QStringLiteral(
"attribute" ), mAttribute );
214 QDomElement catsElem = doc.createElement( QStringLiteral(
"categories" ) );
217 QDomElement catElem = doc.createElement( QStringLiteral(
"category" ) );
218 catElem.setAttribute( QStringLiteral(
"value" ), QString::number( category.value() ) );
219 catElem.setAttribute( QStringLiteral(
"label" ), category.label() );
221 catElem.setAttribute( QStringLiteral(
"render" ), category.renderState() ?
"true" :
"false" );
222 catsElem.appendChild( catElem );
224 rendererElem.appendChild( catsElem );
240 QList<QgsLayerTreeModelLegendNode *> nodes;
244 nodes <<
new QgsRasterSymbolLegendNode( nodeLayer, category.color(), category.label(),
nullptr,
true, QString::number( category.value() ) );
255 res << QString::number( category.value() );
263 const int value = key.toInt( &ok );
269 if ( category.value() == value )
270 return category.renderState();
278 const int value = key.toInt( &ok );
282 for (
auto it = mCategories.begin(); it != mCategories.end(); ++it )
284 if ( it->value() == value )
286 it->setRenderState( state );
314 mCategories.append( category );
Custom exception class for Coordinate Reference System related exceptions.
QgsRange which stores a range of double values.
bool isInfinite() const
Returns true if the range consists of all possible values.
Layer tree node points to a map layer.
Collection of point cloud attributes.
int pointRecordSize() const
Returns total size of record.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
Attribute for point cloud data pair of name and size in bytes.
DataType
Systems of unit measurement.
Base class for storing raw data from point cloud nodes.
const char * data() const
Returns raw pointer to data.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes that are stored in the data block, along with their size.
int pointCount() const
Returns number of points that are stored in the block.
Represents an individual category (class) from a QgsPointCloudClassifiedRenderer.
QgsPointCloudCategory()=default
Constructor for QgsPointCloudCategory.
void addCategory(const QgsPointCloudCategory &category)
Adds a category to the renderer.
QString attribute() const
Returns the attribute to use for the renderer.
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.
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.
QgsPointCloudClassifiedRenderer()
Constructor for QgsPointCloudClassifiedRenderer.
static QMap< int, QString > translatedLasClassificationCodes()
Returns the map of LAS classification code to translated string value, corresponding to the ASPRS Sta...
Encapsulates the render context for a 2D point cloud rendering operation.
void getAttribute(const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value) const
Retrieves the attribute value from data at the specified offset, where type indicates the original da...
void incrementPointsRendered(long count)
Increments the count of points rendered by the specified amount.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Abstract base class for 2d point cloud renderers.
void saveCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Saves common renderer properties (such as point size and screen error) to the specified DOM element.
void copyCommonProperties(QgsPointCloudRenderer *destination) const
Copies common point cloud properties (such as point size and screen error) to the destination rendere...
void drawPoint(double x, double y, const QColor &color, QgsPointCloudRenderContext &context) const
Draws a point using a color at the specified x and y (in map coordinates).
static double pointZ(QgsPointCloudRenderContext &context, const char *ptr, int i)
Retrieves the z value for the point at index i.
static void pointXY(QgsPointCloudRenderContext &context, const char *ptr, int i, double &x, double &y)
Retrieves the x and y coordinate for the point at index i.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
Implementation of legend node interface for displaying raster legend entries.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
bool contains(const QgsRectangle &rect) const SIP_HOLDGIL
Returns true when rectangle contains other rectangle.
QgsDoubleRange zRange() const
Returns the range of z-values which should be rendered.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)
QList< QgsPointCloudCategory > QgsPointCloudCategoryList