Skip to content

Commit

Permalink
Expose option for irregular time steps when exporting map animations
Browse files Browse the repository at this point in the history
Fixes #51546
  • Loading branch information
nyalldawson committed Jan 31, 2023
1 parent f373f5b commit 0f03bbe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/core/auto_generated/qgstemporalutils.sip.in
Expand Up @@ -58,6 +58,8 @@ The returned list may be non-contiguous and have gaps in the ranges. The ranges

QList<QgsMapDecoration *> decorations;

QList<QgsDateTimeRange> availableTemporalRanges;

double frameRate;

};
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsanimationexportdialog.cpp
Expand Up @@ -102,7 +102,8 @@ QgsAnimationExportDialog::QgsAnimationExportDialog( QWidget *parent, QgsMapCanva
QgsUnitTypes::TemporalMonths,
QgsUnitTypes::TemporalYears,
QgsUnitTypes::TemporalDecades,
QgsUnitTypes::TemporalCenturies
QgsUnitTypes::TemporalCenturies,
QgsUnitTypes::TemporalIrregularStep
} )
{
mTimeStepsComboBox->addItem( QgsUnitTypes::toString( u ), u );
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgstemporalcontrollerdockwidget.cpp
Expand Up @@ -116,6 +116,8 @@ void QgsTemporalControllerDockWidget::exportAnimation()
animationSettings.outputDirectory = outputDir;
animationSettings.fileNameTemplate = fileNameExpression;
animationSettings.decorations = decorations;
if ( frameDuration.originalUnit() == QgsUnitTypes::TemporalIrregularStep )
animationSettings.availableTemporalRanges = QgsTemporalUtils::usedTemporalRangesForProject( QgsProject::instance() );

const bool success = QgsTemporalUtils::exportAnimation( s, animationSettings, error, &progressFeedback );

Expand Down
3 changes: 3 additions & 0 deletions src/core/qgstemporalutils.cpp
Expand Up @@ -99,6 +99,9 @@ bool QgsTemporalUtils::exportAnimation( const QgsMapSettings &mapSettings, const
QgsTemporalNavigationObject navigator;
navigator.setTemporalExtents( settings.animationRange );
navigator.setFrameDuration( settings.frameDuration );
if ( settings.frameDuration.originalUnit() == QgsUnitTypes::TemporalIrregularStep )
navigator.setAvailableTemporalRanges( settings.availableTemporalRanges );

QgsMapSettings ms = mapSettings;
const QgsExpressionContext context = ms.expressionContext();
ms.setFrameRate( settings.frameRate );
Expand Down
13 changes: 13 additions & 0 deletions src/core/qgstemporalutils.h
Expand Up @@ -167,6 +167,19 @@ class CORE_EXPORT QgsTemporalUtils
//! List of decorations to draw onto exported frames.
QList<QgsMapDecoration *> decorations;

/**
* Contains the list of all available temporal ranges which have data available.
*
* The list can be a list of non-contiguous ranges (i.e. containing gaps)
* which together describe the complete range of times which contain data.
*
* This list is required whenever the QgsUnitTypes::TemporalIrregularStep interval is used
* for an animation.
*
* \since QGIS 3.30
*/
QList<QgsDateTimeRange> availableTemporalRanges;

/**
* Target animation frame rate in frames per second.
*
Expand Down

0 comments on commit 0f03bbe

Please sign in to comment.