QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
src
core
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
#include "
qgslabelingenginev2.h
"
20
#include "
qgsrendererv2.h
"
21
22
class
QgsAbstractFeatureSource
;
23
class
QgsFeatureRendererV2
;
24
class
QgsSymbolV2
;
25
35
class
CORE_EXPORT
QgsVectorLayerLabelProvider
:
public
QgsAbstractLabelProvider
36
{
37
public
:
38
40
explicit
QgsVectorLayerLabelProvider
(
QgsVectorLayer
* layer,
41
const
QString
& providerId,
42
bool
withFeatureLoop =
true
,
43
const
QgsPalLayerSettings
* settings =
nullptr
,
44
const
QString
& layerName =
QString
() );
45
47
QgsVectorLayerLabelProvider
(
const
QgsPalLayerSettings
& settings,
48
const
QString
& layerId,
49
const
QgsFields
& fields,
50
const
QgsCoordinateReferenceSystem
& crs,
51
QgsAbstractFeatureSource
* source,
52
bool
ownsSource,
53
QgsFeatureRendererV2
* renderer =
nullptr
);
54
55
~
QgsVectorLayerLabelProvider
();
56
57
virtual
QList<QgsLabelFeature*>
labelFeatures
(
QgsRenderContext
& context )
override
;
58
59
virtual
void
drawLabel
(
QgsRenderContext
& context,
pal::LabelPosition
* label )
const override
;
60
61
// new virtual methods
62
69
virtual
bool
prepare(
const
QgsRenderContext
& context,
QStringList
& attributeNames );
70
82
virtual
void
registerFeature(
QgsFeature
& feature,
QgsRenderContext
&context,
QgsGeometry
* obstacleGeometry =
nullptr
);
83
92
static
QgsGeometry
* getPointObstacleGeometry(
QgsFeature
& fet,
QgsRenderContext
& context,
const
QgsSymbolV2List
& symbols );
93
94
protected
:
96
void
init();
98
void
drawLabelPrivate(
pal::LabelPosition
* label,
QgsRenderContext
& context,
QgsPalLayerSettings
& tmpLyr,
QgsPalLabeling::DrawLabelType
drawType,
double
dpiRatio = 1.0 )
const
;
99
100
protected
:
102
QgsPalLayerSettings
mSettings
;
104
QGis::GeometryType
mLayerGeometryType
;
105
106
QgsFeatureRendererV2
*
mRenderer
;
107
108
// these are needed only if using own renderer loop
109
111
QgsFields
mFields
;
113
QgsCoordinateReferenceSystem
mCrs
;
115
QgsAbstractFeatureSource
*
mSource
;
117
bool
mOwnsSource
;
118
120
QList<QgsLabelFeature*>
mLabels
;
121
122
friend
class
TestQgsLabelingEngineV2;
123
};
124
125
#endif // QGSVECTORLAYERLABELPROVIDER_H
QgsVectorLayerLabelProvider::mRenderer
QgsFeatureRendererV2 * mRenderer
Definition:
qgsvectorlayerlabelprovider.h:106
QGis::GeometryType
GeometryType
Definition:
qgis.h:115
QgsVectorLayerLabelProvider::mOwnsSource
bool mOwnsSource
Whether layer's feature source is owned.
Definition:
qgsvectorlayerlabelprovider.h:117
QgsPalLayerSettings
Definition:
qgspallabeling.h:68
QgsFields
Container of fields for a vector layer.
Definition:
qgsfield.h:252
QgsVectorLayerLabelProvider
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
Definition:
qgsvectorlayerlabelprovider.h:35
QgsGeometry
A geometry is the spatial representation of a feature.
Definition:
qgsgeometry.h:76
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition:
qgsfeature.h:187
QgsVectorLayerLabelProvider::mLabels
QList< QgsLabelFeature * > mLabels
List of generated.
Definition:
qgsvectorlayerlabelprovider.h:120
QgsAbstractLabelProvider::labelFeatures
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Return list of label features (they are owned by the provider and thus deleted on its destruction) ...
QgsVectorLayerLabelProvider::mSettings
QgsPalLayerSettings mSettings
Layer's labeling configuration.
Definition:
qgsvectorlayerlabelprovider.h:102
qgsrendererv2.h
QString
QList
QgsAbstractFeatureSource
Base class that can be used for any class that is capable of returning features.
Definition:
qgsfeaturerequest.h:423
QgsSymbolV2
Definition:
qgssymbolv2.h:55
QStringList
QgsAbstractLabelProvider
The QgsAbstractLabelProvider class is an interface class.
Definition:
qgslabelingenginev2.h:42
QgsVectorLayerLabelProvider::mFields
QgsFields mFields
Layer's fields.
Definition:
qgsvectorlayerlabelprovider.h:111
QgsVectorLayerLabelProvider::mSource
QgsAbstractFeatureSource * mSource
Layer's feature source.
Definition:
qgsvectorlayerlabelprovider.h:115
QgsRenderContext
Contains information about the context of a rendering operation.
Definition:
qgsrendercontext.h:45
QgsVectorLayerLabelProvider::mCrs
QgsCoordinateReferenceSystem mCrs
Layer's CRS.
Definition:
qgsvectorlayerlabelprovider.h:113
qgslabelingenginev2.h
QgsCoordinateReferenceSystem
Class for storing a coordinate reference system (CRS)
Definition:
qgscoordinatereferencesystem.h:52
pal::LabelPosition
LabelPosition is a candidate feature label position.
Definition:
labelposition.h:51
QgsFeatureRendererV2
Definition:
qgsrendererv2.h:84
QgsAbstractLabelProvider::drawLabel
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
draw this label at the position determined by the labeling engine
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition:
qgsvectorlayer.h:408
QgsPalLabeling::DrawLabelType
DrawLabelType
Definition:
qgspallabeling.h:878
QgsVectorLayerLabelProvider::mLayerGeometryType
QGis::GeometryType mLayerGeometryType
Geometry type of layer.
Definition:
qgsvectorlayerlabelprovider.h:104
Generated on Sun Jun 24 2018 11:42:48 for QGIS API Documentation by
1.8.13