QGIS API Documentation  3.6.0-Noosa (5873452)
qgsvectorlayerlabelprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerlabelprovider.h
3  --------------------------------------
4  Date : September 2015
5  Copyright : (C) 2015 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSVECTORLAYERLABELPROVIDER_H
17 #define QGSVECTORLAYERLABELPROVIDER_H
18 
19 #define SIP_NO_FILE
20 
21 #include "qgis_core.h"
22 #include "qgslabelingengine.h"
23 #include "qgsrenderer.h"
24 
26 class QgsFeatureRenderer;
27 class QgsSymbol;
28 
40 {
41  public:
42 
45  const QString &providerId,
46  bool withFeatureLoop,
47  const QgsPalLayerSettings *settings,
48  const QString &layerName = QString() );
49 
50  ~QgsVectorLayerLabelProvider() override;
51 
52  QList<QgsLabelFeature *> labelFeatures( QgsRenderContext &context ) override;
53 
54  void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
55 
56  // new virtual methods
57 
64  virtual bool prepare( const QgsRenderContext &context, QSet<QString> &attributeNames );
65 
77  virtual void registerFeature( const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
78 
88  static QgsGeometry getPointObstacleGeometry( QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols );
89 
90  protected:
92  void init();
94  void drawLabelPrivate( pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, QgsTextRenderer::TextPart drawType, double dpiRatio = 1.0 ) const;
95 
96  protected:
101 
102  QgsFeatureRenderer *mRenderer = nullptr;
103 
104  // these are needed only if using own renderer loop
105 
111  QgsAbstractFeatureSource *mSource = nullptr;
114 
116  QList<QgsLabelFeature *> mLabels;
117 
118  friend class TestQgsLabelingEngine;
119 };
120 
121 #endif // QGSVECTORLAYERLABELPROVIDER_H
QList< QgsLabelFeature * > mLabels
List of generated.
QgsWkbTypes::GeometryType mLayerGeometryType
Geometry type of layer.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
bool mOwnsSource
Whether layer&#39;s feature source is owned.
Container of fields for a vector layer.
Definition: qgsfields.h:42
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:106
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Returns list of label features (they are owned by the provider and thus deleted on its destruction) ...
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:43
QgsPalLayerSettings mSettings
Layer&#39;s labeling configuration.
Base class that can be used for any class that is capable of returning features.
The QgsAbstractLabelProvider class is an interface class.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:138
TextPart
Components of text.
QgsFields mFields
Layer&#39;s fields.
Contains information about the context of a rendering operation.
QgsCoordinateReferenceSystem mCrs
Layer&#39;s CRS.
This class represents a coordinate reference system (CRS).
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
draw this label at the position determined by the labeling engine
Represents a vector layer which manages a vector based data sets.