QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
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... | |
QgsFields & | fields () |
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... | |
bool | isInScaleRange (double scale) const |
Return true if the label is visible at the given scale. More... | |
QgsLabelAttributes * | labelAttributes () |
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=nullptr) |
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... | |
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.
enum QgsLabel::LabelField |
Definition at line 59 of file qgslabel.h.
QgsLabel::QgsLabel | ( | const QgsFields & | fields | ) |
Definition at line 47 of file qgslabel.cpp.
QgsLabel::~QgsLabel | ( | ) |
Definition at line 61 of file qgslabel.cpp.
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 | ( | ) |
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.
bool QgsLabel::isInScaleRange | ( | double | scale | ) | const |
Return true if the label is visible at the given scale.
Definition at line 1418 of file qgslabel.cpp.
QgsLabelAttributes * QgsLabel::labelAttributes | ( | ) |
Pointer to default attributes.
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 1413 of file qgslabel.cpp.
float QgsLabel::minScale | ( | ) | const |
Definition at line 1403 of file qgslabel.cpp.
void QgsLabel::readXML | ( | const QDomNode & | node | ) |
Reads the renderer configuration from an XML file.
node | the Dom node to read |
Definition at line 745 of file qgslabel.cpp.
void QgsLabel::renderLabel | ( | QgsRenderContext & | renderContext, |
QgsFeature & | feature, | ||
bool | selected, | ||
QgsLabelAttributes * | classAttributes = nullptr |
||
) |
render label
renderContext | the render context |
feature | feature to render the label for |
selected | feature is selected |
classAttributes | attributes to create the label from |
Definition at line 72 of file qgslabel.cpp.
bool QgsLabel::scaleBasedVisibility | ( | ) | const |
Definition at line 1393 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 1408 of file qgslabel.cpp.
void QgsLabel::setMinScale | ( | float | theMinScale | ) |
Accessor and mutator for the minimum scale member.
Definition at line 1398 of file qgslabel.cpp.
void QgsLabel::setScaleBasedVisibility | ( | bool | theVisibilityFlag | ) |
Accessor and mutator for the scale based visilibility flag.
Definition at line 1388 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 1038 of file qgslabel.cpp.