QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
34 return QStringLiteral(
"ramp" );
39 std::unique_ptr< QgsPointCloudAttributeByRampRenderer > res = std::make_unique< QgsPointCloudAttributeByRampRenderer >();
40 res->mAttribute = mAttribute;
41 res->mColorRampShader = mColorRampShader;
54 const char *ptr = block->
data();
59 int attributeOffset = 0;
68 const bool applyZOffset =
attribute->name() == QLatin1String(
"Z" );
69 const bool applyXOffset =
attribute->name() == QLatin1String(
"X" );
70 const bool applyYOffset =
attribute->name() == QLatin1String(
"Y" );
77 const bool reproject = ct.
isValid();
83 for (
int i = 0; i < count; ++i )
93 z =
pointZ( context, ptr, i );
98 pointXY( context, ptr, i, x, y );
99 if ( visibleExtent.
contains( x, y ) )
113 double attributeValue = 0;
114 context.
getAttribute( ptr, i * recordSize + attributeOffset, attributeType, attributeValue );
117 attributeValue = context.
offset().
x() + context.
scale().
x() * attributeValue;
119 attributeValue = context.
offset().
y() + context.
scale().
y() * attributeValue;
123 mColorRampShader.
shade( attributeValue, &red, &green, &blue, &alpha );
124 drawPoint( x, y, QColor( red, green, blue, alpha ), context );
135 std::unique_ptr< QgsPointCloudAttributeByRampRenderer > r = std::make_unique< QgsPointCloudAttributeByRampRenderer >();
137 r->setAttribute( element.attribute( QStringLiteral(
"attribute" ), QStringLiteral(
"Intensity" ) ) );
139 QDomElement elemShader = element.firstChildElement( QStringLiteral(
"colorrampshader" ) );
140 r->mColorRampShader.readXml( elemShader, context );
142 r->setMinimum( element.attribute( QStringLiteral(
"min" ), QStringLiteral(
"0" ) ).toDouble() );
143 r->setMaximum( element.attribute( QStringLiteral(
"max" ), QStringLiteral(
"100" ) ).toDouble() );
145 r->restoreCommonProperties( element, context );
152 QDomElement rendererElem = doc.createElement( QStringLiteral(
"renderer" ) );
154 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ramp" ) );
155 rendererElem.setAttribute( QStringLiteral(
"min" ), mMin );
156 rendererElem.setAttribute( QStringLiteral(
"max" ), mMax );
158 rendererElem.setAttribute( QStringLiteral(
"attribute" ), mAttribute );
160 QDomElement elemShader = mColorRampShader.
writeXml( doc, context );
161 rendererElem.appendChild( elemShader );
177 QList<QgsLayerTreeModelLegendNode *> res;
198 QList< QPair< QString, QColor > > items;
200 res.reserve( items.size() );
201 for (
const QPair< QString, QColor > &item : std::as_const( items ) )
223 return mColorRampShader;
228 mColorRampShader = shader;
253 std::unique_ptr< QgsPointCloudAttributeByRampRendererPreparedData> data = std::make_unique< QgsPointCloudAttributeByRampRendererPreparedData >();
254 data->attributeName = mAttribute;
255 data->colorRampShader = mColorRampShader;
257 data->attributeIsX = mAttribute == QLatin1String(
"X" );
258 data->attributeIsY = mAttribute == QLatin1String(
"Y" );
259 data->attributeIsZ = mAttribute == QLatin1String(
"Z" );
265 double attributeValue = 0;
272 attributeValue = block->
offset().
x() + block->
scale().
x() * attributeValue;
274 attributeValue = block->
offset().
y() + block->
scale().
y() * attributeValue;
281 return QColor( red, green, blue, alpha );
QString type() const override
Returns the identifier of the renderer type.
QSet< QString > usedAttributes() const override
Returns the set of attributes used by the prepared point cloud renderer.
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.
void setSourceColorRamp(QgsColorRamp *colorramp)
Set the source color ramp.
DataType
Systems of unit measurement.
The class is used as a container of context for various read/write operations on other objects.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
QgsPointCloudAttribute::DataType attributeType
double y() const
Returns Y coordinate.
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.
std::unique_ptr< QgsPreparedPointCloudRendererData > prepare() override
Returns prepared data container for bulk point color retrieval.
Implementation of legend node interface for displaying arbitrary label with icon.
A legend node which renders a color ramp.
QgsPointCloudAttributeByRampRenderer()
Constructor for QgsPointCloudAttributeByRampRenderer.
void classifyColorRamp(int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
Classify color ramp shader.
double maximumValue() const
Returns the minimum value for the raster shader.
void copyCommonProperties(QgsPointCloudRenderer *destination) const
Copies common point cloud properties (such as point size and screen error) to the destination rendere...
Base class for storing raw data from point cloud nodes.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
QSet< QString > usedAttributes(const QgsPointCloudRenderContext &context) const override
Returns a list of attributes required by this renderer.
QgsColorRampShader colorRampShader
A rectangle specified with double values.
void setMinimum(double minimum)
Sets the minimum value for attributes which will be used by the color ramp shader.
QgsColorRampShader colorRampShader() const
Returns the color ramp shader function used to visualize the attribute.
int pointCount() const
Returns number of points that are stored in the block.
static QgsStyle * defaultStyle()
Returns default application-wide style.
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...
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
@ Discrete
Assigns the color of the higher class for every pixel between two class breaks.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Custom exception class for Coordinate Reference System related exceptions.
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).
QgsColorRamp * sourceColorRamp() const
Returns the source color ramp.
Encapsulates the render context for a 2D point cloud rendering operation.
void setMaximum(double maximum)
Sets the maximum value for attributes which will be used by the color ramp shader.
int pointRecordSize() const
Returns total size of record.
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.
void setAttribute(const QString &attribute)
Sets the attribute to use for the renderer.
void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const override
Returns legend symbology items if provided by renderer.
void incrementPointsRendered(long count)
Increments the count of points rendered by the specified amount.
double z() const
Returns Z coordinate.
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes configuration to a new DOM element.
double minimum() const
Returns the minimum value for attributes which will be used by the color ramp shader.
double maximum() const
Returns the maximum value for attributes which will be used by the color ramp shader.
double zValueFixedOffset() const
Returns any constant offset which must be applied to z values taken from the point cloud index.
Layer tree node points to a map layer.
Collection of point cloud attributes.
bool contains(const QgsRectangle &rect) const SIP_HOLDGIL
Returns true when rectangle contains other rectangle.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an RGB renderer from an XML element.
QgsVector3D offset() const
Returns the offset of the layer's int32 coordinates compared to CRS coords.
Attribute for point cloud data pair of name and size in bytes.
void setColorRampShader(const QgsColorRampShader &shader)
Sets the color ramp shader function used to visualize the attribute.
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 useContinuousLegend() const
Returns true if a continuous gradient legend will be used.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
double minimumValue() const
Returns the maximum value for the raster shader.
bool isInfinite() const
Returns true if the range consists of all possible values.
QgsDoubleRange zRange() const
Returns the range of z-values which should be rendered.
Type colorRampType() const
Returns the color ramp type.
double zValueScale() const
Returns any constant scaling factor which must be applied to z values taken from the point cloud inde...
int pointRecordSize() const
Returns the total size of each individual point record.
QgsRange which stores a range of double values.
bool shade(double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue) const override
Generates and new RGB value based on one input value.
QgsVector3D scale() const
Returns the scale of the layer's int32 coordinates compared to CRS coords.
QString attribute() const
Returns the attribute to use for the renderer.
QgsVector3D offset() const
Returns the custom offset of the block.
QgsPointCloudRenderer * clone() const override
Create a deep copy of this renderer.
Abstract base class for 2d point cloud renderers.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Saves the renderer configuration to an XML element.
Implementation of legend node interface for displaying raster legend entries.
void saveCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Saves common renderer properties (such as point size and screen error) to the specified DOM element.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
static double pointZ(QgsPointCloudRenderContext &context, const char *ptr, int i)
Retrieves the z value for the point at index i.
@ Interpolated
Interpolates the color between two class breaks linearly.
double x() const
Returns X coordinate.
Settings for a color ramp legend node.
QgsVector3D scale() const
Returns the custom scale of the block.
DataType type() const
Returns the data type.
bool prepareBlock(const QgsPointCloudBlock *block) override
Prepares the renderer for using the specified block.
const QgsColorRampLegendNodeSettings * legendSettings() const
Returns the color ramp shader legend settings.