QGIS API Documentation 3.99.0-Master (357b655ed83)
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 <QString>
34
35using namespace Qt::StringLiterals;
36
38
39class QgsAlgorithmElevationProfilePlotItem : public Qgs2DXyPlot
40{
41 public:
42 explicit QgsAlgorithmElevationProfilePlotItem( int width, int height, int dpi )
43 : mDpi( dpi )
44 {
45 setYMinimum( 0 );
46 setYMaximum( 10 );
47 setSize( QSizeF( width, height ) );
48 }
49
50 void setRenderer( QgsProfilePlotRenderer *renderer )
51 {
52 mRenderer = renderer;
53 }
54
55 QRectF plotArea()
56 {
57 if ( !mPlotArea.isNull() )
58 {
59 return mPlotArea;
60 }
61
62 // calculate plot area
63 QgsRenderContext context;
64 context.setScaleFactor( mDpi / 25.4 );
65
66 QgsPlotRenderContext plotContext;
67 calculateOptimisedIntervals( context, plotContext );
68 mPlotArea = interiorPlotArea( context, plotContext );
69 return mPlotArea;
70 }
71
72 void renderContent( QgsRenderContext &rc, QgsPlotRenderContext &, const QRectF &plotArea, const QgsPlotData & ) override
73 {
74 mPlotArea = plotArea;
75
76 if ( !mRenderer )
77 return;
78
79 rc.painter()->translate( mPlotArea.left(), mPlotArea.top() );
80 const QStringList sourceIds = mRenderer->sourceIds();
81 for ( const QString &source : sourceIds )
82 {
83 mRenderer->render( rc, mPlotArea.width(), mPlotArea.height(), xMinimum(), xMaximum(), yMinimum(), yMaximum(), source );
84 }
85 rc.painter()->translate( -mPlotArea.left(), -mPlotArea.top() );
86 }
87
88 private:
89 int mDpi = 96;
90 QRectF mPlotArea;
91 QgsProfilePlotRenderer *mRenderer = nullptr;
92};
93
94void QgsGenerateElevationProfileAlgorithm::initAlgorithm( const QVariantMap & )
95{
96 addParameter( new QgsProcessingParameterGeometry( u"CURVE"_s, QObject::tr( "Profile curve" ), QVariant(), false, QList<int>() << static_cast<int>( Qgis::GeometryType::Line ) ) );
97 addParameter( new QgsProcessingParameterMultipleLayers( u"MAP_LAYERS"_s, QObject::tr( "Map layers" ), Qgis::ProcessingSourceType::MapLayer, QVariant(), false ) );
98 addParameter( new QgsProcessingParameterNumber( u"WIDTH"_s, QObject::tr( "Chart width (in pixels)" ), Qgis::ProcessingNumberParameterType::Integer, 400, false, 0 ) );
99 addParameter( new QgsProcessingParameterNumber( u"HEIGHT"_s, QObject::tr( "Chart height (in pixels)" ), Qgis::ProcessingNumberParameterType::Integer, 300, false, 0 ) );
100 addParameter( 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 ) ) );
101
102 auto minimumDistanceParam = std::make_unique<QgsProcessingParameterNumber>( u"MINIMUM_DISTANCE"_s, QObject::tr( "Chart minimum distance (X axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
103 minimumDistanceParam->setFlags( minimumDistanceParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
104 addParameter( minimumDistanceParam.release() );
105 auto maximumDistanceParam = std::make_unique<QgsProcessingParameterNumber>( u"MAXIMUM_DISTANCE"_s, QObject::tr( "Chart maximum distance (X axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
106 maximumDistanceParam->setFlags( maximumDistanceParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
107 addParameter( maximumDistanceParam.release() );
108 auto minimumElevationParam = std::make_unique<QgsProcessingParameterNumber>( u"MINIMUM_ELEVATION"_s, QObject::tr( "Chart minimum elevation (Y axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
109 minimumElevationParam->setFlags( minimumElevationParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
110 addParameter( minimumElevationParam.release() );
111 auto maximumElevationParam = std::make_unique<QgsProcessingParameterNumber>( u"MAXIMUM_ELEVATION"_s, QObject::tr( "Chart maximum elevation (Y axis)" ), Qgis::ProcessingNumberParameterType::Double, QVariant(), true );
112 maximumElevationParam->setFlags( maximumElevationParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
113 addParameter( maximumElevationParam.release() );
114
115 auto textColorParam = std::make_unique<QgsProcessingParameterColor>( u"TEXT_COLOR"_s, QObject::tr( "Chart text color" ), QColor( 0, 0, 0 ), true, true );
116 textColorParam->setFlags( textColorParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
117 addParameter( textColorParam.release() );
118
119 auto textFontFamilyParam = std::make_unique<QgsProcessingParameterString>( u"TEXT_FONT_FAMILY"_s, QObject::tr( "Chart text font family" ), QVariant(), false, true );
120 textFontFamilyParam->setFlags( textFontFamilyParam->flags() | Qgis::ProcessingParameterFlag::Hidden );
121 addParameter( textFontFamilyParam.release() );
122
123 auto textFontStyleParam = std::make_unique<QgsProcessingParameterString>( u"TEXT_FONT_STYLE"_s, QObject::tr( "Chart text font style" ), QVariant(), false, true );
124 textFontStyleParam->setFlags( textFontStyleParam->flags() | Qgis::ProcessingParameterFlag::Hidden );
125 addParameter( textFontStyleParam.release() );
126
127 auto textFontSizeParam = std::make_unique<QgsProcessingParameterNumber>( u"TEXT_FONT_SIZE"_s, QObject::tr( "Chart text font size" ), Qgis::ProcessingNumberParameterType::Double, 0, true );
128 textFontSizeParam->setFlags( textFontSizeParam->flags() | Qgis::ProcessingParameterFlag::Hidden );
129 addParameter( textFontSizeParam.release() );
130
131 auto backgroundColorParam = std::make_unique<QgsProcessingParameterColor>( u"BACKGROUND_COLOR"_s, QObject::tr( "Chart background color" ), QColor( 255, 255, 255 ), true, true );
132 backgroundColorParam->setFlags( backgroundColorParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
133 addParameter( backgroundColorParam.release() );
134 auto borderColorParam = std::make_unique<QgsProcessingParameterColor>( u"BORDER_COLOR"_s, QObject::tr( "Chart border color" ), QColor( 99, 99, 99 ), true, true );
135 borderColorParam->setFlags( borderColorParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
136 addParameter( borderColorParam.release() );
137
138 auto toleranceParam = std::make_unique<QgsProcessingParameterNumber>( u"TOLERANCE"_s, QObject::tr( "Profile tolerance" ), Qgis::ProcessingNumberParameterType::Double, 5.0, false, 0 );
139 toleranceParam->setFlags( toleranceParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
140 addParameter( toleranceParam.release() );
141
142 auto dpiParam = std::make_unique<QgsProcessingParameterNumber>( u"DPI"_s, QObject::tr( "Chart DPI" ), Qgis::ProcessingNumberParameterType::Integer, 96, false, 0 );
143 dpiParam->setFlags( dpiParam->flags() | Qgis::ProcessingParameterFlag::Advanced );
144 addParameter( dpiParam.release() );
145
146 addParameter( new QgsProcessingParameterFileDestination( u"OUTPUT"_s, QObject::tr( "Output image" ) ) );
147}
148
149QString QgsGenerateElevationProfileAlgorithm::name() const
150{
151 return u"generateelevationprofileimage"_s;
152}
153
154QString QgsGenerateElevationProfileAlgorithm::displayName() const
155{
156 return QObject::tr( "Generate elevation profile image" );
157}
158
159QStringList QgsGenerateElevationProfileAlgorithm::tags() const
160{
161 return QObject::tr( "altitude,elevation,terrain,dem" ).split( ',' );
162}
163
164QString QgsGenerateElevationProfileAlgorithm::group() const
165{
166 return QObject::tr( "Plots" );
167}
168
169QString QgsGenerateElevationProfileAlgorithm::groupId() const
170{
171 return u"plots"_s;
172}
173
174QString QgsGenerateElevationProfileAlgorithm::shortHelpString() const
175{
176 return QObject::tr( "This algorithm creates an elevation profile image from a list of map layer and an optional terrain." );
177}
178
179QString QgsGenerateElevationProfileAlgorithm::shortDescription() const
180{
181 return QObject::tr( "Creates an elevation profile image from a list of map layer and an optional terrain." );
182}
183
184QgsGenerateElevationProfileAlgorithm *QgsGenerateElevationProfileAlgorithm::createInstance() const
185{
186 return new QgsGenerateElevationProfileAlgorithm();
187}
188
189bool QgsGenerateElevationProfileAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
190{
191 const QgsGeometry curveGeom = parameterAsGeometry( parameters, u"CURVE"_s, context );
192 const QgsCoordinateReferenceSystem curveCrs = parameterAsGeometryCrs( parameters, u"CURVE"_s, context );
193
194 QList<QgsMapLayer *> layers = parameterAsLayerList( parameters, u"MAP_LAYERS"_s, context );
195 QgsMapLayer *terrainLayer = parameterAsLayer( parameters, u"TERRAIN_LAYER"_s, context );
196
197 const double tolerance = parameterAsDouble( parameters, u"TOLERANCE"_s, context );
198
199 QList<QgsAbstractProfileSource *> sources;
200 for ( QgsMapLayer *layer : layers )
201 {
202 if ( QgsAbstractProfileSource *source = layer->profileSource() )
203 sources.append( source );
204 }
205
206 QgsProfileRequest request( static_cast<QgsCurve *>( curveGeom.constGet()->clone() ) );
207 request.setCrs( curveCrs );
208 request.setTolerance( tolerance );
209 request.setTransformContext( context.transformContext() );
210 request.setExpressionContext( context.expressionContext() );
211
212 if ( terrainLayer )
213 {
214 if ( QgsRasterLayer *rasterLayer = dynamic_cast<QgsRasterLayer *>( terrainLayer ) )
215 {
216 auto terrainProvider = std::make_unique<QgsRasterDemTerrainProvider>();
217 terrainProvider->setLayer( rasterLayer );
218 request.setTerrainProvider( terrainProvider.release() );
219 }
220 else if ( QgsMeshLayer *meshLayer = dynamic_cast<QgsMeshLayer *>( terrainLayer ) )
221 {
222 auto terrainProvider = std::make_unique<QgsMeshTerrainProvider>();
223 terrainProvider->setLayer( meshLayer );
224 request.setTerrainProvider( terrainProvider.release() );
225 }
226 }
227
228
229 mRenderer = std::make_unique<QgsProfilePlotRenderer>( sources, request );
230
231 return true;
232}
233
234QVariantMap QgsGenerateElevationProfileAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
235{
236 const QgsGeometry curveGeom = parameterAsGeometry( parameters, u"CURVE"_s, context );
237
238 const bool hasMinimumDistance = parameters.value( u"MINIMUM_DISTANCE"_s ).isValid();
239 const double minimumDistance = parameterAsDouble( parameters, u"MINIMUM_DISTANCE"_s, context );
240 const bool hasMaximumDistance = parameters.value( u"MAXIMUM_DISTANCE"_s ).isValid();
241 const double maximumDistance = parameterAsDouble( parameters, u"MAXIMUM_DISTANCE"_s, context );
242 const bool hasMinimumElevation = parameters.value( u"MINIMUM_ELEVATION"_s ).isValid();
243 const double minimumElevation = parameterAsDouble( parameters, u"MINIMUM_ELEVATION"_s, context );
244 const bool hasMaximumElevation = parameters.value( u"MAXIMUM_ELEVATION"_s ).isValid();
245 const double maximumElevation = parameterAsDouble( parameters, u"MAXIMUM_ELEVATION"_s, context );
246
247 const int width = parameterAsInt( parameters, u"WIDTH"_s, context );
248 const int height = parameterAsInt( parameters, u"HEIGHT"_s, context );
249 const int dpi = parameterAsInt( parameters, u"DPI"_s, context );
250
251 const QString outputImage = parameterAsString( parameters, u"OUTPUT"_s, context );
252
253 const QColor textColor = parameterAsColor( parameters, u"TEXT_COLOR"_s, context );
254 const QColor backgroundColor = parameterAsColor( parameters, u"BACKGROUND_COLOR"_s, context );
255 const QColor borderColor = parameterAsColor( parameters, u"BORDER_COLOR"_s, context );
256
257 QgsAlgorithmElevationProfilePlotItem plotItem( width, height, dpi );
258
259 const QString textFontFamily = parameterAsString( parameters, u"TEXT_FONT_FAMILY"_s, context );
260 const QString textFontStyle = parameterAsString( parameters, u"TEXT_FONT_STYLE"_s, context );
261 const double textFontSize = parameterAsDouble( parameters, u"TEXT_FONT_SIZE"_s, context );
262
263 if ( !textFontFamily.isEmpty() || !textFontStyle.isEmpty() || textFontSize > 0 )
264 {
265 QgsTextFormat textFormat = plotItem.xAxis().textFormat();
266 QFont font = textFormat.font();
267 if ( !textFontFamily.isEmpty() )
268 {
269 QgsFontUtils::setFontFamily( font, textFontFamily );
270 }
271 if ( !textFontStyle.isEmpty() )
272 {
273 QgsFontUtils::updateFontViaStyle( font, textFontStyle );
274 }
275 textFormat.setFont( font );
276 if ( textFontSize > 0 )
277 {
278 textFormat.setSize( textFontSize );
280 }
281
282 plotItem.xAxis().setTextFormat( textFormat );
283 plotItem.yAxis().setTextFormat( textFormat );
284 }
285
286 if ( textColor.isValid() )
287 {
288 QgsTextFormat textFormat = plotItem.xAxis().textFormat();
289 textFormat.setColor( textColor );
290 plotItem.xAxis().setTextFormat( textFormat );
291 textFormat = plotItem.yAxis().textFormat();
292 textFormat.setColor( textColor );
293 plotItem.yAxis().setTextFormat( textFormat );
294 }
295
296 if ( borderColor.isValid() )
297 {
298 auto lineSymbolLayer = std::make_unique<QgsSimpleLineSymbolLayer>( borderColor, 0.1 );
299 lineSymbolLayer->setPenCapStyle( Qt::FlatCap );
300 plotItem.xAxis().setGridMinorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
301 plotItem.yAxis().setGridMinorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
302 plotItem.xAxis().setGridMajorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
303 plotItem.yAxis().setGridMajorSymbol( new QgsLineSymbol( QgsSymbolLayerList( { lineSymbolLayer->clone() } ) ) );
304 plotItem.setChartBorderSymbol( new QgsFillSymbol( QgsSymbolLayerList( { lineSymbolLayer.release() } ) ) );
305 }
306
307 if ( backgroundColor.isValid() )
308 {
309 auto fillSymbolLayer = std::make_unique<QgsSimpleFillSymbolLayer>( backgroundColor, Qt::SolidPattern, backgroundColor );
310 plotItem.setChartBackgroundSymbol( new QgsFillSymbol( QgsSymbolLayerList( { fillSymbolLayer.release() } ) ) );
311 }
312
313 QgsProfileGenerationContext generationContext;
314 generationContext.setDpi( dpi );
315 generationContext.setMaximumErrorMapUnits( MAX_ERROR_PIXELS * ( curveGeom.constGet()->length() ) / plotItem.plotArea().width() );
316 generationContext.setMapUnitsPerDistancePixel( curveGeom.constGet()->length() / plotItem.plotArea().width() );
317
318 mRenderer->setContext( generationContext );
319
320 mRenderer->startGeneration();
321 mRenderer->waitForFinished();
322
323 const QgsDoubleRange zRange = mRenderer->zRange();
324 double zMinimum = 0;
325 double zMaximum = 0;
326 if ( zRange.upper() < zRange.lower() )
327 {
328 // invalid range, e.g. no features found in plot!
329 zMinimum = 0;
330 zMaximum = 10;
331 }
332 else if ( qgsDoubleNear( zRange.lower(), zRange.upper(), 0.0000001 ) )
333 {
334 // corner case ... a zero height plot! Just pick an arbitrary +/- 5 height range.
335 zMinimum = zRange.lower() - 5;
336 zMaximum = zRange.lower() + 5;
337 }
338 else
339 {
340 // add 5% margin to height range
341 const double margin = ( zRange.upper() - zRange.lower() ) * 0.05;
342 zMinimum = zRange.lower() - margin;
343 zMaximum = zRange.upper() + margin;
344 }
345
346 plotItem.setYMinimum( hasMinimumElevation ? minimumElevation : zMinimum );
347 plotItem.setYMaximum( hasMaximumElevation ? maximumElevation : zMaximum );
348 plotItem.setXMinimum( hasMinimumDistance ? minimumDistance : 0 );
349 plotItem.setXMaximum( hasMaximumDistance ? maximumDistance : curveGeom.constGet()->length() );
350
351 plotItem.setRenderer( mRenderer.get() );
352
353 QImage image( static_cast<int>( plotItem.size().width() ), static_cast<int>( plotItem.size().height() ), QImage::Format_ARGB32_Premultiplied );
354 image.fill( Qt::transparent );
355
356 QPainter painter( &image );
357 painter.setRenderHint( QPainter::Antialiasing, true );
358 QgsRenderContext renderContext = QgsRenderContext::fromQPainter( &painter );
359 renderContext.setScaleFactor( dpi / 25.4 );
360 renderContext.setExpressionContext( context.expressionContext() );
361 QgsPlotRenderContext plotContext;
362 plotItem.calculateOptimisedIntervals( renderContext, plotContext );
363 plotItem.render( renderContext, plotContext );
364 painter.end();
365 image.save( outputImage );
366
367 QVariantMap outputs;
368 outputs.insert( u"OUTPUT"_s, outputImage );
369 return outputs;
370}
371
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer).
Definition qgis.h:3603
@ Mesh
Mesh layers.
Definition qgis.h:3611
@ Raster
Raster layers.
Definition qgis.h:3608
@ Line
Lines.
Definition qgis.h:367
@ Points
Points (e.g., for font sizes).
Definition qgis.h:5295
@ Hidden
Parameter is hidden and should not be shown to users.
Definition qgis.h:3835
@ Advanced
Parameter is an advanced parameter which should be hidden from users by default.
Definition qgis.h:3834
@ Double
Double/float values.
Definition qgis.h:3875
virtual void renderContent(QgsRenderContext &context, QgsPlotRenderContext &plotContext, const QRectF &plotArea, const QgsPlotData &plotData=QgsPlotData())
Renders the plot content.
Definition qgsplot.cpp:267
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:278
Base class for 2-dimensional plot/chart/graphs with an X and Y axes.
Definition qgsplot.h:659
double yMaximum() const
Returns the maximum value of the y axis.
Definition qgsplot.h:742
void setYMinimum(double minimum)
Sets the minimum value of the y axis.
Definition qgsplot.h:721
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:893
double yMinimum() const
Returns the minimum value of the y axis.
Definition qgsplot.h:714
QRectF interiorPlotArea(QgsRenderContext &context, QgsPlotRenderContext &plotContext) const override
Returns the area of the plot which corresponds to the actual plot content (excluding all titles and o...
Definition qgsplot.cpp:764
void setYMaximum(double maximum)
Sets the maximum value of the y axis.
Definition qgsplot.h:749
double xMaximum() const
Returns the maximum value of the x axis.
Definition qgsplot.h:728
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:236
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:184
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.
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:81
T upper() const
Returns the upper bound of the range.
Definition qgsrange.h:88
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:6935
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition qgssymbol.h:30