QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 renderLabel (QgsRenderContext &renderContext, QgsFeature &feature, bool selected, QgsLabelAttributes *classAttributes=0)
 render label More...
 
void readXML (const QDomNode &node)
 Reads the renderer configuration from an XML file. More...
 
void writeXML (QDomNode &label_node, QDomDocument &document) const
 Writes the contents of the renderer to a configuration file. More...
 
void addRequiredFields (QgsAttributeList &fields) const
 add vector of required fields to existing list of fields More...
 
void setFields (const QgsFields &fields)
 Set available fields. More...
 
QgsFieldsfields ()
 Available vector fields. More...
 
QgsLabelAttributeslabelAttributes ()
 Pointer to default attributes. More...
 
void setLabelField (int attr, int fieldIndex)
 Set label field. More...
 
QString labelField (int attr) const
 label field 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...
 
void setMinScale (float theMinScale)
 Accessor and mutator for the minimum scale member. More...
 
float minScale () const
 
void setMaxScale (float theMaxScale)
 Accessor and mutator for the maximum scale member. More...
 
float maxScale () const
 
void setScaleBasedVisibility (bool theVisibilityFlag)
 Accessor and mutator for the scale based visilibility flag. More...
 
bool scaleBasedVisibility () const
 

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.

Constructor & Destructor Documentation

QgsLabel::QgsLabel ( const QgsFields fields)
QgsLabel::~QgsLabel ( )

Member Function Documentation

void QgsLabel::addRequiredFields ( QgsAttributeList fields) const

add vector of required fields to existing list of fields

QgsFields & QgsLabel::fields ( void  )

Available vector fields.

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.

QgsLabelAttributes * QgsLabel::labelAttributes ( void  )

Pointer to default attributes.

Note
this replaces the to-be-deprecated layerAttributes method.
introduced in QGIS 1.4
QString QgsLabel::labelField ( int  attr) const

label field

float QgsLabel::maxScale ( ) const
float QgsLabel::minScale ( ) const
void QgsLabel::readXML ( const QDomNode &  node)

Reads the renderer configuration from an XML file.

Parameters
nodethe Dom node to read
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
Note
added in 1.2
bool QgsLabel::scaleBasedVisibility ( ) const
void QgsLabel::setFields ( const QgsFields fields)

Set available fields.

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

Set label field.

void QgsLabel::setMaxScale ( float  theMaxScale)

Accessor and mutator for the maximum scale member.

void QgsLabel::setMinScale ( float  theMinScale)

Accessor and mutator for the minimum scale member.

void QgsLabel::setScaleBasedVisibility ( bool  theVisibilityFlag)

Accessor and mutator for the scale based visilibility flag.

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

Writes the contents of the renderer to a configuration file.


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