QgsMapToolIdentify class
Map tool for identifying features in layers.
Contents
after selecting a point, performs the identification:
- for raster layers shows value of underlying pixel
- for vector layers shows feature attributes within search radius (allows editing values when vector layer is in editing mode)
Base classes
- class QgsMapTool
- Abstract base class for all map tools.
Derived classes
- class QgsMapToolIdentifyFeature
- The QgsMapToolIdentifyFeature class is a map tool to identify a feature on a chosen layer.
Constructors, destructors, conversion operators
- QgsMapToolIdentify(QgsMapCanvas* canvas)
- constructor
Public functions
- void activate() override
- called when set as currently active map tool
- void canvasMoveEvent(QgsMapMouseEvent* e) override
- Mouse move event for overriding. Default implementation does nothing.
- void canvasPressEvent(QgsMapMouseEvent* e) override
- Mouse press event for overriding. Default implementation does nothing.
- void canvasReleaseEvent(QgsMapMouseEvent* e) override
- Mouse release event for overriding. Default implementation does nothing.
- void deactivate() override
- called when map tool is being deactivated
- auto flags() const -> Flags override
- Returns the flags for the map tool.
-
auto identify(int x,
int y,
const QList<QgsMapLayer*>& layerList = QList<QgsMapLayer*>(),
IdentifyMode mode = DefaultQgsSetting) -> QList<QgsMapToolIdentify::
IdentifyResult> - Performs the identification.
-
auto identify(int x,
int y,
IdentifyMode mode,
LayerType layerType = AllLayers) -> QList<QgsMapToolIdentify::
IdentifyResult> - Performs the identification.
-
auto identify(const QgsGeometry& geometry,
IdentifyMode mode,
LayerType layerType) -> QList<QgsMapToolIdentify::
IdentifyResult> - Performs identification based on a geometry (in map coordinates)
-
auto identify(const QgsGeometry& geometry,
IdentifyMode mode,
const QList<QgsMapLayer*>& layerList,
LayerType layerType) -> QList<QgsMapToolIdentify::
IdentifyResult> - Performs identification based on a geometry (in map coordinates)
- auto identifyMenu() -> QgsIdentifyMenu*
- Returns a pointer to the identify menu which will be used in layer selection mode this menu can also be customized.
Protected functions
- auto derivedAttributesForPoint(const QgsPoint& point) -> QMap<QString, QString>
- Returns derived attributes map for a clicked point in map coordinates. May be 2D or 3D point.
-
auto identify(int x,
int y,
IdentifyMode mode,
const QList<QgsMapLayer*>& layerList,
LayerType layerType = AllLayers) -> QList<QgsMapToolIdentify::
IdentifyResult> - Performs the identification.
-
auto identifyLayer(QList<QgsMapToolIdentify::
IdentifyResult>* results, QgsMapLayer* layer, const QgsPointXY& point, const QgsRectangle& viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType = AllLayers) -> bool - Call the right method depending on layer type.
- void restoreCanvasPropertiesOverrides()
- Clears canvas properties overrides previously set with setCanvasPropertiesOverrides()
- void setCanvasPropertiesOverrides(double searchRadiusMapUnits)
- Overrides some map canvas properties inside the map tool for the upcoming identify requests.
Private functions
-
auto displayAreaUnits() const -> QgsUnitTypes::
AreaUnit virtual - Desired units for area display.
-
auto displayDistanceUnits() const -> QgsUnitTypes::
DistanceUnit virtual - Desired units for distance display.
Function documentation
Flags QgsMapToolIdentify:: flags() const override
Returns the flags for the map tool.
QList<QgsMapToolIdentify:: IdentifyResult> QgsMapToolIdentify:: identify(int x,
int y,
const QList<QgsMapLayer*>& layerList = QList<QgsMapLayer*>(),
IdentifyMode mode = DefaultQgsSetting)
Performs the identification.
| Parameters | |
|---|---|
| x | x coordinates of mouseEvent |
| y | y coordinates of mouseEvent |
| layerList | Performs the identification within the given list of layers. Default value is an empty list, i.e. uses all the layers. |
| mode | Identification mode. Can use Qgis default settings or a defined mode. Default mode is DefaultQgsSetting. |
| Returns | a list of IdentifyResult |
QList<QgsMapToolIdentify:: IdentifyResult> QgsMapToolIdentify:: identify(int x,
int y,
IdentifyMode mode,
LayerType layerType = AllLayers)
Performs the identification.
| Parameters | |
|---|---|
| x | x coordinates of mouseEvent |
| y | y coordinates of mouseEvent |
| mode | Identification mode. Can use Qgis default settings or a defined mode. |
| layerType | Only performs identification in a certain type of layers (raster, vector). Default value is AllLayers. |
| Returns | a list of IdentifyResult |
To avoid being forced to specify IdentifyMode with a list of layers this has been made private and two publics methods are offered
QList<QgsMapToolIdentify:: IdentifyResult> QgsMapToolIdentify:: identify(int x,
int y,
IdentifyMode mode,
const QList<QgsMapLayer*>& layerList,
LayerType layerType = AllLayers) protected
Performs the identification.
| Parameters | |
|---|---|
| x | x coordinates of mouseEvent |
| y | y coordinates of mouseEvent |
| mode | Identification mode. Can use Qgis default settings or a defined mode. |
| layerList | Performs the identification within the given list of layers. |
| layerType | Only performs identification in a certain type of layers (raster, vector). |
| Returns | a list of IdentifyResult |
To avoid being forced to specify IdentifyMode with a list of layers this has been made private and two publics methods are offered
void QgsMapToolIdentify:: restoreCanvasPropertiesOverrides() protected
Clears canvas properties overrides previously set with setCanvasPropertiesOverrides()
void QgsMapToolIdentify:: setCanvasPropertiesOverrides(double searchRadiusMapUnits) protected
Overrides some map canvas properties inside the map tool for the upcoming identify requests.
This is useful when the identification is triggered by some other piece of GUI like a 3D map view and some properties like search radius need to be adjusted so that identification returns correct results. Currently only search radius may be overridden.
When the custom identification has finished, restoreCanvasPropertiesOverrides() should be called to erase any overrides.
QgsUnitTypes:: AreaUnit QgsMapToolIdentify:: displayAreaUnits() const virtual private
Desired units for area display.
QgsUnitTypes:: DistanceUnit QgsMapToolIdentify:: displayDistanceUnits() const virtual private
Desired units for distance display.