QGIS API Documentation  2.99.0-Master (08ee180)
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
QgsPalLabeling Class Reference

#include <qgspallabeling.h>

Inheritance diagram for QgsPalLabeling:
Inheritance graph
[legend]

Public Types

enum  Search {
  Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain,
  Falp
}
 

Public Member Functions

 QgsPalLabeling ()
 
 ~QgsPalLabeling ()
 
virtual void clearActiveLayer (const QString &layerID) override
 clears data defined objects from PAL layer settings for a registered layer More...
 
virtual void clearActiveLayers () override
 clears all PAL layer settings for registered layers More...
 
void clearEngineSettings ()
 
virtual QgsPalLabelingclone () override
 called when passing engine among map renderers More...
 
virtual void drawLabeling (QgsRenderContext &context) override
 called when the map is drawn and labels should be placed More...
 
bool drawLabelRectOnly () const
 Returns whether the engine will only draw the outline rectangles of labels, not the label contents themselves. More...
 
virtual void exit () override
 called when we're done with rendering More...
 
virtual void init (const QgsMapSettings &mapSettings) override
 called when we're going to start with rendering More...
 
bool isDrawingOutlineLabels () const
 
bool isShowingAllLabels () const
 
bool isShowingCandidates () const
 
bool isShowingPartialsLabels () const
 
void loadEngineSettings ()
 load/save engine settings to project file More...
 
void numCandidatePositions (int &candPoint, int &candLine, int &candPolygon)
 
virtual int prepareDiagramLayer (QgsVectorLayer *layer, QSet< QString > &attrNames, QgsRenderContext &ctx) override
 adds a diagram layer to the labeling engine More...
 
virtual int prepareLayer (QgsVectorLayer *layer, QSet< QString > &attrNames, QgsRenderContext &ctx) override
 hook called when drawing layer before issuing select() More...
 
virtual void registerDiagramFeature (const QString &layerID, QgsFeature &feat, QgsRenderContext &context) override
 called for every diagram feature More...
 
virtual void registerFeature (const QString &layerID, QgsFeature &feat, QgsRenderContext &context) override
 Register a feature for labelling. More...
 
void saveEngineSettings ()
 
Search searchMethod () const
 
void setDrawingOutlineLabels (bool outline)
 
void setDrawLabelRectOnly (bool drawRect)
 Sets whether the engine should only draw the outline rectangles of labels, not the label contents themselves. More...
 
void setNumCandidatePositions (int candPoint, int candLine, int candPolygon)
 
void setSearchMethod (Search s)
 
void setShowingAllLabels (bool showing)
 
void setShowingCandidates (bool showing)
 
void setShowingPartialsLabels (bool showing)
 
QgsLabelingResultstakeResults ()
 Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to the caller. More...
 
virtual bool willUseLayer (QgsVectorLayer *layer) override
 called to find out whether the layer is used for labeling More...
 
- Public Member Functions inherited from QgsLabelingEngineInterface
virtual ~QgsLabelingEngineInterface ()
 

Static Public Member Functions

static void drawLabelCandidateRect (pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList< QgsLabelCandidate > *candidates=nullptr)
 
static bool geometryRequiresPreparation (const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry=nullptr)
 Checks whether a geometry requires preparation before registration with PAL. More...
 
static QgsGeometry prepareGeometry (const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, QgsGeometry *clipGeometry=nullptr)
 Prepares a geometry for registration with PAL. More...
 
static QStringList splitToGraphemes (const QString &text)
 Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string. More...
 
static QStringList splitToLines (const QString &text, const QString &wrapCharacter)
 Splits a text string to a list of separate lines, using a specified wrap character. More...
 
static bool staticWillUseLayer (QgsVectorLayer *layer)
 called to find out whether the layer is used for labeling More...
 
static bool staticWillUseLayer (const QString &layerID)
 

Protected Member Functions

void deleteTemporaryData ()
 

Static Protected Member Functions

static bool checkMinimumSizeMM (const QgsRenderContext &context, const QgsGeometry *geom, double minSize)
 Checks whether a geometry exceeds the minimum required size for a geometry to be labeled. More...
 
static void dataDefinedDropShadow (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
static void dataDefinedShapeBackground (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
static void dataDefinedTextBuffer (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
static void dataDefinedTextFormatting (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
static void dataDefinedTextStyle (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 

Protected Attributes

QList< QgsLabelCandidatemCandidates
 
QHash< QString, QgsVectorLayerDiagramProvider * > mDiagramProviders
 hashtable of diagram providers (key = layer ID) More...
 
QgsLabelingEnginemEngine
 New labeling engine to interface with PAL. More...
 
QgsPalLayerSettings mInvalidLayerSettings
 
QHash< QString, QgsVectorLayerLabelProvider * > mLabelProviders
 hashtable of label providers, being filled during labeling (key = layer ID) More...
 

Friends

class QgsDxfExport
 
class QgsPalLayerSettings
 
class QgsVectorLayerLabelProvider
 

Detailed Description

Definition at line 766 of file qgspallabeling.h.

Member Enumeration Documentation

§ Search

Enumerator
Chain 
Popmusic_Tabu 
Popmusic_Chain 
Popmusic_Tabu_Chain 
Falp 

Definition at line 776 of file qgspallabeling.h.

Constructor & Destructor Documentation

§ QgsPalLabeling()

QgsPalLabeling::QgsPalLabeling ( )

Definition at line 3200 of file qgspallabeling.cpp.

§ ~QgsPalLabeling()

QgsPalLabeling::~QgsPalLabeling ( )

Definition at line 3205 of file qgspallabeling.cpp.

Member Function Documentation

§ checkMinimumSizeMM()

bool QgsPalLabeling::checkMinimumSizeMM ( const QgsRenderContext context,
const QgsGeometry geom,
double  minSize 
)
staticprotected

Checks whether a geometry exceeds the minimum required size for a geometry to be labeled.

Parameters
contextrender context
geomgeometry
minSizeminimum size for geometry
Returns
true if geometry exceeds minimum size
Note
added in QGIS 2.9

Definition at line 3436 of file qgspallabeling.cpp.

§ clearActiveLayer()

void QgsPalLabeling::clearActiveLayer ( const QString &  layerID)
overridevirtual

clears data defined objects from PAL layer settings for a registered layer

Implements QgsLabelingEngineInterface.

Definition at line 3242 of file qgspallabeling.cpp.

§ clearActiveLayers()

void QgsPalLabeling::clearActiveLayers ( )
overridevirtual

clears all PAL layer settings for registered layers

Implements QgsLabelingEngineInterface.

Definition at line 3238 of file qgspallabeling.cpp.

§ clearEngineSettings()

void QgsPalLabeling::clearEngineSettings ( )

Definition at line 4059 of file qgspallabeling.cpp.

§ clone()

QgsPalLabeling * QgsPalLabeling::clone ( )
overridevirtual

called when passing engine among map renderers

Implements QgsLabelingEngineInterface.

Definition at line 4071 of file qgspallabeling.cpp.

§ dataDefinedDropShadow()

void QgsPalLabeling::dataDefinedDropShadow ( QgsPalLayerSettings tmpLyr,
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &  ddValues 
)
staticprotected

Definition at line 3810 of file qgspallabeling.cpp.

§ dataDefinedShapeBackground()

void QgsPalLabeling::dataDefinedShapeBackground ( QgsPalLayerSettings tmpLyr,
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &  ddValues 
)
staticprotected

Definition at line 3659 of file qgspallabeling.cpp.

§ dataDefinedTextBuffer()

void QgsPalLabeling::dataDefinedTextBuffer ( QgsPalLayerSettings tmpLyr,
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &  ddValues 
)
staticprotected

Definition at line 3581 of file qgspallabeling.cpp.

§ dataDefinedTextFormatting()

void QgsPalLabeling::dataDefinedTextFormatting ( QgsPalLayerSettings tmpLyr,
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &  ddValues 
)
staticprotected

Definition at line 3526 of file qgspallabeling.cpp.

§ dataDefinedTextStyle()

void QgsPalLabeling::dataDefinedTextStyle ( QgsPalLayerSettings tmpLyr,
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &  ddValues 
)
staticprotected

Definition at line 3492 of file qgspallabeling.cpp.

§ deleteTemporaryData()

void QgsPalLabeling::deleteTemporaryData ( )
protected

Definition at line 3911 of file qgspallabeling.cpp.

§ drawLabelCandidateRect()

void QgsPalLabeling::drawLabelCandidateRect ( pal::LabelPosition lp,
QPainter *  painter,
const QgsMapToPixel xform,
QList< QgsLabelCandidate > *  candidates = nullptr 
)
static
Note
not available in python bindings

Definition at line 3990 of file qgspallabeling.cpp.

§ drawLabeling()

void QgsPalLabeling::drawLabeling ( QgsRenderContext context)
overridevirtual

called when the map is drawn and labels should be placed

Implements QgsLabelingEngineInterface.

Definition at line 3906 of file qgspallabeling.cpp.

§ drawLabelRectOnly()

bool QgsPalLabeling::drawLabelRectOnly ( ) const

Returns whether the engine will only draw the outline rectangles of labels, not the label contents themselves.

Used for debugging and testing purposes.

See also
setDrawLabelRectOnly
Note
added in QGIS 2.12

Definition at line 3980 of file qgspallabeling.cpp.

§ exit()

void QgsPalLabeling::exit ( )
overridevirtual

called when we're done with rendering

Implements QgsLabelingEngineInterface.

Definition at line 3486 of file qgspallabeling.cpp.

§ geometryRequiresPreparation()

bool QgsPalLabeling::geometryRequiresPreparation ( const QgsGeometry geometry,
QgsRenderContext context,
const QgsCoordinateTransform ct,
QgsGeometry clipGeometry = nullptr 
)
static

Checks whether a geometry requires preparation before registration with PAL.

Parameters
geometrygeometry to prepare
contextrender context
ctcoordinate transform, or invalid transform if no transformation required
clipGeometrygeometry to clip features to, if applicable
Returns
true if geometry requires preparation
Note
added in QGIS 2.9

Definition at line 3298 of file qgspallabeling.cpp.

§ init()

void QgsPalLabeling::init ( const QgsMapSettings mapSettings)
overridevirtual

called when we're going to start with rendering

Implements QgsLabelingEngineInterface.

Definition at line 3481 of file qgspallabeling.cpp.

§ isDrawingOutlineLabels()

bool QgsPalLabeling::isDrawingOutlineLabels ( ) const
Note
added in 2.4

Definition at line 3970 of file qgspallabeling.cpp.

§ isShowingAllLabels()

bool QgsPalLabeling::isShowingAllLabels ( ) const

Definition at line 3950 of file qgspallabeling.cpp.

§ isShowingCandidates()

bool QgsPalLabeling::isShowingCandidates ( ) const

Definition at line 3940 of file qgspallabeling.cpp.

§ isShowingPartialsLabels()

bool QgsPalLabeling::isShowingPartialsLabels ( ) const

Definition at line 3960 of file qgspallabeling.cpp.

§ loadEngineSettings()

void QgsPalLabeling::loadEngineSettings ( )

load/save engine settings to project file

Definition at line 4049 of file qgspallabeling.cpp.

§ numCandidatePositions()

void QgsPalLabeling::numCandidatePositions ( int &  candPoint,
int &  candLine,
int &  candPolygon 
)

Definition at line 3920 of file qgspallabeling.cpp.

§ prepareDiagramLayer()

int QgsPalLabeling::prepareDiagramLayer ( QgsVectorLayer layer,
QSet< QString > &  attrNames,
QgsRenderContext ctx 
)
overridevirtual

adds a diagram layer to the labeling engine

Note
added in QGIS 2.12

Reimplemented from QgsLabelingEngineInterface.

Definition at line 3276 of file qgspallabeling.cpp.

§ prepareGeometry()

QgsGeometry QgsPalLabeling::prepareGeometry ( const QgsGeometry geometry,
QgsRenderContext context,
const QgsCoordinateTransform ct,
QgsGeometry clipGeometry = nullptr 
)
static

Prepares a geometry for registration with PAL.

Handles reprojection, rotation, clipping, etc.

Parameters
geometrygeometry to prepare
contextrender context
ctcoordinate transform, or invalid transform if no transformation required
clipGeometrygeometry to clip features to, if applicable
Returns
prepared geometry
Note
added in QGIS 2.9

Definition at line 3358 of file qgspallabeling.cpp.

§ prepareLayer()

int QgsPalLabeling::prepareLayer ( QgsVectorLayer layer,
QSet< QString > &  attrNames,
QgsRenderContext ctx 
)
overridevirtual

hook called when drawing layer before issuing select()

Implements QgsLabelingEngineInterface.

Definition at line 3248 of file qgspallabeling.cpp.

§ registerDiagramFeature()

void QgsPalLabeling::registerDiagramFeature ( const QString &  layerID,
QgsFeature feat,
QgsRenderContext context 
)
overridevirtual

called for every diagram feature

Reimplemented from QgsLabelingEngineInterface.

Definition at line 3474 of file qgspallabeling.cpp.

§ registerFeature()

void QgsPalLabeling::registerFeature ( const QString &  layerID,
QgsFeature feat,
QgsRenderContext context 
)
overridevirtual

Register a feature for labelling.

Parameters
layerIDstring identifying layer associated with label
featfeature 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.

Implements QgsLabelingEngineInterface.

Definition at line 3292 of file qgspallabeling.cpp.

§ saveEngineSettings()

void QgsPalLabeling::saveEngineSettings ( )

Definition at line 4054 of file qgspallabeling.cpp.

§ searchMethod()

QgsPalLabeling::Search QgsPalLabeling::searchMethod ( ) const

Definition at line 3935 of file qgspallabeling.cpp.

§ setDrawingOutlineLabels()

void QgsPalLabeling::setDrawingOutlineLabels ( bool  outline)

Definition at line 3975 of file qgspallabeling.cpp.

§ setDrawLabelRectOnly()

void QgsPalLabeling::setDrawLabelRectOnly ( bool  drawRect)

Sets whether the engine should only draw the outline rectangles of labels, not the label contents themselves.

Used for debugging and testing purposes.

Parameters
drawRectset to true to enable rect drawing only
See also
drawLabelRectOnly
Note
added in QGIS 2.12

Definition at line 3985 of file qgspallabeling.cpp.

§ setNumCandidatePositions()

void QgsPalLabeling::setNumCandidatePositions ( int  candPoint,
int  candLine,
int  candPolygon 
)

Definition at line 3925 of file qgspallabeling.cpp.

§ setSearchMethod()

void QgsPalLabeling::setSearchMethod ( QgsPalLabeling::Search  s)

Definition at line 3930 of file qgspallabeling.cpp.

§ setShowingAllLabels()

void QgsPalLabeling::setShowingAllLabels ( bool  showing)

Definition at line 3955 of file qgspallabeling.cpp.

§ setShowingCandidates()

void QgsPalLabeling::setShowingCandidates ( bool  showing)

Definition at line 3945 of file qgspallabeling.cpp.

§ setShowingPartialsLabels()

void QgsPalLabeling::setShowingPartialsLabels ( bool  showing)

Definition at line 3965 of file qgspallabeling.cpp.

§ splitToGraphemes()

QStringList QgsPalLabeling::splitToGraphemes ( const QString &  text)
static

Splits a text string to a list of graphemes, which are the smallest allowable character divisions in the string.

This accounts for scripts were individual characters are not allowed to be split apart (eg Arabic and Indic based scripts)

Parameters
textstring to split
Returns
list of graphemes
Note
added in QGIS 2.10

Definition at line 3344 of file qgspallabeling.cpp.

§ splitToLines()

QStringList QgsPalLabeling::splitToLines ( const QString &  text,
const QString &  wrapCharacter 
)
static

Splits a text string to a list of separate lines, using a specified wrap character.

The text string will be split on either newline characters or the wrap character.

Parameters
texttext string to split
wrapCharacteradditional character to wrap on
Returns
list of text split to lines
Note
added in QGIS 2.9

Definition at line 3325 of file qgspallabeling.cpp.

§ staticWillUseLayer() [1/2]

bool QgsPalLabeling::staticWillUseLayer ( QgsVectorLayer layer)
static

called to find out whether the layer is used for labeling

Note
added in 2.4

Definition at line 3225 of file qgspallabeling.cpp.

§ staticWillUseLayer() [2/2]

bool QgsPalLabeling::staticWillUseLayer ( const QString &  layerID)
static

Definition at line 3216 of file qgspallabeling.cpp.

§ takeResults()

QgsLabelingResults * QgsPalLabeling::takeResults ( )

Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to the caller.

Note
added in 2.4

Definition at line 3915 of file qgspallabeling.cpp.

§ willUseLayer()

bool QgsPalLabeling::willUseLayer ( QgsVectorLayer layer)
overridevirtual

called to find out whether the layer is used for labeling

Implements QgsLabelingEngineInterface.

Definition at line 3211 of file qgspallabeling.cpp.

Friends And Related Function Documentation

§ QgsDxfExport

friend class QgsDxfExport
friend

Definition at line 920 of file qgspallabeling.h.

§ QgsPalLayerSettings

friend class QgsPalLayerSettings
friend

Definition at line 945 of file qgspallabeling.h.

§ QgsVectorLayerLabelProvider

friend class QgsVectorLayerLabelProvider
friend

Definition at line 919 of file qgspallabeling.h.

Member Data Documentation

§ mCandidates

QList<QgsLabelCandidate> QgsPalLabeling::mCandidates
protected

Definition at line 943 of file qgspallabeling.h.

§ mDiagramProviders

QHash<QString, QgsVectorLayerDiagramProvider*> QgsPalLabeling::mDiagramProviders
protected

hashtable of diagram providers (key = layer ID)

Definition at line 936 of file qgspallabeling.h.

§ mEngine

QgsLabelingEngine* QgsPalLabeling::mEngine
protected

New labeling engine to interface with PAL.

Definition at line 940 of file qgspallabeling.h.

§ mInvalidLayerSettings

QgsPalLayerSettings QgsPalLabeling::mInvalidLayerSettings
protected

Definition at line 937 of file qgspallabeling.h.

§ mLabelProviders

QHash<QString, QgsVectorLayerLabelProvider*> QgsPalLabeling::mLabelProviders
protected

hashtable of label providers, being filled during labeling (key = layer ID)

Definition at line 934 of file qgspallabeling.h.


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