QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgspointcloudrenderer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudrenderer.cpp
3 --------------------
4 begin : October 2020
5 copyright : (C) 2020 by Peter Petrik
6 email : zilolv at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
20#include "qgsapplication.h"
21#include "qgselevationmap.h"
22#include "qgssymbollayerutils.h"
23#include "qgspointcloudlayer.h"
24#include "qgspointcloudindex.h"
25#include "qgslogger.h"
26#include "qgscircle.h"
27#include "qgsunittypes.h"
28
29#include <QThread>
30#include <QPointer>
31
32QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset, QgsFeedback *feedback )
33 : mRenderContext( context )
34 , mScale( scale )
35 , mOffset( offset )
36 , mZValueScale( zValueScale )
37 , mZValueFixedOffset( zValueFixedOffset )
38 , mFeedback( feedback )
39{
40
41}
42
44{
45 return mPointsRendered;
46}
47
49{
50 mPointsRendered += count;
51}
52
54{
55 mAttributes = attributes;
56 mPointRecordSize = mAttributes.pointRecordSize();
57
58 // fetch offset for x/y/z attributes
59 attributes.find( QStringLiteral( "X" ), mXOffset );
60 attributes.find( QStringLiteral( "Y" ), mYOffset );
61 attributes.find( QStringLiteral( "Z" ), mZOffset );
62}
63
65{
66 if ( element.isNull() )
67 return nullptr;
68
69 // load renderer
70 const QString rendererType = element.attribute( QStringLiteral( "type" ) );
71
73 if ( !m )
74 return nullptr;
75
76 std::unique_ptr< QgsPointCloudRenderer > r( m->createRenderer( element, context ) );
77 return r.release();
78}
79
81{
82 return QSet< QString >();
83}
84
85std::unique_ptr<QgsPreparedPointCloudRendererData> QgsPointCloudRenderer::prepare()
86{
87 return nullptr;
88}
89
91{
92#ifdef QGISDEBUG
93 if ( !mThread )
94 {
95 mThread = QThread::currentThread();
96 }
97 else
98 {
99 Q_ASSERT_X( mThread == QThread::currentThread(), "QgsPointCloudRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
100 }
101#endif
102
103 mDefaultPainterPenWidth = context.renderContext().convertToPainterUnits( pointSize(), pointSizeUnit(), pointSizeMapUnitScale() );
104
105 switch ( mPointSymbol )
106 {
108 // for square point we always disable antialiasing -- it's not critical here and we benefit from the performance boost disabling it gives
109 context.renderContext().painter()->setRenderHint( QPainter::Antialiasing, false );
110 break;
111
113 break;
114 }
115}
116
118{
119#ifdef QGISDEBUG
120 Q_ASSERT_X( mThread == QThread::currentThread(), "QgsPointCloudRenderer::stopRender", "stopRender called in a different thread - use a cloned renderer instead" );
121#endif
122}
123
125{
126 return false;
127}
128
129void QgsPointCloudRenderer::checkLegendItem( const QString &, bool )
130{
131
132}
133
135{
136 return mMaximumScreenError;
137}
138
140{
141 mMaximumScreenError = error;
142}
143
145{
146 return mMaximumScreenErrorUnit;
147}
148
150{
151 mMaximumScreenErrorUnit = unit;
152}
153
154QList<QgsLayerTreeModelLegendNode *> QgsPointCloudRenderer::createLegendNodes( QgsLayerTreeLayer * )
155{
156 return QList<QgsLayerTreeModelLegendNode *>();
157}
158
160{
161 return QStringList();
162}
163
164void QgsPointCloudRenderer::drawPointToElevationMap( double x, double y, double z, QgsPointCloudRenderContext &context ) const
165{
166 drawPointToElevationMap( x, y, z, mDefaultPainterPenWidth, context );
167}
168
169void QgsPointCloudRenderer::drawPointToElevationMap( double x, double y, double z, int width, QgsPointCloudRenderContext &context ) const
170{
171 const QPointF originalXY( x, y );
172 context.renderContext().mapToPixel().transformInPlace( x, y );
173 QPainter *elevationPainter = context.renderContext().elevationMap()->painter();
174
175 QBrush brush( QgsElevationMap::encodeElevation( z ) );
176 switch ( mPointSymbol )
177 {
179 elevationPainter->fillRect( QRectF( x - width * 0.5,
180 y - width * 0.5,
181 width, width ), brush );
182 break;
183
185 elevationPainter->setBrush( brush );
186 elevationPainter->setPen( Qt::NoPen );
187 elevationPainter->drawEllipse( QRectF( x - width * 0.5,
188 y - width * 0.5,
189 width, width ) );
190 break;
191 };
192}
193
195{
196 destination->setPointSize( mPointSize );
197 destination->setPointSizeUnit( mPointSizeUnit );
198 destination->setPointSizeMapUnitScale( mPointSizeMapUnitScale );
199 destination->setMaximumScreenError( mMaximumScreenError );
200 destination->setMaximumScreenErrorUnit( mMaximumScreenErrorUnit );
201 destination->setPointSymbol( mPointSymbol );
202 destination->setDrawOrder2d( mDrawOrder2d );
203
204 destination->setRenderAsTriangles( mRenderAsTriangles );
205 destination->setHorizontalTriangleFilter( mHorizontalTriangleFilter );
206 destination->setHorizontalTriangleFilterThreshold( mHorizontalTriangleFilterThreshold );
207 destination->setHorizontalTriangleFilterUnit( mHorizontalTriangleFilterUnit );
208}
209
211{
212 mPointSize = element.attribute( QStringLiteral( "pointSize" ), QStringLiteral( "1" ) ).toDouble();
213 mPointSizeUnit = QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral( "pointSizeUnit" ), QStringLiteral( "MM" ) ) );
214 mPointSizeMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( element.attribute( QStringLiteral( "pointSizeMapUnitScale" ), QString() ) );
215
216 mMaximumScreenError = element.attribute( QStringLiteral( "maximumScreenError" ), QStringLiteral( "0.3" ) ).toDouble();
217 mMaximumScreenErrorUnit = QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral( "maximumScreenErrorUnit" ), QStringLiteral( "MM" ) ) );
218 mPointSymbol = static_cast< Qgis::PointCloudSymbol >( element.attribute( QStringLiteral( "pointSymbol" ), QStringLiteral( "0" ) ).toInt() );
219 mDrawOrder2d = static_cast< Qgis::PointCloudDrawOrder >( element.attribute( QStringLiteral( "drawOrder2d" ), QStringLiteral( "0" ) ).toInt() );
220
221 mRenderAsTriangles = element.attribute( QStringLiteral( "renderAsTriangles" ), QStringLiteral( "0" ) ).toInt();
222 mHorizontalTriangleFilter = element.attribute( QStringLiteral( "horizontalTriangleFilter" ), QStringLiteral( "0" ) ).toInt();
223 mHorizontalTriangleFilterThreshold = element.attribute( QStringLiteral( "horizontalTriangleFilterThreshold" ), QStringLiteral( "5" ) ).toDouble();
224 mHorizontalTriangleFilterUnit = QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral( "horizontalTriangleFilterUnit" ), QStringLiteral( "MM" ) ) );
225}
226
227void QgsPointCloudRenderer::saveCommonProperties( QDomElement &element, const QgsReadWriteContext & ) const
228{
229 element.setAttribute( QStringLiteral( "pointSize" ), qgsDoubleToString( mPointSize ) );
230 element.setAttribute( QStringLiteral( "pointSizeUnit" ), QgsUnitTypes::encodeUnit( mPointSizeUnit ) );
231 element.setAttribute( QStringLiteral( "pointSizeMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( mPointSizeMapUnitScale ) );
232
233 element.setAttribute( QStringLiteral( "maximumScreenError" ), qgsDoubleToString( mMaximumScreenError ) );
234 element.setAttribute( QStringLiteral( "maximumScreenErrorUnit" ), QgsUnitTypes::encodeUnit( mMaximumScreenErrorUnit ) );
235 element.setAttribute( QStringLiteral( "pointSymbol" ), QString::number( static_cast< int >( mPointSymbol ) ) );
236 element.setAttribute( QStringLiteral( "drawOrder2d" ), QString::number( static_cast< int >( mDrawOrder2d ) ) );
237
238 element.setAttribute( QStringLiteral( "renderAsTriangles" ), QString::number( static_cast< int >( mRenderAsTriangles ) ) );
239 element.setAttribute( QStringLiteral( "horizontalTriangleFilter" ), QString::number( static_cast< int >( mHorizontalTriangleFilter ) ) );
240 element.setAttribute( QStringLiteral( "horizontalTriangleFilterThreshold" ), qgsDoubleToString( mHorizontalTriangleFilterThreshold ) );
241 element.setAttribute( QStringLiteral( "horizontalTriangleFilterUnit" ), QgsUnitTypes::encodeUnit( mHorizontalTriangleFilterUnit ) );
242}
243
245{
246 return mPointSymbol;
247}
248
250{
251 mPointSymbol = symbol;
252}
253
255{
256 return mDrawOrder2d;
257}
258
260{
261 mDrawOrder2d = order;
262}
263
264QVector<QVariantMap> QgsPointCloudRenderer::identify( QgsPointCloudLayer *layer, const QgsRenderContext &renderContext, const QgsGeometry &geometry, double toleranceForPointIdentification )
265{
266 QVector<QVariantMap> selectedPoints;
267
268 QgsPointCloudIndex *index = layer->dataProvider()->index();
269
270 if ( !index || !index->isValid() )
271 return selectedPoints;
272
273 const IndexedPointCloudNode root = index->root();
274
275 const double maxErrorPixels = renderContext.convertToPainterUnits( maximumScreenError(), maximumScreenErrorUnit() );// in pixels
276
277 const QgsRectangle rootNodeExtentLayerCoords = index->nodeMapExtent( root );
278 QgsRectangle rootNodeExtentMapCoords;
279 if ( !renderContext.coordinateTransform().isShortCircuited() )
280 {
281 try
282 {
283 QgsCoordinateTransform extentTransform = renderContext.coordinateTransform();
284 extentTransform.setBallparkTransformsAreAppropriate( true );
285 rootNodeExtentMapCoords = extentTransform.transformBoundingBox( rootNodeExtentLayerCoords );
286 }
287 catch ( QgsCsException & )
288 {
289 QgsDebugError( QStringLiteral( "Could not transform node extent to map CRS" ) );
290 rootNodeExtentMapCoords = rootNodeExtentLayerCoords;
291 }
292 }
293 else
294 {
295 rootNodeExtentMapCoords = rootNodeExtentLayerCoords;
296 }
297
298 const double rootErrorInMapCoordinates = rootNodeExtentMapCoords.width() / index->span();
299 const double rootErrorInLayerCoordinates = rootNodeExtentLayerCoords.width() / index->span();
300
301 const double mapUnitsPerPixel = renderContext.mapToPixel().mapUnitsPerPixel();
302 if ( ( rootErrorInMapCoordinates < 0.0 ) || ( mapUnitsPerPixel < 0.0 ) || ( maxErrorPixels < 0.0 ) )
303 {
304 QgsDebugError( QStringLiteral( "invalid screen error" ) );
305 return selectedPoints;
306 }
307
308 const double maxErrorInMapCoordinates = maxErrorPixels * mapUnitsPerPixel;
309 const double maxErrorInLayerCoordinates = maxErrorInMapCoordinates * rootErrorInLayerCoordinates / rootErrorInMapCoordinates;
310
311 QgsGeometry selectionGeometry = geometry;
312 if ( geometry.type() == Qgis::GeometryType::Point )
313 {
314 const double x = geometry.asPoint().x();
315 const double y = geometry.asPoint().y();
316 const double toleranceInPixels = toleranceForPointIdentification / renderContext.mapToPixel().mapUnitsPerPixel();
317 const double pointSizePixels = renderContext.convertToPainterUnits( mPointSize, mPointSizeUnit, mPointSizeMapUnitScale );
318 switch ( pointSymbol() )
319 {
321 {
322 const QgsPointXY deviceCoords = renderContext.mapToPixel().transform( QgsPointXY( x, y ) );
323 const QgsPointXY point1( deviceCoords.x() - std::max( toleranceInPixels, pointSizePixels / 2.0 ), deviceCoords.y() - std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
324 const QgsPointXY point2( deviceCoords.x() + std::max( toleranceInPixels, pointSizePixels / 2.0 ), deviceCoords.y() + std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
325 const QgsPointXY point1MapCoords = renderContext.mapToPixel().toMapCoordinates( point1.x(), point1.y() );
326 const QgsPointXY point2MapCoords = renderContext.mapToPixel().toMapCoordinates( point2.x(), point2.y() );
327 const QgsRectangle pointRect( point1MapCoords, point2MapCoords );
328 selectionGeometry = QgsGeometry::fromRect( pointRect );
329 break;
330 }
332 {
333 const QgsPoint centerMapCoords( x, y );
334 const QgsPointXY deviceCoords = renderContext.mapToPixel().transform( centerMapCoords );
335 const QgsPoint point1( deviceCoords.x(), deviceCoords.y() - std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
336 const QgsPoint point2( deviceCoords.x(), deviceCoords.y() + std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
337 const QgsPointXY point1MapCoords = renderContext.mapToPixel().toMapCoordinates( point1.x(), point1.y() );
338 const QgsPointXY point2MapCoords = renderContext.mapToPixel().toMapCoordinates( point2.x(), point2.y() );
339 const QgsCircle circle = QgsCircle::from2Points( QgsPoint( point1MapCoords ), QgsPoint( point2MapCoords ) );
340 std::unique_ptr<QgsPolygon> polygon( circle.toPolygon( 6 ) );
341 const QgsGeometry circleGeometry( std::move( polygon ) );
342 selectionGeometry = circleGeometry;
343 break;
344 }
345 }
346 }
347
348 // selection geometry must be in layer CRS for QgsPointCloudDataProvider::identify
349 try
350 {
351 selectionGeometry.transform( renderContext.coordinateTransform(), Qgis::TransformDirection::Reverse );
352 }
353 catch ( QgsCsException & )
354 {
355 QgsDebugError( QStringLiteral( "Could not transform geometry to layer CRS" ) );
356 return selectedPoints;
357 }
358
359 selectedPoints = layer->dataProvider()->identify( maxErrorInLayerCoordinates, selectionGeometry, renderContext.zRange() );
360
361 selectedPoints.erase( std::remove_if( selectedPoints.begin(), selectedPoints.end(), [this]( const QMap<QString, QVariant> &point ) { return !this->willRenderPoint( point ); } ), selectedPoints.end() );
362
363 return selectedPoints;
364}
365
366//
367// QgsPreparedPointCloudRendererData
368//
Represents a indexed point cloud node in octree.
PointCloudSymbol
Rendering symbols for point cloud points.
Definition qgis.h:3654
@ Circle
Renders points as circles.
@ Square
Renders points as squares.
PointCloudDrawOrder
Pointcloud rendering order for 2d views.
Definition qgis.h:3666
RenderUnit
Rendering size units.
Definition qgis.h:4489
@ Reverse
Reverse/inverse transform (from destination to source)
static QgsPointCloudRendererRegistry * pointCloudRendererRegistry()
Returns the application's point cloud renderer registry, used for managing point cloud layer 2D rende...
Circle geometry type.
Definition qgscircle.h:43
static QgsCircle from2Points(const QgsPoint &pt1, const QgsPoint &pt2)
Constructs a circle by 2 points on the circle.
Definition qgscircle.cpp:38
Class for doing transforms between two map coordinate systems.
void setBallparkTransformsAreAppropriate(bool appropriate)
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.
bool isShortCircuited() const
Returns true if the transform short circuits because the source and destination are equivalent.
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const
Transforms a rectangle from the source CRS to the destination CRS.
Custom exception class for Coordinate Reference System related exceptions.
static QRgb encodeElevation(float z)
Converts elevation value to an actual color.
QPainter * painter() const
Returns painter to the underlying QImage with elevations.
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A geometry is the spatial representation of a feature.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
Qgis::GeometryType type
Layer tree node points to a map layer.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
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 device coordinates to map coordinates.
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.
QVector< QVariantMap > identify(double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange=QgsDoubleRange(), int pointsLimit=1000)
Returns the list of points of the point cloud according to a zoom level defined by maxError (in layer...
virtual QgsPointCloudIndex * index() const
Returns the point cloud index associated with the provider.
Represents a indexed point clouds data in octree.
int span() const
Returns the number of points in one direction in a single node.
QgsRectangle nodeMapExtent(const IndexedPointCloudNode &node) const
Returns the extent of a node in map coordinates.
virtual bool isValid() const =0
Returns whether index is loaded and valid.
IndexedPointCloudNode root()
Returns root node of the index.
Represents a map layer supporting display of point clouds.
QgsPointCloudDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
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.
long pointsRendered() const
Returns the total number of points rendered.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes associated with the rendered block.
QgsPointCloudRenderContext(QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset, QgsFeedback *feedback=nullptr)
Constructor for QgsPointCloudRenderContext.
void setAttributes(const QgsPointCloudAttributeCollection &attributes)
Sets the attributes associated with the rendered block.
Stores metadata about one point cloud renderer class.
virtual QgsPointCloudRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
QgsPointCloudRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
Abstract base class for 2d point cloud renderers.
virtual void checkLegendItem(const QString &key, bool state=true)
Called when the check state of the legend item with the specified key is changed.
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when rendering the point cloud.
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 restoreCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Restores common renderer properties (such as point size and screen error) from the specified DOM elem...
void setMaximumScreenErrorUnit(Qgis::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the point cloud.
void saveCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Saves common renderer properties (such as point size and screen error) to the specified DOM element.
const QgsMapUnitScale & pointSizeMapUnitScale() const
Returns the map unit scale used for the point size.
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.
void setHorizontalTriangleFilterThreshold(double threshold)
Sets threshold for filtering of triangles.
static QgsPointCloudRenderer * load(QDomElement &element, const QgsReadWriteContext &context)
Creates a renderer from an XML element.
void setHorizontalTriangleFilterUnit(Qgis::RenderUnit unit)
Sets units of the threshold for filtering of triangles.
Qgis::RenderUnit maximumScreenErrorUnit() const
Returns the unit for the maximum screen error allowed when rendering the point cloud.
void setDrawOrder2d(Qgis::PointCloudDrawOrder order)
Sets the drawing order used by the renderer for drawing points.
virtual QStringList legendRuleKeys() const
Returns a list of all rule keys for legend nodes created by the renderer.
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.
void setRenderAsTriangles(bool asTriangles)
Sets whether points are triangulated to render solid surface.
void copyCommonProperties(QgsPointCloudRenderer *destination) const
Copies common point cloud properties (such as point size and screen error) to the destination rendere...
void setPointSymbol(Qgis::PointCloudSymbol symbol)
Sets the symbol used by the renderer for drawing points.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the point cloud.
Qgis::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
Qgis::PointCloudSymbol pointSymbol() const
Returns the symbol used by the renderer for drawing points.
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.
Qgis::PointCloudDrawOrder drawOrder2d() const
Returns the drawing order used by the renderer for drawing points.
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer)
Creates a set of legend nodes representing the renderer.
void setHorizontalTriangleFilter(bool enabled)
Sets whether large triangles will get rendered.
double pointSize() const
Returns the point size.
A class to represent a 2D point.
Definition qgspointxy.h:60
double y
Definition qgspointxy.h:64
double x
Definition qgspointxy.h:63
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
double x
Definition qgspoint.h:52
double y
Definition qgspoint.h:53
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
double width() const
Returns the width of the rectangle.
Contains information about the context of a rendering operation.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsElevationMap * elevationMap() const
Returns the destination elevation map for the render operation.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsDoubleRange zRange() const
Returns the range of z-values which should be rendered.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition qgis.h:5362
#define QgsDebugError(str)
Definition qgslogger.h:38