QGIS API Documentation  2.12.0-Lyon
Classes | Public Types | Public Member Functions | List of all members
QgsLabel Class Reference

A class to render labels. More...

#include <qgslabel.h>

Classes

struct  labelpoint
 

Public Types

enum  LabelField {
  Text = 0, Family, Size, SizeType,
  Bold, Italic, Underline, Color,
  XCoordinate, YCoordinate, XOffset, YOffset,
  Angle, Alignment, BufferEnabled, BufferSize,
  BufferColor, BufferBrush, BorderWidth, BorderColor,
  BorderStyle, MultilineEnabled, StrikeOut, LabelFieldCount
}
 

Public Member Functions

 QgsLabel (const QgsFields &fields)
 
 ~QgsLabel ()
 
void addRequiredFields (QgsAttributeList &fields) const
 add vector of required fields to existing list of fields More...
 
QgsFieldsfields ()
 Available vector fields. More...
 
QString fieldValue (int attr, QgsFeature &feature)
 Get field value if : 1) field name is not empty 2) field exists 3) value is defined otherwise returns empty string. More...
 
QgsLabelAttributeslabelAttributes ()
 Pointer to default attributes. More...
 
QString labelField (int attr) const
 label field More...
 
float maxScale () const
 
float minScale () const
 
void readXML (const QDomNode &node)
 Reads the renderer configuration from an XML file. More...
 
void renderLabel (QgsRenderContext &renderContext, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes=0)
 render label More...
 
bool scaleBasedVisibility () const
 
void setFields (const QgsFields &fields)
 Set available fields. More...
 
void setLabelField (int attr, int fieldIndex)
 Set label field. More...
 
void setMaxScale (float theMaxScale)
 Accessor and mutator for the maximum scale member. More...
 
void setMinScale (float theMinScale)
 Accessor and mutator for the minimum scale member. More...
 
void setScaleBasedVisibility (bool theVisibilityFlag)
 Accessor and mutator for the scale based visilibility flag. More...
 
void writeXML (QDomNode &label_node, QDomDocument &document) const
 Writes the contents of the renderer to a configuration file. More...
 

Detailed Description

A class to render labels.

Label rendering properties can be either specified directly or in most cases determined dynamically based on the value of an attribute.

Definition at line 51 of file qgslabel.h.

Constructor & Destructor Documentation

QgsLabel::QgsLabel ( const QgsFields fields)

Definition at line 47 of file qgslabel.cpp.

QgsLabel::~QgsLabel ( )

Definition at line 61 of file qgslabel.cpp.

Member Function Documentation

void QgsLabel::addRequiredFields ( QgsAttributeList fields) const

add vector of required fields to existing list of fields

Definition at line 459 of file qgslabel.cpp.

QgsFields & QgsLabel::fields ( void  )

Available vector fields.

Definition at line 486 of file qgslabel.cpp.

QString QgsLabel::fieldValue ( int  attr,
QgsFeature feature 
)

Get field value if : 1) field name is not empty 2) field exists 3) value is defined otherwise returns empty string.

Definition at line 66 of file qgslabel.cpp.

QgsLabelAttributes * QgsLabel::labelAttributes ( void  )

Pointer to default attributes.

Note
this replaces the to-be-deprecated layerAttributes method.
introduced in QGIS 1.4

Definition at line 510 of file qgslabel.cpp.

QString QgsLabel::labelField ( int  attr) const

label field

Definition at line 499 of file qgslabel.cpp.

float QgsLabel::maxScale ( ) const

Definition at line 1411 of file qgslabel.cpp.

float QgsLabel::minScale ( ) const

Definition at line 1401 of file qgslabel.cpp.

void QgsLabel::readXML ( const QDomNode node)

Reads the renderer configuration from an XML file.

Parameters
nodethe Dom node to read

Definition at line 743 of file qgslabel.cpp.

void QgsLabel::renderLabel ( QgsRenderContext renderContext,
QgsFeature feature,
bool  selected,
QgsLabelAttributes classAttributes = 0 
)

render label

Parameters
renderContextthe render context
featurefeature to render the label for
selectedfeature is selected
classAttributesattributes to create the label from

Definition at line 72 of file qgslabel.cpp.

bool QgsLabel::scaleBasedVisibility ( ) const

Definition at line 1391 of file qgslabel.cpp.

void QgsLabel::setFields ( const QgsFields fields)

Set available fields.

Definition at line 481 of file qgslabel.cpp.

void QgsLabel::setLabelField ( int  attr,
int  fieldIndex 
)

Set label field.

Definition at line 491 of file qgslabel.cpp.

void QgsLabel::setMaxScale ( float  theMaxScale)

Accessor and mutator for the maximum scale member.

Definition at line 1406 of file qgslabel.cpp.

void QgsLabel::setMinScale ( float  theMinScale)

Accessor and mutator for the minimum scale member.

Definition at line 1396 of file qgslabel.cpp.

void QgsLabel::setScaleBasedVisibility ( bool  theVisibilityFlag)

Accessor and mutator for the scale based visilibility flag.

Definition at line 1386 of file qgslabel.cpp.

void QgsLabel::writeXML ( QDomNode label_node,
QDomDocument document 
) const

Writes the contents of the renderer to a configuration file.

Definition at line 1036 of file qgslabel.cpp.


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