QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
33 const QMap<QString, QgsMapLayer *> &mapLayers = project->
mapLayers();
39 for ( QMap<QString, QgsMapLayer *>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it )
41 currentLayer = it.value();
47 if ( layerRange.begin().isValid() && ( !minDate.isValid() || layerRange.begin() < minDate ) )
48 minDate = layerRange.begin();
49 if ( layerRange.end().isValid() && ( !maxDate.isValid() || layerRange.end() > maxDate ) )
50 maxDate = layerRange.end();
53 return QgsDateTimeRange( minDate, maxDate );
60 error = QObject::tr(
"Filename template is empty" );
64 if ( numberOfDigits < 0 )
66 error = QObject::tr(
"Wrong filename template format (must contain #)" );
69 const QString token( numberOfDigits, QLatin1Char(
'#' ) );
72 error = QObject::tr(
"Filename template must contain all # placeholders in one continuous group." );
77 error = QObject::tr(
"Output directory creation failure." );
88 long long currentFrame = 0;
90 while ( currentFrame < totalFrames )
96 error = QObject::tr(
"Export canceled" );
99 feedback->
setProgress( currentFrame /
static_cast<double>( totalFrames ) * 100 );
114 const QString frameNoPaddedLeft( QStringLiteral(
"%1" ).arg( currentFrame, numberOfDigits, 10, QChar(
'0' ) ) );
115 fileName.replace( token, frameNoPaddedLeft );
116 const QString path = QDir( settings.
outputDirectory ).filePath( fileName );
119 img.setDotsPerMeterX( 1000 * ms.
outputDpi() / 25.4 );
120 img.setDotsPerMeterY( 1000 * ms.
outputDpi() / 25.4 );
131 const auto constMDecorations = settings.
decorations;
134 decoration->render( ms, context );
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setProgress(double progress)
Sets the current progress for the feedback object.
static bool exportAnimation(const QgsMapSettings &mapSettings, const AnimationExportSettings &settings, QString &error, QgsFeedback *feedback=nullptr)
Exports animation frames by rendering the map to multiple destination images.
void waitForFinished() override
Block until the job has finished.
QSize outputSize() const
Returns the size of the resulting map image.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Contains settings relating to exporting animations.
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
void setIsTemporal(bool enabled)
Sets whether the temporal range is enabled (i.e.
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
Contains information about the context of a rendering operation.
QgsDateTimeRange dateTimeRangeForFrameNumber(long long frame) const
Calculates the temporal range associated with a particular animation frame.
virtual QgsDateTimeRange calculateTemporalExtent(QgsMapLayer *layer) const
Attempts to calculate the overall temporal extent for the specified layer, using the settings defined...
QImage::Format outputImageFormat() const
format of internal QImage, default QImage::Format_ARGB32_Premultiplied
QgsDateTimeRange animationRange
Dictates the overall temporal range of the animation.
void setFrameDuration(QgsInterval duration)
Sets the frame duration, which dictates the temporal length of each frame in the animation.
void start() override
Start the rendering job and immediately return.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QString outputDirectory
Destination directory for created image files.
bool isActive() const
Returns true if the temporal property is active.
void setCurrentFrameNumber(long long frame)
Sets the current animation frame number.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
void setTemporalExtents(const QgsDateTimeRange &extents)
Sets the navigation temporal extents, which dictate the earliest and latest date time possible in the...
QString fileNameTemplate
The filename template for exporting the frames.
QColor backgroundColor() const
Gets the background color of the map.
virtual QgsMapLayerTemporalProperties * temporalProperties()
Returns the layer's temporal properties.
QgsExpressionContextScope * createExpressionContextScope() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
long long totalFrameCount()
Returns the total number of frames for the navigation.
const QgsExpressionContext & expressionContext() const
Gets the expression context.
Implements a temporal controller based on a frame by frame navigation and animation.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Job implementation that renders everything sequentially using a custom painter.
bool isCanceled() const
Tells whether the operation has been canceled already.
QgsInterval frameDuration
Duration of individual export frames.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
Base class for all map layer types.
void setTemporalRange(const QgsDateTimeRange &range)
Sets the temporal range for the object.
Interface for map decorations.
double outputDpi() const
Returns DPI used for conversion between real world units (e.g.
The QgsMapSettings class contains configuration for rendering of the map.
QList< QgsMapDecoration * > decorations
List of decorations to draw onto exported frames.
static QgsDateTimeRange calculateTemporalRangeForProject(QgsProject *project)
Calculates the temporal range for a project.