33 return QStringLiteral(
"ramp" );
38 std::unique_ptr< QgsPointCloudAttributeByRampRenderer > res = qgis::make_unique< QgsPointCloudAttributeByRampRenderer >();
39 res->mAttribute = mAttribute;
40 res->mColorRampShader = mColorRampShader;
53 const char *ptr = block->
data();
58 int attributeOffset = 0;
67 const bool applyZOffset =
attribute->name() == QLatin1String(
"Z" );
68 const bool applyXOffset =
attribute->name() == QLatin1String(
"X" );
69 const bool applyYOffset =
attribute->name() == QLatin1String(
"Y" );
76 const bool reproject = ct.
isValid();
82 for (
int i = 0; i < count; ++i )
92 z =
pointZ( context, ptr, i );
97 pointXY( context, ptr, i, x, y );
112 double attributeValue = 0;
113 context.
getAttribute( ptr, i * recordSize + attributeOffset, attributeType, attributeValue );
116 attributeValue = context.
offset().
x() + context.
scale().
x() * attributeValue;
118 attributeValue = context.
offset().
y() + context.
scale().
y() * attributeValue;
122 mColorRampShader.
shade( attributeValue, &red, &green, &blue, &alpha );
123 drawPoint( x, y, QColor( red, green, blue, alpha ), context );
134 std::unique_ptr< QgsPointCloudAttributeByRampRenderer > r = qgis::make_unique< QgsPointCloudAttributeByRampRenderer >();
136 r->setAttribute( element.attribute( QStringLiteral(
"attribute" ), QStringLiteral(
"Intensity" ) ) );
138 QDomElement elemShader = element.firstChildElement( QStringLiteral(
"colorrampshader" ) );
139 r->mColorRampShader.readXml( elemShader, context );
141 r->setMinimum( element.attribute( QStringLiteral(
"min" ), QStringLiteral(
"0" ) ).toDouble() );
142 r->setMaximum( element.attribute( QStringLiteral(
"max" ), QStringLiteral(
"100" ) ).toDouble() );
144 r->restoreCommonProperties( element, context );
151 QDomElement rendererElem = doc.createElement( QStringLiteral(
"renderer" ) );
153 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"ramp" ) );
154 rendererElem.setAttribute( QStringLiteral(
"min" ), mMin );
155 rendererElem.setAttribute( QStringLiteral(
"max" ), mMax );
157 rendererElem.setAttribute( QStringLiteral(
"attribute" ), mAttribute );
159 QDomElement elemShader = mColorRampShader.
writeXml( doc, context );
160 rendererElem.appendChild( elemShader );
176 QList<QgsLayerTreeModelLegendNode *> res;
197 QList< QPair< QString, QColor > > items;
199 res.reserve( items.size() );
200 for (
const QPair< QString, QColor > &item : qgis::as_const( items ) )
222 return mColorRampShader;
227 mColorRampShader = shader;
Settings for a color ramp legend node.
bool useContinuousLegend() const
Returns true if a continuous gradient legend will be used.
A legend node which renders a color ramp.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
void legendSymbologyItems(QList< QPair< QString, QColor > > &symbolItems) const override
Returns legend symbology items if provided by renderer.
const QgsColorRampLegendNodeSettings * legendSettings() const
Returns the color ramp shader legend settings.
Type colorRampType() const
Returns the color ramp type.
void setSourceColorRamp(QgsColorRamp *colorramp)
Set the source color ramp.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes configuration to a new DOM element.
bool shade(double value, int *returnRedValue, int *returnGreenValue, int *returnBlueValue, int *returnAlphaValue) const override
Generates and new RGB value based on one input value.
QgsColorRamp * sourceColorRamp() const
Returns the source color ramp.
@ Interpolated
Interpolates the color between two class breaks linearly.
@ Discrete
Assigns the color of the higher class for every pixel between two class breaks.
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
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.
QString type() const override
Returns the identifier of the renderer type.
void setMaximum(double maximum)
Sets the maximum value for attributes which will be used by the color ramp shader.
QgsPointCloudRenderer * clone() const override
Create a deep copy of this renderer.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an RGB renderer from an XML element.
void renderBlock(const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context) override
Renders a block of point cloud data using the specified render context.
void setMinimum(double minimum)
Sets the minimum value for attributes which will be used by the color ramp shader.
QgsPointCloudAttributeByRampRenderer()
Constructor for QgsPointCloudAttributeByRampRenderer.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Saves the renderer configuration to an XML element.
double maximum() const
Returns the maximum value for attributes which will be used by the color ramp shader.
QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer) override
Creates a set of legend nodes representing the renderer.
void setColorRampShader(const QgsColorRampShader &shader)
Sets the color ramp shader function used to visualize the attribute.
QSet< QString > usedAttributes(const QgsPointCloudRenderContext &context) const override
Returns a list of attributes required by this renderer.
QgsColorRampShader colorRampShader() const
Returns the color ramp shader function used to visualize the attribute.
double minimum() const
Returns the minimum value for attributes which will be used by the color ramp shader.
QString attribute() const
Returns the attribute to use for the renderer.
void setAttribute(const QString &attribute)
Sets the attribute to use for the renderer.
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.
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...
double zValueFixedOffset() const
Returns any constant offset which must be applied to z values taken from the point cloud index.
QgsVector3D offset() const
Returns the offset of the layer's int32 coordinates compared to CRS coords.
void incrementPointsRendered(long count)
Increments the count of points rendered by the specified amount.
double zValueScale() const
Returns any constant scaling factor which must be applied to z values taken from the point cloud inde...
QgsVector3D scale() const
Returns the scale of the layer's int32 coordinates compared to CRS coords.
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.
A class to represent a 2D point.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
double maximumValue() const
Returns the minimum value for the raster shader.
double minimumValue() const
Returns the maximum value for the raster shader.
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
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...
Implementation of legend node interface for displaying arbitrary label with icon.
static QgsStyle * defaultStyle()
Returns default application-wide style.
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.