Skip to content

Commit

Permalink
fix updating disabled scalar dataset group for mesh layer
Browse files Browse the repository at this point in the history
  • Loading branch information
vcloarec authored and nyalldawson committed Jul 6, 2021
1 parent 4675600 commit f76f3a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/gui/mesh/qgsmeshlayerproperties.cpp
Expand Up @@ -214,7 +214,7 @@ void QgsMeshLayerProperties::syncToLayer()
mDatasetGroupTreeWidget->syncToLayer( mMeshLayer );

QgsDebugMsgLevel( QStringLiteral( "populate config tab" ), 4 );
for ( QgsMapLayerConfigWidget *w : mConfigWidgets )
for ( QgsMapLayerConfigWidget *w : std::as_const( mConfigWidgets ) )
w->syncToLayer( mMeshLayer );

QgsDebugMsgLevel( QStringLiteral( "populate rendering tab" ), 4 );
Expand Down Expand Up @@ -362,7 +362,7 @@ void QgsMeshLayerProperties::apply()

QgsDebugMsgLevel( QStringLiteral( "processing config tabs" ), 4 );

for ( QgsMapLayerConfigWidget *w : mConfigWidgets )
for ( QgsMapLayerConfigWidget *w : std::as_const( mConfigWidgets ) )
w->apply();

QgsDebugMsgLevel( QStringLiteral( "processing rendering tab" ), 4 );
Expand Down Expand Up @@ -410,7 +410,8 @@ void QgsMeshLayerProperties::apply()

// Resync what have to be resync (widget that can be changed by other properties part)
mStaticDatasetWidget->syncToLayer();
mRendererMeshPropertiesWidget->syncToLayer();
for ( QgsMapLayerConfigWidget *w : std::as_const( mConfigWidgets ) )
w->syncToLayer( mMeshLayer );
}

void QgsMeshLayerProperties::changeCrs( const QgsCoordinateReferenceSystem &crs )
Expand Down
18 changes: 16 additions & 2 deletions src/gui/mesh/qgsmeshstaticdatasetwidget.cpp
Expand Up @@ -48,8 +48,22 @@ void QgsMeshStaticDatasetWidget::apply()
if ( !mLayer )
return;

mLayer->setStaticScalarDatasetIndex( QgsMeshDatasetIndex( mScalarDatasetGroup, mScalarDatasetComboBox->currentIndex() - 1 ) );
mLayer->setStaticVectorDatasetIndex( QgsMeshDatasetIndex( mVectorDatasetGroup, mVectorDatasetComboBox->currentIndex() - 1 ) );
int scalarIndex;
// if only one item, there is no active dataset group.
// Set to 0 instead of -1 to avoid none dataset (item 0) when the group is reactivate
if ( mScalarDatasetComboBox->count() == 1 )
scalarIndex = 0;
else
scalarIndex = mScalarDatasetComboBox->currentIndex() - 1;
int vectorIndex;
// Same as scalar
if ( mVectorDatasetComboBox->count() == 1 )
vectorIndex = 0;
else
vectorIndex = mVectorDatasetComboBox->currentIndex() - 1;

mLayer->setStaticScalarDatasetIndex( QgsMeshDatasetIndex( mScalarDatasetGroup, scalarIndex ) );
mLayer->setStaticVectorDatasetIndex( QgsMeshDatasetIndex( mVectorDatasetGroup, vectorIndex ) );
}

void QgsMeshStaticDatasetWidget::setScalarDatasetGroup( int index )
Expand Down

0 comments on commit f76f3a1

Please sign in to comment.