Quantum GIS API Documentation  master-ce49b66
QgsPalLayerSettings Class Reference

#include <qgspallabeling.h>

+ Collaboration diagram for QgsPalLayerSettings:

List of all members.

Public Types

enum  DataDefinedProperties {
  Size = 0, Bold, Italic, Underline,
  Color, Strikeout, Family, BufferSize,
  BufferColor, PositionX, PositionY, Hali,
  Vali, LabelDistance, Rotation, Show,
  MinScale, MaxScale, FontTransp, BufferTransp,
  AlwaysShow
}
enum  DirectionSymbols { SymbolLeftRight, SymbolAbove, SymbolBelow }
enum  LinePlacementFlags { OnLine = 1, AboveLine = 2, BelowLine = 4, MapOrientation = 8 }
enum  MultiLineAlign { MultiLeft = 0, MultiCenter, MultiRight }
enum  Placement {
  AroundPoint, OverPoint, Line, Curved,
  Horizontal, Free
}
enum  RotationType { RotationSync = 0, RotationOffset, RotationFixed }
enum  ShadowType { ShadowLowest = 0, ShadowText, ShadowBuffer, ShadowShape }
enum  ShapeType {
  ShapeRectangle = 0, ShapeSquare, ShapeEllipse, ShapeCircle,
  ShapeSVG
}
enum  SizeType { SizeBuffer = 0, SizeFixed, SizePercent }
enum  SizeUnit { Points = 0, MM, MapUnits, Percent }
 Units used for option sizes, before being converted to rendered sizes. More...
enum  UpsideDownLabels { Upright, ShowDefined, ShowAll }

Public Member Functions

 QgsPalLayerSettings ()
 QgsPalLayerSettings (const QgsPalLayerSettings &s)
 ~QgsPalLayerSettings ()
void calculateLabelSize (const QFontMetricsF *fm, QString text, double &labelX, double &labelY)
QList< QString > dataDefinedNames () const
 List of data defined enum names.
QgsExpressiongetLabelExpression ()
 Returns the QgsExpression for this label settings.
void readFromLayer (QgsVectorLayer *layer)
void registerFeature (QgsVectorLayer *layer, QgsFeature &f, const QgsRenderContext &context)
void removeDataDefinedProperty (DataDefinedProperties p)
 Set a property to static instead data defined.
double scaleToPixelContext (double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false) const
 Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling)
void setDataDefinedProperty (DataDefinedProperties p, QString attributeName)
 Set a property as data defined.
int sizeToPixel (double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false) const
 Calculates pixel size (considering output size should be in pixel or map units, scale factors and optionally oversampling)
void writeToLayer (QgsVectorLayer *layer)

Public Attributes

bool addDirectionSymbol
double angleOffset
QPainter::CompositionMode blendMode
QPainter::CompositionMode bufferBlendMode
QColor bufferColor
Qt::PenJoinStyle bufferJoinStyle
bool bufferNoFill
double bufferSize
bool bufferSizeInMapUnits
int bufferTransp
bool centroidWhole
const QgsCoordinateTransformct
QMap< DataDefinedProperties,
QString > 
dataDefinedProperties
 Stores field names for data defined layer properties.
int decimals
bool displayAll
double dist
bool distInMapUnits
bool enabled
QgsGeometryextentGeom
int fieldIndex
QString fieldName
bool fontLimitPixelSize
int fontMaxPixelSize
int fontMinPixelSize
bool fontSizeInMapUnits
bool formatNumbers
QList< QgsPalGeometry * > geometries
bool isExpression
 Is this label made from a expression string eg FieldName || 'mm'.
bool labelOffsetInMapUnits
bool labelPerPart
QString leftDirectionSymbol
bool limitNumLabels
double maxCurvedCharAngleIn
double maxCurvedCharAngleOut
int maxNumLabels
bool mergeLines
int mFeatsRegPal
int mFeatsSendingToPal
int mFeaturesToLabel
double minFeatureSize
MultiLineAlign multilineAlign
double multilineHeight
bool obstacle
pal::Layer * palLayer
DirectionSymbols placeDirectionSymbol
Placement placement
unsigned int placementFlags
bool plusSign
bool preserveRotation
QColor previewBkgrdColor
int priority
QgsPoint ptOne
QgsPoint ptZero
double rasterCompressFactor
bool reverseDirectionSymbol
QString rightDirectionSymbol
int scaleMax
int scaleMin
QPainter::CompositionMode shadowBlendMode
QColor shadowColor
bool shadowDraw
int shadowOffsetAngle
double shadowOffsetDist
bool shadowOffsetGlobal
SizeUnit shadowOffsetUnits
double shadowRadius
bool shadowRadiusAlphaOnly
SizeUnit shadowRadiusUnits
int shadowScale
int shadowTransparency
ShadowType shadowUnder
QPainter::CompositionMode shapeBlendMode
QColor shapeBorderColor
double shapeBorderWidth
SizeUnit shapeBorderWidthUnits
bool shapeDraw
QColor shapeFillColor
Qt::PenJoinStyle shapeJoinStyle
QPointF shapeOffset
SizeUnit shapeOffsetUnits
QPointF shapeRadii
SizeUnit shapeRadiiUnits
double shapeRotation
RotationType shapeRotationType
QPointF shapeSize
SizeType shapeSizeType
SizeUnit shapeSizeUnits
QString shapeSVGFile
int shapeTransparency
ShapeType shapeType
bool showingShadowRects
QColor textColor
QFont textFont
QString textNamedStyle
int textTransp
unsigned int upsidedownLabels
double vectorScaleFactor
QString wrapChar
const QgsMapToPixelxform
double xOffset
int xQuadOffset
double yOffset
int yQuadOffset

Private Member Functions

bool checkMinimumSizeMM (const QgsRenderContext &ct, QgsGeometry *geom, double minSize) const
 Checks if a feature is larger than a minimum size (in mm)
void readDataDefinedProperty (QgsVectorLayer *layer, QgsPalLayerSettings::DataDefinedProperties p, QMap< QgsPalLayerSettings::DataDefinedProperties, QString > &propertyMap)
void readDataDefinedPropertyMap (QgsVectorLayer *layer, QMap< QgsPalLayerSettings::DataDefinedProperties, QString > &propertyMap)
void updateFontViaStyle (const QString &fontstyle)
 Updates layer font with one of its named styles.
void writeDataDefinedPropertyMap (QgsVectorLayer *layer, const QMap< QgsPalLayerSettings::DataDefinedProperties, QString > &propertyMap)

Private Attributes

QgsExpressionexpression
QList< QString > mDataDefinedNames
QFontDatabase mFontDB

Detailed Description

Definition at line 60 of file qgspallabeling.h.


Member Enumeration Documentation

Enumerator:
Size 
Bold 
Italic 
Underline 
Color 
Strikeout 
Family 
BufferSize 
BufferColor 
PositionX 
PositionY 
Hali 
Vali 
LabelDistance 
Rotation 
Show 
MinScale 
MaxScale 
FontTransp 
BufferTransp 
AlwaysShow 

Definition at line 147 of file qgspallabeling.h.

Enumerator:
SymbolLeftRight 
SymbolAbove 
SymbolBelow 

Definition at line 92 of file qgspallabeling.h.

Enumerator:
OnLine 
AboveLine 
BelowLine 
MapOrientation 

Definition at line 77 of file qgspallabeling.h.

Enumerator:
MultiLeft 
MultiCenter 
MultiRight 

Definition at line 99 of file qgspallabeling.h.

Enumerator:
AroundPoint 
OverPoint 
Line 
Curved 
Horizontal 
Free 

Definition at line 67 of file qgspallabeling.h.

Enumerator:
RotationSync 
RotationOffset 
RotationFixed 

Definition at line 122 of file qgspallabeling.h.

Enumerator:
ShadowLowest 
ShadowText 
ShadowBuffer 
ShadowShape 

Definition at line 138 of file qgspallabeling.h.

Enumerator:
ShapeRectangle 
ShapeSquare 
ShapeEllipse 
ShapeCircle 
ShapeSVG 

Definition at line 106 of file qgspallabeling.h.

Enumerator:
SizeBuffer 
SizeFixed 
SizePercent 

Definition at line 115 of file qgspallabeling.h.

Units used for option sizes, before being converted to rendered sizes.

Enumerator:
Points 
MM 
MapUnits 
Percent 

Definition at line 130 of file qgspallabeling.h.

Enumerator:
Upright 
ShowDefined 
ShowAll 

Definition at line 85 of file qgspallabeling.h.


Constructor & Destructor Documentation

Definition at line 193 of file qgspallabeling.cpp.

References addDirectionSymbol, angleOffset, AroundPoint, blendMode, bufferBlendMode, bufferColor, bufferJoinStyle, bufferNoFill, bufferSize, bufferSizeInMapUnits, bufferTransp, centroidWhole, decimals, displayAll, dist, distInMapUnits, enabled, fontLimitPixelSize, fontMaxPixelSize, fontMinPixelSize, fontSizeInMapUnits, formatNumbers, labelOffsetInMapUnits, labelPerPart, leftDirectionSymbol, limitNumLabels, maxCurvedCharAngleIn, maxCurvedCharAngleOut, maxNumLabels, mDataDefinedNames, mergeLines, minFeatureSize, MM, MultiLeft, multilineAlign, multilineHeight, obstacle, placeDirectionSymbol, placement, placementFlags, plusSign, preserveRotation, previewBkgrdColor, priority, rasterCompressFactor, reverseDirectionSymbol, rightDirectionSymbol, RotationSync, scaleMax, scaleMin, shadowBlendMode, shadowColor, shadowDraw, ShadowLowest, shadowOffsetAngle, shadowOffsetDist, shadowOffsetGlobal, shadowOffsetUnits, shadowRadius, shadowRadiusAlphaOnly, shadowRadiusUnits, shadowScale, shadowTransparency, shadowUnder, shapeBlendMode, shapeBorderColor, shapeBorderWidth, shapeBorderWidthUnits, shapeDraw, shapeFillColor, shapeJoinStyle, shapeOffset, shapeOffsetUnits, shapeRadii, shapeRadiiUnits, ShapeRectangle, shapeRotation, shapeRotationType, shapeSize, shapeSizeType, shapeSizeUnits, shapeSVGFile, shapeTransparency, shapeType, showingShadowRects, SizeBuffer, SymbolLeftRight, textColor, textFont, textNamedStyle, textTransp, Upright, upsidedownLabels, vectorScaleFactor, wrapChar, xOffset, xQuadOffset, yOffset, and yQuadOffset.

Definition at line 322 of file qgspallabeling.cpp.

References addDirectionSymbol, angleOffset, blendMode, bufferBlendMode, bufferColor, bufferJoinStyle, bufferNoFill, bufferSize, bufferSizeInMapUnits, bufferTransp, centroidWhole, ct, dataDefinedProperties, decimals, displayAll, dist, distInMapUnits, enabled, expression, extentGeom, fieldName, fontLimitPixelSize, fontMaxPixelSize, fontMinPixelSize, fontSizeInMapUnits, formatNumbers, isExpression, labelOffsetInMapUnits, labelPerPart, leftDirectionSymbol, limitNumLabels, maxCurvedCharAngleIn, maxCurvedCharAngleOut, maxNumLabels, mDataDefinedNames, mergeLines, minFeatureSize, multilineAlign, multilineHeight, obstacle, placeDirectionSymbol, placement, placementFlags, plusSign, preserveRotation, previewBkgrdColor, priority, rasterCompressFactor, reverseDirectionSymbol, rightDirectionSymbol, scaleMax, scaleMin, shadowBlendMode, shadowColor, shadowDraw, shadowOffsetAngle, shadowOffsetDist, shadowOffsetGlobal, shadowOffsetUnits, shadowRadius, shadowRadiusAlphaOnly, shadowRadiusUnits, shadowScale, shadowTransparency, shadowUnder, shapeBlendMode, shapeBorderColor, shapeBorderWidth, shapeBorderWidthUnits, shapeDraw, shapeFillColor, shapeJoinStyle, shapeOffset, shapeOffsetUnits, shapeRadii, shapeRadiiUnits, shapeRotation, shapeRotationType, shapeSize, shapeSizeType, shapeSizeUnits, shapeSVGFile, shapeTransparency, shapeType, textColor, textFont, textNamedStyle, textTransp, upsidedownLabels, vectorScaleFactor, wrapChar, xOffset, xQuadOffset, yOffset, and yQuadOffset.

Definition at line 429 of file qgspallabeling.cpp.

References ct, expression, and extentGeom.


Member Function Documentation

bool QgsPalLayerSettings::checkMinimumSizeMM ( const QgsRenderContext ct,
QgsGeometry geom,
double  minSize 
) const [private]

Checks if a feature is larger than a minimum size (in mm)

Returns:
true if above size, false if below

Definition at line 831 of file qgspallabeling.cpp.

References QgsGeometry::area(), QgsGeometry::length(), QGis::Line, QgsRenderContext::mapToPixel(), QgsMapToPixel::mapUnitsPerPixel(), QGis::Point, QGis::Polygon, QgsRenderContext::scaleFactor(), and QgsGeometry::type().

Referenced by registerFeature().

QList<QString> QgsPalLayerSettings::dataDefinedNames ( ) const [inline]

List of data defined enum names.

Note:
adding in 1.9

Definition at line 325 of file qgspallabeling.h.

Returns the QgsExpression for this label settings.

Definition at line 438 of file qgspallabeling.cpp.

References expression, and fieldName.

Referenced by registerFeature().

void QgsPalLayerSettings::readDataDefinedPropertyMap ( QgsVectorLayer layer,
QMap< QgsPalLayerSettings::DataDefinedProperties, QString > &  propertyMap 
) [private]

Definition at line 465 of file qgspallabeling.cpp.

References mDataDefinedNames, and readDataDefinedProperty().

Referenced by readFromLayer().

Definition at line 586 of file qgspallabeling.cpp.

References _readColor(), addDirectionSymbol, angleOffset, blendMode, QgsMapRenderer::BlendMultiply, QgsMapRenderer::BlendNormal, bufferBlendMode, bufferColor, bufferJoinStyle, bufferNoFill, bufferSize, bufferSizeInMapUnits, bufferTransp, centroidWhole, QgsMapLayer::customProperty(), dataDefinedProperties, decimals, displayAll, dist, distInMapUnits, enabled, fieldName, fontLimitPixelSize, fontMaxPixelSize, fontMinPixelSize, fontSizeInMapUnits, formatNumbers, QgsMapRenderer::getCompositionMode(), isExpression, labelOffsetInMapUnits, labelPerPart, leftDirectionSymbol, limitNumLabels, maxCurvedCharAngleIn, maxCurvedCharAngleOut, maxNumLabels, mergeLines, minFeatureSize, MM, MultiLeft, multilineAlign, multilineHeight, obstacle, placeDirectionSymbol, placement, placementFlags, plusSign, preserveRotation, previewBkgrdColor, priority, readDataDefinedPropertyMap(), reverseDirectionSymbol, rightDirectionSymbol, RotationSync, scaleMax, scaleMin, shadowBlendMode, shadowColor, shadowDraw, ShadowLowest, shadowOffsetAngle, shadowOffsetDist, shadowOffsetGlobal, shadowOffsetUnits, shadowRadius, shadowRadiusAlphaOnly, shadowRadiusUnits, shadowScale, shadowTransparency, shadowUnder, shapeBlendMode, shapeBorderColor, shapeBorderWidth, shapeBorderWidthUnits, shapeDraw, shapeFillColor, shapeJoinStyle, shapeOffset, shapeOffsetUnits, shapeRadii, shapeRadiiUnits, ShapeRectangle, shapeRotation, shapeRotationType, shapeSize, shapeSizeType, shapeSizeUnits, shapeSVGFile, shapeTransparency, shapeType, SizeBuffer, SymbolLeftRight, textColor, textFont, textNamedStyle, textTransp, updateFontViaStyle(), Upright, upsidedownLabels, wrapChar, xOffset, xQuadOffset, yOffset, and yQuadOffset.

Referenced by QgsPalLabeling::prepareLayer(), and QgsPalLabeling::willUseLayer().

void QgsPalLayerSettings::registerFeature ( QgsVectorLayer layer,
QgsFeature f,
const QgsRenderContext context 
)

Definition at line 921 of file qgspallabeling.cpp.

References QgsPalGeometry::addDataDefinedValue(), AlwaysShow, MathUtils::angle(), angleOffset, AroundPoint, QgsGeometry::asGeos(), QgsFeature::attribute(), calculateLabelSize(), centroidWhole, checkMinimumSizeMM(), QgsGeometry::contains(), ct, Curved, dataDefinedProperties, decimals, dist, distInMapUnits, QgsExpression::evalErrorString(), QgsExpression::evaluate(), extentGeom, fieldIndex, fontLimitPixelSize, fontMaxPixelSize, fontMinPixelSize, fontSizeInMapUnits, formatNumbers, geometries, QgsFeature::geometry(), getLabelExpression(), Hali, QgsExpression::hasEvalError(), QgsExpression::hasParserError(), QgsFeature::id(), QgsPalGeometry::info(), QgsGeometry::intersection(), isExpression, LabelDistance, labelOffsetInMapUnits, limitNumLabels, M_PI, QgsRenderContext::mapToPixel(), MapUnits, QgsMapToPixel::mapUnitsPerPixel(), maxCurvedCharAngleIn, maxCurvedCharAngleOut, maxNumLabels, MaxScale, mFeatsRegPal, mFeatsSendingToPal, mFeaturesToLabel, minFeatureSize, MinScale, OverPoint, palLayer, QgsExpression::parserErrorString(), QgsVectorLayer::pendingFields(), placement, plusSign, Points, QGis::Polygon, PositionX, PositionY, ptOne, ptZero, QgsDebugMsg, rasterCompressFactor, QgsRenderContext::rendererScale(), Rotation, QgsRenderContext::scaleFactor(), QgsPalGeometry::setIsPinned(), QgsExpression::setScale(), Show, size, Size, sizeToPixel(), QgsPalGeometry::strId(), textFont, QgsGeometry::transform(), QgsCoordinateTransform::transformInPlace(), QgsGeometry::type(), Vali, vectorScaleFactor, QgsPoint::x(), xform, xOffset, xQuadOffset, yOffset, and yQuadOffset.

Referenced by QgsPalLabeling::registerFeature().

Set a property to static instead data defined.

Definition at line 826 of file qgspallabeling.cpp.

References dataDefinedProperties.

double QgsPalLayerSettings::scaleToPixelContext ( double  size,
const QgsRenderContext c,
SizeUnit  unit,
bool  rasterfactor = false 
) const

Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling)

Parameters:
sizesize to convert
crendercontext
unitSizeUnit enum value of size
rasterfactorwhether to consider oversampling
Returns:
size that will render, as double
Note:
added in 1.9, as a better precision replacement for sizeToPixel

Definition at line 1354 of file qgspallabeling.cpp.

References QgsRenderContext::mapToPixel(), MapUnits, QgsMapToPixel::mapUnitsPerPixel(), Points, QgsRenderContext::rasterScaleFactor(), QgsRenderContext::scaleFactor(), and size.

Referenced by QgsPalLabeling::drawLabelBackground(), QgsPalLabeling::drawLabelBuffer(), QgsPalLabeling::drawLabelShadow(), and sizeToPixel().

void QgsPalLayerSettings::setDataDefinedProperty ( DataDefinedProperties  p,
QString  attributeName 
)

Set a property as data defined.

Definition at line 821 of file qgspallabeling.cpp.

References dataDefinedProperties.

int QgsPalLayerSettings::sizeToPixel ( double  size,
const QgsRenderContext c,
SizeUnit  unit,
bool  rasterfactor = false 
) const

Calculates pixel size (considering output size should be in pixel or map units, scale factors and optionally oversampling)

Parameters:
sizesize to convert
crendercontext
unitSizeUnit enum value of size
rasterfactorwhether to consider oversampling
Returns:
font pixel size

Definition at line 1349 of file qgspallabeling.cpp.

References scaleToPixelContext().

Referenced by QgsPalLabeling::drawLabeling(), QgsPalLabeling::prepareLayer(), and registerFeature().

void QgsPalLayerSettings::updateFontViaStyle ( const QString &  fontstyle) [private]

Updates layer font with one of its named styles.

Definition at line 573 of file qgspallabeling.cpp.

References mFontDB, and textFont.

Referenced by readFromLayer().

Definition at line 707 of file qgspallabeling.cpp.

References _writeColor(), addDirectionSymbol, angleOffset, blendMode, bufferBlendMode, bufferColor, bufferJoinStyle, bufferNoFill, bufferSize, bufferSizeInMapUnits, bufferTransp, centroidWhole, dataDefinedProperties, decimals, displayAll, dist, distInMapUnits, enabled, fieldName, fontLimitPixelSize, fontMaxPixelSize, fontMinPixelSize, fontSizeInMapUnits, formatNumbers, QgsMapRenderer::getBlendModeEnum(), isExpression, labelOffsetInMapUnits, labelPerPart, leftDirectionSymbol, limitNumLabels, maxCurvedCharAngleIn, maxCurvedCharAngleOut, maxNumLabels, mergeLines, minFeatureSize, multilineAlign, multilineHeight, obstacle, placeDirectionSymbol, placement, placementFlags, plusSign, preserveRotation, previewBkgrdColor, priority, reverseDirectionSymbol, rightDirectionSymbol, scaleMax, scaleMin, QgsMapLayer::setCustomProperty(), shadowBlendMode, shadowColor, shadowDraw, shadowOffsetAngle, shadowOffsetDist, shadowOffsetGlobal, shadowOffsetUnits, shadowRadius, shadowRadiusAlphaOnly, shadowRadiusUnits, shadowScale, shadowTransparency, shadowUnder, shapeBlendMode, shapeBorderColor, shapeBorderWidth, shapeBorderWidthUnits, shapeDraw, shapeFillColor, shapeJoinStyle, shapeOffset, shapeOffsetUnits, shapeRadii, shapeRadiiUnits, shapeRotation, shapeRotationType, shapeSize, shapeSizeType, shapeSizeUnits, shapeSVGFile, shapeTransparency, shapeType, textColor, textFont, textNamedStyle, textTransp, upsidedownLabels, wrapChar, writeDataDefinedPropertyMap(), xOffset, xQuadOffset, yOffset, and yQuadOffset.


Member Data Documentation

Stores field names for data defined layer properties.

Note:
not available in python bindings

Definition at line 299 of file qgspallabeling.h.

Referenced by QgsPalLabeling::prepareLayer(), QgsPalLayerSettings(), readFromLayer(), registerFeature(), removeDataDefinedProperty(), setDataDefinedProperty(), and writeToLayer().

Is this label made from a expression string eg FieldName || 'mm'.

Definition at line 176 of file qgspallabeling.h.

Referenced by QgsPalLabeling::prepareLayer(), QgsPalLayerSettings(), readFromLayer(), registerFeature(), and writeToLayer().

Definition at line 337 of file qgspallabeling.h.

Referenced by registerFeature().

QFontDatabase QgsPalLayerSettings::mFontDB [private]

Definition at line 360 of file qgspallabeling.h.

Referenced by updateFontViaStyle().

Definition at line 328 of file qgspallabeling.h.

Referenced by QgsPalLabeling::prepareLayer(), and registerFeature().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines