Skip to content
Permalink
Browse files
Select mesh elements by expression UI (#44835)
[mesh] [feature] Select mesh elements by expression
  • Loading branch information
vcloarec committed Sep 9, 2021
1 parent b90b86b commit 45e07dd72fe44da70fd277d5431182a9218d2370
@@ -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>
@@ -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.003672" transform="matrix(1.013697 0 0 .98287877 -.369842 -.425299)"><path d="m13 2-11 11m0-11 11 11m-11.5-11.5h12v12h-12z"/><path d="m13.5 1.5h9v12h-9zm-12 12h12v9h-12zm20.5-11.5-8 11m-6.5 1v8"/><path d="m13 18h-11"/></g><g fill="#fce94f" stroke="#c4a000" stroke-linejoin="round" stroke-width="1.077"><path d="m1.1507031 1.0490189 5.9317031 5.9446938-5.9317031 5.8498513z"/><path d="m1.1507031 1.0490189h12.1643639l-6.2326608 5.9446938z"/><path d="m1.1507031 12.843564 5.9317031-5.8498513 6.2326608 5.8498513z"/><path d="m13.315067 12.843564-6.2326608-5.8498513 6.2326608-5.9446938z"/><path d="m13.315067 12.843564v-11.7945451h9.123273z"/><path d="m13.315067 12.843564 9.123273-11.7945451v11.7945451z"/><path d="m7.2 12.831149 6.115067.01242v4.344658l-6.0958115.03813z"/></g></g><g transform="translate(5.491525 -3.576271)"><path d="m-12.901812 19.194933c-1.92383-.683586-2.885744-1.718741-2.885742-3.105469-.000002-1.093739.50781-1.967761 1.523438-2.62207 1.025386-.654284 2.294916-.981432 3.808593-.981445 1.3769451.000013 2.470694.229505 3.2812505.688476.8105357.449232 1.2158087.991223 1.2158203 1.625977-.0000116.332042-.1269646.625011-.3808594.878906-.2539172.244151-.5468856.366221-.8789062.366211-.5468848.00001-.9961031-.380849-1.3476563-1.142578-.4882897-1.054675-1.2207109-1.582019-2.1972659-1.582031-.77149.000012-1.406255.253918-1.904297.761718-.498051.507824-.747074 1.215832-.74707 2.124024-.000004 1.787117.922847 2.680671 2.768555 2.680664.195305.000007.419914-.01952.6738279-.05859.4394451-.05859.7812417-.08788 1.0253906-.08789.595694.000008.8935452.170906.8935547.512696-.0000095.380866-.3027435.571295-.9082031.571289-.2148521.000006-.5371174-.03417-.9667969-.102539-.3222732-.05859-.5712962-.08788-.7470702-.08789-1.95313.000007-2.929692.996099-2.929688 2.988281-.000004.9668.258785 1.748049.776368 2.34375.517572.585939 1.240228.878907 2.167968.878907 1.1621017 0 1.9335853-.600585 2.3144535-1.801758.1953031-.634763.4101466-1.074216.6445312-1.31836.2441306-.244136.5663959-.366207.9667969-.366211.3320201.000004.6298714.122075.8935547.366211.2734255.234379.4101441.537113.4101562.908204-.0000121.888673-.4980585 1.625977-1.4941406 2.211914-.9961034.576171-2.2021568.864257-3.6181639.864257-1.55274 0-2.934575-.371093-4.145508-1.113281-1.201173-.742186-1.801759-1.733396-1.801758-2.973633-.000001-1.552729 1.196287-2.695306 3.588867-3.427734" fill="#5c3566" transform="translate(22.960894 .402232)"/><g fill="#fff"><path d="m8.8453703 15.335963c-1.8135886 1.95573-1.401671-.322256-.3145916-1.106748 1.1264312-.81289 1.7573183-.79349 1.7490763-.54418-.0096.290414-.8636237 1.035325-1.4344847 1.650928z" opacity=".5"/><path d="m8.2348719 21.645433c-1.8135886 1.95573-1.5022297.147018-.4151503-.637474 1.1264312-.81289 1.7573183-.79349 1.7490763-.54418-.0096.290414-.763065.566051-1.333926 1.181654z" opacity=".5"/><path d="m16.204463 23.831019c-1.74795 1.952651-1.613829.09846-.49057-.620714.858053-.549374 1.112902-.0745.49057.620714z" opacity=".5"/></g></g></svg>
@@ -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
@@ -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

@@ -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:
@@ -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"}]
}
@@ -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"}]
}
@@ -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"}
]
}
@@ -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"}
]
}
@@ -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"}
]
}
@@ -251,6 +251,7 @@ set(QGIS_APP_SRCS
mesh/qgsnewmeshlayerdialog.cpp
mesh/qgsmaptooleditmeshframe.cpp
mesh/qgsmeshtransformcoordinatesdockwidget.cpp
mesh/qgsmeshselectbyexpressiondialog.cpp
)

if (WITH_SPATIALITE)

0 comments on commit 45e07dd

Please sign in to comment.