Skip to content

Commit

Permalink
Select mesh elements by expression UI (#44835)
Browse files Browse the repository at this point in the history
[mesh] [feature] Select mesh elements by expression
  • Loading branch information
vcloarec committed Sep 9, 2021
1 parent b90b86b commit 45e07dd
Show file tree
Hide file tree
Showing 26 changed files with 840 additions and 86 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -924,6 +924,7 @@
<file>themes/default/mActionMeasureBearing.svg</file>
<file>themes/default/mActionMeshDigitizing.svg</file>
<file>themes/default/mActionMeshSelectPolygon.svg</file>
<file>themes/default/mActionMeshSelectExpression.svg</file>
<file>themes/default/mActionNewMeshLayer.svg</file>
<file>themes/default/mActionMeshTransformByExpression.svg</file>
<file>themes/default/mIconGeometryCollectionLayer.svg</file>
Expand Down
1 change: 1 addition & 0 deletions images/themes/default/mActionMeshSelectExpression.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -367,9 +367,9 @@ Creates a new scope which contains variables and functions relating to provider
Registers all known core functions provided by :py:class:`QgsExpressionContextScope` objects.
%End

static QgsExpressionContextScope *meshExpressionScope() /Factory/;
static QgsExpressionContextScope *meshExpressionScope( QgsMesh::ElementType elementType ) /Factory/;
%Docstring
Creates a new scope which contains functions relating to mesh layer elements (face, vertex, ...)
Creates a new scope which contains functions relating to mesh layer element ``elementType``

.. versionadded:: 3.22
%End
Expand Down
12 changes: 11 additions & 1 deletion python/core/auto_generated/mesh/qgsmeshlayer.sip.in
Expand Up @@ -660,13 +660,23 @@ The returned position is in map coordinates.
.. versionadded:: 3.14
%End

QList<int> selectVerticesByExpression( const QString &expression, const QgsExpressionContext &expressionContext = QgsExpressionContext() );
QList<int> selectVerticesByExpression( QgsExpression expression );
%Docstring
Returns a list of vertex indexes that meet the condition defined by ``expression`` with the context ``expressionContext``

To express the relation with a vertex, the expression can be defined with function returning value
linked to the current vertex, like " $vertex_z ", "$vertex_as_point"

.. versionadded:: 3.22
%End

QList<int> selectFacesByExpression( QgsExpression expression );
%Docstring
Returns a list of faces indexes that meet the condition defined by ``expression`` with the context ``expressionContext``

To express the relation with a face, the expression can be defined with function returning value
linked to the current face, like " $face_area "

.. versionadded:: 3.22
%End

Expand Down
7 changes: 7 additions & 0 deletions python/gui/auto_generated/qgsexpressionbuilderwidget.sip.in
Expand Up @@ -288,6 +288,13 @@ Will be set to ``True`` if the current expression text reports a parser error
with the context.

.. versionadded:: 3.0
%End

void setExpressionPreviewVisible( bool isVisible );
%Docstring
Sets whether the expression preview is visible.

.. versionadded:: 3.22
%End

public slots:
Expand Down
7 changes: 7 additions & 0 deletions resources/function_help/json/$face_area
@@ -0,0 +1,7 @@
{
"name": "$face_area",
"type": "function",
"groups": ["Meshes"],
"description": "Returns the area of the current mesh face. The area calculated by this function respects both the current project's ellipsoid setting and area unit settings. For example, if an ellipsoid has been set for the project then the calculated area will be ellipsoidal, and if no ellipsoid is set then the calculated area will be planimetric.",
"examples": [ { "expression":"$face_area", "returns":"42"}]
}
7 changes: 7 additions & 0 deletions resources/function_help/json/$face_index
@@ -0,0 +1,7 @@
{
"name": "$face_index",
"type": "function",
"groups": ["Meshes"],
"description": "Returns the index of the current mesh face. ",
"examples": [ { "expression":"$face_index", "returns":"4581"}]
}
8 changes: 8 additions & 0 deletions resources/function_help/json/$vertex_index
@@ -0,0 +1,8 @@
{
"name": "$vertex_index",
"type": "function",
"groups": ["Meshes"],
"description": "Returns the index of the current mesh vertex.",
"examples": [ { "expression":"$vertex_index", "returns":"9874"}
]
}
8 changes: 8 additions & 0 deletions resources/function_help/json/$vertex_x
@@ -0,0 +1,8 @@
{
"name": "$vertex_x",
"type": "function",
"groups": ["Meshes"],
"description": "Returns the X coordinate of the current mesh vertex.",
"examples": [ { "expression":"$vertex_x", "returns":"42.12"}
]
}
8 changes: 8 additions & 0 deletions resources/function_help/json/$vertex_y
@@ -0,0 +1,8 @@
{
"name": "$vertex_y",
"type": "function",
"groups": ["Meshes"],
"description": "Returns the Y coordinate of the current mesh vertex.",
"examples": [ { "expression":"$vertex_y", "returns":"12.24"}
]
}
1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Expand Up @@ -251,6 +251,7 @@ set(QGIS_APP_SRCS
mesh/qgsnewmeshlayerdialog.cpp
mesh/qgsmaptooleditmeshframe.cpp
mesh/qgsmeshtransformcoordinatesdockwidget.cpp
mesh/qgsmeshselectbyexpressiondialog.cpp
)

if (WITH_SPATIALITE)
Expand Down

0 comments on commit 45e07dd

Please sign in to comment.