mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Mesh selection actions (#58888)
* add new actions * icons for actions * fix styling * select by expression * add tests
This commit is contained in:
parent
10883253d3
commit
3d92b2b460
@ -938,11 +938,13 @@
|
||||
<file>themes/default/mActionMeshDigitizing.svg</file>
|
||||
<file>themes/default/mActionMeshSelectPolygon.svg</file>
|
||||
<file>themes/default/mActionMeshSelectExpression.svg</file>
|
||||
<file>themes/default/mActionMeshSelectIsolatedVertices.svg</file>
|
||||
<file>themes/default/mActionNewMeshLayer.svg</file>
|
||||
<file>themes/default/mActionMeshTransformByExpression.svg</file>
|
||||
<file>themes/default/mIconVertexCoordinates.svg</file>
|
||||
<file>themes/default/mActionMeshEditForceByVectorLines.svg</file>
|
||||
<file>themes/default/mActionMeshReindex.svg</file>
|
||||
<file>themes/default/mActionMeshSelectAll.svg</file>
|
||||
<file>themes/default/mIconGeometryCollectionLayer.svg</file>
|
||||
<file>themes/default/mIconGps.svg</file>
|
||||
<file>themes/default/mActionNewGpx.svg</file>
|
||||
|
1
images/themes/default/mActionMeshSelectAll.svg
Normal file
1
images/themes/default/mActionMeshSelectAll.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg height="24" width="24" xmlns="http://www.w3.org/2000/svg"><g stroke-linecap="round"><g fill="none" stroke="#6d7281" stroke-width="1" transform="matrix(1.013697,0,0,0.98287877,-0.369842,-0.425299)"><path d="M 13,2 2.3040952,12.995327 m 0,-10.9999995 L 13,13 M 1.8040952,1.4953275 13.5,1.5 v 12 L 1.8040952,13.4953 Z" /><path d="m 13.5,1.5 h 9 v 12 h -9 z M 1.8040952,13.495327 13.5,13.5 v 9 L 1.8040952,22.495327 Z M 22,2 14,13" /><path d="m 13.5,13.5 -12,9" /></g><g fill="#fce94f" stroke="#c4a000" stroke-width="0.5" transform="translate(12.529724,13.101342)"><rect height="2.5" rx="1.5" width="2.5" x="1.9143078" y="1.2829129" /><rect height="2.5" rx="1.5" width="2.5" x="4.6882553" y="7.1954389" /><rect height="2.5" rx="1.5" width="2.5" x="8.4036779" y="3.6098669" /></g></g><g fill="#fce94f" stroke="#c4a000" stroke-linejoin="round" stroke-width="1.077" ><path d="M 1.1507031,1.0490189 7.0824062,6.9937127 1.1507031,12.843564 Z" /><path d="M 1.1507031,1.0490189 H 13.315067 L 7.0824062,6.9937127 Z" /><path d="M 1.1507031,12.843564 7.0824062,6.9937127 13.315067,12.843564 Z" /><path d="M 13.315067,12.843564 7.0824062,6.9937127 13.315067,1.0490189 Z" /><path d="M 13.315067,12.843564 V 1.0490189 h 9.123273 z" /><path d="M 13.315067,12.843564 22.43834,1.0490189 V 12.843564 Z" /><path d="m 13.315067,12.843569 v 0 l 10e-7,8.845904 H 1.1507035 Z" /><path d="m 13.315067,12.843569 -12.1643639,-5e-6 v 0 l 4e-7,8.845909 z" /></g></svg>
|
After Width: | Height: | Size: 1.4 KiB |
@ -0,0 +1 @@
|
||||
<svg height="24" width="24" xmlns="http://www.w3.org/2000/svg"><g stroke-linecap="round" fill="none" stroke="#6d7281" stroke-width="1.0"><path d="m 13.315068,1.0490192 h 9.123273 V 12.843564 H 13.315068 Z M 1.1507035,12.843564 H 13.315068 v 8.845909 H 1.1507035 Z M 21.931492,1.5404585 13.821916,12.352125 m -6.5890305,0.982879 v 7.86303" /><path d="M 12.808219,17.266519 H 1.657552" /></g><g fill="#fce94f" stroke="#c4a000" stroke-width="0.5"><rect height="2.4919915" rx="1.5574945" width="2.4919913" x="1.9143078" y="1.2829129" /><rect height="2.4919915" rx="1.5574945" width="2.4919913" x="2.6882553" y="7.1954389" /><rect height="2.4919915" rx="1.5574945" width="2.4919913" x="8.4036779" y="3.6098669" /><rect height="2.4919915" rx="1.5574945" width="2.4919913" x="16.027996" y="14.243526" /></g></svg>
|
After Width: | Height: | Size: 807 B |
@ -222,8 +222,13 @@ QgsMapToolEditMeshFrame::QgsMapToolEditMeshFrame( QgsMapCanvas *canvas )
|
||||
|
||||
mSelectionHandler = std::make_unique<QgsMapToolSelectionHandler>( 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 );
|
||||
@ -273,6 +278,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<int> 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 );
|
||||
@ -371,7 +389,9 @@ void QgsMapToolEditMeshFrame::setActionsEnable( bool enable )
|
||||
<< mActionSelectByExpression
|
||||
<< mActionTransformCoordinates
|
||||
<< mActionForceByLines
|
||||
<< mActionReindexMesh;
|
||||
<< mActionReindexMesh
|
||||
<< mActionSelectIsolatedVertices
|
||||
<< mActionSelectAllVertices;
|
||||
|
||||
for ( QAction *action : std::as_const( actions ) )
|
||||
action->setEnabled( enable );
|
||||
|
@ -351,6 +351,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;
|
||||
|
||||
|
@ -37,6 +37,8 @@ class TestQgsMapToolEditMesh : public QObject
|
||||
|
||||
void editMesh();
|
||||
|
||||
void selectElements();
|
||||
|
||||
private:
|
||||
QgisApp *mQgisApp = nullptr;
|
||||
std::unique_ptr<QgsMeshLayer> 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<QgsMeshLayer> layer = std::make_unique<QgsMeshLayer>( uri, "quad and triangle", "mdal" );
|
||||
QVERIFY( layer->isValid() );
|
||||
|
||||
const QgsCoordinateTransform transform;
|
||||
QgsMeshEditingError error;
|
||||
layer->startFrameEditing( transform, error, false );
|
||||
QVERIFY( error == QgsMeshEditingError() );
|
||||
|
||||
mCanvas->setLayers( QList<QgsMapLayer *>() << 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"
|
||||
|
13
tests/testdata/mesh/quad_and_triangle_with_free_vertices.2dm
vendored
Normal file
13
tests/testdata/mesh/quad_and_triangle_with_free_vertices.2dm
vendored
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user