mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
When matching render elevation range to layer ranges, only consider
datasets from the same parent group
This commit is contained in:
parent
4eb7661d85
commit
0ff90a5698
@ -431,6 +431,13 @@ Constructs a valid metadata object
|
||||
QString name() const;
|
||||
%Docstring
|
||||
Returns name of the dataset group
|
||||
%End
|
||||
|
||||
QString parentGroup() const;
|
||||
%Docstring
|
||||
Returns the name of the dataset's parent group.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
QString uri() const;
|
||||
|
||||
@ -431,6 +431,13 @@ Constructs a valid metadata object
|
||||
QString name() const;
|
||||
%Docstring
|
||||
Returns name of the dataset group
|
||||
%End
|
||||
|
||||
QString parentGroup() const;
|
||||
%Docstring
|
||||
Returns the name of the dataset's parent group.
|
||||
|
||||
.. versionadded:: 3.38
|
||||
%End
|
||||
|
||||
QString uri() const;
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#include "qgsmeshdataprovider.h"
|
||||
#include "qgsrectangle.h"
|
||||
#include "qgis.h"
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
|
||||
QgsMeshDatasetIndex::QgsMeshDatasetIndex( int group, int dataset )
|
||||
: mGroupIndex( group ), mDatasetIndex( dataset )
|
||||
@ -142,6 +144,13 @@ QgsMeshDatasetGroupMetadata::QgsMeshDatasetGroupMetadata( const QString &name,
|
||||
, mReferenceTime( referenceTime )
|
||||
, mIsTemporal( isTemporal )
|
||||
{
|
||||
const thread_local QRegularExpression parentGroupNameRegex( QStringLiteral( "^(.*):.*?$" ) );
|
||||
|
||||
const QRegularExpressionMatch parentGroupMatch = parentGroupNameRegex.match( mName );
|
||||
if ( parentGroupMatch.hasMatch() )
|
||||
{
|
||||
mParentGroupName = parentGroupMatch.captured( 1 );
|
||||
}
|
||||
}
|
||||
|
||||
QMap<QString, QString> QgsMeshDatasetGroupMetadata::extraOptions() const
|
||||
@ -169,7 +178,13 @@ QString QgsMeshDatasetGroupMetadata::name() const
|
||||
return mName;
|
||||
}
|
||||
|
||||
QgsMeshDatasetGroupMetadata::DataType QgsMeshDatasetGroupMetadata::dataType() const
|
||||
QString QgsMeshDatasetGroupMetadata::parentGroup() const
|
||||
{
|
||||
return mParentGroupName;
|
||||
}
|
||||
|
||||
QgsMeshDatasetGroupMetadata::DataType
|
||||
QgsMeshDatasetGroupMetadata::dataType() const
|
||||
{
|
||||
return mDataType;
|
||||
}
|
||||
|
||||
@ -397,6 +397,13 @@ class CORE_EXPORT QgsMeshDatasetGroupMetadata
|
||||
*/
|
||||
QString name() const;
|
||||
|
||||
/**
|
||||
* Returns the name of the dataset's parent group.
|
||||
*
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
QString parentGroup() const;
|
||||
|
||||
/**
|
||||
* Returns the uri of the source
|
||||
*
|
||||
@ -457,6 +464,7 @@ class CORE_EXPORT QgsMeshDatasetGroupMetadata
|
||||
|
||||
private:
|
||||
QString mName;
|
||||
QString mParentGroupName;
|
||||
QString mUri;
|
||||
bool mIsScalar = false;
|
||||
DataType mDataType = DataType::DataOnFaces;
|
||||
|
||||
@ -99,28 +99,47 @@ QgsMeshLayerRenderer::QgsMeshLayerRenderer(
|
||||
|
||||
case Qgis::MeshElevationMode::FixedRangePerGroup:
|
||||
{
|
||||
// find the top-most group which matches the map range
|
||||
int currentMatchingGroup = -1;
|
||||
QgsDoubleRange currentMatchingRange;
|
||||
// find the top-most group which matches the map range and parent group
|
||||
int currentMatchingVectorGroup = -1;
|
||||
int currentMatchingScalarGroup = -1;
|
||||
QgsDoubleRange currentMatchingVectorRange;
|
||||
QgsDoubleRange currentMatchingScalarRange;
|
||||
|
||||
const QMap<int, QgsDoubleRange > rangePerGroup = elevProp->fixedRangePerGroup();
|
||||
|
||||
const int activeVectorDatasetGroup = mRendererSettings.activeVectorDatasetGroup();
|
||||
const int activeScalarDatasetGroup = mRendererSettings.activeScalarDatasetGroup();
|
||||
|
||||
for ( auto it = rangePerGroup.constBegin(); it != rangePerGroup.constEnd(); ++it )
|
||||
{
|
||||
if ( it.value().overlaps( context.zRange() ) )
|
||||
{
|
||||
if ( currentMatchingRange.isInfinite()
|
||||
|| ( it.value().includeUpper() && it.value().upper() >= currentMatchingRange.upper() )
|
||||
|| ( !currentMatchingRange.includeUpper() && it.value().upper() >= currentMatchingRange.upper() ) )
|
||||
const bool matchesVectorParentGroup = QgsMeshLayerUtils::haveSameParentGroup( layer, QgsMeshDatasetIndex( activeVectorDatasetGroup ), QgsMeshDatasetIndex( it.key() ) );
|
||||
const bool matchesScalarParentGroup = QgsMeshLayerUtils::haveSameParentGroup( layer, QgsMeshDatasetIndex( activeScalarDatasetGroup ), QgsMeshDatasetIndex( it.key() ) );
|
||||
|
||||
if ( matchesVectorParentGroup && (
|
||||
currentMatchingVectorRange.isInfinite()
|
||||
|| ( it.value().includeUpper() && it.value().upper() >= currentMatchingVectorRange.upper() )
|
||||
|| ( !currentMatchingVectorRange.includeUpper() && it.value().upper() >= currentMatchingVectorRange.upper() ) ) )
|
||||
{
|
||||
currentMatchingGroup = it.key();
|
||||
currentMatchingRange = it.value();
|
||||
currentMatchingVectorGroup = it.key();
|
||||
currentMatchingVectorRange = it.value();
|
||||
}
|
||||
|
||||
if ( matchesScalarParentGroup && (
|
||||
currentMatchingScalarRange.isInfinite()
|
||||
|| ( it.value().includeUpper() && it.value().upper() >= currentMatchingScalarRange.upper() )
|
||||
|| ( !currentMatchingScalarRange.includeUpper() && it.value().upper() >= currentMatchingScalarRange.upper() ) ) )
|
||||
{
|
||||
currentMatchingScalarGroup = it.key();
|
||||
currentMatchingScalarRange = it.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( currentMatchingGroup >= 0 )
|
||||
{
|
||||
mRendererSettings.setActiveScalarDatasetGroup( currentMatchingGroup );
|
||||
mRendererSettings.setActiveVectorDatasetGroup( currentMatchingGroup );
|
||||
}
|
||||
if ( currentMatchingVectorGroup >= 0 )
|
||||
mRendererSettings.setActiveVectorDatasetGroup( currentMatchingVectorGroup );
|
||||
if ( currentMatchingScalarGroup >= 0 )
|
||||
mRendererSettings.setActiveScalarDatasetGroup( currentMatchingScalarGroup );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
#include <limits>
|
||||
#include <QTime>
|
||||
#include <QDateTime>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
|
||||
#include "qgsmeshlayerutils.h"
|
||||
#include "qgsmeshtimesettings.h"
|
||||
@ -702,4 +704,17 @@ QVector<QVector3D> QgsMeshLayerUtils::calculateNormals( const QgsTriangularMesh
|
||||
return normals;
|
||||
}
|
||||
|
||||
bool QgsMeshLayerUtils::haveSameParentGroup( const QgsMeshLayer *layer, const QgsMeshDatasetIndex &index1, const QgsMeshDatasetIndex &index2 )
|
||||
{
|
||||
const QgsMeshDatasetGroupMetadata metadata1 = layer->datasetGroupMetadata( index1 );
|
||||
if ( metadata1.parentGroup().isEmpty() )
|
||||
return false;
|
||||
|
||||
const QgsMeshDatasetGroupMetadata metadata2 = layer->datasetGroupMetadata( index2 );
|
||||
if ( metadata2.parentGroup().isEmpty() )
|
||||
return false;
|
||||
|
||||
return metadata1.parentGroup().compare( metadata2.parentGroup(), Qt::CaseInsensitive ) == 0;
|
||||
}
|
||||
|
||||
///@endcond
|
||||
|
||||
@ -369,6 +369,14 @@ class CORE_EXPORT QgsMeshLayerUtils
|
||||
const QgsTriangularMesh &triangularMesh,
|
||||
const QVector<double> &verticalMagnitude,
|
||||
bool isRelative );
|
||||
|
||||
/**
|
||||
* Returns TRUE if the datasets from \a layer at \a index1 and \a index2 share the same parent group.
|
||||
*
|
||||
* \since QGIS 3.38
|
||||
*/
|
||||
static bool haveSameParentGroup( const QgsMeshLayer *layer, const QgsMeshDatasetIndex &index1, const QgsMeshDatasetIndex &index2 );
|
||||
|
||||
};
|
||||
|
||||
///@endcond
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user