1
/***************************************************************************
2
qgslabel.h - render vector labels
5
copyright : (C) 2004 by Radim Blazek
7
***************************************************************************/
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
16
/* $Id: qgslabel.h 5686 2006-08-10 16:19:19Z rblazek $ */
33
class QgsLabelAttributes;
36
class QgsCoordinateTransform;
38
/** Render class to display labels */
42
QgsLabel ( std::vector<QgsField> const & fields );
71
void dialog( QWidget * parent = 0 );
73
/** \brief render label
74
* \param sizeScale global scale factor for size in pixels, labels in map units are not scaled
76
void renderLabel ( QPainter* painter, QgsRect* viewExtent,
77
const QgsCoordinateTransform& coordTransform,
78
bool doCoordTransform, QgsMapToPixel *transform,
79
QgsFeature *feature, bool selected, QgsLabelAttributes *classAttributes=0, double sizeScale = 1.);
81
/** Reads the renderer configuration from an XML file
82
@param rnode the DOM node to read
84
void readXML(const QDomNode& node);
86
/** Writes the contents of the renderer to a configuration file */
87
void writeXML(std::ostream& xml);
89
//! add vector of required fields to existing list of fields
90
void addRequiredFields ( std::list<int> *fields );
92
//! Set available fields
93
void setFields( std::vector<QgsField> const & fields );
95
//! Available vector fields
96
std::vector<QgsField> & fields ( void );
98
//! Pointer to default attributes
99
QgsLabelAttributes *layerAttributes ( void );
102
void setLabelField ( int attr, const QString str );
105
QString labelField ( int attr );
107
/** Get field value if : 1) field name is not empty
109
* 3) value is defined
110
* otherwise returns empty string
112
QString fieldValue ( int attr, QgsFeature *feature );
115
/** Does the actual rendering of a label at the given point
118
void renderLabel(QPainter* painter, QgsPoint point,
119
bool doCoordTransform,
120
const QgsCoordinateTransform& coordTransform,
121
QgsMapToPixel* transform,
122
QString text, QFont font, QPen pen,
124
double xoffset, double yoffset,
127
/** Get label point for simple feature in map units */
128
void labelPoint ( std::vector<QgsPoint>&, QgsFeature *feature );
130
/** Get label point for the given feature in wkb format. */
131
unsigned char* labelPoint( QgsPoint& point, unsigned char* wkb);
133
/** Color to draw selected features */
134
QColor mSelectionColor;
136
//! Default layer attributes
137
QgsLabelAttributes *mLabelAttributes;
139
//! Available layer fields
140
std::vector<QgsField> mField;
143
std::vector<QString> mLabelField;
145
//! Label field indexes
146
std::vector<int> mLabelFieldIdx;