QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Public Types | Public Member Functions | List of all members
QgsLabelObstacleSettings Class Reference

Contains settings related to how the label engine treats features as obstacles. More...

#include <qgslabelobstaclesettings.h>

Public Types

enum  ObstacleType { PolygonInterior , PolygonBoundary , PolygonWhole }
 Valid obstacle types, which affect how features within the layer will act as obstacles for labels. More...
 

Public Member Functions

double factor () const
 Returns the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels,

1.0 less likely to be covered

More...
 
bool isObstacle () const
 Returns true if the features are obstacles to labels of other layers. More...
 
QgsGeometry obstacleGeometry () const
 Returns the label's obstacle geometry, if different to the feature geometry. More...
 
void setFactor (double factor)
 Sets the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels,

1.0 less likely to be covered

More...
 
void setIsObstacle (bool isObstacle)
 Sets whether features are obstacles to labels of other layers. More...
 
void setObstacleGeometry (const QgsGeometry &obstacleGeom)
 Sets the label's obstacle geometry, if different to the feature geometry. More...
 
void setType (ObstacleType type)
 Controls how features act as obstacles for labels. More...
 
ObstacleType type () const
 Returns how features act as obstacles for labels. More...
 
void updateDataDefinedProperties (const QgsPropertyCollection &properties, QgsExpressionContext &context)
 Updates the obstacle settings to respect any data defined properties set within the specified properties collection. More...
 

Detailed Description

Contains settings related to how the label engine treats features as obstacles.

Since
QGIS 3.10.2

Definition at line 34 of file qgslabelobstaclesettings.h.

Member Enumeration Documentation

◆ ObstacleType

Valid obstacle types, which affect how features within the layer will act as obstacles for labels.

Enumerator
PolygonInterior 

avoid placing labels over interior of polygon (prefer placing labels totally outside or just slightly inside polygon)

PolygonBoundary 

avoid placing labels over boundary of polygon (prefer placing outside or completely inside polygon)

PolygonWhole 

avoid placing labels over ANY part of polygon. Where PolygonInterior will prefer to place labels with the smallest area of intersection between the label and the polygon, PolygonWhole will penalise any label which intersects with the polygon by an equal amount, so that placing labels over any part of the polygon is avoided.

Definition at line 42 of file qgslabelobstaclesettings.h.

Member Function Documentation

◆ factor()

double QgsLabelObstacleSettings::factor ( ) const
inline

Returns the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels,

1.0 less likely to be covered

See also
setFactor()
isObstacle()
type()

Definition at line 84 of file qgslabelobstaclesettings.h.

◆ isObstacle()

bool QgsLabelObstacleSettings::isObstacle ( ) const
inline

Returns true if the features are obstacles to labels of other layers.

See also
setIsObstacle()
factor()
type()

Definition at line 60 of file qgslabelobstaclesettings.h.

◆ obstacleGeometry()

QgsGeometry QgsLabelObstacleSettings::obstacleGeometry ( ) const

Returns the label's obstacle geometry, if different to the feature geometry.

See also
setObstacleGeometry()

Definition at line 26 of file qgslabelobstaclesettings.cpp.

◆ setFactor()

void QgsLabelObstacleSettings::setFactor ( double  factor)
inline

Sets the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels,

1.0 less likely to be covered

See also
factor()
isObstacle()
type()

Definition at line 97 of file qgslabelobstaclesettings.h.

◆ setIsObstacle()

void QgsLabelObstacleSettings::setIsObstacle ( bool  isObstacle)
inline

Sets whether features are obstacles to labels of other layers.

See also
isObstacle()
factor()
type()

Definition at line 71 of file qgslabelobstaclesettings.h.

◆ setObstacleGeometry()

void QgsLabelObstacleSettings::setObstacleGeometry ( const QgsGeometry obstacleGeom)

Sets the label's obstacle geometry, if different to the feature geometry.

This can be used to override the shape of the feature for obstacle detection, e.g., to buffer around a point geometry to prevent labels being placed too close to the point itself. It not set, the feature's geometry is used for obstacle detection.

See also
obstacleGeometry()

Definition at line 21 of file qgslabelobstaclesettings.cpp.

◆ setType()

void QgsLabelObstacleSettings::setType ( ObstacleType  type)
inline

Controls how features act as obstacles for labels.

See also
type()
isObstacle()
factor()

Definition at line 119 of file qgslabelobstaclesettings.h.

◆ type()

ObstacleType QgsLabelObstacleSettings::type ( ) const
inline

Returns how features act as obstacles for labels.

See also
setType()
isObstacle()
factor()

Definition at line 108 of file qgslabelobstaclesettings.h.

◆ updateDataDefinedProperties()

void QgsLabelObstacleSettings::updateDataDefinedProperties ( const QgsPropertyCollection properties,
QgsExpressionContext context 
)

Updates the obstacle settings to respect any data defined properties set within the specified properties collection.

Definition at line 31 of file qgslabelobstaclesettings.cpp.


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