QGIS API Documentation  2.12.0-Lyon
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsVectorLayerLabelProvider Class Reference

The QgsVectorLayerLabelProvider class implements a label provider for vector layers. More...

#include <qgsvectorlayerlabelprovider.h>

Inheritance diagram for QgsVectorLayerLabelProvider:
Inheritance graph
[legend]

Public Member Functions

 QgsVectorLayerLabelProvider (QgsVectorLayer *layer, bool withFeatureLoop=true, const QgsPalLayerSettings *settings=0, const QString &layerName=QString())
 Convenience constructor to initialize the provider from given vector layer. More...
 
 QgsVectorLayerLabelProvider (const QgsPalLayerSettings &settings, const QString &layerId, const QgsFields &fields, const QgsCoordinateReferenceSystem &crs, QgsAbstractFeatureSource *source, bool ownsSource)
 Construct diagram provider with all the necessary configuration parameters. More...
 
 ~QgsVectorLayerLabelProvider ()
 
virtual void drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const override
 draw this label at the position determined by the labeling engine More...
 
virtual QList< QgsLabelFeature * > labelFeatures (QgsRenderContext &context) override
 Return list of label features (they are owned by the provider and thus deleted on its destruction) More...
 
virtual bool prepare (const QgsRenderContext &context, QStringList &attributeNames)
 Prepare for registration of features. More...
 
virtual void registerFeature (QgsFeature &feature, QgsRenderContext &context)
 Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels. More...
 
- Public Member Functions inherited from QgsAbstractLabelProvider
 QgsAbstractLabelProvider ()
 Construct the provider with default values. More...
 
virtual ~QgsAbstractLabelProvider ()
 Vritual destructor. More...
 
Flags flags () const
 Flags associated with the provider. More...
 
unsigned int linePlacementFlags () const
 For layers with linestring geometries - extra placement flags (or-ed combination of QgsPalLayerSettings::LinePlacementFlags) More...
 
QString name () const
 Name of the layer (for statistics, debugging etc.) - does not need to be unique. More...
 
QgsPalLayerSettings::ObstacleType obstacleType () const
 How the feature geometries will work as obstacles. More...
 
QgsPalLayerSettings::Placement placement () const
 What placement strategy to use for the labels. More...
 
double priority () const
 Default priority of labels (may be overridden by individual labels) More...
 
void setEngine (const QgsLabelingEngineV2 *engine)
 Associate provider with a labeling engine (should be only called internally from QgsLabelingEngineV2) More...
 
virtual QList< QgsAbstractLabelProvider * > subProviders ()
 Return list of child providers - useful if the provider needs to put labels into more layers with different configuration. More...
 
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels () const
 How to handle labels that would be upside down. More...
 

Protected Member Functions

void drawLabelPrivate (pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, QgsPalLabeling::DrawLabelType drawType, double dpiRatio=1.0) const
 Internal label drawing method. More...
 
void init ()
 initialization method - called from constructors More...
 

Protected Attributes

QgsCoordinateReferenceSystem mCrs
 Layer's CRS. More...
 
QgsFields mFields
 Layer's fields. More...
 
QList< QgsLabelFeature * > mLabels
 List of generated. More...
 
QString mLayerId
 Layer's ID. More...
 
bool mOwnsSource
 Whether layer's feature source is owned. More...
 
QgsPalLayerSettings mSettings
 Layer's labeling configuration. More...
 
QgsAbstractFeatureSourcemSource
 Layer's feature source. More...
 
- Protected Attributes inherited from QgsAbstractLabelProvider
const QgsLabelingEngineV2mEngine
 Associated labeling engine. More...
 
Flags mFlags
 Flags altering drawing and registration of features. More...
 
unsigned int mLinePlacementFlags
 Extra placement flags for linestring geometries. More...
 
QString mName
 Name of the layer. More...
 
QgsPalLayerSettings::ObstacleType mObstacleType
 Type of the obstacle of feature geometries. More...
 
QgsPalLayerSettings::Placement mPlacement
 Placement strategy. More...
 
double mPriority
 Default priority of labels. More...
 
QgsPalLayerSettings::UpsideDownLabels mUpsidedownLabels
 How to handle labels that would be upside down. More...
 

Additional Inherited Members

- Public Types inherited from QgsAbstractLabelProvider
enum  Flag {
  DrawLabels = 1 << 1, DrawAllLabels = 1 << 2, MergeConnectedLines = 1 << 3, CentroidMustBeInside = 1 << 4,
  FitInPolygonOnly = 1 << 5, LabelPerFeaturePart = 1 << 6
}
 

Detailed Description

The QgsVectorLayerLabelProvider class implements a label provider for vector layers.

Parameters for the labeling are taken from the layer's custom properties or from the given settings.

Note
added in QGIS 2.12

Definition at line 30 of file qgsvectorlayerlabelprovider.h.

Constructor & Destructor Documentation

QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider ( QgsVectorLayer layer,
bool  withFeatureLoop = true,
const QgsPalLayerSettings settings = 0,
const QString layerName = QString() 
)
explicit

Convenience constructor to initialize the provider from given vector layer.

Definition at line 47 of file qgsvectorlayerlabelprovider.cpp.

QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider ( const QgsPalLayerSettings settings,
const QString layerId,
const QgsFields fields,
const QgsCoordinateReferenceSystem crs,
QgsAbstractFeatureSource source,
bool  ownsSource 
)

Construct diagram provider with all the necessary configuration parameters.

Definition at line 68 of file qgsvectorlayerlabelprovider.cpp.

QgsVectorLayerLabelProvider::~QgsVectorLayerLabelProvider ( )

Definition at line 103 of file qgsvectorlayerlabelprovider.cpp.

Member Function Documentation

void QgsVectorLayerLabelProvider::drawLabel ( QgsRenderContext context,
pal::LabelPosition label 
) const
overridevirtual

draw this label at the position determined by the labeling engine

Implements QgsAbstractLabelProvider.

Reimplemented in QgsDxfLabelProvider.

Definition at line 282 of file qgsvectorlayerlabelprovider.cpp.

void QgsVectorLayerLabelProvider::drawLabelPrivate ( pal::LabelPosition label,
QgsRenderContext context,
QgsPalLayerSettings tmpLyr,
QgsPalLabeling::DrawLabelType  drawType,
double  dpiRatio = 1.0 
) const
protected

Internal label drawing method.

Definition at line 380 of file qgsvectorlayerlabelprovider.cpp.

void QgsVectorLayerLabelProvider::init ( )
protected

initialization method - called from constructors

Definition at line 86 of file qgsvectorlayerlabelprovider.cpp.

QList< QgsLabelFeature * > QgsVectorLayerLabelProvider::labelFeatures ( QgsRenderContext context)
overridevirtual

Return list of label features (they are owned by the provider and thus deleted on its destruction)

Implements QgsAbstractLabelProvider.

Definition at line 240 of file qgsvectorlayerlabelprovider.cpp.

bool QgsVectorLayerLabelProvider::prepare ( const QgsRenderContext context,
QStringList attributeNames 
)
virtual

Prepare for registration of features.

Must be called after provider has been added to engine (uses its map settings)

Parameters
contextrender context.
attributeNameslist of attribute names to which additional required attributes shall be added
Returns
Whether the preparation was successful - if not, the provider shall not be used

Reimplemented in QgsRuleBasedLabelProvider.

Definition at line 112 of file qgsvectorlayerlabelprovider.cpp.

void QgsVectorLayerLabelProvider::registerFeature ( QgsFeature feature,
QgsRenderContext context 
)
virtual

Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels.

Parameters
featurefeature to label
contextrender context. The QgsExpressionContext contained within the render context must have already had the feature and fields sets prior to calling this method.

Reimplemented in QgsRuleBasedLabelProvider.

Definition at line 272 of file qgsvectorlayerlabelprovider.cpp.

Member Data Documentation

QgsCoordinateReferenceSystem QgsVectorLayerLabelProvider::mCrs
protected

Layer's CRS.

Definition at line 87 of file qgsvectorlayerlabelprovider.h.

QgsFields QgsVectorLayerLabelProvider::mFields
protected

Layer's fields.

Definition at line 85 of file qgsvectorlayerlabelprovider.h.

QList<QgsLabelFeature*> QgsVectorLayerLabelProvider::mLabels
protected

List of generated.

Definition at line 94 of file qgsvectorlayerlabelprovider.h.

QString QgsVectorLayerLabelProvider::mLayerId
protected

Layer's ID.

Definition at line 80 of file qgsvectorlayerlabelprovider.h.

bool QgsVectorLayerLabelProvider::mOwnsSource
protected

Whether layer's feature source is owned.

Definition at line 91 of file qgsvectorlayerlabelprovider.h.

QgsPalLayerSettings QgsVectorLayerLabelProvider::mSettings
protected

Layer's labeling configuration.

Definition at line 78 of file qgsvectorlayerlabelprovider.h.

QgsAbstractFeatureSource* QgsVectorLayerLabelProvider::mSource
protected

Layer's feature source.

Definition at line 89 of file qgsvectorlayerlabelprovider.h.


The documentation for this class was generated from the following files: