QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Friends | List of all members
QgsMapHitTest Class Reference

Class that runs a hit test with given map settings. More...

#include <qgsmaphittest.h>

Public Types

typedef QMap< QString, QString > LayerFilterExpression
 Maps an expression string to a layer id.
 

Public Member Functions

 QgsMapHitTest (const QgsLayerTreeFilterSettings &settings)
 Constructor based off layer tree filter settings.
 
 QgsMapHitTest (const QgsMapSettings &settings, const QgsGeometry &polygon=QgsGeometry(), const QgsMapHitTest::LayerFilterExpression &layerFilterExpression=QgsMapHitTest::LayerFilterExpression())
 
 QgsMapHitTest (const QgsMapSettings &settings, const QgsMapHitTest::LayerFilterExpression &layerFilterExpression)
 Constructor version used with only expressions to filter symbols (no extent or polygon intersection)
 
bool legendKeyVisible (const QString &ruleKey, QgsVectorLayer *layer) const
 Tests whether a given legend key is visible for a specified layer.
 
QMap< QString, QSet< QString > > results () const
 Returns the hit test results, which are a map of layer ID to visible symbol legend keys.
 
void run ()
 Runs the map hit test.
 
PRIVATE bool symbolVisible (QgsSymbol *symbol, QgsVectorLayer *layer) const
 Tests whether a symbol is visible for a specified layer.
 

Friends

class QgsMapHitTestTask
 

Detailed Description

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.

Definition at line 42 of file qgsmaphittest.h.

Member Typedef Documentation

◆ LayerFilterExpression

typedef QMap<QString, QString> QgsMapHitTest::LayerFilterExpression

Maps an expression string to a layer id.

Definition at line 46 of file qgsmaphittest.h.

Constructor & Destructor Documentation

◆ QgsMapHitTest() [1/3]

QgsMapHitTest::QgsMapHitTest ( const QgsMapSettings settings,
const QgsGeometry polygon = QgsGeometry(),
const QgsMapHitTest::LayerFilterExpression layerFilterExpression = QgsMapHitTest::LayerFilterExpression() 
)
Parameters
settingsMap settings used to evaluate symbols
polygonPolygon geometry to refine the hit test
layerFilterExpressionExpression string for each layer id to evaluate in order to refine the symbol selection

Definition at line 30 of file qgsmaphittest.cpp.

◆ QgsMapHitTest() [2/3]

QgsMapHitTest::QgsMapHitTest ( const QgsMapSettings settings,
const QgsMapHitTest::LayerFilterExpression layerFilterExpression 
)

Constructor version used with only expressions to filter symbols (no extent or polygon intersection)

Definition at line 37 of file qgsmaphittest.cpp.

◆ QgsMapHitTest() [3/3]

QgsMapHitTest::QgsMapHitTest ( const QgsLayerTreeFilterSettings settings)

Constructor based off layer tree filter settings.

Since
QGIS 3.32

Definition at line 44 of file qgsmaphittest.cpp.

Member Function Documentation

◆ legendKeyVisible()

bool QgsMapHitTest::legendKeyVisible ( const QString &  ruleKey,
QgsVectorLayer layer 
) const

Tests whether a given legend key is visible for a specified layer.

Parameters
ruleKeylegend rule key
layervector layer
See also
symbolVisible()

Definition at line 131 of file qgsmaphittest.cpp.

◆ results()

QMap< QString, QSet< QString > > QgsMapHitTest::results ( ) const

Returns the hit test results, which are a map of layer ID to visible symbol legend keys.

Note
Not available in Python bindings
Since
QGIS 3.32

Definition at line 102 of file qgsmaphittest.cpp.

◆ run()

void QgsMapHitTest::run ( )

Runs the map hit test.

Definition at line 50 of file qgsmaphittest.cpp.

◆ symbolVisible()

PRIVATE bool QgsMapHitTest::symbolVisible ( QgsSymbol symbol,
QgsVectorLayer layer 
) const

Tests whether a symbol is visible for a specified layer.

Parameters
symbolsymbol to find
layervector layer
See also
legendKeyVisible()

Definition at line 119 of file qgsmaphittest.cpp.

Friends And Related Symbol Documentation

◆ QgsMapHitTestTask

friend class QgsMapHitTestTask
friend

Definition at line 143 of file qgsmaphittest.h.


The documentation for this class was generated from the following files: