QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | 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, QStringLayerFilterExpression
 Maps an expression string to a layer id. More...
 

Public Member Functions

 QgsMapHitTest (const QgsMapSettings &settings, const QgsGeometry &polygon=QgsGeometry(), const LayerFilterExpression &layerFilterExpression=LayerFilterExpression())
 
 QgsMapHitTest (const QgsMapSettings &settings, const LayerFilterExpression &layerFilterExpression)
 Constructor version used with only expressions to filter symbols (no extent or polygon intersection) More...
 
bool legendKeyVisible (const QString &ruleKey, QgsVectorLayer *layer) const
 Tests whether a given legend key is visible for a specified layer. More...
 
void run ()
 Runs the map hit test. More...
 
bool symbolVisible (QgsSymbolV2 *symbol, QgsVectorLayer *layer) const
 Tests whether a symbol is visible for a specified layer. More...
 

Protected Types

typedef QMap< QgsVectorLayer *, SymbolV2SetHitTest
 
typedef QSet< QStringSymbolV2Set
 

Protected Member Functions

void runHitTestLayer (QgsVectorLayer *vl, SymbolV2Set &usedSymbols, SymbolV2Set &usedSymbolsRuleKey, QgsRenderContext &context)
 Runs test for visible symbols within a layer. More...
 

Protected Attributes

HitTest mHitTest
 The hit test. More...
 
HitTest mHitTestRuleKey
 The hit test, using legend rule keys. More...
 
LayerFilterExpression mLayerFilterExpression
 List of expression filter for each layer. More...
 
bool mOnlyExpressions
 Whether to use only expressions during the filtering. More...
 
QgsGeometry mPolygon
 Polygon used for filtering items. May be empty. More...
 
QgsMapSettings mSettings
 The initial map settings. More...
 

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.

Note
added in 2.6

Definition at line 34 of file qgsmaphittest.h.

Member Typedef Documentation

Note
not available in Python bindings

Definition at line 73 of file qgsmaphittest.h.

Maps an expression string to a layer id.

Definition at line 38 of file qgsmaphittest.h.

Note
not available in Python bindings

Definition at line 70 of file qgsmaphittest.h.

Constructor & Destructor Documentation

QgsMapHitTest::QgsMapHitTest ( const QgsMapSettings settings,
const QgsGeometry polygon = QgsGeometry(),
const LayerFilterExpression layerFilterExpression = 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 29 of file qgsmaphittest.cpp.

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

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

Definition at line 40 of file qgsmaphittest.cpp.

Member Function Documentation

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
Note
added in QGIS 2.14
See also
symbolVisible()

Definition at line 97 of file qgsmaphittest.cpp.

void QgsMapHitTest::run ( )

Runs the map hit test.

Definition at line 47 of file qgsmaphittest.cpp.

void QgsMapHitTest::runHitTestLayer ( QgsVectorLayer vl,
SymbolV2Set usedSymbols,
SymbolV2Set usedSymbolsRuleKey,
QgsRenderContext context 
)
protected

Runs test for visible symbols within a layer.

Parameters
vlvector layer
usedSymbolsset for storage of visible symbols
usedSymbolsRuleKeyset of storage of visible legend rule keys
contextrender context
Note
added in QGIS 2.12
not available in Python bindings

Definition at line 105 of file qgsmaphittest.cpp.

bool QgsMapHitTest::symbolVisible ( QgsSymbolV2 symbol,
QgsVectorLayer layer 
) const

Tests whether a symbol is visible for a specified layer.

Parameters
symbolsymbol to find
layervector layer
Note
added in QGIS 2.12
See also
legendKeyVisible()

Definition at line 89 of file qgsmaphittest.cpp.

Member Data Documentation

HitTest QgsMapHitTest::mHitTest
protected

The hit test.

Definition at line 89 of file qgsmaphittest.h.

HitTest QgsMapHitTest::mHitTestRuleKey
protected

The hit test, using legend rule keys.

Definition at line 92 of file qgsmaphittest.h.

LayerFilterExpression QgsMapHitTest::mLayerFilterExpression
protected

List of expression filter for each layer.

Definition at line 95 of file qgsmaphittest.h.

bool QgsMapHitTest::mOnlyExpressions
protected

Whether to use only expressions during the filtering.

Definition at line 101 of file qgsmaphittest.h.

QgsGeometry QgsMapHitTest::mPolygon
protected

Polygon used for filtering items. May be empty.

Definition at line 98 of file qgsmaphittest.h.

QgsMapSettings QgsMapHitTest::mSettings
protected

The initial map settings.

Definition at line 86 of file qgsmaphittest.h.


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