QGIS API Documentation 4.1.0-Master (26185ffb827)
Loading...
Searching...
No Matches
qgsalgorithmgenerateelevationprofile.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmgenerateelevationprofile.cpp
3 ---------------------
4 begin : October 2024
5 copyright : (C) 2024 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
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
19
20#include "qgis.h"
22#include "qgscurve.h"
23#include "qgsfillsymbol.h"
24#include "qgsfillsymbollayer.h"
25#include "qgsfontutils.h"
26#include "qgslinesymbol.h"
27#include "qgslinesymbollayer.h"
28#include "qgsplot.h"
29#include "qgsprofilerequest.h"
30#include "qgsterrainprovider.h"
31#include "qgstextformat.h"
32
33#include <QImageWriter>
34#include <QString>
35
36using namespace Qt::StringLiterals;
37
39
40class QgsAlgorithmElevationProfilePlotItem : public Qgs2DXyPlot
41{
42 public:
43 explicit QgsAlgorithmElevationProfilePlotItem( int width, int height, int dpi )
44 : mDpi( dpi )
45 {
46 setYMinimum( 0 );
47 setYMaximum( 10 );
48 setSize( QSizeF( width, height ) );
49 }
50
51 void setRenderer( QgsProfilePlotRenderer *renderer ) { mRenderer = renderer; }
52
53 QRectF plotArea()
54 {
55 if ( !mPlotArea.isNull() )
56 {
57 return mPlotArea;
58 }
59
60 // calculate plot area
61 QgsRenderContext context;
62 context.setScaleFactor( mDpi / 25.4 );
63
64 QgsPlotRenderContext plotContext;
65 calculateOptimisedIntervals( context, plotContext );
66 mPlotArea = interiorPlotArea( context, plotContext );
67 return mPlotArea;
68 }
69
70 void renderContent( QgsRenderContext &rc, QgsPlotRenderContext &, const QRectF &plotArea, const QgsPlotData & ) override
71 {
72 mPlotArea = plotArea;
73
74 if ( !mRenderer )
75 return;
76
77 rc.painter()->translate( mPlotArea.left(), mPlotArea.top() );
78 const QStringList sourceIds = mRenderer->sourceIds();
79 for ( const QString &source : sourceIds )
80 {
81 mRenderer->render( rc, mPlotArea.width(), mPlotArea.height(), xMinimum(), xMaximum(), yMinimum(), yMaximum(), source );
82 }
83 rc.painter()->translate( -mPlotArea.left(), -mPlotArea.top() );
84 }
85
86 private:
87 int mDpi = 96;
88 QRectF mPlotArea;
89 QgsProfilePlotRenderer *mRenderer = nullptr;
90};
91
92void QgsGenerateElevationProfileAlgorithm::initAlgorithm( const QVariantMap & )
93{
94 addParameter( new QgsProcessingParameterGeometry( u"CURVE"_s, QObject::tr( "Profile curve" ), QVariant(), false, QList<int>() << static_cast<int>( Qgis::GeometryType::Line ) ) );
95 addParameter( new QgsProcessingParameterMultipleLayers( u"MAP_LAYERS"_s, QObject::tr( "Map layers" ), Qgis::ProcessingSourceType::MapLayer, QVariant(), false ) );
96 addParameter( new QgsProcessingParameterNumber( u"WIDTH"_s, QObject::tr( "Chart width (in pixels)" ), Qgis::ProcessingNumberParameterType::Integer, 400, false, 0 ) );
97 addParameter( new QgsProcessingParameterNumber( u"HEIGHT"_s, QObject::tr( "Chart height (in pixels)" ), Qgis::ProcessingNumberParameterType::Integer, 300, false, 0 ) );
98 addParameter(
99 new QgsProcessingParameterMapLayer( u"TERRAIN_LAYER"_s, QObject::tr( "Terrain layer" ), QVariant(), true, QList<int>() << static_cast<int>( Qgis::ProcessingSourceType::Raster ) << static_cast<int>( Qgis::ProcessingSourceType::Mesh ) )
100 );
101
102 auto minimumDistanceParam
103 = std::make_unique<QgsProcessingParameterNumber>( u"MINIMUM_DISTANCE"_s, QObject::tr( "Chart minimum distance (X axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
104 minimumDistanceParam->setFlags( minimumDistanceParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
105 addParameter( minimumDistanceParam.release() );
106 auto maximumDistanceParam
107 = std::make_unique<QgsProcessingParameterNumber>( u"MAXIMUM_DISTANCE"_s, QObject::tr( "Chart maximum distance (X axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
108 maximumDistanceParam->setFlags( maximumDistanceParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
109 addParameter( maximumDistanceParam.release() );
110 auto minimumElevationParam
111 = std::make_unique<QgsProcessingParameterNumber>( u"MINIMUM_ELEVATION"_s, QObject::tr( "Chart minimum elevation (Y axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
112 minimumElevationParam->setFlags( minimumElevationParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
113 addParameter( minimumElevationParam.release() );
114 auto maximumElevationParam
115 = std::make_unique<QgsProcessingParameterNumber>( u"MAXIMUM_ELEVATION"_s, QObject::tr( "Chart maximum elevation (Y axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
116 maximumElevationParam->setFlags( maximumElevationParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
117 addParameter( maximumElevationParam.release() );
118
119 auto textColorParam = std::make_unique<QgsProcessingParameterColor>( u"TEXT_COLOR"_s, QObject::tr( "Chart text color" ), QColor( 0, 0, 0 ), true, true );
120 textColorParam->setFlags( textColorParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
121 addParameter( textColorParam.release() );
122
123 auto textFontFamilyParam = std::make_unique<QgsProcessingParameterString>( u"TEXT_FONT_FAMILY"_s, QObject::tr( "Chart text font family" ), QVariant(), false, true );
124 textFontFamilyParam->setFlags( textFontFamilyParam->flags() | Qgis::ProcessingParameterFlag::Hidden );
125 addParameter( textFontFamilyParam.release() );
126
127 auto textFontStyleParam = std::make_unique<QgsProcessingParameterString>( u"TEXT_FONT_STYLE"_s, QObject::tr( "Chart text font style" ), QVariant(), false, true );
128 textFontStyleParam->setFlags( textFontStyleParam->flags() | Qgis::ProcessingParameterFlag::Hidden );
129 addParameter( textFontStyleParam.release() );
130
131 auto textFontSizeParam = std::make_unique<QgsProcessingParameterNumber>( u"TEXT_FONT_SIZE"_s, QObject::tr( "Chart text font size" ), Qgis::ProcessingNumberParameterType::Double, 0, true );
132 textFontSizeParam->setFlags( textFontSizeParam->flags() | Qgis::ProcessingParameterFlag::Hidden );
133 addParameter( textFontSizeParam.release() );
134
135 auto backgroundColorParam = std::make_unique<QgsProcessingParameterColor>( u"BACKGROUND_COLOR"_s, QObject::tr( "Chart background color" ), QColor( 255, 255, 255 ), true, true );
136 backgroundColorParam->setFlags( backgroundColorParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
137 addParameter( backgroundColorParam.release() );
138 auto borderColorParam = std::make_unique<QgsProcessingParameterColor>( u"BORDER_COLOR"_s, QObject::tr( "Chart border color" ), QColor( 99, 99, 99 ), true, true );
139 borderColorParam->setFlags( borderColorParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
140 addParameter( borderColorParam.release() );
141
142 auto toleranceParam = std::make_unique<QgsProcessingParameterNumber>( u"TOLERANCE"_s, QObject::tr( "Profile tolerance" ), Qgis::ProcessingNumberParameterType::Double, 5.0, false, 0 );
143 toleranceParam->setFlags( toleranceParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
144 addParameter( toleranceParam.release() );
145
146 auto dpiParam = std::make_unique<QgsProcessingParameterNumber>( u"DPI"_s, QObject::tr( "Chart DPI" ), Qgis::ProcessingNumberParameterType::Integer, 96, false, 0 );
147 dpiParam->setFlags( dpiParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
148 addParameter( dpiParam.release() );
149
150 addParameter( new QgsProcessingParameterFileDestination( u"OUTPUT"_s, QObject::tr( "Output image" ), QgsProcessingUtils::supportedImageFileFilters() ) );
151}
152
153QString QgsGenerateElevationProfileAlgorithm::name() const
154{
155 return u"generateelevationprofileimage"_s;
156}
157
158QString QgsGenerateElevationProfileAlgorithm::displayName() const
159{
160 return QObject::tr( "Generate elevation profile image" );
161}
162
163QStringList QgsGenerateElevationProfileAlgorithm::tags() const
164{
165 return QObject::tr( "altitude,elevation,terrain,dem" ).split( ',' );
166}
167
168QString QgsGenerateElevationProfileAlgorithm::group() const
169{
170 return QObject::tr( "Plots" );
171}
172
173QString QgsGenerateElevationProfileAlgorithm::groupId() const
174{
175 return u"plots"_s;
176}
177
178QString QgsGenerateElevationProfileAlgorithm::shortHelpString() const
179{
180 return QObject::tr( "This algorithm creates an elevation profile image from a list of map layer and an optional terrain." );
181}
182
183QString QgsGenerateElevationProfileAlgorithm::shortDescription() const
184{
185 return QObject::tr( "Creates an elevation profile image from a list of map layer and an optional terrain." );
186}
187
188QgsGenerateElevationProfileAlgorithm *QgsGenerateElevationProfileAlgorithm::createInstance() const
189{
190 return new QgsGenerateElevationProfileAlgorithm();
191}
192
193bool QgsGenerateElevationProfileAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
194{
195 const QgsGeometry curveGeom = parameterAsGeometry( parameters, u"CURVE"_s, context );
196 const QgsCoordinateReferenceSystem curveCrs = parameterAsGeometryCrs( parameters, u"CURVE"_s, context );
197
198 QList<QgsMapLayer *> layers = parameterAsLayerList( parameters, u"MAP_LAYERS"_s, context );
199 QgsMapLayer *terrainLayer = parameterAsLayer( parameters, u"TERRAIN_LAYER"_s, context );
200
201 const double tolerance = parameterAsDouble( parameters, u"TOLERANCE"_s, context );
202
203 QList<QgsAbstractProfileSource *> sources;
204 for ( QgsMapLayer *layer : layers )
205 {
206 if ( QgsAbstractProfileSource *source = layer->profileSource() )
207 sources.append( source );
208 }
209
210 QgsProfileRequest request( static_cast<QgsCurve *>( curveGeom.constGet()->clone() ) );
211 request.setCrs( curveCrs );
212 request.setTolerance( tolerance );
213 request.setTransformContext( context.transformContext() );
214 request.setExpressionContext( context.expressionContext() );
215
216 if ( terrainLayer )
217 {
218 if ( QgsRasterLayer *rasterLayer = dynamic_cast<QgsRasterLayer *>( terrainLayer ) )
219 {
220 auto terrainProvider = std::make_unique<QgsRasterDemTerrainProvider>();
221 terrainProvider->setLayer( rasterLayer );
222 request.setTerrainProvider( terrainProvider.release() );
223 }
224 else if ( QgsMeshLayer *meshLayer = dynamic_cast<QgsMeshLayer *>( terrainLayer ) )
225 {
226 auto terrainProvider = std::make_unique<QgsMeshTerrainProvider>();
227 terrainProvider->setLayer( meshLayer );
228 request.setTerrainProvider( terrainProvider.release() );
229 }
230 }
231
232
233 mRenderer = std::make_unique<QgsProfilePlotRenderer>( sources, request );
234
235 return true;
236}
237
238QVariantMap QgsGenerateElevationProfileAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
239{
240 const QgsGeometry curveGeom = parameterAsGeometry( parameters, u"CURVE"_s, context );
241
242 const bool hasMinimumDistance = parameters.value( u"MINIMUM_DISTANCE"_s ).isValid();
243 const double minimumDistance = parameterAsDouble( parameters, u"MINIMUM_DISTANCE"_s, context );
244 const bool hasMaximumDistance = parameters.value( u"MAXIMUM_DISTANCE"_s ).isValid();
245 const double maximumDistance = parameterAsDouble( parameters, u"MAXIMUM_DISTANCE"_s, context );
246 const bool hasMinimumElevation = parameters.value( u"MINIMUM_ELEVATION"_s ).isValid();
247 const double minimumElevation = parameterAsDouble( parameters, u"MINIMUM_ELEVATION"_s, context );
248 const bool hasMaximumElevation = parameters.value( u"MAXIMUM_ELEVATION"_s ).isValid();
249 const double maximumElevation = parameterAsDouble( parameters, u"MAXIMUM_ELEVATION"_s, context );
250
251 const int width = parameterAsInt( parameters, u"WIDTH"_s, context );
252 const int height = parameterAsInt( parameters, u"HEIGHT"_s, context );
253 const int dpi = parameterAsInt( parameters, u"DPI"_s, context );
254
255 const QString outputImage = parameterAsString( parameters, u"OUTPUT"_s, context );
256
257 const QColor textColor = parameterAsColor( parameters, u"TEXT_COLOR"_s, context );
258 const QColor backgroundColor = parameterAsColor( parameters, u"BACKGROUND_COLOR"_s, context );
259 const QColor borderColor = parameterAsColor( parameters, u"BORDER_COLOR"_s, context );
260
261 QgsAlgorithmElevationProfilePlotItem plotItem( width, height, dpi );
262
263 const QString textFontFamily = parameterAsString( parameters, u"TEXT_FONT_FAMILY"_s, context );
264 const QString textFontStyle = parameterAsString( parameters, u"TEXT_FONT_STYLE"_s, context );
265 const double textFontSize = parameterAsDouble( parameters, u"TEXT_FONT_SIZE"_s, context );
266
267 if ( !textFontFamily.isEmpty() || !textFontStyle.isEmpty() || textFontSize > 0 )
268 {
269 QgsTextFormat textFormat = plotItem.xAxis().textFormat();
270 QFont font = textFormat.font();
271 if ( !textFontFamily.isEmpty() )
272 {
273 QgsFontUtils::setFontFamily( font, textFontFamily );
274 }
275 if ( !textFontStyle.isEmpty() )
276 {
277 QgsFontUtils::updateFontViaStyle( font, textFontStyle );
278 }
279 textFormat.setFont( font );
280 if ( textFontSize > 0 )
281 {
282 textFormat.setSize( textFontSize );
284 }
285
286 plotItem.xAxis().setTextFormat( textFormat );
287 plotItem.yAxis().setTextFormat( textFormat );
288 }
289
290 if ( textColor.isValid() )
291 {
292 QgsTextFormat textFormat = plotItem.xAxis().textFormat();
293 textFormat.setColor( textColor );
294 plotItem.xAxis().setTextFormat( textFormat );
295 textFormat = plotItem.yAxis().textFormat();
296 textFormat.setColor( textColor );
297 plotItem.yAxis().setTextFormat( textFormat );
298 }
299
300 if ( borderColor.isValid() )
301 {
302 auto lineSymbolLayer = std::make_unique<QgsSimpleLineSymbolLayer>( borderColor, 0.1 );
303 lineSymbolLayer->setPenCapStyle( Qt::FlatCap );
304 plotItem.xAxis().setGridMinorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
305 plotItem.yAxis().setGridMinorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
306 plotItem.xAxis().setGridMajorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
307 plotItem.yAxis().setGridMajorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
308 plotItem.setChartBorderSymbol( new QgsFillSymbol( QgsSymbolLayerList( { lineSymbolLayer.release() } ) ) );
309 }
310
311 if ( backgroundColor.isValid() )
312 {
313 auto fillSymbolLayer = std::make_unique<QgsSimpleFillSymbolLayer>( backgroundColor, Qt::SolidPattern, backgroundColor );
314 plotItem.setChartBackgroundSymbol( new QgsFillSymbol( QgsSymbolLayerList( { fillSymbolLayer.release() } ) ) );
315 }
316
317 QgsProfileGenerationContext generationContext;
318 generationContext.setDpi( dpi );
319 generationContext.setMaximumErrorMapUnits( MAX_ERROR_PIXELS * ( curveGeom.constGet()->length() ) / plotItem.plotArea().width() );
320 generationContext.setMapUnitsPerDistancePixel( curveGeom.constGet()->length() / plotItem.plotArea().width() );
321
322 mRenderer->setContext( generationContext );
323
324 mRenderer->startGeneration();
325 mRenderer->waitForFinished();
326
327 const QgsDoubleRange zRange = mRenderer->zRange();
328 double zMinimum = 0;
329 double zMaximum = 0;
330 if ( zRange.upper() < zRange.lower() )
331 {
332 // invalid range, e.g. no features found in plot!
333 zMinimum = 0;
334 zMaximum = 10;
335 }
336 else if ( qgsDoubleNear( zRange.lower(), zRange.upper(), 0.0000001 ) )
337 {
338 // corner case ... a zero height plot! Just pick an arbitrary +/- 5 height range.
339 zMinimum = zRange.lower() - 5;
340 zMaximum = zRange.lower() + 5;
341 }
342 else
343 {
344 // add 5% margin to height range
345 const double margin = ( zRange.upper() - zRange.lower() ) * 0.05;
346 zMinimum = zRange.lower() - margin;
347 zMaximum = zRange.upper() + margin;
348 }
349
350 plotItem.setYMinimum( hasMinimumElevation ? minimumElevation : zMinimum );
351 plotItem.setYMaximum( hasMaximumElevation ? maximumElevation : zMaximum );
352 plotItem.setXMinimum( hasMinimumDistance ? minimumDistance : 0 );
353 plotItem.setXMaximum( hasMaximumDistance ? maximumDistance : curveGeom.constGet()->length() );
354
355 plotItem.setRenderer( mRenderer.get() );
356
357 QImage image( static_cast<int>( plotItem.size().width() ), static_cast<int>( plotItem.size().height() ), QImage::Format_ARGB32_Premultiplied );
358 image.fill( Qt::transparent );
359
360 QPainter painter( &image );
361 painter.setRenderHint( QPainter::Antialiasing, true );
362 QgsRenderContext renderContext = QgsRenderContext::fromQPainter( &painter );
363 renderContext.setScaleFactor( dpi / 25.4 );
364 renderContext.setExpressionContext( context.expressionContext() );
365 QgsPlotRenderContext plotContext;
366 plotItem.calculateOptimisedIntervals( renderContext, plotContext );
367 plotItem.render( renderContext, plotContext );
368 painter.end();
369 image.save( outputImage );
370
371 QVariantMap outputs;
372 outputs.insert( u"OUTPUT"_s, outputImage );
373 return outputs;
374}
375
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer).
Definition qgis.h:3713
@ Mesh
Mesh layers.
Definition qgis.h:3721
@ Raster
Raster layers.
Definition qgis.h:3718
@ Line
Lines.
Definition qgis.h:381
@ Points
Points (e.g., for font sizes).
Definition qgis.h:5591
@ Hidden
Parameter is hidden and should not be shown to users.
Definition qgis.h:3948
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
Definition qgis.h:3947
@ Double
Double/float values.
Definition qgis.h:3988
virtual void renderContent(QgsRenderContext &context, QgsPlotRenderContext &plotContext, const QRectF &plotArea, const QgsPlotData &plotData=QgsPlotData())
Renders the plot content.
Definition qgsplot.cpp:310
void setSize(QSizeF size)
Sets the overall size of the plot (including titles and over components which sit outside the plot ar...
Definition qgsplot.cpp:320
Base class for 2-dimensional plot/chart/graphs with an X and Y axes.
Definition qgsplot.h:687
double yMaximum() const
Returns the maximum value of the y axis.
Definition qgsplot.h:769
void setYMinimum(double minimum)
Sets the minimum value of the y axis.
Definition qgsplot.h:748
void calculateOptimisedIntervals(QgsRenderContext &context, QgsPlotRenderContext &plotContext)
Automatically sets the grid and label intervals to optimal values for display in the given render con...
Definition qgsplot.cpp:1042
double yMinimum() const
Returns the minimum value of the y axis.
Definition qgsplot.h:741
QRectF interiorPlotArea(QgsRenderContext &context, QgsPlotRenderContext &plotContext, const QgsPlotData &plotData=QgsPlotData()) const override
Returns the area of the plot which corresponds to the actual plot content (excluding all titles and o...
Definition qgsplot.cpp:871
void setYMaximum(double maximum)
Sets the maximum value of the y axis.
Definition qgsplot.h:776
double xMaximum() const
Returns the maximum value of the x axis.
Definition qgsplot.h:755
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
Interface for classes which can generate elevation profiles.
Represents a coordinate reference system (CRS).
Abstract base class for curved geometry type.
Definition qgscurve.h:36
QgsRange which stores a range of double values.
Definition qgsrange.h:217
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
static void setFontFamily(QFont &font, const QString &family)
Sets the family for a font object.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
A line symbol type, for rendering LineString and MultiLineString geometries.
Base class for all map layer types.
Definition qgsmaplayer.h:83
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Contains information about the context of a plot rendering operation.
Definition qgsplot.h:191
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
Base class for providing feedback from a processing algorithm.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
A geometry parameter for processing algorithms.
A map layer parameter for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
A numeric parameter for processing algorithms.
static QString supportedImageFileFilters()
Returns a file filter string of all supported image formats, suitable for use in file picker dialogs.
Encapsulates the context in which an elevation profile is to be generated.
void setDpi(double dpi)
Sets the dpi (dots per inch) for the profie, to be used in size conversions.
void setMaximumErrorMapUnits(double error)
Sets the maximum allowed error in the generated result, in profile curve map units.
void setMapUnitsPerDistancePixel(double units)
Sets the number of map units per pixel in the distance dimension.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
T lower() const
Returns the lower bound of the range.
Definition qgsrange.h:79
T upper() const
Returns the upper bound of the range.
Definition qgsrange.h:86
Represents a raster layer.
Contains information about the context of a rendering operation.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
QPainter * painter()
Returns the destination QPainter for the render operation.
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setSize(double size)
Sets the size for rendered text.
void setFont(const QFont &font)
Sets the font used for rendering text.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the size of rendered text.
QFont font() const
Returns the font used for rendering text.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:7257
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition qgssymbol.h:30