QGIS API Documentation 4.1.0-Master (4aad578bf8d)
Loading...
Searching...
No Matches
QgsMapToolSelectUtils Namespace Reference

The QgsMapToolSelectUtils namespace containing methods which are useful for the select maptool widgets. More...

Classes

class  QgsMapToolSelectMenuActions
 Handles actions which can be displayed in a context menu related to feature selection. More...

Functions

QgsRectangle GUI_EXPORT expandSelectRectangle (QgsPointXY mapPoint, QgsMapCanvas *canvas, QgsMapLayer *layer)
 Expands a point to a rectangle with minimum size for selection based on the layer.
QgsMapLayergetCurrentTargetLayer (QgsMapCanvas *canvas)
 Get the current selected canvas map layer.
QgsFeatureIds getMatchingFeatures (QgsMapCanvas *canvas, const QgsGeometry &selectGeometry, bool doContains, bool singleSelect)
 Calculates a list of features matching a selection geometry and flags.
void selectMultipleFeatures (QgsMapCanvas *canvas, const QgsGeometry &selectGeometry, Qt::KeyboardModifiers modifiers)
 Selects multiple matching features from within currently selected layer.
void selectSingleFeature (QgsMapCanvas *canvas, const QgsGeometry &selectGeometry, Qt::KeyboardModifiers modifiers)
 Selects a single feature from within currently selected layer.
void GUI_EXPORT setRubberBand (QgsMapCanvas *canvas, QRect &selectRect, QgsRubberBand *rubberBand)
 Sets a QgsRubberband to rectangle in map units using a rectangle defined in device coords.
void setSelectedFeatures (QgsMapCanvas *canvas, const QgsGeometry &selectGeometry, Qgis::SelectBehavior selectBehavior=Qgis::SelectBehavior::SetSelection, bool doContains=true, bool singleSelect=false)
 Selects the features within currently selected layer.

Detailed Description

The QgsMapToolSelectUtils namespace containing methods which are useful for the select maptool widgets.

Note
not available in Python bindings

Function Documentation

◆ expandSelectRectangle()

QgsRectangle QgsMapToolSelectUtils::expandSelectRectangle ( QgsPointXY mapPoint,
QgsMapCanvas * canvas,
QgsMapLayer * layer )

Expands a point to a rectangle with minimum size for selection based on the layer.

Parameters
mapPointThe point to expand the rectangle around (in map coordinates)
canvasThe map canvas used to transform between canvas and map units
layerThe target layer
Returns
Expanded rectangle in map units

Definition at line 104 of file qgsmaptoolselectutils.cpp.

◆ getCurrentTargetLayer()

QgsMapLayer * QgsMapToolSelectUtils::getCurrentTargetLayer ( QgsMapCanvas * canvas)

Get the current selected canvas map layer.

Returns nullptr if it is not a selectable layer

Parameters
canvasThe map canvas used for getting the current layer

Definition at line 53 of file qgsmaptoolselectutils.cpp.

◆ getMatchingFeatures()

QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures ( QgsMapCanvas * canvas,
const QgsGeometry & selectGeometry,
bool doContains,
bool singleSelect )

Calculates a list of features matching a selection geometry and flags.

Parameters
canvasthe map canvas used to get the current selected vector layer and for any required geometry transformations
selectGeometrythe geometry to select the layers features. This geometry must be in terms of the canvas coordinate system.
doContainsfeatures will only be selected if fully contained within the selection rubber band (otherwise intersection is enough).
singleSelectonly selects the closest feature to the selectGeometry.
Returns
list of features which match search geometry and parameters

Definition at line 359 of file qgsmaptoolselectutils.cpp.

◆ selectMultipleFeatures()

void QgsMapToolSelectUtils::selectMultipleFeatures ( QgsMapCanvas * canvas,
const QgsGeometry & selectGeometry,
Qt::KeyboardModifiers modifiers )

Selects multiple matching features from within currently selected layer.

Parameters
canvasthe map canvas used to get the current selected vector layer and for any required geometry transformations
selectGeometrythe geometry to select the layers features. This geometry must be in terms of the canvas coordinate system.
modifiersKeyboard modifiers are used to determine the current selection operations (add, subtract, contains)
See also
selectSingleFeature()

Definition at line 154 of file qgsmaptoolselectutils.cpp.

◆ selectSingleFeature()

void QgsMapToolSelectUtils::selectSingleFeature ( QgsMapCanvas * canvas,
const QgsGeometry & selectGeometry,
Qt::KeyboardModifiers modifiers )

Selects a single feature from within currently selected layer.

Parameters
canvasthe map canvas used to get the current selected vector layer and for any required geometry transformations
selectGeometrythe geometry to select the layers features. This geometry must be in terms of the canvas coordinate system.
modifiersKeyboard modifiers are used to determine the current selection operations (add, subtract, contains)
See also
selectMultipleFeatures()

Definition at line 215 of file qgsmaptoolselectutils.cpp.

◆ setRubberBand()

void QgsMapToolSelectUtils::setRubberBand ( QgsMapCanvas * canvas,
QRect & selectRect,
QgsRubberBand * rubberBand )

Sets a QgsRubberband to rectangle in map units using a rectangle defined in device coords.

Parameters
canvasThe map canvas used to transform the rectangle into map units
selectRectThe input rectangle in device coords
rubberBandThe rubberband that will be set in map units using the input rectangle

Definition at line 86 of file qgsmaptoolselectutils.cpp.

◆ setSelectedFeatures()

void QgsMapToolSelectUtils::setSelectedFeatures ( QgsMapCanvas * canvas,
const QgsGeometry & selectGeometry,
Qgis::SelectBehavior selectBehavior = Qgis::SelectBehavior::SetSelection,
bool doContains = true,
bool singleSelect = false )

Selects the features within currently selected layer.

Parameters
canvasthe map canvas used to get the current selected vector layer and for any required geometry transformations
selectGeometrythe geometry to select the layers features. This geometry must be in terms of the canvas coordinate system.
selectBehaviorbehavior of select (ie replace selection, add to selection)
doContainsfeatures will only be selected if fully contained within the selection rubber band (otherwise intersection is enough).
singleSelectonly selects the closest feature to the selectGeometry.

Definition at line 302 of file qgsmaptoolselectutils.cpp.