Skip to content
Permalink
Browse files

Forward declare QgsMapLayerTemporalProperty subclasses instead of inc…

…luding in header

Speeds up recompilation time
  • Loading branch information
nyalldawson committed May 10, 2020
1 parent 4785f3f commit 702675ca645dda58fc5fc700b2b09e8f26967875
@@ -138,7 +138,7 @@ QgsMeshLayer cannot be copied.

virtual bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const;

virtual QgsMeshLayerTemporalProperties *temporalProperties();
virtual QgsMapLayerTemporalProperties *temporalProperties();

virtual void reload();

@@ -404,11 +404,8 @@ to be drawn outside the data extent.
.. versionadded:: 3.10
%End

virtual QgsRasterLayerTemporalProperties *temporalProperties();
virtual QgsMapLayerTemporalProperties *temporalProperties();

%Docstring
Returns temporal properties associated with the raster layer.
%End

public slots:
void showStatusMessage( const QString &message );
@@ -53,6 +53,7 @@
#include "qgsvectorlayer.h"
#include "qgsvectorlayer3drenderer.h"
#include "qgspoint3dbillboardmaterial.h"
#include "qgsmaplayertemporalproperties.h"

#include "qgslinematerial_p.h"

@@ -33,6 +33,7 @@
#include "qgsproject.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsrenderermeshpropertieswidget.h"
#include "qgsmeshlayertemporalproperties.h"
#include "qgssettings.h"
#include "qgsprojecttimesettings.h"
#include "qgsproviderregistry.h"
@@ -195,8 +196,9 @@ void QgsMeshLayerProperties::syncToLayer()
mSimplifyMeshResolutionSpinBox->setValue( simplifySettings.meshResolution() );

QgsDebugMsgLevel( QStringLiteral( "populate temporal tab" ), 4 );
whileBlocking( mTemporalDateTimeReference )->setDateTime( mMeshLayer->temporalProperties()->referenceTime() );
const QgsDateTimeRange timeRange = mMeshLayer->temporalProperties()->timeExtent();
const QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast< const QgsMeshLayerTemporalProperties * >( mMeshLayer->temporalProperties() );
whileBlocking( mTemporalDateTimeReference )->setDateTime( temporalProperties->referenceTime() );
const QgsDateTimeRange timeRange = temporalProperties->timeExtent();
mTemporalDateTimeStart->setDateTime( timeRange.begin() );
mTemporalDateTimeEnd->setDateTime( timeRange.end() );
if ( mMeshLayer->dataProvider() )
@@ -235,17 +237,19 @@ void QgsMeshLayerProperties::addDataset()
bool ok = mMeshLayer->dataProvider()->addDataset( openFileString );
if ( ok )
{
QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast< QgsMeshLayerTemporalProperties * >( mMeshLayer->temporalProperties() );

if ( !isTemporalBefore && mMeshLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
{
mMeshLayer->temporalProperties()->setDefaultsFromDataProviderTemporalCapabilities(
temporalProperties->setDefaultsFromDataProviderTemporalCapabilities(
mMeshLayer->dataProvider()->temporalCapabilities() );

if ( ! mMeshLayer->temporalProperties()->referenceTime().isValid() )
if ( ! temporalProperties->referenceTime().isValid() )
{
QDateTime referenceTime = QgsProject::instance()->timeSettings()->temporalRange().begin();
if ( !referenceTime.isValid() ) // If project reference time is invalid, use current date
referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ) );
mMeshLayer->temporalProperties()->setReferenceTime( referenceTime, mMeshLayer->dataProvider()->temporalCapabilities() );
temporalProperties->setReferenceTime( referenceTime, mMeshLayer->dataProvider()->temporalCapabilities() );
}
}

@@ -90,6 +90,8 @@
#include "qgsprovidermetadata.h"
#include "qgsfixattributedialog.h"
#include "qgsprojecttimesettings.h"
#include "qgsmaplayertemporalproperties.h"
#include "qgsmeshlayertemporalproperties.h"

#include "qgsanalysis.h"
#include "qgsgeometrycheckregistry.h"
@@ -5530,8 +5532,8 @@ QgsMeshLayer *QgisApp::addMeshLayerPrivate( const QString &url, const QString &b
{
askUserForDatumTransform( newLayer->crs(), QgsProject::instance()->crs(), newLayer );
QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( newLayer );
if ( ! meshLayer->temporalProperties()->referenceTime().isValid() )
meshLayer->temporalProperties()->setReferenceTime( referenceTime, layer->dataProvider()->temporalCapabilities() );
if ( ! qobject_cast< QgsMeshLayerTemporalProperties * >( meshLayer->temporalProperties() )->referenceTime().isValid() )
qobject_cast< QgsMeshLayerTemporalProperties * >( meshLayer->temporalProperties() )->setReferenceTime( referenceTime, layer->dataProvider()->temporalCapabilities() );
bool ok;
newLayer->loadDefaultStyle( ok );
newLayer->loadDefaultMetadata( ok );
@@ -5543,8 +5545,8 @@ QgsMeshLayer *QgisApp::addMeshLayerPrivate( const QString &url, const QString &b
}
else
{
if ( ! layer->temporalProperties()->referenceTime().isValid() )
layer->temporalProperties()->setReferenceTime( referenceTime, layer->dataProvider()->temporalCapabilities() );
if ( ! qobject_cast< QgsMeshLayerTemporalProperties * >( layer->temporalProperties() )->referenceTime().isValid() )
qobject_cast< QgsMeshLayerTemporalProperties * >( layer->temporalProperties() )->setReferenceTime( referenceTime, layer->dataProvider()->temporalCapabilities() );
QgsProject::instance()->addMapLayer( layer.get() );
askUserForDatumTransform( layer->crs(), QgsProject::instance()->crs(), layer.get() );

@@ -23,6 +23,7 @@
#include "qgsmeshlayer.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsmaplayertemporalproperties.h"
#include "qgisapp.h"

QgsLayerTreeViewTemporalIndicatorProvider::QgsLayerTreeViewTemporalIndicatorProvider( QgsLayerTreeView *view )
@@ -254,7 +254,7 @@ void QgsMeshLayer::setTimeSettings( const QgsMeshTimeSettings &settings )
QString QgsMeshLayer::formatTime( double hours )
{
if ( dataProvider() && dataProvider()->temporalCapabilities()->hasReferenceTime() )
return QgsMeshLayerUtils::formatTime( hours, temporalProperties()->referenceTime(), mTimeSettings );
return QgsMeshLayerUtils::formatTime( hours, mTemporalProperties->referenceTime(), mTimeSettings );
else
return QgsMeshLayerUtils::formatTime( hours, QDateTime(), mTimeSettings );
}
@@ -486,9 +486,9 @@ QgsMeshDatasetIndex QgsMeshLayer::staticVectorDatasetIndex() const
void QgsMeshLayer::setReferenceTime( const QDateTime &referenceTime )
{
if ( dataProvider() )
temporalProperties()->setReferenceTime( referenceTime, dataProvider()->temporalCapabilities() );
mTemporalProperties->setReferenceTime( referenceTime, dataProvider()->temporalCapabilities() );
else
temporalProperties()->setReferenceTime( referenceTime, nullptr );
mTemporalProperties->setReferenceTime( referenceTime, nullptr );
}

QgsPointXY QgsMeshLayer::snapOnVertex( const QgsPointXY &point, double searchRadius )
@@ -825,7 +825,7 @@ bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &con

// read temporal
temporalProperties()->readXml( layer_node.toElement(), context );
if ( !temporalProperties()->timeExtent().begin().isValid() )
if ( !mTemporalProperties->timeExtent().begin().isValid() )
temporalProperties()->setDefaultsFromDataProviderTemporalCapabilities( dataProvider()->temporalCapabilities() );


@@ -964,7 +964,7 @@ bool QgsMeshLayer::setDataProvider( QString const &provider, const QgsDataProvid
return true;
}

QgsMeshLayerTemporalProperties *QgsMeshLayer::temporalProperties()
QgsMapLayerTemporalProperties *QgsMeshLayer::temporalProperties()
{
return mTemporalProperties;
return mTemporalProperties;
}
@@ -26,7 +26,6 @@
#include "qgsmeshrenderersettings.h"
#include "qgsmeshtimesettings.h"
#include "qgsmeshsimplificationsettings.h"
#include "qgsmeshlayertemporalproperties.h"

class QgsMapLayerRenderer;
struct QgsMeshLayerRendererCache;
@@ -35,6 +34,7 @@ class QgsTriangularMesh;
class QgsRenderContext;
struct QgsMesh;
class QgsMesh3dAveragingMethod;
class QgsMeshLayerTemporalProperties;

/**
* \ingroup core
@@ -165,7 +165,7 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const override;
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
QgsMeshLayerTemporalProperties *temporalProperties() override;
QgsMapLayerTemporalProperties *temporalProperties() override;
void reload() override;
QStringList subLayers() const override;

@@ -20,6 +20,8 @@
#include "qgsmeshlayer.h"
#include "qgsvectorlayer.h"
#include "qgsvectorlayertemporalproperties.h"
#include "qgsrasterlayertemporalproperties.h"
#include "qgsmeshlayertemporalproperties.h"

QgsDateTimeRange QgsTemporalUtils::calculateTemporalRangeForProject( QgsProject *project )
{
@@ -41,12 +43,13 @@ QgsDateTimeRange QgsTemporalUtils::calculateTemporalRangeForProject( QgsProject
{
case QgsMapLayerType::RasterLayer:
{
QgsRasterLayer *rasterLayer = qobject_cast<QgsRasterLayer *>( currentLayer );
QgsRasterLayer *rasterLayer = qobject_cast< QgsRasterLayer *>( currentLayer );
const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast< const QgsRasterLayerTemporalProperties * >( rasterLayer->temporalProperties() );

switch ( rasterLayer->temporalProperties()->mode() )
switch ( temporalProperties->mode() )
{
case QgsRasterLayerTemporalProperties::ModeFixedTemporalRange:
layerRange = rasterLayer->temporalProperties()->fixedTemporalRange();
layerRange = temporalProperties->fixedTemporalRange();
break;

case QgsRasterLayerTemporalProperties::ModeTemporalRangeFromDataProvider:
@@ -111,7 +114,8 @@ QgsDateTimeRange QgsTemporalUtils::calculateTemporalRangeForProject( QgsProject
case QgsMapLayerType::MeshLayer:
{
QgsMeshLayer *meshLayer = qobject_cast<QgsMeshLayer *>( currentLayer );
layerRange = meshLayer->temporalProperties()->timeExtent();
const QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast< const QgsMeshLayerTemporalProperties * >( meshLayer->temporalProperties() );
layerRange = temporalProperties->timeExtent();
break;
}

@@ -18,6 +18,7 @@
#include "qgsvectorlayertemporalproperties.h"
#include "qgsvectordataprovidertemporalcapabilities.h"
#include "qgsexpression.h"
#include "qgsvectorlayer.h"

QgsVectorLayerTemporalProperties::QgsVectorLayerTemporalProperties( QObject *parent, bool enabled )
: QgsMapLayerTemporalProperties( parent, enabled )
@@ -53,6 +53,7 @@ email : tim at linfiniti.com
#include "qgsgdalprovider.h"
#include "qgsbilinearrasterresampler.h"
#include "qgscubicrasterresampler.h"
#include "qgsrasterlayertemporalproperties.h"

#include <cmath>
#include <cstdio>
@@ -961,7 +962,7 @@ bool QgsRasterLayer::ignoreExtents() const
return mDataProvider ? mDataProvider->ignoreExtents() : false;
}

QgsRasterLayerTemporalProperties *QgsRasterLayer::temporalProperties()
QgsMapLayerTemporalProperties *QgsRasterLayer::temporalProperties()
{
return mTemporalProperties;
}
@@ -38,11 +38,11 @@
#include "qgsrasterviewport.h"
#include "qgsrasterminmaxorigin.h"
#include "qgscontrastenhancement.h"
#include "qgsrasterlayertemporalproperties.h"

class QgsMapToPixel;
class QgsRasterRenderer;
class QgsRectangle;
class QgsRasterLayerTemporalProperties;

class QImage;
class QPixmap;
@@ -446,10 +446,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
*/
bool ignoreExtents() const;

/**
* Returns temporal properties associated with the raster layer.
*/
QgsRasterLayerTemporalProperties *temporalProperties() override;
QgsMapLayerTemporalProperties *temporalProperties() override;

public slots:
void showStatusMessage( const QString &message );
@@ -24,7 +24,7 @@
#include "qgsrendercontext.h"
#include "qgsproject.h"
#include "qgsexception.h"

#include "qgsrasterlayertemporalproperties.h"

///@cond PRIVATE

@@ -229,9 +229,10 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRender
if ( rasterRenderer && !( rendererContext.flags() & QgsRenderContext::RenderPreviewJob ) )
layer->refreshRendererIfNeeded( rasterRenderer, rendererContext.extent() );

if ( layer->temporalProperties()->isActive() && renderContext()->isTemporal() )
const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast< const QgsRasterLayerTemporalProperties * >( layer->temporalProperties() );
if ( temporalProperties->isActive() && renderContext()->isTemporal() )
{
switch ( layer->temporalProperties()->mode() )
switch ( temporalProperties->mode() )
{
case QgsRasterLayerTemporalProperties::ModeFixedTemporalRange:
break;
@@ -241,15 +242,15 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer *layer, QgsRender
if ( mPipe->provider()->temporalCapabilities() )
{
mPipe->provider()->temporalCapabilities()->setRequestedTemporalRange( rendererContext.temporalRange() );
mPipe->provider()->temporalCapabilities()->setIntervalHandlingMethod( layer->temporalProperties()->intervalHandlingMethod() );
mPipe->provider()->temporalCapabilities()->setIntervalHandlingMethod( temporalProperties->intervalHandlingMethod() );
}
break;
}
}
else if ( mPipe->provider()->temporalCapabilities() )
{
mPipe->provider()->temporalCapabilities()->setRequestedTemporalRange( QgsDateTimeRange() );
mPipe->provider()->temporalCapabilities()->setIntervalHandlingMethod( layer->temporalProperties()->intervalHandlingMethod() );
mPipe->provider()->temporalCapabilities()->setIntervalHandlingMethod( temporalProperties->intervalHandlingMethod() );
}
}

@@ -17,6 +17,7 @@

#include "qgsrasterlayertemporalproperties.h"
#include "qgsrasterdataprovidertemporalcapabilities.h"
#include "qgsrasterlayer.h"

QgsRasterLayerTemporalProperties::QgsRasterLayerTemporalProperties( QObject *parent, bool enabled )
: QgsMapLayerTemporalProperties( parent, enabled )
@@ -62,6 +62,7 @@
#include "qgsvectorlayer.h"
#include "qgsprovidermetadata.h"
#include "qgsproviderregistry.h"
#include "qgsrasterlayertemporalproperties.h"

#include "qgsrasterlayertemporalpropertieswidget.h"
#include "qgsprojecttimesettings.h"
@@ -1277,7 +1278,7 @@ void QgsRasterLayerProperties::updateSourceStaticTime()
bool enableTime = !mDisableTime->isChecked();

uri[ QStringLiteral( "enableTime" ) ] = enableTime;
mRasterLayer->temporalProperties()->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >(
qobject_cast< QgsRasterLayerTemporalProperties * >( mRasterLayer->temporalProperties() )->setIntervalHandlingMethod( static_cast< QgsRasterDataProviderTemporalCapabilities::IntervalHandlingMethod >(
mFetchModeComboBox->currentData().toInt() ) );
}
mRasterLayer->setDataSource( metadata->encodeUri( uri ), mRasterLayer->name(), mRasterLayer->providerType(), QgsDataProvider::ProviderOptions() );
@@ -1348,7 +1349,7 @@ void QgsRasterLayerProperties::setSourceStaticTimeState()
mFetchModeComboBox->addItem( tr( "Match to End of Range" ), QgsRasterDataProviderTemporalCapabilities::MatchExactUsingEndOfRange );
mFetchModeComboBox->addItem( tr( "Closest Match to Start of Range" ), QgsRasterDataProviderTemporalCapabilities::FindClosestMatchToStartOfRange );
mFetchModeComboBox->addItem( tr( "Closest Match to End of Range" ), QgsRasterDataProviderTemporalCapabilities::FindClosestMatchToEndOfRange );
mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData( mRasterLayer->temporalProperties()->intervalHandlingMethod() ) );
mFetchModeComboBox->setCurrentIndex( mFetchModeComboBox->findData( qobject_cast< QgsRasterLayerTemporalProperties * >( mRasterLayer->temporalProperties() )->intervalHandlingMethod() ) );

const QString temporalSource = uri.value( QStringLiteral( "temporalSource" ) ).toString();
bool enableTime = uri.value( QStringLiteral( "enableTime" ), true ).toBool();
@@ -21,7 +21,7 @@
#include "qgsprojecttimesettings.h"
#include "qgsrasterdataprovidertemporalcapabilities.h"
#include "qgsrasterlayer.h"

#include "qgsrasterlayertemporalproperties.h"

QgsRasterLayerTemporalPropertiesWidget::QgsRasterLayerTemporalPropertiesWidget( QWidget *parent, QgsRasterLayer *layer )
: QWidget( parent )
@@ -40,7 +40,8 @@ void QgsRasterLayerTemporalPropertiesWidget::init()

mEndTemporalDateTimeEdit->setDisplayFormat( "yyyy-MM-dd HH:mm:ss" );

switch ( mLayer->temporalProperties()->mode() )
const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast< const QgsRasterLayerTemporalProperties * >( mLayer->temporalProperties() );
switch ( temporalProperties->mode() )
{
case QgsRasterLayerTemporalProperties::ModeTemporalRangeFromDataProvider:
mModeAutomaticRadio->setChecked( true );
@@ -50,8 +51,8 @@ void QgsRasterLayerTemporalPropertiesWidget::init()
break;
}

mStartTemporalDateTimeEdit->setDateTime( mLayer->temporalProperties()->fixedTemporalRange().begin() );
mEndTemporalDateTimeEdit->setDateTime( mLayer->temporalProperties()->fixedTemporalRange().end() );
mStartTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
mEndTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().end() );

if ( !mLayer->dataProvider() || !mLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
{
@@ -60,19 +61,21 @@ void QgsRasterLayerTemporalPropertiesWidget::init()
mModeFixedRangeRadio->setChecked( true );
}

mTemporalGroupBox->setChecked( mLayer->temporalProperties()->isActive() );
mTemporalGroupBox->setChecked( temporalProperties->isActive() );
}

void QgsRasterLayerTemporalPropertiesWidget::saveTemporalProperties()
{
mLayer->temporalProperties()->setIsActive( mTemporalGroupBox->isChecked() );

QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast< QgsRasterLayerTemporalProperties * >( mLayer->temporalProperties() );

QgsDateTimeRange normalRange = QgsDateTimeRange( mStartTemporalDateTimeEdit->dateTime(),
mEndTemporalDateTimeEdit->dateTime() );

if ( mModeAutomaticRadio->isChecked() )
mLayer->temporalProperties()->setMode( QgsRasterLayerTemporalProperties::ModeTemporalRangeFromDataProvider );
temporalProperties->setMode( QgsRasterLayerTemporalProperties::ModeTemporalRangeFromDataProvider );
else if ( mModeFixedRangeRadio->isChecked() )
mLayer->temporalProperties()->setMode( QgsRasterLayerTemporalProperties::ModeFixedTemporalRange );
mLayer->temporalProperties()->setFixedTemporalRange( normalRange );
temporalProperties->setMode( QgsRasterLayerTemporalProperties::ModeFixedTemporalRange );
temporalProperties->setFixedTemporalRange( normalRange );
}

0 comments on commit 702675c

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