Class: QgsVectorFieldTraceAnimationGenerator

Renders animated particle traces over a vector field.

Unlike the trace symbology of a layer renderer, which draws a single static frame, this class keeps the particles alive between calls so that successive imageRendered() calls produce the frames of an animation.

The vector field can come from any source, so the same generator serves mesh layers and any other layer type able to expose a vector field.

Added in version 4.4.

List of all members, including inherited members

Class Hierarchy

Inheritance diagram of qgis.core.QgsVectorFieldTraceAnimationGenerator

Subclasses

QgsMeshVectorTraceAnimationGenerator

A wrapper for QgsMeshParticuleTracesField used to render the particles.

Methods

imageRendered

Moves all the particles using frame per second (fps) to calculate the displacement and return the rendered frame

seedRandomParticles

Seeds particles in the vector field

setFramesPerSecond

Sets the number of frames per seconds that will be rendered

setMaximumSpeedPixel

Sets the max number of pixels that can be go through by the particles in 1 second

setMinimumTailLength

Sets the minimum tail length

setParticlesColor

Sets colors of particle

setParticlesLifeTime

Sets maximum life time of particles in seconds

setParticlesSize

Sets particle size in px

setTailFactor

Sets the tail factor, used to adjust the length of the tail.

setTailPersitence

Sets the visual persistence of the tail

Static Methods

fromMeshLayer

Returns a generator for the active vector dataset of layer, or None if the layer has no vector dataset to animate.

class qgis.core.QgsVectorFieldTraceAnimationGenerator[source]

Bases: object

static fromMeshLayer(layer: QgsMeshLayer | None, rendererContext: QgsRenderContext) → QgsVectorFieldTraceAnimationGenerator | None[source]

Returns a generator for the active vector dataset of layer, or None if the layer has no vector dataset to animate.

The caller takes ownership of the returned generator.

Parameters:
Return type:

QgsVectorFieldTraceAnimationGenerator|None

imageRendered(self) → QImage[source]

Moves all the particles using frame per second (fps) to calculate the displacement and return the rendered frame

Return type:

QImage

seedRandomParticles(self, count: int)[source]

Seeds particles in the vector field

Parameters:

count (int)

setFramesPerSecond(self, frames: int)[source]

Sets the number of frames per seconds that will be rendered

Parameters:

frames (int)

setMaximumSpeedPixel(self, pixels: int)[source]

Sets the max number of pixels that can be go through by the particles in 1 second

Parameters:

pixels (int)

setMinimumTailLength(self, l: int)[source]

Sets the minimum tail length

Parameters:

l (int)

setParticlesColor(self, c: QColor | Qt.GlobalColor | int)[source]

Sets colors of particle

Parameters:

c (QColor|Qt.GlobalColor|int)

setParticlesLifeTime(self, particleLifeTime: float)[source]

Sets maximum life time of particles in seconds

Parameters:

particleLifeTime (float)

setParticlesSize(self, width: float)[source]

Sets particle size in px

Parameters:

width (float)

setTailFactor(self, fct: float)[source]

Sets the tail factor, used to adjust the length of the tail. 0 : minimum length, >1 increase the tail

Parameters:

fct (float)

setTailPersitence(self, p: float)[source]

Sets the visual persistence of the tail

Parameters:

p (float)