Skip to content
Permalink
Browse files

mExtent is private

  • Loading branch information
pblottiere committed Mar 10, 2021
1 parent 822dd11 commit fd965af14774015ccbf178ae095d9b21781fc25b
@@ -1823,8 +1823,6 @@ Sets error message





bool hasDependencyCycle( const QSet<QgsMapLayerDependency> & ) const;
%Docstring
Checks whether a new set of dependencies will introduce a cycle
@@ -1911,7 +1911,7 @@ void QgsMapLayer::emitStyleChanged()

void QgsMapLayer::setExtent( const QgsRectangle &extent )
{
mExtent = extent;
updateExtent( extent );
}

bool QgsMapLayer::isReadOnly() const
@@ -2016,7 +2016,7 @@ QgsRectangle QgsMapLayer::wgs84Extent( bool forceRecalculate ) const
{
QgsRectangle wgs84Extent;

if ( mReadFlags & QgsMapLayer::ReadFlag::FlagTrustLayerMetadata && ! forceRecalculate )
if ( ! forceRecalculate && ! mWgs84Extent.isNull() )
{
wgs84Extent = mWgs84Extent;
}
@@ -2035,3 +2035,17 @@ QgsRectangle QgsMapLayer::wgs84Extent( bool forceRecalculate ) const
}
return wgs84Extent;
}

void QgsMapLayer::updateExtent( const QgsRectangle &extent ) const
{
if ( extent == mExtent )
return;

mExtent = extent;

// do not update the wgs84 extent if we trust layer metadata
if ( mReadFlags & QgsMapLayer::ReadFlag::FlagTrustLayerMetadata )
return;

mWgs84Extent = wgs84Extent( true );
}
@@ -1612,12 +1612,6 @@ class CORE_EXPORT QgsMapLayer : public QObject
//! Sets error message
void setError( const QgsError &error ) { mError = error;}

//! Extent of the layer
mutable QgsRectangle mExtent;

//! Extent of the layer in EPSG:4326
QgsRectangle mWgs84Extent;

//! Indicates if the layer is valid and can be drawn
bool mValid = false;

@@ -1698,6 +1692,9 @@ class CORE_EXPORT QgsMapLayer : public QObject
bool &resultFlag, StyleCategories categories = AllStyleCategories );
bool loadNamedPropertyFromDatabase( const QString &db, const QString &uri, QString &xml, QgsMapLayer::PropertyType type );

// const method because extents are mutable
void updateExtent( const QgsRectangle &extent ) const;

/**
* This method returns TRUE by default but can be overwritten to specify
* that a certain layer is writable.
@@ -1755,6 +1752,12 @@ class CORE_EXPORT QgsMapLayer : public QObject
//! Renderer for 3D views
QgsAbstract3DRenderer *m3DRenderer = nullptr;

//! Extent of the layer
mutable QgsRectangle mExtent;

//! Extent of the layer in EPSG:4326
mutable QgsRectangle mWgs84Extent;

/**
* Stores the original XML properties of the layer when loaded from the project
*
@@ -1764,6 +1767,8 @@ class CORE_EXPORT QgsMapLayer : public QObject

//! To avoid firing multiple time repaintRequested signal on circular layer circular dependencies
bool mRepaintRequestedFired = false;

friend class QgsVectorLayer;
};

Q_DECLARE_METATYPE( QgsMapLayer * )
@@ -40,7 +40,7 @@ QString QgsPluginLayer::pluginLayerType()

void QgsPluginLayer::setExtent( const QgsRectangle &extent )
{
mExtent = extent;
QgsMapLayer::setExtent( extent );
static_cast<QgsPluginLayerDataProvider *>( mDataProvider )->setExtent( extent );
}

@@ -848,23 +848,20 @@ QgsRectangle QgsVectorLayer::extent() const

if ( !mValidExtent && mLazyExtent && mDataProvider && !mDataProvider->hasMetadata() && mReadExtentFromXml && !mXmlExtent.isNull() )
{
mExtent = mXmlExtent;
updateExtent( mXmlExtent );
mValidExtent = true;
mLazyExtent = false;
}

if ( !mValidExtent && mLazyExtent && mDataProvider && mDataProvider->isValid() )
{
// get the extent
QgsRectangle mbr = mDataProvider->extent();

// show the extent
QgsDebugMsgLevel( QStringLiteral( "Extent of layer: %1" ).arg( mbr.toString() ), 3 );
// store the extent
updateExtent( mDataProvider->extent() );
mValidExtent = true;
mExtent = mbr;

mLazyExtent = false;

// show the extent
QgsDebugMsgLevel( QStringLiteral( "Extent of layer: %1" ).arg( mExtent.toString() ), 3 );
}

if ( mValidExtent )
@@ -886,7 +883,7 @@ QgsRectangle QgsVectorLayer::extent() const
// but only when there are some features already
if ( mDataProvider->featureCount() != 0 )
{
QgsRectangle r = mDataProvider->extent();
const QgsRectangle r = mDataProvider->extent();
rect.combineExtentWith( r );
}

@@ -897,7 +894,7 @@ QgsRectangle QgsVectorLayer::extent() const
{
if ( it->hasGeometry() )
{
QgsRectangle r = it->geometry().boundingBox();
const QgsRectangle r = it->geometry().boundingBox();
rect.combineExtentWith( r );
}
}
@@ -913,7 +910,7 @@ QgsRectangle QgsVectorLayer::extent() const
{
if ( fet.hasGeometry() && fet.geometry().type() != QgsWkbTypes::UnknownGeometry )
{
QgsRectangle bb = fet.geometry().boundingBox();
const QgsRectangle bb = fet.geometry().boundingBox();
rect.combineExtentWith( bb );
}
}
@@ -925,8 +922,8 @@ QgsRectangle QgsVectorLayer::extent() const
rect = QgsRectangle(); // use rectangle with zero coordinates
}

updateExtent( rect );
mValidExtent = true;
mExtent = rect;

// Send this (hopefully) up the chain to the map canvas
emit recalculateExtents();

0 comments on commit fd965af

Please sign in to comment.