QGIS API Documentation 3.43.0-Master (b60ef06885e)
Classes | Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsProfilePlotRenderer Class Reference

Generates and renders elevation profile plots. More...

#include <qgsprofilerenderer.h>

Inheritance diagram for QgsProfilePlotRenderer:
Inheritance graph
[legend]

Signals

void generationFinished ()
 Emitted when the profile generation is finished (or canceled).
 

Public Member Functions

 QgsProfilePlotRenderer (const QList< QgsAbstractProfileSource * > &sources, const QgsProfileRequest &request)
 Constructor for QgsProfilePlotRenderer, using the provided list of profile sources to generate the results.
 
 QgsProfilePlotRenderer (std::vector< std::unique_ptr< QgsAbstractProfileGenerator > > generators, const QgsProfileRequest &request)
 Constructor for QgsProfilePlotRenderer, using the provided list of profile generators to generate the results.
 
 ~QgsProfilePlotRenderer () override
 
QVector< QgsAbstractProfileResults::FeatureasFeatures (Qgis::ProfileExportType type, QgsFeedback *feedback=nullptr)
 Exports the profile results as a set of features.
 
void cancelGeneration ()
 Stop the generation job - does not return until the job has terminated.
 
void cancelGenerationWithoutBlocking ()
 Triggers cancellation of the generation job without blocking.
 
void generateSynchronously ()
 Generate the profile results synchronously in this thread.
 
QVector< QgsProfileIdentifyResultsidentify (const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context)
 Identify results visible within the specified ranges.
 
QVector< QgsProfileIdentifyResultsidentify (const QgsProfilePoint &point, const QgsProfileIdentifyContext &context)
 Identify results visible at the specified profile point.
 
void invalidateAllRefinableSources ()
 Invalidates previous results from all refinable sources.
 
bool invalidateResults (QgsAbstractProfileSource *source)
 Invalidates the profile results from the source with matching ID.
 
bool isActive () const
 Returns true if the generation job is currently running in background.
 
void regenerateInvalidatedResults ()
 Starts a background regeneration of any invalidated results and immediately returns.
 
void render (QgsRenderContext &context, double width, double height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId=QString())
 Renders a portion of the profile using the specified render context.
 
void renderSubsectionsIndicator (QgsRenderContext &context, const QRectF &plotArea, double distanceMin, double distanceMax, double zMin, double zMax)
 Renders the vertices of the profile curve as vertical lines using the specified render context.
 
QImage renderToImage (int width, int height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId=QString(), double devicePixelRatio=1.0)
 Renders a portion of the profile to an image with the given width and height.
 
void replaceSource (QgsAbstractProfileSource *source)
 Replaces the existing source with matching ID.
 
void setContext (const QgsProfileGenerationContext &context)
 Sets the context in which the profile generation will occur.
 
void setSubsectionsSymbol (QgsLineSymbol *symbol)
 Sets the symbol used to draw the subsections.
 
QgsProfileSnapResult snapPoint (const QgsProfilePoint &point, const QgsProfileSnapContext &context)
 Snap a point to the results.
 
QStringList sourceIds () const
 Returns the ordered list of source IDs for the sources used by the renderer.
 
void startGeneration ()
 Start the generation job and immediately return.
 
QgsLineSymbolsubsectionsSymbol ()
 Returns the line symbol used to draw the subsections.
 
void waitForFinished ()
 Block until the current job has finished.
 
QgsDoubleRange zRange () const
 Returns the limits of the retrieved elevation values.
 

Static Public Member Functions

static std::unique_ptr< QgsLineSymboldefaultSubSectionsSymbol ()
 Returns the default line symbol to use for subsections lines.
 

Detailed Description

Generates and renders elevation profile plots.

This class has two roles:

  1. Extraction and generation of the raw elevation profiles from a list of QgsAbstractProfileSource objects.
  2. Rendering the results

Step 1, involving the generation of the elevation profiles only needs to occur once. This is done via a call to startGeneration(), which commences generation of the profiles from each source in a separate background thread. When the generation is completed for all sources the generationFinished() signal is emitted.

After the profile is generated, it can be rendered. The rendering step may be undertaken multiple times (e.g. to render to different image sizes or data ranges) without having to re-generate the raw profile data.

Since
QGIS 3.26

Definition at line 59 of file qgsprofilerenderer.h.

Constructor & Destructor Documentation

◆ QgsProfilePlotRenderer() [1/2]

QgsProfilePlotRenderer::QgsProfilePlotRenderer ( const QList< QgsAbstractProfileSource * > &  sources,
const QgsProfileRequest request 
)

Constructor for QgsProfilePlotRenderer, using the provided list of profile sources to generate the results.

Definition at line 28 of file qgsprofilerenderer.cpp.

◆ QgsProfilePlotRenderer() [2/2]

QgsProfilePlotRenderer::QgsProfilePlotRenderer ( std::vector< std::unique_ptr< QgsAbstractProfileGenerator > >  generators,
const QgsProfileRequest request 
)

Constructor for QgsProfilePlotRenderer, using the provided list of profile generators to generate the results.

Note
Not available in Python bindings
Since
QGIS 3.32

Definition at line 42 of file qgsprofilerenderer.cpp.

◆ ~QgsProfilePlotRenderer()

QgsProfilePlotRenderer::~QgsProfilePlotRenderer ( )
override

Definition at line 48 of file qgsprofilerenderer.cpp.

Member Function Documentation

◆ asFeatures()

QVector< QgsAbstractProfileResults::Feature > QgsProfilePlotRenderer::asFeatures ( Qgis::ProfileExportType  type,
QgsFeedback feedback = nullptr 
)

Exports the profile results as a set of features.

Since
QGIS 3.32

Definition at line 481 of file qgsprofilerenderer.cpp.

◆ cancelGeneration()

void QgsProfilePlotRenderer::cancelGeneration ( )

Stop the generation job - does not return until the job has terminated.

Does nothing if the generation is not active.

Definition at line 116 of file qgsprofilerenderer.cpp.

◆ cancelGenerationWithoutBlocking()

void QgsProfilePlotRenderer::cancelGenerationWithoutBlocking ( )

Triggers cancellation of the generation job without blocking.

The generation job will continue to operate until it is able to cancel, at which stage the generationFinished() signal will be emitted. Does nothing if the generation is not active.

Definition at line 139 of file qgsprofilerenderer.cpp.

◆ defaultSubSectionsSymbol()

std::unique_ptr< QgsLineSymbol > QgsProfilePlotRenderer::defaultSubSectionsSymbol ( )
static

Returns the default line symbol to use for subsections lines.

See also
setSubsectionsSymbol()
Since
QGIS 3.44

Definition at line 368 of file qgsprofilerenderer.cpp.

◆ generateSynchronously()

void QgsProfilePlotRenderer::generateSynchronously ( )

Generate the profile results synchronously in this thread.

The function does not return until the generation is complete.

This is an alternative to ordinary API (using startGeneration() + waiting for generationFinished() signal). Users are discouraged to use this method unless they have a strong reason for doing it. The synchronous generation blocks the main thread, making the application unresponsive. Also, it is not possible to cancel generation while it is in progress.

Since
QGIS 3.30

Definition at line 91 of file qgsprofilerenderer.cpp.

◆ generationFinished

void QgsProfilePlotRenderer::generationFinished ( )
signal

Emitted when the profile generation is finished (or canceled).

◆ identify() [1/2]

QVector< QgsProfileIdentifyResults > QgsProfilePlotRenderer::identify ( const QgsDoubleRange distanceRange,
const QgsDoubleRange elevationRange,
const QgsProfileIdentifyContext context 
)

Identify results visible within the specified ranges.

Definition at line 462 of file qgsprofilerenderer.cpp.

◆ identify() [2/2]

QVector< QgsProfileIdentifyResults > QgsProfilePlotRenderer::identify ( const QgsProfilePoint point,
const QgsProfileIdentifyContext context 
)

Identify results visible at the specified profile point.

Definition at line 443 of file qgsprofilerenderer.cpp.

◆ invalidateAllRefinableSources()

void QgsProfilePlotRenderer::invalidateAllRefinableSources ( )

Invalidates previous results from all refinable sources.

Definition at line 201 of file qgsprofilerenderer.cpp.

◆ invalidateResults()

bool QgsProfilePlotRenderer::invalidateResults ( QgsAbstractProfileSource source)

Invalidates the profile results from the source with matching ID.

The matching stored source will be deleted and replaced with source.

Returns true if results were previously stored for the matching source and have been invalidated.

See also
regenerateInvalidatedResults()

Definition at line 227 of file qgsprofilerenderer.cpp.

◆ isActive()

bool QgsProfilePlotRenderer::isActive ( ) const

Returns true if the generation job is currently running in background.

Definition at line 167 of file qgsprofilerenderer.cpp.

◆ regenerateInvalidatedResults()

void QgsProfilePlotRenderer::regenerateInvalidatedResults ( )

Starts a background regeneration of any invalidated results and immediately returns.

Does nothing if the generation is already in progress.

See also
invalidateResults()

Definition at line 274 of file qgsprofilerenderer.cpp.

◆ render()

void QgsProfilePlotRenderer::render ( QgsRenderContext context,
double  width,
double  height,
double  distanceMin,
double  distanceMax,
double  zMin,
double  zMax,
const QString &  sourceId = QString() 
)

Renders a portion of the profile using the specified render context.

If sourceId is empty then all sources will be rendered, otherwise only the matching source will be rendered.

Definition at line 337 of file qgsprofilerenderer.cpp.

◆ renderSubsectionsIndicator()

void QgsProfilePlotRenderer::renderSubsectionsIndicator ( QgsRenderContext context,
const QRectF &  plotArea,
double  distanceMin,
double  distanceMax,
double  zMin,
double  zMax 
)

Renders the vertices of the profile curve as vertical lines using the specified render context.

The style of the lines the style corresponds to the symbol defined by setSubsectionsSymbol().

See also
setSubsectionsSymbol()
Since
QGIS 3.44

Definition at line 385 of file qgsprofilerenderer.cpp.

◆ renderToImage()

QImage QgsProfilePlotRenderer::renderToImage ( int  width,
int  height,
double  distanceMin,
double  distanceMax,
double  zMin,
double  zMax,
const QString &  sourceId = QString(),
double  devicePixelRatio = 1.0 
)

Renders a portion of the profile to an image with the given width and height.

If sourceId is empty then all sources will be rendered, otherwise only the matching source will be rendered.

Definition at line 303 of file qgsprofilerenderer.cpp.

◆ replaceSource()

void QgsProfilePlotRenderer::replaceSource ( QgsAbstractProfileSource source)

Replaces the existing source with matching ID.

The matching stored source will be deleted and replaced with source.

Definition at line 222 of file qgsprofilerenderer.cpp.

◆ setContext()

void QgsProfilePlotRenderer::setContext ( const QgsProfileGenerationContext context)

Sets the context in which the profile generation will occur.

Depending on the sources present, this may trigger automatically a regeneration of results.

Definition at line 172 of file qgsprofilerenderer.cpp.

◆ setSubsectionsSymbol()

void QgsProfilePlotRenderer::setSubsectionsSymbol ( QgsLineSymbol symbol)

Sets the symbol used to draw the subsections.

If symbol is nullptr, the subsections are not drawn. Ownership of symbol is transferred.

See also
subsectionsSymbol()
Since
QGIS 3.44

Definition at line 375 of file qgsprofilerenderer.cpp.

◆ snapPoint()

QgsProfileSnapResult QgsProfilePlotRenderer::snapPoint ( const QgsProfilePoint point,
const QgsProfileSnapContext context 
)

Snap a point to the results.

Definition at line 411 of file qgsprofilerenderer.cpp.

◆ sourceIds()

QStringList QgsProfilePlotRenderer::sourceIds ( ) const

Returns the ordered list of source IDs for the sources used by the renderer.

Definition at line 56 of file qgsprofilerenderer.cpp.

◆ startGeneration()

void QgsProfilePlotRenderer::startGeneration ( )

Start the generation job and immediately return.

Does nothing if the generation is already in progress.

Definition at line 67 of file qgsprofilerenderer.cpp.

◆ subsectionsSymbol()

QgsLineSymbol * QgsProfilePlotRenderer::subsectionsSymbol ( )

Returns the line symbol used to draw the subsections.

See also
setSubsectionsSymbol()
Since
QGIS 3.44

Definition at line 380 of file qgsprofilerenderer.cpp.

◆ waitForFinished()

void QgsProfilePlotRenderer::waitForFinished ( )

Block until the current job has finished.

Definition at line 156 of file qgsprofilerenderer.cpp.

◆ zRange()

QgsDoubleRange QgsProfilePlotRenderer::zRange ( ) const

Returns the limits of the retrieved elevation values.

Definition at line 287 of file qgsprofilerenderer.cpp.


The documentation for this class was generated from the following files: