QGIS API Documentation  3.27.0-Master (11ef3e5184)
Classes | Signals | 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). More...
 

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. More...
 
 ~QgsProfilePlotRenderer () override
 
void cancelGeneration ()
 Stop the generation job - does not return until the job has terminated. More...
 
void cancelGenerationWithoutBlocking ()
 Triggers cancellation of the generation job without blocking. More...
 
QVector< QgsProfileIdentifyResultsidentify (const QgsDoubleRange &distanceRange, const QgsDoubleRange &elevationRange, const QgsProfileIdentifyContext &context)
 Identify results visible within the specified ranges. More...
 
QVector< QgsProfileIdentifyResultsidentify (const QgsProfilePoint &point, const QgsProfileIdentifyContext &context)
 Identify results visible at the specified profile point. More...
 
void invalidateAllRefinableSources ()
 Invalidates previous results from all refinable sources. More...
 
bool invalidateResults (QgsAbstractProfileSource *source)
 Invalidates the profile results from the source with matching ID. More...
 
bool isActive () const
 Returns true if the generation job is currently running in background. More...
 
void regenerateInvalidatedResults ()
 Starts a background regeneration of any invalidated results and immediately returns. More...
 
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. More...
 
QImage renderToImage (int width, int height, double distanceMin, double distanceMax, double zMin, double zMax, const QString &sourceId=QString())
 Renders a portion of the profile to an image with the given width and height. More...
 
void replaceSource (QgsAbstractProfileSource *source)
 Replaces the existing source with matching ID. More...
 
void setContext (const QgsProfileGenerationContext &context)
 Sets the context in which the profile generation will occur. More...
 
QgsProfileSnapResult snapPoint (const QgsProfilePoint &point, const QgsProfileSnapContext &context)
 Snap a point to the results. More...
 
QStringList sourceIds () const
 Returns the ordered list of source IDs for the sources used by the renderer. More...
 
void startGeneration ()
 Start the generation job and immediately return. More...
 
void waitForFinished ()
 Block until the current job has finished. More...
 
QgsDoubleRange zRange () const
 Returns the limits of the retrieved elevation values. More...
 

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 58 of file qgsprofilerenderer.h.

Constructor & Destructor Documentation

◆ QgsProfilePlotRenderer()

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 27 of file qgsprofilerenderer.cpp.

◆ ~QgsProfilePlotRenderer()

QgsProfilePlotRenderer::~QgsProfilePlotRenderer ( )
override

Definition at line 41 of file qgsprofilerenderer.cpp.

Member Function Documentation

◆ 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 84 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 107 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 376 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 357 of file qgsprofilerenderer.cpp.

◆ invalidateAllRefinableSources()

void QgsProfilePlotRenderer::invalidateAllRefinableSources ( )

Invalidates previous results from all refinable sources.

Definition at line 169 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 195 of file qgsprofilerenderer.cpp.

◆ isActive()

bool QgsProfilePlotRenderer::isActive ( ) const

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

Definition at line 135 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 242 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 289 of file qgsprofilerenderer.cpp.

◆ renderToImage()

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

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 271 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 190 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 140 of file qgsprofilerenderer.cpp.

◆ snapPoint()

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

Snap a point to the results.

Definition at line 325 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 49 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 60 of file qgsprofilerenderer.cpp.

◆ waitForFinished()

void QgsProfilePlotRenderer::waitForFinished ( )

Block until the current job has finished.

Definition at line 124 of file qgsprofilerenderer.cpp.

◆ zRange()

QgsDoubleRange QgsProfilePlotRenderer::zRange ( ) const

Returns the limits of the retrieved elevation values.

Definition at line 255 of file qgsprofilerenderer.cpp.


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