Skip to content

Commit

Permalink
[processing] fix filtering point cloud layers in the layers combobox
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and nyalldawson committed Nov 26, 2021
1 parent 5c35430 commit e7ae0f4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/gui/processing/qgsprocessingmaplayercombobox.cpp
Expand Up @@ -147,6 +147,10 @@ QgsProcessingMapLayerComboBox::QgsProcessingMapLayerComboBox( const QgsProcessin
{
filters = QgsMapLayerProxyModel::MeshLayer;
}
else if ( mParameter->type() == QgsProcessingParameterPointCloudLayer::typeName() )
{
filters = QgsMapLayerProxyModel::PointCloudLayer;
}
else if ( mParameter->type() == QgsProcessingParameterMapLayer::typeName() )
{
QList<int> dataTypes;
Expand All @@ -164,6 +168,8 @@ QgsProcessingMapLayerComboBox::QgsProcessingMapLayerComboBox( const QgsProcessin
filters |= QgsMapLayerProxyModel::RasterLayer;
if ( dataTypes.contains( QgsProcessing::TypeMesh ) )
filters |= QgsMapLayerProxyModel::MeshLayer;
if ( dataTypes.contains( QgsProcessing::TypePointCloud ) )
filters |= QgsMapLayerProxyModel::PointCloudLayer;
if ( !filters )
filters = QgsMapLayerProxyModel::All;
}
Expand Down
59 changes: 59 additions & 0 deletions tests/src/gui/testprocessinggui.cpp
Expand Up @@ -6019,6 +6019,9 @@ void TestProcessingGui::mapLayerComboBox()
QgsProject::instance()->addMapLayer( mesh );
QgsRasterLayer *raster = new QgsRasterLayer( QStringLiteral( TEST_DATA_DIR ) + "/raster/band1_byte_ct_epsg4326.tif", QStringLiteral( "band1_byte" ) );
QgsProject::instance()->addMapLayer( raster );
QgsPointCloudLayer *pointCloud = new QgsPointCloudLayer( QStringLiteral( TEST_DATA_DIR ) + "/point_clouds/ept/sunshine-coast/ept.json", QStringLiteral( "Point cloud" ), QStringLiteral( "ept" ) );
QVERIFY( pointCloud->isValid() );
QgsProject::instance()->addMapLayer( pointCloud );

// map layer param, all types are acceptable
param = std::make_unique< QgsProcessingParameterMapLayer> ( QStringLiteral( "param" ), QString() );
Expand All @@ -6035,6 +6038,8 @@ void TestProcessingGui::mapLayerComboBox()
QCOMPARE( combo->currentLayer(), mesh );
combo->setLayer( raster );
QCOMPARE( combo->currentLayer(), raster );
combo->setLayer( pointCloud );
QCOMPARE( combo->currentLayer(), pointCloud );
combo.reset();
param.reset();

Expand All @@ -6053,6 +6058,8 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo->setLayer( raster );
QCOMPARE( combo->currentLayer(), raster );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo.reset();
param.reset();

Expand All @@ -6071,6 +6078,8 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo->setLayer( raster );
QCOMPARE( combo->currentLayer(), raster );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo.reset();
param.reset();

Expand All @@ -6089,6 +6098,28 @@ void TestProcessingGui::mapLayerComboBox()
QCOMPARE( combo->currentLayer(), mesh );
combo->setLayer( raster );
QVERIFY( !combo->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo.reset();
param.reset();

// point cloud layer parm, only point cloud types are acceptable
param = std::make_unique< QgsProcessingParameterPointCloudLayer> ( QStringLiteral( "param" ), QString() );
combo = std::make_unique< QgsProcessingMapLayerComboBox >( param.get() );
combo->setLayer( point );
QVERIFY( !combo->currentLayer() );
combo->setLayer( line );
QVERIFY( !combo->currentLayer() );
combo->setLayer( polygon );
QVERIFY( !combo->currentLayer() );
combo->setLayer( noGeom );
QVERIFY( !combo->currentLayer() );
combo->setLayer( mesh );
QVERIFY( !combo->currentLayer() );
combo->setLayer( raster );
QVERIFY( !combo->currentLayer() );
combo->setLayer( pointCloud );
QCOMPARE( combo->currentLayer(), pointCloud );
combo.reset();
param.reset();

Expand Down Expand Up @@ -6122,6 +6153,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo2->setLayer( pointCloud );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
Expand Down Expand Up @@ -6156,6 +6191,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo2->setLayer( pointCloud );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
Expand Down Expand Up @@ -6190,6 +6229,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo2->setLayer( pointCloud );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
Expand Down Expand Up @@ -6224,6 +6267,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo2->setLayer( pointCloud );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
Expand Down Expand Up @@ -6258,6 +6305,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo2->setLayer( pointCloud );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
Expand Down Expand Up @@ -6292,6 +6343,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo2->setLayer( pointCloud );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
Expand Down Expand Up @@ -6326,6 +6381,10 @@ void TestProcessingGui::mapLayerComboBox()
QVERIFY( !combo->currentLayer() );
combo2->setLayer( raster );
QVERIFY( !combo2->currentLayer() );
combo->setLayer( pointCloud );
QVERIFY( !combo->currentLayer() );
combo2->setLayer( pointCloud );
QVERIFY( !combo2->currentLayer() );
combo2.reset();
param2.reset();
combo.reset();
Expand Down

0 comments on commit e7ae0f4

Please sign in to comment.