QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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#include "qgspallabeling.h"
25
28class QgsSymbol;
29
40{
41 public:
42
45 const QString &providerId,
46 bool withFeatureLoop,
47 const QgsPalLayerSettings *settings,
48 const QString &layerName = QString() );
49
52 const QgsFields &fields,
54 const QString &providerId,
55 const QgsPalLayerSettings *settings,
56 QgsMapLayer *layer,
57 const QString &layerName = QString() );
58
60
61 QList<QgsLabelFeature *> labelFeatures( QgsRenderContext &context ) override;
62
63 void drawLabelBackground( QgsRenderContext &context, pal::LabelPosition *label ) const override;
64 void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
65 void drawUnplacedLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
66 void startRender( QgsRenderContext &context ) override;
67 void stopRender( QgsRenderContext &context ) override;
68
69 // new virtual methods
70
77 virtual bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames );
78
93 virtual QList< QgsLabelFeature * > registerFeature( const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry(), const QgsSymbol *symbol = nullptr );
94
103 static QgsGeometry getPointObstacleGeometry( QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols );
104
109 const QgsPalLayerSettings &settings() const;
110
117 void setFields( const QgsFields &fields );
118
119 protected:
121 void init();
123 void drawLabelPrivate( pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, Qgis::TextComponent drawType, double dpiRatio = 1.0 ) const;
124
125 protected:
130
131 QgsFeatureRenderer *mRenderer = nullptr;
132
133 // these are needed only if using own renderer loop
134
140 std::unique_ptr<QgsAbstractFeatureSource> mSource;
141
143 QList<QgsLabelFeature *> mLabels;
144
145 private:
146
147 friend class TestQgsLabelingEngine;
149
150 void drawCallout( QgsRenderContext &context, pal::LabelPosition *label ) const;
151};
152
153#endif // QGSVECTORLAYERLABELPROVIDER_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
TextComponent
Text components.
Definition qgis.h:2716
Base class that can be used for any class that is capable of returning features.
The QgsAbstractLabelProvider class is an interface class.
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
virtual void drawUnplacedLabel(QgsRenderContext &context, pal::LabelPosition *label) const
Draw an unplaced label.
virtual void stopRender(QgsRenderContext &context)
To be called after rendering is complete.
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
Draw this label at the position determined by the labeling engine.
virtual void drawLabelBackground(QgsRenderContext &context, pal::LabelPosition *label) const
Draw the background for the specified label.
virtual void startRender(QgsRenderContext &context)
To be called before rendering of labels begins.
This class represents a coordinate reference system (CRS).
Abstract base class for all 2D vector feature renderers.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Container of fields for a vector layer.
Definition qgsfields.h:46
A geometry is the spatial representation of a feature.
Base class for all map layer types.
Definition qgsmaplayer.h:76
Contains settings for how a map layer will be labeled.
Contains information about the context of a rendering operation.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
QgsCoordinateReferenceSystem mCrs
Layer's CRS.
QList< QgsLabelFeature * > mLabels
List of generated.
Qgis::GeometryType mLayerGeometryType
Geometry type of layer.
QgsPalLayerSettings mSettings
Layer's labeling configuration.
std::unique_ptr< QgsAbstractFeatureSource > mSource
Layer's feature source.
Represents a vector layer which manages a vector based data sets.
Implementation class for QgsVectorTileBasicLabeling.
LabelPosition is a candidate feature label position.
QList< QgsSymbol * > QgsSymbolList
Definition qgsrenderer.h:47
const QgsCoordinateReferenceSystem & crs