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  void setStrikeOut( bool enable );
122  bool strikeOutIsSet() const;
123  bool strikeOut() const;
124 
125  void setSize( double size, int type );
126  bool sizeIsSet() const;
127  int sizeType() const;
128  double size() const;
129 
130  void setColor( const QColor &color );
131  bool colorIsSet() const;
132  const QColor & color() const;
133 
134  /* Offset */
135  void setOffset( double x, double y, int type );
136  bool offsetIsSet() const;
137  int offsetType() const;
138  double xOffset() const;
139  double yOffset() const;
140 
141  /* Angle */
142  void setAngle( double angle );
143  bool angleIsSet() const;
144  double angle() const;
145 
146  bool angleIsAuto() const;
147  void setAutoAngle( bool state );
148 
149  /* Alignment */
150  void setAlignment( int alignment );
151  bool alignmentIsSet() const;
152  int alignment() const;
153 
154  /* Buffer */
155  bool bufferEnabled() const;
156  void setBufferEnabled( bool useBufferFlag );
157  void setBufferSize( double size, int type );
158  bool bufferSizeIsSet() const;
159  int bufferSizeType() const;
160  double bufferSize() const;
161 
162  void setBufferColor( const QColor &color );
163  bool bufferColorIsSet() const;
164  QColor bufferColor() const;
165 
166  void setBufferStyle( Qt::BrushStyle style );
167  bool bufferStyleIsSet() const;
168  Qt::BrushStyle bufferStyle() const;
169 
170  /* Border */
171  void setBorderColor( const QColor &color );
172  bool borderColorIsSet() const;
173  QColor borderColor() const;
174 
175  void setBorderWidth( int width );
176  bool borderWidthIsSet() const;
177  int borderWidth() const;
178 
179  void setBorderStyle( Qt::PenStyle style );
180  bool borderStyleIsSet() const;
181  Qt::PenStyle borderStyle() const;
182 
183  bool multilineEnabled() const;
184  void setMultilineEnabled( bool useMultiline );
185 
186  /* label only selected features */
187  bool selectedOnly() const;
188  void setSelectedOnly( bool selectedonly );
189 
190  protected:
191  /* Text */
192  QString mText;
194 
196  QFont mFont;
202 
205  double mSize;
207 
209  QColor mColor;
211 
214  double mXOffset;
215  double mYOffset;
217 
219  double mAngle;
222 
226 
231  double mBufferSize;
233 
235  QBrush mBufferBrush;
238 
244 
247 
250 };
251 
252 #endif
bool mSelectedOnly
Label only selected.
Definition: qgslabelattributes.h:249
QColor mColor
Color.
Definition: qgslabelattributes.h:209
int mOffsetType
Offset.
Definition: qgslabelattributes.h:213
bool mBoldIsSet
Definition: qgslabelattributes.h:198
int mAlignment
Alignment.
Definition: qgslabelattributes.h:224
QBrush mBufferBrush
Buffer brush (color, style)
Definition: qgslabelattributes.h:235
bool mOffsetIsSet
Definition: qgslabelattributes.h:216
double mSize
Definition: qgslabelattributes.h:205
QString mText
Definition: qgslabelattributes.h:192
bool mBorderColorIsSet
Definition: qgslabelattributes.h:241
int mSizeType
Font size, size type.
Definition: qgslabelattributes.h:204
bool mAlignmentIsSet
Definition: qgslabelattributes.h:225
double mYOffset
Definition: qgslabelattributes.h:215
bool mAngleIsSet
Definition: qgslabelattributes.h:220
double mAngle
Angle (degrees)
Definition: qgslabelattributes.h:219
bool mBorderStyleIsSet
Definition: qgslabelattributes.h:243
bool mUnderlineIsSet
Definition: qgslabelattributes.h:200
Units
Definition: qgslabelattributes.h:87
bool mBufferSizeIsSet
Definition: qgslabelattributes.h:232
bool mAngleIsAuto
Definition: qgslabelattributes.h:221
bool mBufferEnabledFlag
Buffer enablement.
Definition: qgslabelattributes.h:228
bool mMultilineEnabledFlag
Multiline enablement.
Definition: qgslabelattributes.h:246
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:199
QFont mFont
Font (family, weight, italic, underline, strikeout)
Definition: qgslabelattributes.h:196
double mBufferSize
Definition: qgslabelattributes.h:231
bool mBufferColorIsSet
Definition: qgslabelattributes.h:236
bool mTextIsSet
Definition: qgslabelattributes.h:193
bool mBorderWidthIsSet
Definition: qgslabelattributes.h:242
double mXOffset
Definition: qgslabelattributes.h:214
QPen mBorderPen
Border pen (color, width, style)
Definition: qgslabelattributes.h:240
bool mSizeIsSet
Definition: qgslabelattributes.h:206
bool mBufferStyleIsSet
Definition: qgslabelattributes.h:237
int mBufferSizeType
Buffer size, size type.
Definition: qgslabelattributes.h:230
A class to store attributes needed for label rendering.
Definition: qgslabelattributes.h:76
bool mFamilyIsSet
Definition: qgslabelattributes.h:197
double size
Definition: qgssvgcache.cpp:77
bool mColorIsSet
Definition: qgslabelattributes.h:210
bool mStrikeOutIsSet
Definition: qgslabelattributes.h:201