Class: QgsMapClippingUtils

class qgis.core.QgsMapClippingUtils

Bases: sip.wrapper

Utility functions for use when clipping map renders.

New in version 3.16:

Methods

calculateFeatureIntersectionGeometry

Returns the geometry representing the intersection of clipping regions from context which should be used to clip individual feature geometries prior to rendering.

calculateFeatureRequestGeometry

Returns the geometry representing the intersection of clipping regions from context.

calculateLabelIntersectionGeometry

Returns the geometry representing the intersection of clipping regions from context which should be used to clip individual feature geometries while registering them with labeling engines.

calculatePainterClipRegion

Returns a QPainterPath representing the intersection of clipping regions from context which should be used to clip the painter during rendering of a layer of the specified layerType.

collectClippingRegionsForLayer

Collects the list of map clipping regions from a context which apply to a map layer.

calculateFeatureIntersectionGeometry(regions: Iterable[QgsMapClippingRegion], context: QgsRenderContext) Tuple[QgsGeometry, bool]

Returns the geometry representing the intersection of clipping regions from context which should be used to clip individual feature geometries prior to rendering.

The returned geometry will be automatically reprojected into the same CRS as the source layer, ready for use for clipping features.

Parameters:
  • regions (Iterable[QgsMapClippingRegion]) – list of clip regions which apply to the layer

  • context (QgsRenderContext) – a render context

  • shouldClip – will be set to True if layer’s features should be filtered, i.e. one or more clipping regions applies to the layer

Return type:

Tuple[QgsGeometry, bool]

Returns:

combined clipping region for use when rendering features

calculateFeatureRequestGeometry(regions: Iterable[QgsMapClippingRegion], context: QgsRenderContext) Tuple[QgsGeometry, bool]

Returns the geometry representing the intersection of clipping regions from context.

The returned geometry will be automatically reprojected into the same CRS as the source layer, ready for use for filtering a feature request.

Parameters:
  • regions (Iterable[QgsMapClippingRegion]) – list of clip regions which apply to the layer

  • context (QgsRenderContext) – a render context

  • shouldFilter – will be set to True if layer’s features should be filtered, i.e. one or more clipping regions applies to the layer

Return type:

Tuple[QgsGeometry, bool]

Returns:

combined clipping region for use when filtering features to render

calculateLabelIntersectionGeometry(regions: Iterable[QgsMapClippingRegion], context: QgsRenderContext) Tuple[QgsGeometry, bool]

Returns the geometry representing the intersection of clipping regions from context which should be used to clip individual feature geometries while registering them with labeling engines.

The returned geometry will be automatically reprojected into the same CRS as the source layer, ready for use for clipping features.

Parameters:
  • regions (Iterable[QgsMapClippingRegion]) – list of clip regions which apply to the layer

  • context (QgsRenderContext) – a render context

  • shouldClip – will be set to True if layer’s features should be clipped for labeling, i.e. one or more clipping regions applies to the layer

Return type:

Tuple[QgsGeometry, bool]

Returns:

combined clipping region for use when labeling features

calculatePainterClipRegion(regions: Iterable[QgsMapClippingRegion], context: QgsRenderContext, layerType: QgsMapLayerType) Tuple[QPainterPath, bool]

Returns a QPainterPath representing the intersection of clipping regions from context which should be used to clip the painter during rendering of a layer of the specified layerType.

The returned coordinates are in painter coordinates for the destination context.

Parameters:
  • regions (Iterable[QgsMapClippingRegion]) – list of clip regions which apply to the layer

  • context (QgsRenderContext) – a render context

  • shouldClip – will be set to True if the clipping path should be applied

  • layerType (QgsMapLayerType) – the layer type to filter

Return type:

Tuple[QPainterPath, bool]

Returns:

combined painter clipping region for use when rendering maps

collectClippingRegionsForLayer(context: QgsRenderContext, layer: QgsMapLayer) List[QgsMapClippingRegion]

Collects the list of map clipping regions from a context which apply to a map layer.

Parameters:
Return type:

List[QgsMapClippingRegion]