QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  DrawLabelType {
  LabelText = 0, LabelBuffer, LabelShape, LabelSVG,
  LabelShadow
}
 
enum  Search {
  Chain, Popmusic_Tabu, Popmusic_Chain, Popmusic_Tabu_Chain,
  Falp
}
 

Public Member Functions

 QgsPalLabeling ()
 
 ~QgsPalLabeling ()
 
virtual int addDiagramLayer (QgsVectorLayer *layer, const QgsDiagramLayerSettings *s) override
 adds a diagram layer to the labeling engine More...
 
const QList< QgsLabelCandidate > & candidates ()
 
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
QgsLabelingEngineInterface
clone () override
 called when passing engine among map renderers More...
 
virtual void drawLabel (pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, DrawLabelType drawType, double dpiRatio=1.0)
 drawLabel More...
 
void drawLabelCandidateRect (pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform)
 
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 Q_DECL_DEPRECATED void init (QgsMapRenderer *mr) override
 called when we're going to start 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
 
bool isShowingShadowRectangles () const
 
Q_DECL_DEPRECATED bool isStoredWithProject () const
 
virtual Q_DECL_DEPRECATED
QList< QgsLabelPosition
labelsAtPosition (const QgsPoint &p) override
 return infos about labels at a given (map) position More...
 
virtual Q_DECL_DEPRECATED
QList< QgsLabelPosition
labelsWithinRect (const QgsRectangle &r) override
 return infos about labels within a given (map) rectangle More...
 
QgsPalLayerSettingslayer (const QString &layerName) override
 returns PAL layer settings for a registered layer More...
 
void loadEngineSettings ()
 load/save engine settings to project file More...
 
void numCandidatePositions (int &candPoint, int &candLine, int &candPolygon)
 
virtual int prepareLayer (QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx) override
 hook called when drawing layer before issuing select() More...
 
virtual void registerDiagramFeature (const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext()) override
 called for every diagram feature More...
 
virtual void registerFeature (const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext(), QString dxfLayer=QString::null) 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)
 
void setShowingShadowRectangles (bool showing)
 
Q_DECL_DEPRECATED void setStoredWithProject (bool store)
 
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 drawLabelBackground (QgsRenderContext &context, QgsLabelComponent component, const QgsPalLayerSettings &tmpLyr)
 
static void drawLabelBuffer (QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
 
static void drawLabelShadow (QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
 
static bool geometryRequiresPreparation (const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
 Checks whether a geometry requires preparation before registration with PAL. More...
 
static QgsGeometryprepareGeometry (const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
 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 dataDefinedDropShadow (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
void dataDefinedShapeBackground (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
void dataDefinedTextBuffer (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
void dataDefinedTextFormatting (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
void dataDefinedTextStyle (QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
 
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...
 

Protected Attributes

QHash< QString,
QgsDiagramLayerSettings
mActiveDiagramLayers
 
QHash< QString,
QgsPalLayerSettings
mActiveLayers
 
QList< QgsLabelCandidatemCandidates
 
int mCandLine
 
int mCandPoint
 
int mCandPolygon
 
bool mDrawLabelRectOnly
 Whether to only draw the label rect and not the actual label text (used for unit tests) More...
 
bool mDrawOutlineLabels
 
QgsPalLayerSettings mInvalidLayerSettings
 
const QgsMapSettingsmMapSettings
 
pal::PalmPal
 
QgsLabelingResultsmResults
 
Search mSearch
 
bool mShowingAllLabels
 
bool mShowingCandidates
 
bool mShowingPartialsLabels
 
bool mShowingShadowRects
 

Friends

class QgsPalLayerSettings
 

Detailed Description

Definition at line 748 of file qgspallabeling.h.

Member Enumeration Documentation

Enumerator
LabelText 
LabelBuffer 
LabelShape 
LabelSVG 
LabelShadow 

Definition at line 751 of file qgspallabeling.h.

Enumerator
Chain 
Popmusic_Tabu 
Popmusic_Chain 
Popmusic_Tabu_Chain 
Falp 

Definition at line 768 of file qgspallabeling.h.

Constructor & Destructor Documentation

QgsPalLabeling::QgsPalLabeling ( )

Definition at line 3165 of file qgspallabeling.cpp.

QgsPalLabeling::~QgsPalLabeling ( )

Definition at line 3193 of file qgspallabeling.cpp.

Member Function Documentation

int QgsPalLabeling::addDiagramLayer ( QgsVectorLayer layer,
const QgsDiagramLayerSettings s 
)
overridevirtual

adds a diagram layer to the labeling engine

Reimplemented from QgsLabelingEngineInterface.

Definition at line 3471 of file qgspallabeling.cpp.

const QList<QgsLabelCandidate>& QgsPalLabeling::candidates ( )
inline

Definition at line 775 of file qgspallabeling.h.

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 3643 of file qgspallabeling.cpp.

void QgsPalLabeling::clearActiveLayer ( const QString layerID)
overridevirtual

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

Implements QgsLabelingEngineInterface.

Definition at line 3239 of file qgspallabeling.cpp.

void QgsPalLabeling::clearActiveLayers ( )
overridevirtual

clears all PAL layer settings for registered layers

Implements QgsLabelingEngineInterface.

Definition at line 3229 of file qgspallabeling.cpp.

void QgsPalLabeling::clearEngineSettings ( )

Definition at line 5404 of file qgspallabeling.cpp.

QgsLabelingEngineInterface * QgsPalLabeling::clone ( )
overridevirtual

called when passing engine among map renderers

Implements QgsLabelingEngineInterface.

Definition at line 5417 of file qgspallabeling.cpp.

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

Definition at line 4115 of file qgspallabeling.cpp.

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

Definition at line 4004 of file qgspallabeling.cpp.

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

Definition at line 3947 of file qgspallabeling.cpp.

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

Definition at line 3894 of file qgspallabeling.cpp.

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

Definition at line 3869 of file qgspallabeling.cpp.

void QgsPalLabeling::deleteTemporaryData ( )
protected

Definition at line 4444 of file qgspallabeling.cpp.

void QgsPalLabeling::drawLabel ( pal::LabelPosition label,
QgsRenderContext context,
QgsPalLayerSettings tmpLyr,
DrawLabelType  drawType,
double  dpiRatio = 1.0 
)
virtual

drawLabel

Note
not available in python bindings

Reimplemented in QgsDxfPalLabeling.

Definition at line 4580 of file qgspallabeling.cpp.

void QgsPalLabeling::drawLabelBackground ( QgsRenderContext context,
QgsLabelComponent  component,
const QgsPalLayerSettings tmpLyr 
)
static

Definition at line 4918 of file qgspallabeling.cpp.

void QgsPalLabeling::drawLabelBuffer ( QgsRenderContext context,
const QgsLabelComponent component,
const QgsPalLayerSettings tmpLyr 
)
static

Definition at line 4863 of file qgspallabeling.cpp.

void QgsPalLabeling::drawLabelCandidateRect ( pal::LabelPosition lp,
QPainter painter,
const QgsMapToPixel xform 
)
Note
not available in python bindings

Definition at line 4522 of file qgspallabeling.cpp.

void QgsPalLabeling::drawLabeling ( QgsRenderContext context)
overridevirtual

called when the map is drawn and labels should be placed

Implements QgsLabelingEngineInterface.

Definition at line 4188 of file qgspallabeling.cpp.

bool QgsPalLabeling::drawLabelRectOnly ( ) const
inline

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 795 of file qgspallabeling.h.

void QgsPalLabeling::drawLabelShadow ( QgsRenderContext context,
const QgsLabelComponent component,
const QgsPalLayerSettings tmpLyr 
)
static

Definition at line 5215 of file qgspallabeling.cpp.

void QgsPalLabeling::exit ( )
overridevirtual

called when we're done with rendering

Implements QgsLabelingEngineInterface.

Definition at line 3849 of file qgspallabeling.cpp.

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

Checks whether a geometry requires preparation before registration with PAL.

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

Definition at line 3501 of file qgspallabeling.cpp.

void QgsPalLabeling::init ( QgsMapRenderer mr)
overridevirtual

called when we're going to start with rendering

Deprecated:
since 2.4 - use override with QgsMapSettings

Implements QgsLabelingEngineInterface.

Definition at line 3811 of file qgspallabeling.cpp.

void QgsPalLabeling::init ( const QgsMapSettings mapSettings)
overridevirtual

called when we're going to start with rendering

Implements QgsLabelingEngineInterface.

Definition at line 3816 of file qgspallabeling.cpp.

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

Definition at line 787 of file qgspallabeling.h.

bool QgsPalLabeling::isShowingAllLabels ( ) const
inline

Definition at line 780 of file qgspallabeling.h.

bool QgsPalLabeling::isShowingCandidates ( ) const
inline

Definition at line 773 of file qgspallabeling.h.

bool QgsPalLabeling::isShowingPartialsLabels ( ) const
inline

Definition at line 783 of file qgspallabeling.h.

bool QgsPalLabeling::isShowingShadowRectangles ( ) const
inline

Definition at line 777 of file qgspallabeling.h.

Q_DECL_DEPRECATED bool QgsPalLabeling::isStoredWithProject ( ) const
inline
Deprecated:
since 2.4 - settings are always stored in project

Definition at line 882 of file qgspallabeling.h.

QList< QgsLabelPosition > QgsPalLabeling::labelsAtPosition ( const QgsPoint p)
overridevirtual

return infos about labels at a given (map) position

Deprecated:
since 2.4 - use takeResults() and methods of QgsLabelingResults

Implements QgsLabelingEngineInterface.

Definition at line 4476 of file qgspallabeling.cpp.

QList< QgsLabelPosition > QgsPalLabeling::labelsWithinRect ( const QgsRectangle r)
overridevirtual

return infos about labels within a given (map) rectangle

Deprecated:
since 2.4 - use takeResults() and methods of QgsLabelingResults

Implements QgsLabelingEngineInterface.

Definition at line 4481 of file qgspallabeling.cpp.

QgsPalLayerSettings & QgsPalLabeling::layer ( const QString layerName)
overridevirtual

returns PAL layer settings for a registered layer

Implements QgsLabelingEngineInterface.

Definition at line 3856 of file qgspallabeling.cpp.

void QgsPalLabeling::loadEngineSettings ( )

load/save engine settings to project file

Definition at line 5363 of file qgspallabeling.cpp.

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

Definition at line 4498 of file qgspallabeling.cpp.

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

Prepares a geometry for registration with PAL.

Handles reprojection, rotation, clipping, etc.

Parameters
geometrygeometry to prepare
contextrender context
ctcoordinate transform
clipGeometrygeometry to clip features to, if applicable
Returns
prepared geometry, the caller takes ownership
Note
added in QGIS 2.9

Definition at line 3561 of file qgspallabeling.cpp.

int QgsPalLabeling::prepareLayer ( QgsVectorLayer layer,
QStringList attrNames,
QgsRenderContext ctx 
)
overridevirtual

hook called when drawing layer before issuing select()

Implements QgsLabelingEngineInterface.

Definition at line 3253 of file qgspallabeling.cpp.

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

called for every diagram feature

Reimplemented from QgsLabelingEngineInterface.

Definition at line 3681 of file qgspallabeling.cpp.

void QgsPalLabeling::registerFeature ( const QString layerID,
QgsFeature feat,
const QgsRenderContext context = QgsRenderContext(),
QString  dxfLayer = QString::null 
)
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.
dxfLayerdxfLayer name

Implements QgsLabelingEngineInterface.

Definition at line 3495 of file qgspallabeling.cpp.

void QgsPalLabeling::saveEngineSettings ( )

Definition at line 5390 of file qgspallabeling.cpp.

QgsPalLabeling::Search QgsPalLabeling::searchMethod ( ) const

Definition at line 4517 of file qgspallabeling.cpp.

void QgsPalLabeling::setDrawingOutlineLabels ( bool  outline)
inline

Definition at line 788 of file qgspallabeling.h.

void QgsPalLabeling::setDrawLabelRectOnly ( bool  drawRect)
inline

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 803 of file qgspallabeling.h.

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

Definition at line 4505 of file qgspallabeling.cpp.

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

Definition at line 4512 of file qgspallabeling.cpp.

void QgsPalLabeling::setShowingAllLabels ( bool  showing)
inline

Definition at line 781 of file qgspallabeling.h.

void QgsPalLabeling::setShowingCandidates ( bool  showing)
inline

Definition at line 774 of file qgspallabeling.h.

void QgsPalLabeling::setShowingPartialsLabels ( bool  showing)
inline

Definition at line 784 of file qgspallabeling.h.

void QgsPalLabeling::setShowingShadowRectangles ( bool  showing)
inline

Definition at line 778 of file qgspallabeling.h.

Q_DECL_DEPRECATED void QgsPalLabeling::setStoredWithProject ( bool  store)
inline
Deprecated:
since 2.4 - settings are always stored in project

Definition at line 884 of file qgspallabeling.h.

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 3547 of file qgspallabeling.cpp.

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 3528 of file qgspallabeling.cpp.

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 3218 of file qgspallabeling.cpp.

bool QgsPalLabeling::staticWillUseLayer ( const QString layerID)
static

Definition at line 3209 of file qgspallabeling.cpp.

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 4486 of file qgspallabeling.cpp.

bool QgsPalLabeling::willUseLayer ( QgsVectorLayer layer)
overridevirtual

called to find out whether the layer is used for labeling

Implements QgsLabelingEngineInterface.

Definition at line 3204 of file qgspallabeling.cpp.

Friends And Related Function Documentation

friend class QgsPalLayerSettings
friend

Definition at line 981 of file qgspallabeling.h.

Member Data Documentation

QHash<QString, QgsDiagramLayerSettings> QgsPalLabeling::mActiveDiagramLayers
protected

Definition at line 959 of file qgspallabeling.h.

QHash<QString, QgsPalLayerSettings> QgsPalLabeling::mActiveLayers
protected

Definition at line 957 of file qgspallabeling.h.

QList<QgsLabelCandidate> QgsPalLabeling::mCandidates
protected

Definition at line 969 of file qgspallabeling.h.

int QgsPalLabeling::mCandLine
protected

Definition at line 963 of file qgspallabeling.h.

int QgsPalLabeling::mCandPoint
protected

Definition at line 963 of file qgspallabeling.h.

int QgsPalLabeling::mCandPolygon
protected

Definition at line 963 of file qgspallabeling.h.

bool QgsPalLabeling::mDrawLabelRectOnly
protected

Whether to only draw the label rect and not the actual label text (used for unit tests)

Definition at line 972 of file qgspallabeling.h.

bool QgsPalLabeling::mDrawOutlineLabels
protected

Definition at line 977 of file qgspallabeling.h.

QgsPalLayerSettings QgsPalLabeling::mInvalidLayerSettings
protected

Definition at line 960 of file qgspallabeling.h.

const QgsMapSettings* QgsPalLabeling::mMapSettings
protected

Definition at line 962 of file qgspallabeling.h.

pal::Pal* QgsPalLabeling::mPal
protected

Definition at line 966 of file qgspallabeling.h.

QgsLabelingResults* QgsPalLabeling::mResults
protected

Definition at line 979 of file qgspallabeling.h.

Search QgsPalLabeling::mSearch
protected

Definition at line 964 of file qgspallabeling.h.

bool QgsPalLabeling::mShowingAllLabels
protected

Definition at line 974 of file qgspallabeling.h.

bool QgsPalLabeling::mShowingCandidates
protected

Definition at line 973 of file qgspallabeling.h.

bool QgsPalLabeling::mShowingPartialsLabels
protected

Definition at line 976 of file qgspallabeling.h.

bool QgsPalLabeling::mShowingShadowRects
protected

Definition at line 975 of file qgspallabeling.h.


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