18#ifndef QGSPOINTCLOUDRENDERER_H
19#define QGSPOINTCLOUDRENDERER_H
60 double zValueScale,
double zValueFixedOffset,
QgsFeedback *feedback =
nullptr );
104 long pointsRendered()
const;
112 void incrementPointsRendered(
long count );
202 template <
typename T>
208 value = *
reinterpret_cast< const unsigned char *
>( data + offset );
211 value = *( data + offset );
215 value = *
reinterpret_cast< const quint32 *
>( data + offset );
218 value = *
reinterpret_cast< const qint32 *
>( data + offset );
222 value = *
reinterpret_cast< const quint64 *
>( data + offset );
225 value = *
reinterpret_cast< const qint64 *
>( data + offset );
229 value = *
reinterpret_cast< const short *
>( data + offset );
233 value = *
reinterpret_cast< const unsigned short *
>( data + offset );
237 value = *
reinterpret_cast< const float *
>( data + offset );
241 value = *
reinterpret_cast< const double *
>( data + offset );
255 long mPointsRendered = 0;
257 int mPointRecordSize = 0;
261 double mZValueScale = 1.0;
262 double mZValueFixedOffset = 0;
263 std::unique_ptr<QgsElevationMap> mElevationMap;
325 const QString type = sipCpp->type();
327 if ( type == QLatin1String(
"rgb" ) )
328 sipType = sipType_QgsPointCloudRgbRenderer;
329 else if ( type == QLatin1String(
"ramp" ) )
330 sipType = sipType_QgsPointCloudAttributeByRampRenderer;
331 else if ( type == QLatin1String(
"classified" ) )
332 sipType = sipType_QgsPointCloudClassifiedRenderer;
333 else if ( type == QLatin1String(
"extent" ) )
334 sipType = sipType_QgsPointCloudExtentRenderer;
352 virtual QString
type()
const = 0;
387 virtual
bool willRenderPoint( const QMap<QString, QVariant> &pointAttributes )
389 Q_UNUSED( pointAttributes );
423 virtual std::unique_ptr< QgsPreparedPointCloudRendererData > prepare()
SIP_SKIP;
453 virtual
bool legendItemChecked( const QString &key );
460 virtual
void checkLegendItem( const QString &key,
bool state = true );
468 void setPointSize(
double size ) { mPointSize = size; }
554 double maximumScreenError()
const;
566 void setMaximumScreenError(
double error );
592 virtual QStringList legendRuleKeys()
const;
659 const qint32 ix = *
reinterpret_cast< const qint32 *
>( ptr + i * context.
pointRecordSize() + context.
xOffset() );
660 const qint32 iy = *
reinterpret_cast< const qint32 *
>( ptr + i * context.
pointRecordSize() + context.
yOffset() );
672 const qint32 iz = *
reinterpret_cast<const qint32 *
>( ptr + i * context.
pointRecordSize() + context.
zOffset() );
681 const QPointF originalXY( x, y );
684 switch ( mPointSymbol )
687 painter->fillRect( QRectF( x - mPainterPenWidth * 0.5,
688 y - mPainterPenWidth * 0.5,
689 mPainterPenWidth, mPainterPenWidth ), color );
693 painter->setBrush( QBrush( color ) );
694 painter->setPen( Qt::NoPen );
695 painter->drawEllipse( QRectF( x - mPainterPenWidth * 0.5,
696 y - mPainterPenWidth * 0.5,
697 mPainterPenWidth, mPainterPenWidth ) );
722 void restoreCommonProperties(
const QDomElement &element,
const QgsReadWriteContext &context );
730 void saveCommonProperties( QDomElement &element,
const QgsReadWriteContext &context )
const;
739 QThread *mThread =
nullptr;
742 double mMaximumScreenError = 0.3;
745 double mPointSize = 1;
750 int mPainterPenWidth = 1;
753 bool mEyeDomeLightingEnabled =
false;
754 double mEyeDomeLightingStrength = 1000.0;
755 double mEyeDomeLightingDistance = 0.5;
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.
Stores digital elevation model in a raster image which may get updated as a part of map layer renderi...
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.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
void transformInPlace(double &x, double &y) const
Transforms device coordinates to map coordinates.
Struct for storing maximum and minimum scales for measurements in map units.
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 cannot be copied.
QgsPointCloudRenderContext(const QgsPointCloudRenderContext &rh)=delete
QgsPointCloudRenderContext cannot be copied.
QgsElevationMap * elevationMap()
Returns elevation map.
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.
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.
virtual void renderBlock(const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context)=0
Renders a block of point cloud data using the specified render context.
void setPointSizeUnit(const QgsUnitTypes::RenderUnit units)
Sets the units used for the point size.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting effect will be used.
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 setPointSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the point size.
QgsPointCloudRenderer()=default
Constructor for QgsPointCloudRenderer.
QgsUnitTypes::RenderUnit eyeDomeLightingDistanceUnit() const
Returns unit for the eye dome lighting distance.
virtual QString type() const =0
Returns the identifier of the renderer type.
QgsPointCloudRenderer(const QgsPointCloudRenderer &other)=delete
QgsPointCloudRenderer cannot be copied – use clone() instead.
virtual QgsPointCloudRenderer * clone() const =0
Create a deep copy of this renderer.
QgsUnitTypes::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
void setEyeDomeLightingDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets unit for the eye dome lighting distance.
void setEyeDomeLightingDistance(double distance)
Sets the eye dome lighting distance.
virtual ~QgsPointCloudRenderer()=default
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 setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
bool eyeDomeLightingEnabled() const
Returns whether eye dome lighting effect will be used.
double eyeDomeLightingStrength() const
Returns the eye dome lighting strength value.
double pointSize() const
Returns the point size.
double eyeDomeLightingDistance() const
Returns the eye dome lighting distance.
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.
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.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
RenderUnit
Rendering size units.
@ RenderMillimeters
Millimeters.
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)