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