1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
/***************************************************************************
qgslabelattributes.h - render vector labels
-------------------
begin : August 2004
copyright : (C) 2004 by Radim Blazek
email : blazek@itc.it
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#ifndef QGSLABELATTRIBUTES_H
#define QGSLABELATTRIBUTES_H
#include <QBrush>
#include <QFont>
#include <QPen>
class QString;
class QColor;
/** \ingroup core
* A class to store attributes needed for label rendering.
*
* Label attributes:
* border (color, width, style)
* /
* / text bounding box
* / /
* +-----------/--+ buffer (color, pattern)
* | / | /
* | +----+ |/ --+
* | |Text| / |--- text size
* | +----+ /| --+
* | |
* +--------------+
* | | |
* | >|----|<--- buffer width
* |
* >|<--- border width
*
* Text:
* - font family
* - size type (map units, points)
* - size (in points - device independent)
* - bold
* - italic
* - underline
* - color
*
* Position:
* - (coordinates)
* - offset type (map units, points)
* - x offset, y offset (measured in text coordinate system, not in map coordinate system)
* - angle
* - alignment (from a point calculated by angle and offset)
*
* Buffer:
* - buffer size type (map units, points)
* - buffer size
* - buffer color
* - buffer brush
*
* Border:
* - border width
* - border color
* - border style
*
* Each attribute is either set or unset.
*/
class CORE_EXPORT QgsLabelAttributes
{
public:
/** Constructor.
* @param def if true, defaults are set, if false all all attributes are unset
*/
QgsLabelAttributes( bool def = true );
~QgsLabelAttributes();
/* Units type */
enum Units
{
MapUnits = 0,
PointUnits
};
static QString unitsName( int units );
static int unitsCode( const QString &name );
static QString alignmentName( int alignment );
static int alignmentCode( const QString &name );
/* Text */
void setText( const QString & text );
bool textIsSet( void ) const;
const QString text( void ) const;
/* Font */
void setFamily( const QString & family );
bool familyIsSet( void ) const;
const QString family( void ) const;
void setBold( bool enable );
bool boldIsSet( void ) const;
bool bold( void ) const;
void setItalic( bool enable );
bool italicIsSet( void ) const;
bool italic( void ) const;
void setUnderline( bool enable );
bool underlineIsSet( void ) const;
bool underline( void ) const;
void setSize( double size, int type );
bool sizeIsSet( void ) const;
int sizeType( void ) const;
double size( void ) const;
void setColor( const QColor &color );
bool colorIsSet( void ) const;
const QColor & color( void ) const;
/* Offset */
void setOffset( double x, double y, int type );
bool offsetIsSet( void ) const;
int offsetType( void ) const;
double xOffset( void ) const;
double yOffset( void ) const;
/* Angle */
void setAngle( double angle );
bool angleIsSet( void ) const;
double angle( void ) const;
bool angleIsAuto( void ) const;
void setAutoAngle( bool state );
/* Alignment */
void setAlignment( int alignment );
bool alignmentIsSet( void ) const;
int alignment( void ) const;
/* Buffer */
bool bufferEnabled() const;
void setBufferEnabled( bool useBufferFlag );
void setBufferSize( double size, int type );
bool bufferSizeIsSet( void ) const;
int bufferSizeType( void ) const;
double bufferSize( void ) const;
void setBufferColor( const QColor &color );
bool bufferColorIsSet( void ) const;
QColor bufferColor( void ) const;
void setBufferStyle( Qt::BrushStyle style );
bool bufferStyleIsSet( void ) const;
Qt::BrushStyle bufferStyle( void ) const;
/* Border */
void setBorderColor( const QColor &color );
bool borderColorIsSet( void ) const;
QColor borderColor( void ) const;
void setBorderWidth( int width );
bool borderWidthIsSet( void ) const;
int borderWidth( void ) const;
void setBorderStyle( Qt::PenStyle style );
bool borderStyleIsSet( void ) const;
Qt::PenStyle borderStyle( void ) const;
bool multilineEnabled() const;
void setMultilineEnabled( bool useMultiline );
protected:
/* Text */
QString mText;
bool mTextIsSet;
/** Font (family, weight, italic, underline) */
QFont mFont;
bool mFamilyIsSet;
bool mBoldIsSet;
bool mItalicIsSet;
bool mUnderlineIsSet;
/** Font size, size type */
int mSizeType;
double mSize;
bool mSizeIsSet;
/** Color */
QColor mColor;
bool mColorIsSet;
/** Offset */
int mOffsetType;
double mXOffset;
double mYOffset;
bool mOffsetIsSet;
/** Angle (degrees) */
double mAngle;
bool mAngleIsSet;
bool mAngleIsAuto;
/** Alignment */
int mAlignment;
bool mAlignmentIsSet;
/** Buffer enablement */
bool mBufferEnabledFlag;
/** Buffer size, size type */
int mBufferSizeType;
double mBufferSize;
bool mBufferSizeIsSet;
/** Buffer brush (color, style) */
QBrush mBufferBrush;
bool mBufferColorIsSet;
bool mBufferStyleIsSet;
/** Border pen (color, width, style) */
QPen mBorderPen;
bool mBorderColorIsSet;
bool mBorderWidthIsSet;
bool mBorderStyleIsSet;
/** Multiline enablement */
bool mMultilineEnabledFlag;
};
#endif
|