QGIS API Documentation
2.4.0-Chugiak
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
core
qgslabel.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgslabel.h - render vector labels
3
-------------------
4
begin : August 2004
5
copyright : (C) 2004 by Radim Blazek
6
email : blazek@itc.it
7
***************************************************************************/
8
/***************************************************************************
9
* *
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. *
14
* *
15
***************************************************************************/
16
#ifndef QGSLABEL_H
17
#define QGSLABEL_H
18
19
#include <vector>
20
21
#include <QColor>
22
#include <QList>
23
#include <QMap>
24
25
#include "
qgspoint.h
"
26
27
class
QDomNode;
28
class
QDomDocument;
29
class
QDomElement;
30
class
QString;
31
class
QPainter;
32
class
QPaintDevice;
33
34
class
QgsFeature
;
35
class
QgsField
;
36
class
QgsLabelAttributes
;
37
38
#include "
qgsfield.h
"
39
#include "
qgsrectangle.h
"
40
#include "
qgsrendercontext.h
"
41
42
typedef
QList<int>
QgsAttributeList
;
43
44
class
QgsFields
;
45
51
class
CORE_EXPORT
QgsLabel
52
{
53
public
:
54
QgsLabel
(
const
QgsFields
& fields );
55
56
~
QgsLabel
();
57
58
/* Fields */
59
enum
LabelField
60
{
61
Text = 0,
62
Family
,
63
Size
,
64
SizeType
,
65
Bold
,
66
Italic
,
67
Underline
,
68
Color
,
69
XCoordinate
,
70
YCoordinate
,
71
XOffset
,
72
YOffset
,
73
Angle
,
74
Alignment
,
75
BufferEnabled
,
76
BufferSize
,
77
BufferColor
,
78
BufferBrush
,
79
BorderWidth
,
80
BorderColor
,
81
BorderStyle
,
82
MultilineEnabled
,
83
StrikeOut
,
// added in 1.5
84
LabelFieldCount
85
};
86
87
struct
labelpoint
88
{
89
QgsPoint
p
;
90
double
angle
;
91
};
92
100
void
renderLabel(
QgsRenderContext
&renderContext,
QgsFeature
&feature,
bool
selected,
QgsLabelAttributes
*classAttributes = 0 );
101
105
void
readXML(
const
QDomNode& node );
106
108
void
writeXML( QDomNode & label_node, QDomDocument & document )
const
;
109
111
void
addRequiredFields(
QgsAttributeList
& fields )
const
;
112
114
void
setFields(
const
QgsFields
& fields );
115
117
QgsFields
& fields();
118
123
QgsLabelAttributes
*labelAttributes();
124
126
void
setLabelField(
int
attr,
int
fieldIndex );
127
129
QString labelField(
int
attr )
const
;
130
136
QString fieldValue(
int
attr,
QgsFeature
& feature );
137
139
void
setMinScale(
float
theMinScale );
140
float
minScale()
const
;
141
143
void
setMaxScale(
float
theMaxScale );
144
float
maxScale()
const
;
145
147
void
setScaleBasedVisibility(
bool
theVisibilityFlag );
148
bool
scaleBasedVisibility()
const
;
149
150
private
:
154
void
renderLabel(
QgsRenderContext
&renderContext,
QgsPoint
point,
155
QString text, QFont font, QPen pen,
156
int
dx,
int
dy,
157
double
xoffset,
double
yoffset,
158
double
ang,
159
int
width,
int
height,
int
alignment );
160
161
bool
readLabelField( QDomElement &el,
int
attr, QString prefix );
162
164
void
labelPoint( std::vector<labelpoint>&,
QgsFeature
&feature );
165
167
const
unsigned
char
* labelPoint(
labelpoint
& point,
const
unsigned
char
* wkb,
size_t
wkblen );
168
170
QColor
mSelectionColor
;
171
173
QgsLabelAttributes
*
mLabelAttributes
;
174
176
QgsFields
mFields
;
177
179
std::vector<QString>
mLabelField
;
180
182
std::vector<int>
mLabelFieldIdx
;
183
185
float
mMinScale
;
187
float
mMaxScale
;
189
bool
mScaleBasedVisibility
;
190
};
191
192
#endif
qgsfield.h
QgsLabel::Underline
Definition:
qgslabel.h:67
QgsLabel::BorderColor
Definition:
qgslabel.h:80
QgsLabel::mLabelAttributes
QgsLabelAttributes * mLabelAttributes
Default layer attributes.
Definition:
qgslabel.h:173
qgsrendercontext.h
QgsLabel::labelpoint::p
QgsPoint p
Definition:
qgslabel.h:89
QgsLabel::Bold
Definition:
qgslabel.h:65
QgsLabel::mSelectionColor
QColor mSelectionColor
Color to draw selected features.
Definition:
qgslabel.h:170
QgsLabel::BufferSize
Definition:
qgslabel.h:76
QgsLabel::BufferColor
Definition:
qgslabel.h:77
QgsLabel::YCoordinate
Definition:
qgslabel.h:70
QgsFields
Container of fields for a vector layer.
Definition:
qgsfield.h:161
QgsLabel::Angle
Definition:
qgslabel.h:73
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition:
qgsfeature.h:113
QgsLabel::Size
Definition:
qgslabel.h:63
QgsLabel::mScaleBasedVisibility
bool mScaleBasedVisibility
A flag that tells us whether to use the above vars to restrict the label's visibility.
Definition:
qgslabel.h:189
QgsLabel::YOffset
Definition:
qgslabel.h:72
QgsLabel::mFields
QgsFields mFields
Available layer fields.
Definition:
qgslabel.h:176
QgsLabel::Alignment
Definition:
qgslabel.h:74
QgsAttributeList
QList< int > QgsAttributeList
Definition:
qgslabel.h:36
QgsLabel::BorderWidth
Definition:
qgslabel.h:79
QgsLabel::mMaxScale
float mMaxScale
Maximum scale at which this label should be displayed.
Definition:
qgslabel.h:187
QgsAttributeList
QList< int > QgsAttributeList
Definition:
qgsfeaturerequest.h:26
QgsLabel::labelpoint::angle
double angle
Definition:
qgslabel.h:90
QgsLabel::Color
Definition:
qgslabel.h:68
qgsrectangle.h
QgsLabel::SizeType
Definition:
qgslabel.h:64
QgsField
Encapsulate a field in an attribute table or data source.
Definition:
qgsfield.h:31
QgsLabel::BufferEnabled
Definition:
qgslabel.h:75
QgsPoint
A class to represent a point geometry.
Definition:
qgspoint.h:63
QgsLabel
A class to render labels.
Definition:
qgslabel.h:51
QgsLabel::labelpoint
Definition:
qgslabel.h:87
QgsRenderContext
Contains information about the context of a rendering operation.
Definition:
qgsrendercontext.h:39
QgsLabel::StrikeOut
Definition:
qgslabel.h:83
QgsLabel::mLabelFieldIdx
std::vector< int > mLabelFieldIdx
Label field indexes.
Definition:
qgslabel.h:182
QgsLabel::Family
Definition:
qgslabel.h:62
QgsLabel::BorderStyle
Definition:
qgslabel.h:81
QgsLabel::mLabelField
std::vector< QString > mLabelField
Label fields.
Definition:
qgslabel.h:179
QgsLabelAttributes
A class to store attributes needed for label rendering.
Definition:
qgslabelattributes.h:76
QgsLabel::Italic
Definition:
qgslabel.h:66
QgsLabel::XOffset
Definition:
qgslabel.h:71
QgsLabel::MultilineEnabled
Definition:
qgslabel.h:82
QgsLabel::BufferBrush
Definition:
qgslabel.h:78
QgsLabel::XCoordinate
Definition:
qgslabel.h:69
QgsLabel::mMinScale
float mMinScale
Minimum scale at which this label should be displayed.
Definition:
qgslabel.h:185
QgsLabel::LabelField
LabelField
Definition:
qgslabel.h:59
qgspoint.h
Generated on Wed Mar 18 2015 11:40:12 for QGIS API Documentation by
1.8.9.1