QGIS API Documentation 3.29.0-Master (53715c36dc)
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"
26#include "qgslogger.h"
27#include "qgscircle.h"
28#include <QThread>
29#include <QPointer>
30
31QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset, QgsFeedback *feedback )
32 : mRenderContext( context )
33 , mScale( scale )
34 , mOffset( offset )
35 , mZValueScale( zValueScale )
36 , mZValueFixedOffset( zValueFixedOffset )
37 , mFeedback( feedback )
38{
39
40}
41
43{
44 mElevationMap.reset( elevationMap );
45}
46
48{
49 return mPointsRendered;
50}
51
53{
54 mPointsRendered += count;
55}
56
58{
59 mAttributes = attributes;
60 mPointRecordSize = mAttributes.pointRecordSize();
61
62 // fetch offset for x/y/z attributes
63 attributes.find( QStringLiteral( "X" ), mXOffset );
64 attributes.find( QStringLiteral( "Y" ), mYOffset );
65 attributes.find( QStringLiteral( "Z" ), mZOffset );
66}
67
69{
70 if ( element.isNull() )
71 return nullptr;
72
73 // load renderer
74 const QString rendererType = element.attribute( QStringLiteral( "type" ) );
75
77 if ( !m )
78 return nullptr;
79
80 std::unique_ptr< QgsPointCloudRenderer > r( m->createRenderer( element, context ) );
81 return r.release();
82}
83
85{
86 return QSet< QString >();
87}
88
89std::unique_ptr<QgsPreparedPointCloudRendererData> QgsPointCloudRenderer::prepare()
90{
91 return nullptr;
92}
93
95{
96#ifdef QGISDEBUG
97 if ( !mThread )
98 {
99 mThread = QThread::currentThread();
100 }
101 else
102 {
103 Q_ASSERT_X( mThread == QThread::currentThread(), "QgsPointCloudRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
104 }
105#endif
106
108
109 switch ( mPointSymbol )
110 {
112 // for square point we always disable antialiasing -- it's not critical here and we benefit from the performance boost disabling it gives
113 context.renderContext().painter()->setRenderHint( QPainter::Antialiasing, false );
114 break;
115
117 break;
118 }
119}
120
122{
123#ifdef QGISDEBUG
124 Q_ASSERT_X( mThread == QThread::currentThread(), "QgsPointCloudRenderer::stopRender", "stopRender called in a different thread - use a cloned renderer instead" );
125#endif
126}
127
129{
130 return false;
131}
132
133void QgsPointCloudRenderer::checkLegendItem( const QString &, bool )
134{
135
136}
137
139{
140 return mMaximumScreenError;
141}
142
144{
145 mMaximumScreenError = error;
146}
147
149{
150 return mMaximumScreenErrorUnit;
151}
152
154{
155 mMaximumScreenErrorUnit = unit;
156}
157
158QList<QgsLayerTreeModelLegendNode *> QgsPointCloudRenderer::createLegendNodes( QgsLayerTreeLayer * )
159{
160 return QList<QgsLayerTreeModelLegendNode *>();
161}
162
164{
165 return QStringList();
166}
167
168void QgsPointCloudRenderer::drawPointToElevationMap( double x, double y, double z, QgsPointCloudRenderContext &context ) const
169{
170 const QPointF originalXY( x, y );
171 context.renderContext().mapToPixel().transformInPlace( x, y );
172 QPainter *elevationPainter = context.elevationMap()->painter();
173
174 QBrush brush( QgsElevationMap::encodeElevation( z ) );
175 switch ( mPointSymbol )
176 {
178 elevationPainter->fillRect( QRectF( x - mPainterPenWidth * 0.5,
179 y - mPainterPenWidth * 0.5,
180 mPainterPenWidth, mPainterPenWidth ), brush );
181 break;
182
184 elevationPainter->setBrush( brush );
185 elevationPainter->setPen( Qt::NoPen );
186 elevationPainter->drawEllipse( QRectF( x - mPainterPenWidth * 0.5,
187 y - mPainterPenWidth * 0.5,
188 mPainterPenWidth, mPainterPenWidth ) );
189 break;
190 };
191}
192
194{
195 destination->setPointSize( mPointSize );
196 destination->setPointSizeUnit( mPointSizeUnit );
197 destination->setPointSizeMapUnitScale( mPointSizeMapUnitScale );
198 destination->setMaximumScreenError( mMaximumScreenError );
199 destination->setMaximumScreenErrorUnit( mMaximumScreenErrorUnit );
200 destination->setPointSymbol( mPointSymbol );
201 destination->setDrawOrder2d( mDrawOrder2d );
202 destination->setEyeDomeLightingEnabled( mEyeDomeLightingEnabled );
203 destination->setEyeDomeLightingStrength( mEyeDomeLightingStrength );
204 destination->setEyeDomeLightingDistance( mEyeDomeLightingDistance );
205 destination->setEyeDomeLightingDistanceUnit( mEyeDomeLightingDistanceUnit );
206}
207
209{
210 mPointSize = element.attribute( QStringLiteral( "pointSize" ), QStringLiteral( "1" ) ).toDouble();
211 mPointSizeUnit = QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral( "pointSizeUnit" ), QStringLiteral( "MM" ) ) );
212 mPointSizeMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( element.attribute( QStringLiteral( "pointSizeMapUnitScale" ), QString() ) );
213
214 mMaximumScreenError = element.attribute( QStringLiteral( "maximumScreenError" ), QStringLiteral( "0.3" ) ).toDouble();
215 mMaximumScreenErrorUnit = QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral( "maximumScreenErrorUnit" ), QStringLiteral( "MM" ) ) );
216 mPointSymbol = static_cast< Qgis::PointCloudSymbol >( element.attribute( QStringLiteral( "pointSymbol" ), QStringLiteral( "0" ) ).toInt() );
217 mDrawOrder2d = static_cast< Qgis::PointCloudDrawOrder >( element.attribute( QStringLiteral( "drawOrder2d" ), QStringLiteral( "0" ) ).toInt() );
218 mEyeDomeLightingEnabled = element.attribute( QStringLiteral( "use-eye-dome-lighting" ), QStringLiteral( "0" ) ).toInt();
219 mEyeDomeLightingStrength = element.attribute( QStringLiteral( "eye-dome-lighting-strength" ), QStringLiteral( "1000" ) ).toInt();
220 mEyeDomeLightingDistance = element.attribute( QStringLiteral( "eye-dome-lighting-distance" ), QStringLiteral( "0.5" ) ).toDouble();
221 mEyeDomeLightingDistanceUnit = QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral( "eye-dome-lighting-distance-unit" ) ) );
222}
223
224void QgsPointCloudRenderer::saveCommonProperties( QDomElement &element, const QgsReadWriteContext & ) const
225{
226 element.setAttribute( QStringLiteral( "pointSize" ), qgsDoubleToString( mPointSize ) );
227 element.setAttribute( QStringLiteral( "pointSizeUnit" ), QgsUnitTypes::encodeUnit( mPointSizeUnit ) );
228 element.setAttribute( QStringLiteral( "pointSizeMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( mPointSizeMapUnitScale ) );
229
230 element.setAttribute( QStringLiteral( "maximumScreenError" ), qgsDoubleToString( mMaximumScreenError ) );
231 element.setAttribute( QStringLiteral( "maximumScreenErrorUnit" ), QgsUnitTypes::encodeUnit( mMaximumScreenErrorUnit ) );
232 element.setAttribute( QStringLiteral( "pointSymbol" ), QString::number( static_cast< int >( mPointSymbol ) ) );
233 element.setAttribute( QStringLiteral( "drawOrder2d" ), QString::number( static_cast< int >( mDrawOrder2d ) ) );
234 element.setAttribute( QStringLiteral( "use-eye-dome-lighting" ), QString::number( mEyeDomeLightingEnabled ) );
235 element.setAttribute( QStringLiteral( "eye-dome-lighting-strength" ), QString::number( mEyeDomeLightingStrength ) );
236 element.setAttribute( QStringLiteral( "eye-dome-lighting-distance" ), QString::number( mEyeDomeLightingDistance ) );
237 element.setAttribute( QStringLiteral( "eye-dome-lighting-distance-unit" ), QgsUnitTypes::encodeUnit( mEyeDomeLightingDistanceUnit ) );
238}
239
241{
242 return mPointSymbol;
243}
244
246{
247 mPointSymbol = symbol;
248}
249
251{
252 return mDrawOrder2d;
253}
254
256{
257 mDrawOrder2d = order;
258}
259
260QVector<QVariantMap> QgsPointCloudRenderer::identify( QgsPointCloudLayer *layer, const QgsRenderContext &renderContext, const QgsGeometry &geometry, double toleranceForPointIdentification )
261{
262 QVector<QVariantMap> selectedPoints;
263
264 QgsPointCloudIndex *index = layer->dataProvider()->index();
265 const IndexedPointCloudNode root = index->root();
266
267 const double maxErrorPixels = renderContext.convertToPainterUnits( maximumScreenError(), maximumScreenErrorUnit() );// in pixels
268
269 const QgsRectangle rootNodeExtentLayerCoords = index->nodeMapExtent( root );
270 QgsRectangle rootNodeExtentMapCoords;
271 if ( !renderContext.coordinateTransform().isShortCircuited() )
272 {
273 try
274 {
275 QgsCoordinateTransform extentTransform = renderContext.coordinateTransform();
276 extentTransform.setBallparkTransformsAreAppropriate( true );
277 rootNodeExtentMapCoords = extentTransform.transformBoundingBox( rootNodeExtentLayerCoords );
278 }
279 catch ( QgsCsException & )
280 {
281 QgsDebugMsg( QStringLiteral( "Could not transform node extent to map CRS" ) );
282 rootNodeExtentMapCoords = rootNodeExtentLayerCoords;
283 }
284 }
285 else
286 {
287 rootNodeExtentMapCoords = rootNodeExtentLayerCoords;
288 }
289
290 const double rootErrorInMapCoordinates = rootNodeExtentMapCoords.width() / index->span();
291 const double rootErrorInLayerCoordinates = rootNodeExtentLayerCoords.width() / index->span();
292
293 const double mapUnitsPerPixel = renderContext.mapToPixel().mapUnitsPerPixel();
294 if ( ( rootErrorInMapCoordinates < 0.0 ) || ( mapUnitsPerPixel < 0.0 ) || ( maxErrorPixels < 0.0 ) )
295 {
296 QgsDebugMsg( QStringLiteral( "invalid screen error" ) );
297 return selectedPoints;
298 }
299
300 const double maxErrorInMapCoordinates = maxErrorPixels * mapUnitsPerPixel;
301 const double maxErrorInLayerCoordinates = maxErrorInMapCoordinates * rootErrorInLayerCoordinates / rootErrorInMapCoordinates;
302
303 QgsGeometry selectionGeometry = geometry;
304 if ( geometry.type() == QgsWkbTypes::PointGeometry )
305 {
306 const double x = geometry.asPoint().x();
307 const double y = geometry.asPoint().y();
308 const double toleranceInPixels = toleranceForPointIdentification / renderContext.mapToPixel().mapUnitsPerPixel();
309 const double pointSizePixels = renderContext.convertToPainterUnits( mPointSize, mPointSizeUnit, mPointSizeMapUnitScale );
310 switch ( pointSymbol() )
311 {
313 {
314 const QgsPointXY deviceCoords = renderContext.mapToPixel().transform( QgsPointXY( x, y ) );
315 const QgsPointXY point1( deviceCoords.x() - std::max( toleranceInPixels, pointSizePixels / 2.0 ), deviceCoords.y() - std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
316 const QgsPointXY point2( deviceCoords.x() + std::max( toleranceInPixels, pointSizePixels / 2.0 ), deviceCoords.y() + std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
317 const QgsPointXY point1MapCoords = renderContext.mapToPixel().toMapCoordinates( point1.x(), point1.y() );
318 const QgsPointXY point2MapCoords = renderContext.mapToPixel().toMapCoordinates( point2.x(), point2.y() );
319 const QgsRectangle pointRect( point1MapCoords, point2MapCoords );
320 selectionGeometry = QgsGeometry::fromRect( pointRect );
321 break;
322 }
324 {
325 const QgsPoint centerMapCoords( x, y );
326 const QgsPointXY deviceCoords = renderContext.mapToPixel().transform( centerMapCoords );
327 const QgsPoint point1( deviceCoords.x(), deviceCoords.y() - std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
328 const QgsPoint point2( deviceCoords.x(), deviceCoords.y() + std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
329 const QgsPointXY point1MapCoords = renderContext.mapToPixel().toMapCoordinates( point1.x(), point1.y() );
330 const QgsPointXY point2MapCoords = renderContext.mapToPixel().toMapCoordinates( point2.x(), point2.y() );
331 const QgsCircle circle = QgsCircle::from2Points( QgsPoint( point1MapCoords ), QgsPoint( point2MapCoords ) );
332 std::unique_ptr<QgsPolygon> polygon( circle.toPolygon( 6 ) );
333 const QgsGeometry circleGeometry( std::move( polygon ) );
334 selectionGeometry = circleGeometry;
335 break;
336 }
337 }
338 }
339
340 // selection geometry must be in layer CRS for QgsPointCloudDataProvider::identify
341 try
342 {
343 selectionGeometry.transform( renderContext.coordinateTransform(), Qgis::TransformDirection::Reverse );
344 }
345 catch ( QgsCsException & )
346 {
347 QgsDebugMsg( QStringLiteral( "Could not transform geometry to layer CRS" ) );
348 return selectedPoints;
349 }
350
351 selectedPoints = layer->dataProvider()->identify( maxErrorInLayerCoordinates, selectionGeometry, renderContext.zRange() );
352
353 selectedPoints.erase( std::remove_if( selectedPoints.begin(), selectedPoints.end(), [this]( const QMap<QString, QVariant> &point ) { return !this->willRenderPoint( point ); } ), selectedPoints.end() );
354
355 return selectedPoints;
356}
357
358//
359// QgsPreparedPointCloudRendererData
360//
Represents a indexed point cloud node in octree.
PointCloudSymbol
Rendering symbols for point cloud points.
Definition: qgis.h:2276
@ Circle
Renders points as circles.
@ Square
Renders points as squares.
PointCloudDrawOrder
Pointcloud rendering order for 2d views.
Definition: qgis.h:2288
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:44
static QgsCircle from2Points(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
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 SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:66
Stores digital elevation model in a raster image which may get updated as a part of map layer renderi...
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.
Definition: qgsellipse.cpp:224
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:164
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:167
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.
Definition: qgsmaptopixel.h:90
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.
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.
void setElevationMap(QgsElevationMap *elevationMap)
Sets elevation map that will be used to record elevation of rendered points.
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.
QgsElevationMap * elevationMap()
Returns elevation map.
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 setPointSizeUnit(const QgsUnitTypes::RenderUnit units)
Sets the units used for the point size.
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 setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting effect will be used.
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.
static QgsPointCloudRenderer * load(QDomElement &element, const QgsReadWriteContext &context)
Creates a renderer from an XML element.
QgsUnitTypes::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.
QgsUnitTypes::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
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 setEyeDomeLightingDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets unit for the eye dome lighting distance.
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.
void setEyeDomeLightingDistance(double distance)
Sets the eye dome lighting distance.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the point cloud.
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength value.
void setMaximumScreenErrorUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the point cloud.
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.
double pointSize() const
Returns the point size.
A class to represent a 2D point.
Definition: qgspointxy.h:59
double y
Definition: qgspointxy.h:63
Q_GADGET double x
Definition: qgspointxy.h:62
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
Q_GADGET 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.
Definition: qgsrectangle.h:42
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
Definition: qgsrectangle.h:223
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
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 QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition: qgis.h:2719
#define QgsDebugMsg(str)
Definition: qgslogger.h:38