QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
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 #define SIP_NO_FILE
22 
24 #include "qgsrulebasedlabeling.h"
25 
28 
38 {
39  public:
40  virtual ~QgsLabelSink() = default;
41 
47  virtual void drawLabel( const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings ) = 0;
48 
57  virtual void drawUnplacedLabel( const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings )
58  {
59  Q_UNUSED( layerId );
60  Q_UNUSED( context )
61  Q_UNUSED( label );
62  Q_UNUSED( settings );
63  return;
64  }
65 };
66 
75 {
76  public:
79 
80  void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
81  void drawUnplacedLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
82 
83  private:
84  QgsLabelSink *mLabelSink = nullptr;
85 };
86 
95 {
96  public:
99 
104  Q_DECL_DEPRECATED void reinit( QgsVectorLayer *layer );
105 
106  void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
107  void drawUnplacedLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
108 
110  QgsVectorLayerLabelProvider *createProvider( QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings ) override;
111 
112  private:
113  QgsLabelSink *mLabelSink = nullptr;
114 };
115 
116 
117 
118 #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....
Implements a derived label provider for use with QgsLabelSink.
Definition: qgslabelsink.h:75
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.
Definition: qgslabelsink.h:38
virtual void drawUnplacedLabel(const QString &layerId, QgsRenderContext &context, pal::LabelPosition *label, const QgsPalLayerSettings &settings)
The drawLabel method is called for each unplaced label.
Definition: qgslabelsink.h:57
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.
Label provider for rule based labeling.
Implements a derived label provider for rule based labels for use with QgsLabelSink.
Definition: qgslabelsink.h:95
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.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
const QgsPalLayerSettings & settings() const
Returns the layer's settings.
Represents a vector layer which manages a vector based data sets.
LabelPosition is a candidate feature label position.
Definition: labelposition.h:56