QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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 class  ObstacleType : int { 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


 
bool isObstacle () const
 Returns true if the features are obstacles to labels of other layers.
 
QgsGeometry obstacleGeometry () const
 Returns the label's obstacle geometry, if different to the feature geometry.
 
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


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

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

enum class QgsLabelObstacleSettings::ObstacleType : int
strong

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 79 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 55 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 27 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 92 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 66 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 22 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 114 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 103 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 32 of file qgslabelobstaclesettings.cpp.


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