diff --git a/images/images.qrc b/images/images.qrc
index fe20fe0a5868..9293558533f0 100644
--- a/images/images.qrc
+++ b/images/images.qrc
@@ -938,11 +938,13 @@
themes/default/mActionMeshDigitizing.svg
themes/default/mActionMeshSelectPolygon.svg
themes/default/mActionMeshSelectExpression.svg
+ themes/default/mActionMeshSelectIsolatedVertices.svg
themes/default/mActionNewMeshLayer.svg
themes/default/mActionMeshTransformByExpression.svg
themes/default/mIconVertexCoordinates.svg
themes/default/mActionMeshEditForceByVectorLines.svg
themes/default/mActionMeshReindex.svg
+ themes/default/mActionMeshSelectAll.svg
themes/default/mIconGeometryCollectionLayer.svg
themes/default/mIconGps.svg
themes/default/mActionNewGpx.svg
diff --git a/images/themes/default/mActionMeshSelectAll.svg b/images/themes/default/mActionMeshSelectAll.svg
new file mode 100644
index 000000000000..9b99dae7b7d2
--- /dev/null
+++ b/images/themes/default/mActionMeshSelectAll.svg
@@ -0,0 +1 @@
+
diff --git a/images/themes/default/mActionMeshSelectIsolatedVertices.svg b/images/themes/default/mActionMeshSelectIsolatedVertices.svg
new file mode 100644
index 000000000000..ac833c4c9fb1
--- /dev/null
+++ b/images/themes/default/mActionMeshSelectIsolatedVertices.svg
@@ -0,0 +1 @@
+
diff --git a/src/app/mesh/qgsmaptooleditmeshframe.cpp b/src/app/mesh/qgsmaptooleditmeshframe.cpp
index b6677813ffb1..faedf4de40ce 100644
--- a/src/app/mesh/qgsmaptooleditmeshframe.cpp
+++ b/src/app/mesh/qgsmaptooleditmeshframe.cpp
@@ -218,8 +218,13 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas )
mSelectionHandler = std::make_unique( canvas, QgsMapToolSelectionHandler::SelectPolygon );
+ mActionSelectIsolatedVertices = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMeshSelectIsolatedVertices.svg" ) ), tr( "Select Isolated Vertices" ), this );
+ mActionSelectAllVertices = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMeshSelectAll.svg" ) ), tr( "Select All Vertices" ), this );
+
mSelectActions << mActionSelectByPolygon
- << mActionSelectByExpression;
+ << mActionSelectByExpression
+ << mActionSelectIsolatedVertices
+ << mActionSelectAllVertices;
mActionTransformCoordinates = new QAction( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMeshTransformByExpression.svg" ) ), tr( "Transform Vertices Coordinates" ), this );
mActionTransformCoordinates->setCheckable( true );
@@ -269,6 +274,19 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas )
mSelectionBand->reset( Qgis::GeometryType::Polygon );
} );
+ connect( mActionSelectIsolatedVertices, &QAction::triggered, this, [this]
+ {
+ onEditingStarted();
+ setSelectedVertices( mCurrentEditor->freeVerticesIndexes(), Qgis::SelectBehavior::SetSelection );
+ } );
+
+ connect( mActionSelectAllVertices, &QAction::triggered, this, [this]
+ {
+ onEditingStarted();
+ QList verticesIndexes = mCurrentLayer->selectVerticesByExpression( QgsExpression( "true" ) );
+ setSelectedVertices( verticesIndexes, Qgis::SelectBehavior::SetSelection );
+ } );
+
connect( mActionSelectByExpression, &QAction::triggered, this, &QgsMapToolEditMeshFrame::showSelectByExpressionDialog );
connect( mActionTransformCoordinates, &QAction::triggered, this, &QgsMapToolEditMeshFrame::triggerTransformCoordinatesDockWidget );
connect( mActionReindexMesh, &QAction::triggered, this, &QgsMapToolEditMeshFrame::reindexMesh );
@@ -365,7 +383,9 @@ void QgsMapToolEditMeshFrame::setActionsEnable( bool enable )
<< mActionSelectByExpression
<< mActionTransformCoordinates
<< mActionForceByLines
- << mActionReindexMesh;
+ << mActionReindexMesh
+ << mActionSelectIsolatedVertices
+ << mActionSelectAllVertices;
for ( QAction *action : std::as_const( actions ) )
action->setEnabled( enable );
diff --git a/src/app/mesh/qgsmaptooleditmeshframe.h b/src/app/mesh/qgsmaptooleditmeshframe.h
index 850b2a876bb5..ddd23cbd9551 100644
--- a/src/app/mesh/qgsmaptooleditmeshframe.h
+++ b/src/app/mesh/qgsmaptooleditmeshframe.h
@@ -350,6 +350,9 @@ class APP_EXPORT QgsMapToolEditMeshFrame : public QgsMapToolAdvancedDigitizing
QAction *mActionSelectByExpression = nullptr;
QAction *mActionForceByLines = nullptr;
+ QAction *mActionSelectIsolatedVertices = nullptr;
+ QAction *mActionSelectAllVertices = nullptr;
+
QgsMeshEditForceByLineAction *mWidgetActionForceByLine = nullptr;
QAction *mActionReindexMesh = nullptr;
diff --git a/tests/src/app/testqgsmaptooleditmesh.cpp b/tests/src/app/testqgsmaptooleditmesh.cpp
index f2d309c6033d..fcf0336cb425 100644
--- a/tests/src/app/testqgsmaptooleditmesh.cpp
+++ b/tests/src/app/testqgsmaptooleditmesh.cpp
@@ -37,6 +37,8 @@ class TestQgsMapToolEditMesh : public QObject
void editMesh();
+ void selectElements();
+
private:
QgisApp *mQgisApp = nullptr;
std::unique_ptr meshLayerQuadFlower;
@@ -388,5 +390,53 @@ void TestQgsMapToolEditMesh::editMesh()
QCOMPARE( mEditMeshMapTool->mSelectedFaces.count(), 0 );
}
+void TestQgsMapToolEditMesh::selectElements()
+{
+ QString uri = QString( mDataDir + "/quad_and_triangle_with_free_vertices.2dm" );
+ std::unique_ptr layer = std::make_unique( uri, "quad and triangle", "mdal" );
+ QVERIFY( layer->isValid() );
+
+ const QgsCoordinateTransform transform;
+ QgsMeshEditingError error;
+ layer->startFrameEditing( transform, error, false );
+ QVERIFY( error == QgsMeshEditingError() );
+
+ mCanvas->setLayers( QList() << layer.get() );
+
+ QVERIFY( layer->meshEditor() );
+
+ TestQgsMapToolAdvancedDigitizingUtils tool( mEditMeshMapTool );
+ mCanvas->setCurrentLayer( layer.get() );
+ mEditMeshMapTool->mActionDigitizing->trigger();
+
+ // select all vertices
+ QCOMPARE( mEditMeshMapTool->mSelectedVertices.count(), 0 );
+ mEditMeshMapTool->mActionSelectAllVertices->trigger();
+ QCOMPARE( mEditMeshMapTool->mSelectedVertices.count(), 10 );
+
+ // reset selection
+ tool.mouseClick( 0, 0, Qt::LeftButton );
+
+ // select isolated vertices
+ QCOMPARE( mEditMeshMapTool->mSelectedVertices.count(), 0 );
+ mEditMeshMapTool->mActionSelectIsolatedVertices->trigger();
+ QCOMPARE( mEditMeshMapTool->mSelectedVertices.count(), 5 );
+
+ // reset selection
+ tool.mouseClick( 0, 0, Qt::LeftButton );
+
+ // select by polygon
+ QCOMPARE( mEditMeshMapTool->mSelectedVertices.count(), 0 );
+ mEditMeshMapTool->mActionSelectByPolygon->trigger();
+
+ // polygon definition
+ tool.mouseClick( 2100, 3000, Qt::LeftButton );
+ tool.mouseClick( 2900, 2300, Qt::LeftButton );
+ tool.mouseClick( 3100, 3000, Qt::LeftButton );
+ tool.mouseClick( 2500, 3000, Qt::RightButton );
+
+ QCOMPARE( mEditMeshMapTool->mSelectedVertices.count(), 3 );
+}
+
QGSTEST_MAIN( TestQgsMapToolEditMesh )
#include "testqgsmaptooleditmesh.moc"
diff --git a/tests/testdata/mesh/quad_and_triangle_with_free_vertices.2dm b/tests/testdata/mesh/quad_and_triangle_with_free_vertices.2dm
new file mode 100644
index 000000000000..ebf8a79eb3ac
--- /dev/null
+++ b/tests/testdata/mesh/quad_and_triangle_with_free_vertices.2dm
@@ -0,0 +1,13 @@
+MESH2D
+ND 1 1000 2000 20
+ND 2 2000 2000 30
+ND 3 3000 2000 40
+ND 4 2000 3000 50
+ND 5 1000 3000 10
+ND 6 2453.85 2920.15 0
+ND 7 2915.19 2965.09 0
+ND 8 2783.38 2656.53 0
+ND 9 964.98 1799.75 0
+ND 10 1555.14 1781.78 0
+E4Q 1 1 2 4 5
+E3T 2 2 3 4