Skip to content
Permalink
Browse files

updates on temporal animation logic

  • Loading branch information
Samweli authored and nyalldawson committed Mar 11, 2020
1 parent 99129fe commit dd129c1aef28be36d47c385c075fb47d46ad8136
Showing with 589 additions and 234 deletions.
  1. +1 −3 python/core/auto_generated/qgstemporalcontroller.sip.in
  2. +5 −16 python/core/auto_generated/qgstemporalnavigationobject.sip.in
  3. +66 −1 python/core/auto_generated/raster/qgsrasterdataprovidertemporalcapabilities.sip.in
  4. +31 −0 python/core/auto_generated/raster/qgsrasterlayertemporalproperties.sip.in
  5. +2 −1 python/gui/auto_generated/qgsmapcanvas.sip.in
  6. +11 −1 python/gui/auto_generated/qgstemporalcontrollerdockwidget.sip.in
  7. +2 −2 src/app/qgisapp.cpp
  8. +4 −3 src/app/qgsprojectproperties.cpp
  9. +2 −2 src/core/qgsmaplayertemporalproperties.h
  10. +2 −1 src/core/qgstemporalcontroller.cpp
  11. +1 −3 src/core/qgstemporalcontroller.h
  12. +24 −16 src/core/qgstemporalnavigationobject.cpp
  13. +15 −14 src/core/qgstemporalnavigationobject.h
  14. +36 −0 src/core/raster/qgsrasterdataprovidertemporalcapabilities.cpp
  15. +83 −4 src/core/raster/qgsrasterdataprovidertemporalcapabilities.h
  16. +37 −0 src/core/raster/qgsrasterlayer.cpp
  17. +7 −0 src/core/raster/qgsrasterlayer.h
  18. +16 −0 src/core/raster/qgsrasterlayerrenderer.cpp
  19. +41 −2 src/core/raster/qgsrasterlayertemporalproperties.cpp
  20. +39 −5 src/core/raster/qgsrasterlayertemporalproperties.h
  21. +3 −8 src/gui/qgsmapcanvas.cpp
  22. +4 −5 src/gui/qgsmapcanvas.h
  23. +33 −40 src/gui/qgstemporalcontrollerdockwidget.cpp
  24. +15 −16 src/gui/qgstemporalcontrollerdockwidget.h
  25. +0 −3 src/gui/qgstemporalmapsettingsdialog.cpp
  26. +0 −4 src/gui/qgstemporalmapsettingswidget.cpp
  27. +1 −1 src/gui/qgstemporalmapsettingswidget.h
  28. +36 −36 src/gui/raster/qgsrasterlayertemporalpropertieswidget.cpp
  29. +0 −27 src/gui/raster/qgsrasterlayertemporalpropertieswidget.h
  30. +10 −0 src/providers/wms/qgswmsprovider.cpp
  31. +11 −5 src/ui/qgsprojectpropertiesbase.ui
  32. +7 −1 src/ui/qgstemporalcontrollerdockwidgetbase.ui
  33. +32 −2 src/ui/raster/qgsrasterlayertemporalpropertieswidgetbase.ui
  34. +12 −12 tests/src/app/testqgsprojectproperties.cpp
@@ -24,13 +24,11 @@ updates of the objects temporal range.
%End
public:

QgsTemporalController();
QgsTemporalController( QObject *parent = 0 );
%Docstring
Constructor for QgsTemporalController.
%End

virtual ~QgsTemporalController();

signals:

void updateTemporalRange( const QgsDateTimeRange &range );
@@ -12,7 +12,7 @@



class QgsTemporalNavigationObject : QObject
class QgsTemporalNavigationObject : QgsTemporalController
{
%Docstring
The QgsTemporalNavigationObject class
@@ -123,7 +123,8 @@ Returns the total number of frames for the navigation.

void play();
%Docstring
Plays the temporal navigation
Starts playing the temporal navigation from its current frame,
using the direction specified by playBackMode()
%End

void pause();
@@ -133,12 +134,12 @@ Stops the temporal navigation.

void forward();
%Docstring
Forward the temporal navigation up till the end of frames.
Starts the animation playing in a forward direction up till the end of frames.
%End

void backward();
%Docstring
Decrement the temporal navigation till the end of frames.
Starts the animation playing in a reverse direction until the beginning of the time range.
%End

void next();
@@ -159,18 +160,6 @@ Rewind the temporal navigation to start of the temporal extent.
void skipToEnd();
%Docstring
Skips the temporal navigation to end of the temporal extent.
%End

void timerTimeout();
%Docstring
Handles logic when the temporal navigation timer emit a timeout signal.
%End

signals:

void updateTemporalRange( QgsDateTimeRange temporalRange );
%Docstring
Emitted when navigation range changes.
%End

};
@@ -9,7 +9,6 @@




class QgsRasterDataProviderTemporalCapabilities : QgsDataProviderTemporalCapabilities
{
%Docstring
@@ -36,6 +35,72 @@ The ``enabled`` argument specifies whether the data provider has temporal capabi

virtual ~QgsRasterDataProviderTemporalCapabilities();

enum TemporalMode
{
ModeFixedTemporalRange,
ModeTemporalRangeFromDataProvider
};

TemporalMode mode() const;
%Docstring
Returns the temporal mode.

.. seealso:: :py:func:`setMode`
%End

void setMode( TemporalMode mode );
%Docstring
Sets the temporal ``mode``.

.. seealso:: :py:func:`mode`
%End

enum FetchMode
{
Earliest,
Latest,
Range
};

FetchMode fetchMode() const;
%Docstring
Returns the temporal capabilities fetch mode.

.. seealso:: :py:func:`setFetchMode`
%End

void setFetchMode( FetchMode mode );
%Docstring
Sets the temporal properties fetch ``mode``.

.. seealso:: :py:func:`fetchMode`
%End

enum TimeInterval
{
Seconds,
Minutes,
Hours,
Days,
Months,
Years,
None
};

TimeInterval timeInterval() const;
%Docstring
Returns the temporal interval.

.. seealso:: :py:func:`setTimeInterval`
%End

void setTimeInterval( TimeInterval interval );
%Docstring
Sets the temporal time ``interval``.

.. seealso:: :py:func:`timeInterval`
%End

void setFixedTemporalRange( const QgsDateTimeRange &range );
%Docstring
Sets the fixed datetime ``range`` for the temporal properties.
@@ -50,6 +50,27 @@ Returns the temporal properties mode.
Sets the temporal properties ``mode``.

.. seealso:: :py:func:`mode`
%End

enum FetchMode
{
Earliest,
Latest,
Range
};

FetchMode fetchMode() const;
%Docstring
Returns the temporal properties fetch mode.

.. seealso:: :py:func:`setFetchMode`
%End

void setFetchMode( FetchMode mode );
%Docstring
Sets the temporal properties fetch ``mode``.

.. seealso:: :py:func:`fetchMode`
%End

void setFixedTemporalRange( const QgsDateTimeRange &range );
@@ -164,6 +185,16 @@ Returns the current active reference datetime range for these temporal propertie
virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context );


TemporalMode indexToMode( int index );
%Docstring
Returns the temporal mode given index
%End

FetchMode indexToFetchMode( int index );
%Docstring
Returns the temporal fetch mode given index
%End

};

/************************************************************************
@@ -18,6 +18,7 @@




class QgsMapCanvas : QGraphicsView
{
%Docstring
@@ -72,7 +73,7 @@ Gets access to properties used for map rendering
.. versionadded:: 2.4
%End

void setTemporalController( QgsTemporalNavigationObject *controller );
void setTemporalController( QgsTemporalController *controller );
%Docstring
Sets the temporal controller, this controller will be used to
update the canvas temporal range.
@@ -31,11 +31,21 @@ Constructor for QgsTemporalControllerDockWidget

~QgsTemporalControllerDockWidget();

QgsTemporalNavigationObject *temporalController();
QgsTemporalController *temporalController();
%Docstring
Returns the temporal controller object used by this object in navigation.
%End

enum TimeUnit
{
Seconds,
Minutes,
Hours,
Days,
Months,
Years
};

};

/************************************************************************
@@ -1153,8 +1153,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mBrowserWidget->setObjectName( QStringLiteral( "Browser" ) );
mBrowserWidget->setMessageBar( mInfoBar );

mTemporalControllerWidget = new QgsTemporalControllerDockWidget( tr( "Temporal VCR" ), this );
mTemporalControllerWidget->setObjectName( QStringLiteral( "Temporal VCR" ) );
mTemporalControllerWidget = new QgsTemporalControllerDockWidget( tr( "Temporal Controller" ), this );
mTemporalControllerWidget->setObjectName( QStringLiteral( "Temporal Controller" ) );
addDockWidget( Qt::BottomDockWidgetArea, mTemporalControllerWidget );
mTemporalControllerWidget->hide();

@@ -2540,9 +2540,10 @@ void QgsProjectProperties::calculateFromLayersButton_clicked()
mStartDateTimeEdit->setDateTime( minDate );
mEndDateTimeEdit->setDateTime( maxDate );

mCurrentRangeLabel->setText( tr( "Current range: %1 to %2" ).arg(
mStartDateTimeEdit->dateTime().toString( "yyyy-MM-dd hh:mm:ss" ),
mEndDateTimeEdit->dateTime().toString( "yyyy-MM-dd hh:mm:ss" ) ) );
QLocale locale;
mCurrentRangeLabel->setText( tr( "Current selected range: %1 to %2" ).arg(
mStartDateTimeEdit->dateTime().toString( locale.dateTimeFormat() ),
mEndDateTimeEdit->dateTime().toString( locale.dateTimeFormat() ) ) );
}

QListWidgetItem *QgsProjectProperties::addScaleToScaleList( const QString &newScale )
@@ -70,8 +70,8 @@ class CORE_EXPORT QgsMapLayerTemporalProperties : public QgsTemporalProperty
*/
enum TemporalSource
{
Layer, //! Defined from layer .
Project//! Defined from project time settings;
Layer = 0, //! Defined from layer .
Project = 1//! Defined from project time settings;
};

/**
@@ -17,6 +17,7 @@

#include "qgstemporalcontroller.h"

QgsTemporalController::QgsTemporalController( )
QgsTemporalController::QgsTemporalController( QObject *parent )
: QObject( parent )
{
}
@@ -42,9 +42,7 @@ class CORE_EXPORT QgsTemporalController : public QObject
* Constructor for QgsTemporalController.
*
*/
QgsTemporalController();

virtual ~QgsTemporalController() = default;
QgsTemporalController( QObject *parent = nullptr );

signals:

@@ -19,44 +19,54 @@
#include "qgis.h"

QgsTemporalNavigationObject::QgsTemporalNavigationObject( QObject *parent )
: QObject( parent )
: QgsTemporalController( parent )
{
mNewFrameTimer = new QTimer( this );

connect( mNewFrameTimer, &QTimer::timeout,
this, qgis::overload<>::of( &QgsTemporalNavigationObject::timerTimeout ) );
this, &QgsTemporalNavigationObject::timerTimeout );
}


void QgsTemporalNavigationObject::timerTimeout()
{
if ( mPlayBackMode == PlaybackMode::Forward )
forward();
if ( mPlayBackMode == PlaybackMode::Reverse )
backward();
return;
switch ( mPlayBackMode )
{
case PlaybackMode::Forward:
forward();
break;

case PlaybackMode::Reverse:
backward();
break;

case PlaybackMode::Idle:
pause();
break;
}
}

QgsDateTimeRange QgsTemporalNavigationObject::dateTimeRangeForFrameNumber( long long frame ) const
{
QDateTime start = mTemporalExtents.begin();

long long pastFrame = frame - 1;
if ( pastFrame < 0 )
pastFrame = 0;
if ( frame < 0 )
frame = 0;
long long nextFrame = frame + 1;

QDateTime begin = start.addSecs( pastFrame * mFrameDuration.seconds() );
QDateTime end = start.addSecs( frame * mFrameDuration.seconds() );
QDateTime begin = start.addSecs( frame * mFrameDuration.seconds() );
QDateTime end = start.addSecs( nextFrame * mFrameDuration.seconds() );

if ( end <= mTemporalExtents.end() )
return QgsDateTimeRange( begin, end );

return mTemporalExtents;
return QgsDateTimeRange( begin, mTemporalExtents.end() );
}

void QgsTemporalNavigationObject::setTemporalExtents( QgsDateTimeRange temporalExtents )
{
mTemporalExtents = temporalExtents;
setCurrentFrameNumber( 0 );
}

QgsDateTimeRange QgsTemporalNavigationObject::temporalExtents() const
@@ -68,10 +78,7 @@ void QgsTemporalNavigationObject::setCurrentFrameNumber( long long frameNumber )
{
if ( frameNumber < 0 ||
frameNumber >= totalFrameCount() )
{
pause();
return;
}

if ( mCurrentFrameNumber != frameNumber )
{
@@ -89,6 +96,7 @@ long long QgsTemporalNavigationObject::currentFrameNumber() const
void QgsTemporalNavigationObject::setFrameDuration( QgsInterval frameDuration )
{
mFrameDuration = frameDuration;
setCurrentFrameNumber( 0 );
}

QgsInterval QgsTemporalNavigationObject::frameDuration() const

0 comments on commit dd129c1

Please sign in to comment.
You can’t perform that action at this time.