Skip to content

Commit

Permalink
Push all available temporal ranges to temporal controller when
Browse files Browse the repository at this point in the history
it changes
  • Loading branch information
nyalldawson committed Mar 25, 2021
1 parent d443e4a commit 9c1ddfc
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
24 changes: 24 additions & 0 deletions python/core/auto_generated/qgstemporalnavigationobject.sip.in
Expand Up @@ -90,6 +90,30 @@ Returns the navigation temporal extents, which dictate the earliest
and latest date time possible in the animation.

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

void setAvailableTemporalRanges( const QList< QgsDateTimeRange > &ranges );
%Docstring
Sets the list of all available temporal ``ranges`` which have data available.

The ``ranges`` list can be a list of non-contiguous ranges (i.e. containing gaps)
which together describe the complete range of times which contain data.

.. seealso:: :py:func:`availableTemporalRanges`

.. versionadded:: 3.20
%End

QList< QgsDateTimeRange > availableTemporalRanges() const;
%Docstring
Returns the list of all available temporal ranges which have data available.

The ranges list can be a list of non-contiguous ranges (i.e. containing gaps)
which together describe the complete range of times which contain data.

.. seealso:: :py:func:`setAvailableTemporalRanges`

.. versionadded:: 3.20
%End

void setCurrentFrameNumber( long long frame );
Expand Down
10 changes: 10 additions & 0 deletions src/core/qgstemporalnavigationobject.cpp
Expand Up @@ -169,6 +169,16 @@ QgsDateTimeRange QgsTemporalNavigationObject::temporalExtents() const
return mTemporalExtents;
}

void QgsTemporalNavigationObject::setAvailableTemporalRanges( const QList<QgsDateTimeRange> &ranges )
{
mAllRanges = ranges;
}

QList<QgsDateTimeRange> QgsTemporalNavigationObject::availableTemporalRanges() const
{
return mAllRanges;
}

void QgsTemporalNavigationObject::setCurrentFrameNumber( long long frameNumber )
{
if ( mCurrentFrameNumber != frameNumber )
Expand Down
25 changes: 25 additions & 0 deletions src/core/qgstemporalnavigationobject.h
Expand Up @@ -109,6 +109,28 @@ class CORE_EXPORT QgsTemporalNavigationObject : public QgsTemporalController, pu
*/
QgsDateTimeRange temporalExtents() const;

/**
* Sets the list of all available temporal \a ranges which have data available.
*
* The \a ranges list can be a list of non-contiguous ranges (i.e. containing gaps)
* which together describe the complete range of times which contain data.
*
* \see availableTemporalRanges()
* \since QGIS 3.20
*/
void setAvailableTemporalRanges( const QList< QgsDateTimeRange > &ranges );

/**
* Returns the list of all available temporal ranges which have data available.
*
* The ranges list can be a list of non-contiguous ranges (i.e. containing gaps)
* which together describe the complete range of times which contain data.
*
* \see setAvailableTemporalRanges()
* \since QGIS 3.20
*/
QList< QgsDateTimeRange > availableTemporalRanges() const;

/**
* Sets the current animation \a frame number.
*
Expand Down Expand Up @@ -298,6 +320,9 @@ class CORE_EXPORT QgsTemporalNavigationObject : public QgsTemporalController, pu
//! The controller temporal navigation extent range.
QgsDateTimeRange mTemporalExtents;

//! Complete list of time ranges with data available
QList< QgsDateTimeRange > mAllRanges;

NavigationMode mNavigationMode = NavigationOff;

//! The current set frame value
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgstemporalcontrollerwidget.cpp
Expand Up @@ -410,6 +410,7 @@ void QgsTemporalControllerWidget::onLayersAdded( const QList<QgsMapLayer *> &lay
{
mHasTemporalLayersLoaded = true;
firstTemporalLayerLoaded( layer );
mNavigationObject->setAvailableTemporalRanges( QgsTemporalUtils::usedTemporalRangesForProject( QgsProject::instance() ) );
}
} );
}
Expand All @@ -418,6 +419,8 @@ void QgsTemporalControllerWidget::onLayersAdded( const QList<QgsMapLayer *> &lay
}
}
}

mNavigationObject->setAvailableTemporalRanges( QgsTemporalUtils::usedTemporalRangesForProject( QgsProject::instance() ) );
}

void QgsTemporalControllerWidget::firstTemporalLayerLoaded( QgsMapLayer *layer )
Expand Down Expand Up @@ -636,6 +639,8 @@ void QgsTemporalControllerWidget::setDatesToAllLayers()
{
QgsDateTimeRange range;
range = QgsTemporalUtils::calculateTemporalRangeForProject( QgsProject::instance() );
mNavigationObject->setAvailableTemporalRanges( QgsTemporalUtils::usedTemporalRangesForProject( QgsProject::instance() ) );

setDates( range );
}

Expand All @@ -653,6 +658,8 @@ void QgsTemporalControllerWidget::setDatesToProjectTime()
range = QgsTemporalUtils::calculateTemporalRangeForProject( QgsProject::instance() );
}

mNavigationObject->setAvailableTemporalRanges( QgsTemporalUtils::usedTemporalRangesForProject( QgsProject::instance() ) );

setDates( range );
}

Expand Down

0 comments on commit 9c1ddfc

Please sign in to comment.