29 return QStringLiteral(
"rgb" );
34 std::unique_ptr< QgsPointCloudRgbRenderer > res = std::make_unique< QgsPointCloudRgbRenderer >();
35 res->mRedAttribute = mRedAttribute;
36 res->mGreenAttribute = mGreenAttribute;
37 res->mBlueAttribute = mBlueAttribute;
39 if ( mRedContrastEnhancement )
43 if ( mGreenContrastEnhancement )
47 if ( mBlueContrastEnhancement )
61 const char *ptr = block->
data();
73 attribute = request.
find( mGreenAttribute, greenOffset );
79 attribute = request.
find( mBlueAttribute, blueOffset );
90 const bool considerZ = !zRange.
isInfinite() || renderElevation;
97 const bool reproject = ct.
isValid();
98 for (
int i = 0; i < count; ++i )
108 z =
pointZ( context, ptr, i );
113 pointXY( context, ptr, i, x, y );
114 if ( visibleExtent.
contains( x, y ) )
129 context.
getAttribute( ptr, i * recordSize + redOffset, redType, red );
131 context.
getAttribute( ptr, i * recordSize + greenOffset, greenType, green );
133 context.
getAttribute( ptr, i * recordSize + blueOffset, blueType, blue );
136 if ( ( useRedContrastEnhancement && !mRedContrastEnhancement->isValueInDisplayableRange( red ) )
137 || ( useGreenContrastEnhancement && !mGreenContrastEnhancement->isValueInDisplayableRange( green ) )
138 || ( useBlueContrastEnhancement && !mBlueContrastEnhancement->isValueInDisplayableRange( blue ) ) )
144 if ( useRedContrastEnhancement )
146 red = mRedContrastEnhancement->enhanceContrast( red );
148 if ( useGreenContrastEnhancement )
150 green = mGreenContrastEnhancement->enhanceContrast( green );
152 if ( useBlueContrastEnhancement )
154 blue = mBlueContrastEnhancement->enhanceContrast( blue );
157 red = std::max( 0, std::min( 255, red ) );
158 green = std::max( 0, std::min( 255, green ) );
159 blue = std::max( 0, std::min( 255, blue ) );
161 drawPoint( x, y, QColor( red, green, blue ), context );
162 if ( renderElevation )
173 std::unique_ptr< QgsPointCloudRgbRenderer > r = std::make_unique< QgsPointCloudRgbRenderer >();
175 r->setRedAttribute( element.attribute( QStringLiteral(
"red" ), QStringLiteral(
"Red" ) ) );
176 r->setGreenAttribute( element.attribute( QStringLiteral(
"green" ), QStringLiteral(
"Green" ) ) );
177 r->setBlueAttribute( element.attribute( QStringLiteral(
"blue" ), QStringLiteral(
"Blue" ) ) );
179 r->restoreCommonProperties( element, context );
183 const QDomElement redContrastElem = element.firstChildElement( QStringLiteral(
"redContrastEnhancement" ) );
184 if ( !redContrastElem.isNull() )
192 const QDomElement greenContrastElem = element.firstChildElement( QStringLiteral(
"greenContrastEnhancement" ) );
193 if ( !greenContrastElem.isNull() )
201 const QDomElement blueContrastElem = element.firstChildElement( QStringLiteral(
"blueContrastEnhancement" ) );
202 if ( !blueContrastElem.isNull() )
214 QDomElement rendererElem = doc.createElement( QStringLiteral(
"renderer" ) );
216 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"rgb" ) );
218 rendererElem.setAttribute( QStringLiteral(
"red" ), mRedAttribute );
219 rendererElem.setAttribute( QStringLiteral(
"green" ), mGreenAttribute );
220 rendererElem.setAttribute( QStringLiteral(
"blue" ), mBlueAttribute );
225 if ( mRedContrastEnhancement )
227 QDomElement redContrastElem = doc.createElement( QStringLiteral(
"redContrastEnhancement" ) );
228 mRedContrastEnhancement->writeXml( doc, redContrastElem );
229 rendererElem.appendChild( redContrastElem );
231 if ( mGreenContrastEnhancement )
233 QDomElement greenContrastElem = doc.createElement( QStringLiteral(
"greenContrastEnhancement" ) );
234 mGreenContrastEnhancement->writeXml( doc, greenContrastElem );
235 rendererElem.appendChild( greenContrastElem );
237 if ( mBlueContrastEnhancement )
239 QDomElement blueContrastElem = doc.createElement( QStringLiteral(
"blueContrastEnhancement" ) );
240 mBlueContrastEnhancement->writeXml( doc, blueContrastElem );
241 rendererElem.appendChild( blueContrastElem );
250 res << mRedAttribute << mGreenAttribute << mBlueAttribute;
256 std::unique_ptr< QgsPointCloudRgbRendererPreparedData > data = std::make_unique< QgsPointCloudRgbRendererPreparedData >();
257 data->redAttribute = mRedAttribute;
258 if ( mRedContrastEnhancement )
260 data->greenAttribute = mGreenAttribute;
261 if ( mGreenContrastEnhancement )
263 data->blueAttribute = mBlueAttribute;
264 if ( mBlueContrastEnhancement )
304 const char *ptr = block->
data();
336 red = std::max( 0, std::min( 255, red ) );
337 green = std::max( 0, std::min( 255, green ) );
338 blue = std::max( 0, std::min( 255, blue ) );
340 return QColor( red, green, blue );
345 return mRedAttribute;
355 return mGreenAttribute;
365 return mBlueAttribute;
375 return mRedContrastEnhancement.get();
380 mRedContrastEnhancement.reset( enhancement );
385 return mGreenContrastEnhancement.get();
390 mGreenContrastEnhancement.reset( enhancement );
395 return mBlueContrastEnhancement.get();
400 mBlueContrastEnhancement.reset( enhancement );
@ UnknownDataType
Unknown or unspecified type.
Manipulates raster or point cloud pixel values so that they enhanceContrast or clip into a specified ...
@ NoEnhancement
Default color scaling algorithm, no scaling is applied.
void readXml(const QDomElement &elem)
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.
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.
DataType type() const
Returns the data type.
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.
int pointRecordSize() const
Returns the total size of each individual point record.
Encapsulates the render context for a 2D point cloud rendering operation.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
void incrementPointsRendered(long count)
Increments the count of points rendered by the specified amount.
static void getAttribute(const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value)
Retrieves the attribute value from data at the specified offset, where type indicates the original da...
Abstract base class for 2d point cloud renderers.
void drawPointToElevationMap(double x, double y, double z, QgsPointCloudRenderContext &context) const
Draws a point at the elevation z using at the specified x and y (in map coordinates) on the elevation...
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 useRedContrastEnhancement
std::unique_ptr< QgsContrastEnhancement > redContrastEnhancement
QSet< QString > usedAttributes() const override
Returns the set of attributes used by the prepared point cloud renderer.
std::unique_ptr< QgsContrastEnhancement > greenContrastEnhancement
bool prepareBlock(const QgsPointCloudBlock *block) override
Prepares the renderer for using the specified block.
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.
bool useGreenContrastEnhancement
std::unique_ptr< QgsContrastEnhancement > blueContrastEnhancement
QgsPointCloudAttribute::DataType blueType
bool useBlueContrastEnhancement
QgsPointCloudAttribute::DataType redType
QgsPointCloudAttribute::DataType greenType
std::unique_ptr< QgsPreparedPointCloudRendererData > prepare() override
Returns prepared data container for bulk point color retrieval.
void setRedContrastEnhancement(QgsContrastEnhancement *enhancement)
Sets the contrast enhancement to use for the red channel.
QString redAttribute() const
Returns the attribute to use for the red channel.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an RGB renderer from an XML element.
QString greenAttribute() const
Returns the attribute to use for the green channel.
QString type() const override
Returns the identifier of the renderer type.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Saves the renderer configuration to an XML element.
void setBlueContrastEnhancement(QgsContrastEnhancement *enhancement)
Sets the contrast enhancement to use for the blue channel.
void renderBlock(const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context) override
Renders a block of point cloud data using the specified render context.
const QgsContrastEnhancement * greenContrastEnhancement() const
Returns the contrast enhancement to use for the green channel.
QString blueAttribute() const
Returns the attribute to use for the blue channel.
QgsPointCloudRgbRenderer()
Constructor for QgsPointCloudRgbRenderer.
void setGreenContrastEnhancement(QgsContrastEnhancement *enhancement)
Sets the contrast enhancement to use for the green channel.
void setBlueAttribute(const QString &attribute)
Sets the attribute to use for the blue channel.
const QgsContrastEnhancement * blueContrastEnhancement() const
Returns the contrast enhancement to use for the blue channel.
void setGreenAttribute(const QString &attribute)
Sets the attribute to use for the green channel.
void setRedAttribute(const QString &attribute)
Sets the attribute to use for the red channel.
QgsPointCloudRenderer * clone() const override
Create a deep copy of this renderer.
const QgsContrastEnhancement * redContrastEnhancement() const
Returns the contrast enhancement to use for the red channel.
QSet< QString > usedAttributes(const QgsPointCloudRenderContext &context) const override
Returns a list of attributes required by this renderer.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
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
Returns true when rectangle contains other rectangle.
QgsElevationMap * elevationMap() const
Returns the destination elevation map for the render operation.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
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.