QGIS API Documentation  3.8.0-Zanzibar (11aff65)
Public Types | Public Member Functions | Protected Attributes | List of all members
QgsAbstractLabelProvider Class Referenceabstract

The QgsAbstractLabelProvider class is an interface class. More...

#include <qgslabelingengine.h>

Inheritance diagram for QgsAbstractLabelProvider:
Inheritance graph
[legend]

Public Types

enum  Flag {
  DrawLabels = 1 << 1, DrawAllLabels = 1 << 2, MergeConnectedLines = 1 << 3, CentroidMustBeInside = 1 << 4,
  LabelPerFeaturePart = 1 << 6
}
 

Public Member Functions

 QgsAbstractLabelProvider (QgsMapLayer *layer, const QString &providerId=QString())
 Construct the provider with default values. More...
 
virtual ~QgsAbstractLabelProvider ()=default
 
virtual void drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const =0
 draw this label at the position determined by the labeling engine More...
 
Flags flags () const
 Flags associated with the provider. More...
 
virtual QList< QgsLabelFeature * > labelFeatures (QgsRenderContext &context)=0
 Returns list of label features (they are owned by the provider and thus deleted on its destruction) More...
 
QgsMapLayerlayer () const
 Returns the associated layer, or nullptr if no layer is associated with the provider. More...
 
QString layerId () const
 Returns ID of associated layer, or empty string if no layer is associated with the provider. More...
 
QString name () const
 Name of the layer (for statistics, debugging etc.) - does not need to be unique. More...
 
QgsPalLayerSettings::ObstacleType obstacleType () const
 How the feature geometries will work as obstacles. More...
 
QgsPalLayerSettings::Placement placement () const
 What placement strategy to use for the labels. More...
 
double priority () const
 Default priority of labels (may be overridden by individual labels) More...
 
QString providerId () const
 Returns provider ID - useful in case there is more than one label provider within a layer (e.g. More...
 
void setEngine (const QgsLabelingEngine *engine)
 Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine) More...
 
virtual QList< QgsAbstractLabelProvider * > subProviders ()
 Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration. More...
 
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels () const
 How to handle labels that would be upside down. More...
 

Protected Attributes

const QgsLabelingEnginemEngine = nullptr
 Associated labeling engine. More...
 
Flags mFlags
 Flags altering drawing and registration of features. More...
 
QgsWeakMapLayerPointer mLayer
 Weak pointer to source layer. More...
 
QString mLayerId
 Associated layer's ID, if applicable. More...
 
QString mName
 Name of the layer. More...
 
QgsPalLayerSettings::ObstacleType mObstacleType
 Type of the obstacle of feature geometries. More...
 
QgsPalLayerSettings::Placement mPlacement
 Placement strategy. More...
 
double mPriority
 Default priority of labels. More...
 
QString mProviderId
 Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling) More...
 
QgsPalLayerSettings::UpsideDownLabels mUpsidedownLabels
 How to handle labels that would be upside down. More...
 

Detailed Description

The QgsAbstractLabelProvider class is an interface class.

Implementations return list of labels and their associated geometries - these are used by QgsLabelingEngine to compute the final layout of labels.

Implementations also take care of drawing the returned final label positions.

Note
this class is not a part of public API yet. See notes in QgsLabelingEngine
not available in Python bindings
Since
QGIS 2.12

Definition at line 43 of file qgslabelingengine.h.

Member Enumeration Documentation

◆ Flag

Enumerator
DrawLabels 

Whether the labels should be rendered.

DrawAllLabels 

Whether all features will be labelled even though overlaps occur.

MergeConnectedLines 

Whether adjacent lines (with the same label text) should be merged.

CentroidMustBeInside 

Whether location of centroid must be inside of polygons.

LabelPerFeaturePart 

Whether to label each part of multi-part features separately.

Definition at line 55 of file qgslabelingengine.h.

Constructor & Destructor Documentation

◆ QgsAbstractLabelProvider()

QgsAbstractLabelProvider::QgsAbstractLabelProvider ( QgsMapLayer layer,
const QString &  providerId = QString() 
)

Construct the provider with default values.

Definition at line 389 of file qgslabelingengine.cpp.

◆ ~QgsAbstractLabelProvider()

virtual QgsAbstractLabelProvider::~QgsAbstractLabelProvider ( )
virtualdefault

Member Function Documentation

◆ drawLabel()

virtual void QgsAbstractLabelProvider::drawLabel ( QgsRenderContext context,
pal::LabelPosition label 
) const
pure virtual

draw this label at the position determined by the labeling engine

Implemented in QgsDxfRuleBasedLabelProvider, QgsVectorLayerDiagramProvider, QgsVectorLayerLabelProvider, and QgsDxfLabelProvider.

◆ flags()

Flags QgsAbstractLabelProvider::flags ( ) const
inline

Flags associated with the provider.

Definition at line 91 of file qgslabelingengine.h.

◆ labelFeatures()

virtual QList<QgsLabelFeature *> QgsAbstractLabelProvider::labelFeatures ( QgsRenderContext context)
pure virtual

Returns list of label features (they are owned by the provider and thus deleted on its destruction)

Implemented in QgsVectorLayerDiagramProvider, and QgsVectorLayerLabelProvider.

◆ layer()

QgsMapLayer* QgsAbstractLabelProvider::layer ( ) const
inline

Returns the associated layer, or nullptr if no layer is associated with the provider.

Definition at line 81 of file qgslabelingengine.h.

◆ layerId()

QString QgsAbstractLabelProvider::layerId ( ) const
inline

Returns ID of associated layer, or empty string if no layer is associated with the provider.

Definition at line 78 of file qgslabelingengine.h.

◆ name()

QString QgsAbstractLabelProvider::name ( ) const
inline

Name of the layer (for statistics, debugging etc.) - does not need to be unique.

Definition at line 75 of file qgslabelingengine.h.

◆ obstacleType()

QgsPalLayerSettings::ObstacleType QgsAbstractLabelProvider::obstacleType ( ) const
inline

How the feature geometries will work as obstacles.

Definition at line 100 of file qgslabelingengine.h.

◆ placement()

QgsPalLayerSettings::Placement QgsAbstractLabelProvider::placement ( ) const
inline

What placement strategy to use for the labels.

Definition at line 94 of file qgslabelingengine.h.

◆ priority()

double QgsAbstractLabelProvider::priority ( ) const
inline

Default priority of labels (may be overridden by individual labels)

Definition at line 97 of file qgslabelingengine.h.

◆ providerId()

QString QgsAbstractLabelProvider::providerId ( ) const
inline

Returns provider ID - useful in case there is more than one label provider within a layer (e.g.

in case of rule-based labeling - provider ID = rule's key). May be empty string if layer ID is sufficient for identification of provider's configuration.

Definition at line 88 of file qgslabelingengine.h.

◆ setEngine()

void QgsAbstractLabelProvider::setEngine ( const QgsLabelingEngine engine)
inline

Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine)

Definition at line 53 of file qgslabelingengine.h.

◆ subProviders()

virtual QList<QgsAbstractLabelProvider *> QgsAbstractLabelProvider::subProviders ( )
inlinevirtual

Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration.

Reimplemented in QgsRuleBasedLabelProvider.

Definition at line 72 of file qgslabelingengine.h.

◆ upsidedownLabels()

QgsPalLayerSettings::UpsideDownLabels QgsAbstractLabelProvider::upsidedownLabels ( ) const
inline

How to handle labels that would be upside down.

Definition at line 103 of file qgslabelingengine.h.

Member Data Documentation

◆ mEngine

const QgsLabelingEngine* QgsAbstractLabelProvider::mEngine = nullptr
protected

Associated labeling engine.

Definition at line 107 of file qgslabelingengine.h.

◆ mFlags

Flags QgsAbstractLabelProvider::mFlags
protected

Flags altering drawing and registration of features.

Definition at line 118 of file qgslabelingengine.h.

◆ mLayer

QgsWeakMapLayerPointer QgsAbstractLabelProvider::mLayer
protected

Weak pointer to source layer.

Definition at line 114 of file qgslabelingengine.h.

◆ mLayerId

QString QgsAbstractLabelProvider::mLayerId
protected

Associated layer's ID, if applicable.

Definition at line 112 of file qgslabelingengine.h.

◆ mName

QString QgsAbstractLabelProvider::mName
protected

Name of the layer.

Definition at line 110 of file qgslabelingengine.h.

◆ mObstacleType

QgsPalLayerSettings::ObstacleType QgsAbstractLabelProvider::mObstacleType
protected

Type of the obstacle of feature geometries.

Definition at line 124 of file qgslabelingengine.h.

◆ mPlacement

QgsPalLayerSettings::Placement QgsAbstractLabelProvider::mPlacement
protected

Placement strategy.

Definition at line 120 of file qgslabelingengine.h.

◆ mPriority

double QgsAbstractLabelProvider::mPriority
protected

Default priority of labels.

Definition at line 122 of file qgslabelingengine.h.

◆ mProviderId

QString QgsAbstractLabelProvider::mProviderId
protected

Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling)

Definition at line 116 of file qgslabelingengine.h.

◆ mUpsidedownLabels

QgsPalLayerSettings::UpsideDownLabels QgsAbstractLabelProvider::mUpsidedownLabels
protected

How to handle labels that would be upside down.

Definition at line 126 of file qgslabelingengine.h.


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