Class: QgsProfilePlotRenderer

class qgis.core.QgsProfilePlotRenderer

Bases: PyQt5.QtCore.QObject

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.

New in version 3.26.

QgsProfilePlotRenderer(sources: Iterable[QgsAbstractProfileSource], request: QgsProfileRequest) Constructor for QgsProfilePlotRenderer, using the provided list of profile sources to generate the results.

Methods

cancelGeneration

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

cancelGenerationWithoutBlocking

Triggers cancellation of the generation job without blocking.

childEvent

connectNotify

customEvent

disconnectNotify

identify

Identify results visible at the specified profile point.

invalidateAllRefinableSources

Invalidates previous results from all refinable sources.

invalidateResults

Invalidates the profile results from the source with matching ID.

isActive

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

isSignalConnected

receivers

regenerateInvalidatedResults

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

render

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

renderToImage

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

replaceSource

Replaces the existing source with matching ID.

sender

senderSignalIndex

setContext

Sets the context in which the profile generation will occur.

snapPoint

Snap a point to the results.

sourceIds

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

startGeneration

Start the generation job and immediately return.

timerEvent

waitForFinished

Block until the current job has finished.

zRange

Returns the limits of the retrieved elevation values.

Signals

generationFinished

pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL

cancelGeneration(self)

Stop the generation job - does not return until the job has terminated. Does nothing if the generation is not active.

cancelGenerationWithoutBlocking(self)

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.

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
generationFinished

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

identify(self, point: QgsProfilePoint, context: QgsProfileIdentifyContext) List[QgsProfileIdentifyResults]

Identify results visible at the specified profile point.

identify(self, distanceRange: QgsDoubleRange, elevationRange: QgsDoubleRange, context: QgsProfileIdentifyContext) -> List[QgsProfileIdentifyResults] Identify results visible within the specified ranges.

Parameters:
Return type:

List[QgsProfileIdentifyResults]

invalidateAllRefinableSources(self)

Invalidates previous results from all refinable sources.

invalidateResults(self, source: QgsAbstractProfileSource) bool

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.

Parameters:

source (QgsAbstractProfileSource) –

Return type:

bool

isActive(self) bool

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

Return type:

bool

isSignalConnected(self, QMetaMethod) bool
receivers(self, PYQT_SIGNAL) int
regenerateInvalidatedResults(self)

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

Does nothing if the generation is already in progress.

render(self, context: QgsRenderContext, width: float, height: float, distanceMin: float, distanceMax: float, zMin: float, zMax: float, sourceId: str = '')

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.

Parameters:
  • context (QgsRenderContext) –

  • width (float) –

  • height (float) –

  • distanceMin (float) –

  • distanceMax (float) –

  • zMin (float) –

  • zMax (float) –

  • sourceId (str = '') –

renderToImage(self, width: int, height: int, distanceMin: float, distanceMax: float, zMin: float, zMax: float, sourceId: str = '') QImage

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.

Parameters:
  • width (int) –

  • height (int) –

  • distanceMin (float) –

  • distanceMax (float) –

  • zMin (float) –

  • zMax (float) –

  • sourceId (str = '') –

Return type:

QImage

replaceSource(self, source: QgsAbstractProfileSource)

Replaces the existing source with matching ID.

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

Parameters:

source (QgsAbstractProfileSource) –

sender(self) QObject
senderSignalIndex(self) int
setContext(self, context: QgsProfileGenerationContext)

Sets the context in which the profile generation will occur.

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

Parameters:

context (QgsProfileGenerationContext) –

snapPoint(self, point: QgsProfilePoint, context: QgsProfileSnapContext) QgsProfileSnapResult

Snap a point to the results.

Parameters:
Return type:

QgsProfileSnapResult

sourceIds(self) List[str]

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

Return type:

List[str]

startGeneration(self)

Start the generation job and immediately return. Does nothing if the generation is already in progress.

timerEvent(self, QTimerEvent)
waitForFinished(self)

Block until the current job has finished.

zRange(self) QgsDoubleRange

Returns the limits of the retrieved elevation values.

Return type:

QgsDoubleRange