Class: QgsMapHitTest¶
-
class
qgis.core.
QgsMapHitTest
(settings: QgsMapSettings, polygon: QgsGeometry = QgsGeometry(), layerFilterExpression: object = QgsMapHitTest.LayerFilterExpression())¶ Bases:
sip.wrapper
- Parameters
settings (QgsMapSettings) – Map settings used to evaluate symbols
polygon (
QgsGeometry
= QgsGeometry()) – Polygon geometry to refine the hit testlayerFilterExpression (object = QgsMapHitTest.LayerFilterExpression()) – Expression string for each layer id to evaluate in order to refine the symbol selection
QgsMapHitTest(settings:
QgsMapSettings
, layerFilterExpression: object) Constructor version used with only expressions to filter symbols (no extent or polygon intersection)QgsMapHitTest(
QgsMapHitTest
)Class that runs a hit test with given map settings. Based on the hit test it returns which symbols will be visible on the map - this is useful for content based legend.
Methods
Tests whether a given legend key is visible for a specified layer.
Runs the map hit test
Tests whether a symbol is visible for a specified layer.
-
legendKeyVisible
(self, ruleKey: str, layer: QgsVectorLayer) → bool¶ Tests whether a given legend key is visible for a specified layer.
- Parameters
ruleKey (str) – legend rule key
layer (QgsVectorLayer) – vector layer
See also
New in version 2.14.
- Return type
bool
-
run
(self)¶ Runs the map hit test
-
symbolVisible
(self, symbol: QgsSymbol, layer: QgsVectorLayer) → bool¶ Tests whether a symbol is visible for a specified layer.
- Parameters
symbol (QgsSymbol) – symbol to find
layer (QgsVectorLayer) – vector layer
See also
New in version 2.12.
- Return type
bool