18#ifndef QGSPOINTCLOUDRENDERER_H
19#define QGSPOINTCLOUDRENDERER_H
32using namespace Qt::StringLiterals;
105 long pointsRendered()
const;
113 void incrementPointsRendered(
long count );
190 value = *
reinterpret_cast< const unsigned char *
>( data +
offset );
193 value = *( data +
offset );
197 value = *
reinterpret_cast< const quint32 *
>( data +
offset );
200 value = *
reinterpret_cast< const qint32 *
>( data +
offset );
204 value = *
reinterpret_cast< const quint64 *
>( data +
offset );
207 value = *
reinterpret_cast< const qint64 *
>( data +
offset );
211 value = *
reinterpret_cast< const short *
>( data +
offset );
215 value = *
reinterpret_cast< const unsigned short *
>( data +
offset );
219 value = *
reinterpret_cast< const float *
>( data +
offset );
223 value = *
reinterpret_cast< const double *
>( data +
offset );
259 long mPointsRendered = 0;
261 int mPointRecordSize = 0;
265 double mZValueScale = 1.0;
266 double mZValueFixedOffset = 0;
270 TriangulationData mTriangulationData;
327 const QString
type = sipCpp->type();
329 if (
type ==
"rgb"_L1 )
330 sipType = sipType_QgsPointCloudRgbRenderer;
331 else if (
type ==
"ramp"_L1 )
332 sipType = sipType_QgsPointCloudAttributeByRampRenderer;
333 else if (
type ==
"classified"_L1 )
334 sipType = sipType_QgsPointCloudClassifiedRenderer;
335 else if (
type ==
"extent"_L1 )
336 sipType = sipType_QgsPointCloudExtentRenderer;
360 virtual QString
type()
const = 0;
397 Q_UNUSED( pointAttributes );
431 virtual std::unique_ptr< QgsPreparedPointCloudRendererData >
prepare()
SIP_SKIP;
562 double maximumScreenError()
const;
574 void setMaximumScreenError(
double error );
686 virtual QStringList legendRuleKeys()
const;
734 void setOverviewSwitchingScale(
const double value );
790 const qint32 ix = *
reinterpret_cast< const qint32 *
>( ptr + i * context.
pointRecordSize() + context.
xOffset() );
791 const qint32 iy = *
reinterpret_cast< const qint32 *
>( ptr + i * context.
pointRecordSize() + context.
yOffset() );
803 const qint32 iz = *
reinterpret_cast<const qint32 *
>( ptr + i * context.
pointRecordSize() + context.
zOffset() );
819 const QPointF originalXY( x, y );
822 switch ( mPointSymbol )
825 painter->fillRect( QRectF( x - width * 0.5, y - width * 0.5, width, width ), color );
829 painter->setBrush( QBrush( color ) );
830 painter->setPen( Qt::NoPen );
831 painter->drawEllipse( QRectF( x - width * 0.5, y - width * 0.5, width, width ) );
859 triangulation.
points.push_back( p.
x() );
860 triangulation.
points.push_back( p.
y() );
861 triangulation.
colors.push_back( color.rgb() );
863 triangulation.
elevations.push_back(
static_cast<float>( z ) );
877 void restoreCommonProperties(
const QDomElement &element,
const QgsReadWriteContext &context );
885 void saveCommonProperties( QDomElement &element,
const QgsReadWriteContext &context )
const;
901 QThread *mThread =
nullptr;
904 double mMaximumScreenError = 0.3;
907 double mPointSize = 1;
912 int mDefaultPainterPenWidth = 1;
915 bool mRenderAsTriangles =
false;
916 bool mHorizontalTriangleFilter =
false;
917 double mHorizontalTriangleFilterThreshold = 5.0;
920 bool mShowLabels =
false;
924 double mOverviewSwitchingScale = 1.0;
928 static void initPropertyDefinitions();
932 std::unique_ptr<QgsExpressionContextScope> mExpressionContextScope;
PointCloudSymbol
Rendering symbols for point cloud points.
@ Circle
Renders points as circles.
@ Square
Renders points as squares.
PointCloudDrawOrder
Pointcloud rendering order for 2d views.
@ Default
Draw points in the order they are stored.
PointCloudZoomOutRenderBehavior
Point cloud zoom out options.
@ RenderExtents
Render only point cloud extents when zoomed out.
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
Stores a digital elevation model in a raster image which may get updated as a part of the map layer r...
Renders elevation shading on an image with different methods (eye dome lighting, hillshading,...
Single scope for storing variables and functions for use within a QgsExpressionContext.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
A geometry is the spatial representation of a feature.
Layer tree node points to a map layer.
An abstract interface for legend items returned from QgsMapLayerLegend implementation.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
void transformInPlace(double &x, double &y) const
Transforms map coordinates to device coordinates.
Struct for storing maximum and minimum scales for measurements in map units.
A collection of point cloud attributes.
DataType
Systems of unit measurement.
@ UShort
Unsigned short int 2 bytes.
@ Short
Short int 2 bytes.
@ UChar
Unsigned char 1 byte.
@ UInt32
Unsigned int32 4 bytes.
@ UInt64
Unsigned int64 8 bytes.
Base class for storing raw data from point cloud nodes.
Represents a map layer supporting display of point clouds.
Encapsulates the render context for a 2D point cloud rendering operation.
int yOffset() const
Returns the offset for the y value in a point record.
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.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
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...
void setOffset(const QgsVector3D &offset)
Sets the offset of the layer's int32 coordinates compared to CRS coords.
void setScale(const QgsVector3D &scale)
Sets the scale of the layer's int32 coordinates compared to CRS coords.
int pointRecordSize() const
Returns the size of a single point record.
int xOffset() const
Returns the offset for the x value in a point record.
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
QgsPointCloudRenderContext & operator=(const QgsPointCloudRenderContext &)=delete
QgsPointCloudRenderContext(const QgsPointCloudRenderContext &rh)=delete
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.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes associated with the rendered block.
TriangulationData & triangulationData()
Returns reference to the triangulation data structure (only used when rendering as triangles is enabl...
QgsPointCloudRenderContext(QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset, QgsFeedback *feedback=nullptr)
Constructor for QgsPointCloudRenderContext.
int zOffset() const
Returns the offset for the y value in a point record.
QgsFeedback * feedback() const
Returns the feedback object used to cancel rendering.
Abstract base class for 2d point cloud renderers.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Saves the renderer configuration to an XML element.
Qgis::PointCloudZoomOutRenderBehavior zoomOutBehavior() const
Returns the renderer behavior when zoomed out.
bool renderAsTriangles() const
Returns whether points are triangulated to render solid surface.
virtual void checkLegendItem(const QString &key, bool state=true)
Called when the check state of the legend item with the specified key is changed.
QgsTextFormat labelTextFormat() const
Returns the text format renderer is using for rendering labels.
virtual void renderBlock(const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context)=0
Renders a block of point cloud data using the specified render context.
double overviewSwitchingScale() const
Returns the overview switching scale.
QgsPointCloudRenderer & operator=(const QgsPointCloudRenderer &other)=delete
QgsPointCloudRenderer cannot be copied – use clone() instead.
const QgsMapUnitScale & pointSizeMapUnitScale() const
Returns the map unit scale used for the point size.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the renderer's property collection, used for data defined overrides.
virtual std::unique_ptr< QgsPreparedPointCloudRendererData > prepare()
Returns prepared data container for bulk point color retrieval.
void setPointSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the point size.
virtual QSet< QString > usedAttributes(const QgsPointCloudRenderContext &context) const
Returns a list of attributes required by this renderer.
virtual bool legendItemChecked(const QString &key)
Returns true if the legend item with the specified key is checked.
void setPointSize(double size)
Sets the point size.
bool horizontalTriangleFilter() const
Returns whether large triangles will get rendered.
virtual QString type() const =0
Returns the identifier of the renderer type.
void setHorizontalTriangleFilterThreshold(double threshold)
Sets threshold for filtering of triangles.
void setHorizontalTriangleFilterUnit(Qgis::RenderUnit unit)
Sets units of the threshold for filtering of triangles.
QgsPointCloudRenderer(const QgsPointCloudRenderer &other)=delete
QgsPointCloudRenderer cannot be copied – use clone() instead.
bool showLabels() const
Returns whether the renderer shows file labels inside the extent rectangle.
virtual QgsPointCloudRenderer * clone() const =0
Create a deep copy of this renderer.
void addPointToTriangulation(double x, double y, double z, const QColor &color, QgsPointCloudRenderContext &context)
Adds a point to the list of points to be triangulated (only used when renderAsTriangles() is enabled)...
QVector< QVariantMap > identify(QgsPointCloudLayer *layer, const QgsRenderContext &context, const QgsGeometry &geometry, double toleranceForPointIdentification=0)
Returns the list of visible points of the point cloud layer layer and an extent defined by a geometry...
void setPointSizeUnit(const Qgis::RenderUnit units)
Sets the units used for the point size.
Qgis::RenderUnit horizontalTriangleFilterUnit() const
Returns units of the threshold for filtering of triangles.
Property
Data-defined properties that can be set on the renderer.
void setRenderAsTriangles(bool asTriangles)
Sets whether points are triangulated to render solid surface.
virtual bool willRenderPoint(const QMap< QString, QVariant > &pointAttributes)
Checks whether the point holding pointAttributes attributes will be rendered By default if not overri...
virtual ~QgsPointCloudRenderer()=default
void setLabelTextFormat(const QgsTextFormat &textFormat)
Sets the text format renderers should use for rendering labels.
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).
void drawPoint(double x, double y, const QColor &color, int width, QgsPointCloudRenderContext &context) const
Draws a point using a color and painter width at the specified x and y (in map coordinates).
void setShowLabels(const bool show)
Set whether the renderer should also render file labels inside extent.
const QgsPropertyCollection & dataDefinedProperties() const
Returns the renderer's property collection, used for data defined overrides.
Qgis::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
double horizontalTriangleFilterThreshold() const
Returns threshold for filtering of triangles.
virtual void startRender(QgsPointCloudRenderContext &context)
Must be called when a new render cycle is started.
virtual void stopRender(QgsPointCloudRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
void setHorizontalTriangleFilter(bool enabled)
Sets whether large triangles will get rendered.
double pointSize() const
Returns the point size.
void setZoomOutBehavior(const Qgis::PointCloudZoomOutRenderBehavior behavior)
Sets the renderer behavior when zoomed out.
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.
void setElevationShadingRenderer(const QgsElevationShadingRenderer &renderer)
Sets the shading renderer used to render shading on the layer.
Base class for 2d point cloud renderer prepared data containers.
virtual ~QgsPreparedPointCloudRendererData()
virtual QColor pointColor(const QgsPointCloudBlock *block, int i, double z)=0
An optimised method of retrieving the color of a point from a point cloud block.
virtual bool prepareBlock(const QgsPointCloudBlock *block)=0
Prepares the renderer for using the specified block.
virtual QSet< QString > usedAttributes() const =0
Returns the set of attributes used by the prepared point cloud renderer.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsElevationMap * elevationMap() const
Returns the destination elevation map for the render operation.
float devicePixelRatio() const
Returns the device pixel ratio.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Container for all settings relating to text rendering.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Helper data structure used when rendering points as triangulated surface.
std::vector< QRgb > colors
RGB color for each point.
std::vector< float > elevations
Z value for each point (only used when global map shading is enabled).
std::vector< double > points
X,Y for each point - kept in this structure so that we can use it without further conversions in Dela...