Class: QgsLayerTreeFilterSettings¶
- class qgis.core.QgsLayerTreeFilterSettings¶
Bases:
sip.wrapper
Contains settings relating to filtering the contents of
QgsLayerTreeModel
and views.New in version 3.32.
QgsLayerTreeFilterSettings(settings:
QgsMapSettings
) Constructor forQgsLayerTreeFilterSettings
, using the specified mapsettings
.QgsLayerTreeFilterSettings(other:
QgsLayerTreeFilterSettings
) Copy constructor.Methods
Adds a visible extent
polygon
for a maplayer
.Returns the combined visible extent for a
layer
.Returns the optional filter polygon, used when testing for symbols to show in the legend.
Returns the filter flags.
Returns the filter expression to use for the layer with the specified
layerId
, or an empty string if no expression is set for the layer.Returns the map of layer IDs to legend filter expression.
Returns the layers which should be shown in the legend.
Returns the map settings used to filter the legend content.
Sets the optional filter
polygon
, used when testing for symbols to show in the legend.Sets the filter
flags
.Sets the map of layer IDs to legend filter expression.
Sets layer filter expressions using a layer
tree
.- addVisibleExtentForLayer(self, layer: QgsMapLayer, polygon: QgsReferencedGeometry)¶
Adds a visible extent
polygon
for a maplayer
.If
layer
is already included in the layers contained withinmapSettings()
(or previously added by calling this method) then thispolygon
extent will be unioned with the existing extent.The
layer
will be appended to the list of layers to use during the legend hit test. (Seelayers()
).- Parameters:
layer (QgsMapLayer) –
polygon (QgsReferencedGeometry) –
- combinedVisibleExtentForLayer(self, layer: QgsMapLayer) QgsGeometry ¶
Returns the combined visible extent for a
layer
.The combined visible extent includes:
the
mapSettings()
extent (respectingfilterPolygon()
if set) IF the layer is contained inmapSettings()
all additional extents added by calls to
addVisibleExtentForLayer()
The returned geometry will always be in the layer’s CRS.
- Parameters:
layer (QgsMapLayer) –
- Return type:
- filterPolygon(self) QgsGeometry ¶
Returns the optional filter polygon, used when testing for symbols to show in the legend.
The CRS of the polygon will match the destination CRS of
mapSettings()
.If not set then the filter visibility extent will use the extent of
mapSettings()
.See also
- Return type:
- flags(self) Qgis.LayerTreeFilterFlags ¶
Returns the filter flags.
See also
- Return type:
- layerFilterExpression(self, layerId: str) str ¶
Returns the filter expression to use for the layer with the specified
layerId
, or an empty string if no expression is set for the layer.See also
See also
- Parameters:
layerId (str) –
- Return type:
str
- layerFilterExpressions(self) Dict[str, str] ¶
Returns the map of layer IDs to legend filter expression.
See also
See also
- Return type:
Dict[str, str]
- layers(self) List[QgsMapLayer] ¶
Returns the layers which should be shown in the legend.
This includes all layers from the
mapSettings()
and any additional layers added by calls toaddVisibleExtentForLayer()
.See also
- Return type:
List[QgsMapLayer]
- mapSettings(self) QgsMapSettings ¶
Returns the map settings used to filter the legend content.
- Return type:
- setFilterPolygon(self, polygon: QgsGeometry)¶
Sets the optional filter
polygon
, used when testing for symbols to show in the legend.The CRS of the polygon must match the destination CRS of
mapSettings()
.If not set then the filter visibility extent will use the extent of
mapSettings()
.See also
- Parameters:
polygon (QgsGeometry) –
- setFlags(self, flags: Qgis.LayerTreeFilterFlags | Qgis.LayerTreeFilterFlag)¶
Sets the filter
flags
.See also
- Parameters:
flags (Union[Qgis.LayerTreeFilterFlags) –
- setLayerFilterExpressions(self, expressions: Dict[str, str])¶
Sets the map of layer IDs to legend filter expression.
See also
- Parameters:
expressions (Dict[str) –
- setLayerFilterExpressionsFromLayerTree(self, tree: QgsLayerTree)¶
Sets layer filter expressions using a layer
tree
.- Parameters:
tree (QgsLayerTree) –