QGIS API Documentation 3.99.0-Master (c03dd32cbdd)
Loading...
Searching...
No Matches
qgslabelsink.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslabelsink.h
3 -------------------
4 begin : January 2014
5 copyright : (C) 2014 by Marco Hugentobler
6 email : marco at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSLABELSINK_H
19#define QGSLABELSINK_H
20
21
24
25#define SIP_NO_FILE
26
29
39{
40 public:
41 virtual ~QgsLabelSink() = default;
42
48 virtual void drawLabel( const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings ) = 0;
49
58 virtual void drawUnplacedLabel( const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings )
59 {
60 Q_UNUSED( layerId );
61 Q_UNUSED( context )
62 Q_UNUSED( label );
63 Q_UNUSED( settings );
64 return;
65 }
66};
67
76{
77 public:
80
81 void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
82 void drawUnplacedLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
83
84 private:
85 QgsLabelSink *mLabelSink = nullptr;
86};
87
96{
97 public:
100
105 Q_DECL_DEPRECATED void reinit( QgsVectorLayer *layer );
106
107 void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
108 void drawUnplacedLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
109
111 QgsVectorLayerLabelProvider *createProvider( QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings ) override;
112
113 private:
114 QgsLabelSink *mLabelSink = nullptr;
115};
116
117
118
119#endif // QGSLABELSINK_H
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e....
void drawUnplacedLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw an unplaced label.
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw this label at the position determined by the labeling engine.
QgsLabelSinkProvider(QgsVectorLayer *layer, const QString &providerId, QgsLabelSink *sink, const QgsPalLayerSettings *settings)
Creates a rule based label sink provider which will draw/register labels in sink.
Abstract base class that can be used to intercept rendered labels from a labeling / rendering job.
virtual void drawUnplacedLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
The drawLabel method is called for each unplaced label.
virtual void drawLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)=0
The drawLabel method is called for each label that is being drawn.
virtual ~QgsLabelSink()=default
Contains settings for how a map layer will be labeled.
Contains information about the context of a rendering operation.
QgsRuleBasedLabelProvider(const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, bool withFeatureLoop=true)
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw this label at the position determined by the labeling engine.
Q_DECL_DEPRECATED void reinit(QgsVectorLayer *layer)
Reinitialize the subproviders with QgsLabelSinkProviders.
QgsVectorLayerLabelProvider * createProvider(QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings) override
Creates a QgsRuleBasedLabelSinkProvider.
void drawUnplacedLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw an unplaced label.
QgsRuleBasedLabelSinkProvider(const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, QgsLabelSink *sink)
Creates a rule based label sink provider which will draw/register labels in sink.
Rule based labeling for a vector layer.
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.
const QgsPalLayerSettings & settings() const
Returns the layer's settings.
Represents a vector layer which manages a vector based dataset.
LabelPosition is a candidate feature label position.