QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgslabelattributes.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslabelattributes.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 QGSLABELATTRIBUTES_H
17 #define QGSLABELATTRIBUTES_H
18 
19 #include <QBrush>
20 #include <QFont>
21 #include <QPen>
22 
23 class QString;
24 class QColor;
25 
76 class CORE_EXPORT QgsLabelAttributes
77 {
78  public:
82  QgsLabelAttributes( bool def = true );
83 
85 
86  /* Units type */
87  enum Units
88  {
89  MapUnits = 0,
90  PointUnits
91  };
92 
93  static QString unitsName( int units );
94  static int unitsCode( const QString &name );
95 
96  static QString alignmentName( int alignment );
97  static int alignmentCode( const QString &name );
98 
99  /* Text */
100  void setText( const QString & text );
101  bool textIsSet() const;
102  const QString text() const;
103 
104  /* Font */
105  void setFamily( const QString & family );
106  bool familyIsSet() const;
107  const QString family() const;
108 
109  void setBold( bool enable );
110  bool boldIsSet() const;
111  bool bold() const;
112 
113  void setItalic( bool enable );
114  bool italicIsSet() const;
115  bool italic() const;
116 
117  void setUnderline( bool enable );
118  bool underlineIsSet() const;
119  bool underline() const;
120 
121  /* strikeout added in 1.5 */
122  void setStrikeOut( bool enable );
123  bool strikeOutIsSet() const;
124  bool strikeOut() const;
125 
126  void setSize( double size, int type );
127  bool sizeIsSet() const;
128  int sizeType() const;
129  double size() const;
130 
131  void setColor( const QColor &color );
132  bool colorIsSet() const;
133  const QColor & color() const;
134 
135  /* Offset */
136  void setOffset( double x, double y, int type );
137  bool offsetIsSet() const;
138  int offsetType() const;
139  double xOffset() const;
140  double yOffset() const;
141 
142  /* Angle */
143  void setAngle( double angle );
144  bool angleIsSet() const;
145  double angle() const;
146 
147  bool angleIsAuto() const;
148  void setAutoAngle( bool state );
149 
150  /* Alignment */
151  void setAlignment( int alignment );
152  bool alignmentIsSet() const;
153  int alignment() const;
154 
155  /* Buffer */
156  bool bufferEnabled() const;
157  void setBufferEnabled( bool useBufferFlag );
158  void setBufferSize( double size, int type );
159  bool bufferSizeIsSet() const;
160  int bufferSizeType() const;
161  double bufferSize() const;
162 
163  void setBufferColor( const QColor &color );
164  bool bufferColorIsSet() const;
165  QColor bufferColor() const;
166 
167  void setBufferStyle( Qt::BrushStyle style );
168  bool bufferStyleIsSet() const;
169  Qt::BrushStyle bufferStyle() const;
170 
171  /* Border */
172  void setBorderColor( const QColor &color );
173  bool borderColorIsSet() const;
174  QColor borderColor() const;
175 
176  void setBorderWidth( int width );
177  bool borderWidthIsSet() const;
178  int borderWidth() const;
179 
180  void setBorderStyle( Qt::PenStyle style );
181  bool borderStyleIsSet() const;
182  Qt::PenStyle borderStyle() const;
183 
184  bool multilineEnabled() const;
185  void setMultilineEnabled( bool useMultiline );
186 
187  /* label only selected features
188  * added in 1.5
189  */
190  bool selectedOnly() const;
191  void setSelectedOnly( bool selectedonly );
192 
193  protected:
194  /* Text */
195  QString mText;
197 
199  QFont mFont;
205 
208  double mSize;
210 
212  QColor mColor;
214 
217  double mXOffset;
218  double mYOffset;
220 
222  double mAngle;
225 
229 
234  double mBufferSize;
236 
238  QBrush mBufferBrush;
241 
247 
250 
253 };
254 
255 #endif
bool mSelectedOnly
Label only selected.
Definition: qgslabelattributes.h:252
QColor mColor
Color.
Definition: qgslabelattributes.h:212
int mOffsetType
Offset.
Definition: qgslabelattributes.h:216
bool mBoldIsSet
Definition: qgslabelattributes.h:201
int mAlignment
Alignment.
Definition: qgslabelattributes.h:227
QBrush mBufferBrush
Buffer brush (color, style)
Definition: qgslabelattributes.h:238
bool mOffsetIsSet
Definition: qgslabelattributes.h:219
double mSize
Definition: qgslabelattributes.h:208
QString mText
Definition: qgslabelattributes.h:195
bool mBorderColorIsSet
Definition: qgslabelattributes.h:244
int mSizeType
Font size, size type.
Definition: qgslabelattributes.h:207
bool mAlignmentIsSet
Definition: qgslabelattributes.h:228
double mYOffset
Definition: qgslabelattributes.h:218
bool mAngleIsSet
Definition: qgslabelattributes.h:223
double mAngle
Angle (degrees)
Definition: qgslabelattributes.h:222
bool mBorderStyleIsSet
Definition: qgslabelattributes.h:246
bool mUnderlineIsSet
Definition: qgslabelattributes.h:203
Units
Definition: qgslabelattributes.h:87
bool mBufferSizeIsSet
Definition: qgslabelattributes.h:235
bool mAngleIsAuto
Definition: qgslabelattributes.h:224
bool mBufferEnabledFlag
Buffer enablement.
Definition: qgslabelattributes.h:231
bool mMultilineEnabledFlag
Multiline enablement.
Definition: qgslabelattributes.h:249
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
bool mItalicIsSet
Definition: qgslabelattributes.h:202
QFont mFont
Font (family, weight, italic, underline, strikeout)
Definition: qgslabelattributes.h:199
double mBufferSize
Definition: qgslabelattributes.h:234
bool mBufferColorIsSet
Definition: qgslabelattributes.h:239
bool mTextIsSet
Definition: qgslabelattributes.h:196
bool mBorderWidthIsSet
Definition: qgslabelattributes.h:245
double mXOffset
Definition: qgslabelattributes.h:217
QPen mBorderPen
Border pen (color, width, style)
Definition: qgslabelattributes.h:243
bool mSizeIsSet
Definition: qgslabelattributes.h:209
bool mBufferStyleIsSet
Definition: qgslabelattributes.h:240
int mBufferSizeType
Buffer size, size type.
Definition: qgslabelattributes.h:233
A class to store attributes needed for label rendering.
Definition: qgslabelattributes.h:76
bool mFamilyIsSet
Definition: qgslabelattributes.h:200
double size
Definition: qgssvgcache.cpp:77
bool mColorIsSet
Definition: qgslabelattributes.h:213
bool mStrikeOutIsSet
Definition: qgslabelattributes.h:204