QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
Public Member Functions | List of all members
QgsRuleBasedLabelSinkProvider Class Reference

Implements a derived label provider for rule based labels for use with QgsLabelSink. More...

#include <qgslabelsink.h>

Inheritance diagram for QgsRuleBasedLabelSinkProvider:
Inheritance graph
[legend]

Public Member Functions

 QgsRuleBasedLabelSinkProvider (const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, QgsLabelSink *sink)
 Creates a rule based label sink provider which will draw/register labels in sink. More...
 
QgsVectorLayerLabelProvidercreateProvider (QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings) override
 Creates a QgsRuleBasedLabelSinkProvider. More...
 
void drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const override
 Draw this label at the position determined by the labeling engine. More...
 
Q_DECL_DEPRECATED void reinit (QgsVectorLayer *layer)
 Reinitialize the subproviders with QgsLabelSinkProviders. More...
 
- Public Member Functions inherited from QgsRuleBasedLabelProvider
 QgsRuleBasedLabelProvider (const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, bool withFeatureLoop=true)
 
bool prepare (QgsRenderContext &context, QSet< QString > &attributeNames) override
 Prepare for registration of features. More...
 
void registerFeature (const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr) override
 Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels. More...
 
QList< QgsAbstractLabelProvider * > subProviders () override
 Returns subproviders. More...
 
- Public Member Functions inherited from QgsVectorLayerLabelProvider
 QgsVectorLayerLabelProvider (QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings, const QString &layerName=QString())
 Convenience constructor to initialize the provider from given vector layer. More...
 
 QgsVectorLayerLabelProvider (QgsWkbTypes::GeometryType geometryType, const QgsFields &fields, const QgsCoordinateReferenceSystem &crs, const QString &providerId, const QgsPalLayerSettings *settings, QgsMapLayer *layer, const QString &layerName=QString())
 Constructor to initialize the provider from any map layer (e.g. vector tile layer) More...
 
 ~QgsVectorLayerLabelProvider () override
 
void drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const override
 Draw this label at the position determined by the labeling engine. More...
 
void drawLabelBackground (QgsRenderContext &context, pal::LabelPosition *label) const override
 Draw the background for the specified label. More...
 
void drawUnplacedLabel (QgsRenderContext &context, pal::LabelPosition *label) const override
 Draw an unplaced label. More...
 
QList< QgsLabelFeature * > labelFeatures (QgsRenderContext &context) override
 Returns list of label features (they are owned by the provider and thus deleted on its destruction) More...
 
void setFields (const QgsFields &fields)
 Sets fields of this label provider. More...
 
const QgsPalLayerSettingssettings () const
 Returns the layer's settings. More...
 
void startRender (QgsRenderContext &context) override
 To be called before rendering of labels begins. More...
 
void stopRender (QgsRenderContext &context) override
 To be called after rendering is complete. More...
 
- Public Member Functions inherited from QgsAbstractLabelProvider
 QgsAbstractLabelProvider (QgsMapLayer *layer, const QString &providerId=QString())
 Construct the provider with default values. More...
 
virtual ~QgsAbstractLabelProvider ()=default
 
Flags flags () const
 Flags associated with the provider. 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...
 
QgsLabelObstacleSettings::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...
 
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels () const
 How to handle labels that would be upside down. More...
 

Additional Inherited Members

- Public Types inherited from QgsAbstractLabelProvider
enum  Flag { DrawLabels = 1 << 1, DrawAllLabels = 1 << 2, MergeConnectedLines = 1 << 3, CentroidMustBeInside = 1 << 4 }
 
- Static Public Member Functions inherited from QgsVectorLayerLabelProvider
static QgsGeometry getPointObstacleGeometry (QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols)
 Returns the geometry for a point feature which should be used as an obstacle for labels. More...
 
- Protected Member Functions inherited from QgsVectorLayerLabelProvider
void drawLabelPrivate (pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, QgsTextRenderer::TextPart drawType, double dpiRatio=1.0) const
 Internal label drawing method. More...
 
void init ()
 initialization method - called from constructors More...
 
- Protected Attributes inherited from QgsRuleBasedLabelProvider
std::unique_ptr< QgsRuleBasedLabelingmRules
 owned copy More...
 
QgsRuleBasedLabeling::RuleToProviderMap mSubProviders
 label providers are owned by labeling engine More...
 
- Protected Attributes inherited from QgsVectorLayerLabelProvider
QgsCoordinateReferenceSystem mCrs
 Layer's CRS. More...
 
QgsFields mFields
 Layer's fields. More...
 
QList< QgsLabelFeature * > mLabels
 List of generated. More...
 
QgsWkbTypes::GeometryType mLayerGeometryType
 Geometry type of layer. More...
 
QgsFeatureRenderermRenderer = nullptr
 
QgsPalLayerSettings mSettings
 Layer's labeling configuration. More...
 
std::unique_ptr< QgsAbstractFeatureSourcemSource
 Layer's feature source. More...
 
- Protected Attributes inherited from QgsAbstractLabelProvider
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...
 
QgsLabelObstacleSettings::ObstacleType mObstacleType = QgsLabelObstacleSettings::PolygonBoundary
 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

Implements a derived label provider for rule based labels for use with QgsLabelSink.

Note
not available in Python bindings
Since
QGIS 3.14

Definition at line 76 of file qgslabelsink.h.

Constructor & Destructor Documentation

◆ QgsRuleBasedLabelSinkProvider()

QgsRuleBasedLabelSinkProvider::QgsRuleBasedLabelSinkProvider ( const QgsRuleBasedLabeling rules,
QgsVectorLayer layer,
QgsLabelSink sink 
)
explicit

Creates a rule based label sink provider which will draw/register labels in sink.

Definition at line 35 of file qgslabelsink.cpp.

Member Function Documentation

◆ createProvider()

QgsVectorLayerLabelProvider * QgsRuleBasedLabelSinkProvider::createProvider ( QgsVectorLayer layer,
const QString &  providerId,
bool  withFeatureLoop,
const QgsPalLayerSettings settings 
)
overridevirtual

Creates a QgsRuleBasedLabelSinkProvider.

Reimplemented from QgsRuleBasedLabelProvider.

Definition at line 47 of file qgslabelsink.cpp.

◆ drawLabel()

void QgsRuleBasedLabelSinkProvider::drawLabel ( QgsRenderContext context,
pal::LabelPosition label 
) const
overridevirtual

Draw this label at the position determined by the labeling engine.

Before any calls to drawLabel(), a provider should be prepared for rendering by a call to startRender() and a corresponding call to stopRender().

Implements QgsAbstractLabelProvider.

Definition at line 53 of file qgslabelsink.cpp.

◆ reinit()

void QgsRuleBasedLabelSinkProvider::reinit ( QgsVectorLayer layer)

Reinitialize the subproviders with QgsLabelSinkProviders.

Deprecated:
since QGIS 3.12

Definition at line 42 of file qgslabelsink.cpp.


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