QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 : [email protected]
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 
84  /* Units type */
85  enum Units
86  {
87  MapUnits = 0,
88  PointUnits
89  };
90 
91  static QString unitsName( int units );
92  static int unitsCode( const QString &name );
93 
94  static QString alignmentName( int alignment );
95  static int alignmentCode( const QString &name );
96 
97  /* Text */
98  void setText( const QString & text );
99  bool textIsSet() const;
100  const QString text() const;
101 
102  /* Font */
103  void setFamily( const QString & family );
104  bool familyIsSet() const;
105  const QString family() const;
106 
107  void setBold( bool enable );
108  bool boldIsSet() const;
109  bool bold() const;
110 
111  void setItalic( bool enable );
112  bool italicIsSet() const;
113  bool italic() const;
114 
115  void setUnderline( bool enable );
116  bool underlineIsSet() const;
117  bool underline() const;
118 
119  void setStrikeOut( bool enable );
120  bool strikeOutIsSet() const;
121  bool strikeOut() const;
122 
123  void setSize( double size, int type );
124  bool sizeIsSet() const;
125  int sizeType() const;
126  double size() const;
127 
128  void setColor( const QColor &color );
129  bool colorIsSet() const;
130  const QColor & color() const;
131 
132  /* Offset */
133  void setOffset( double x, double y, int type );
134  bool offsetIsSet() const;
135  int offsetType() const;
136  double xOffset() const;
137  double yOffset() const;
138 
139  /* Angle */
140  void setAngle( double angle );
141  bool angleIsSet() const;
142  double angle() const;
143 
144  bool angleIsAuto() const;
145  void setAutoAngle( bool state );
146 
147  /* Alignment */
148  void setAlignment( int alignment );
149  bool alignmentIsSet() const;
150  int alignment() const;
151 
152  /* Buffer */
153  bool bufferEnabled() const;
154  void setBufferEnabled( bool useBufferFlag );
155  void setBufferSize( double size, int type );
156  bool bufferSizeIsSet() const;
157  int bufferSizeType() const;
158  double bufferSize() const;
159 
160  void setBufferColor( const QColor &color );
161  bool bufferColorIsSet() const;
162  QColor bufferColor() const;
163 
164  void setBufferStyle( Qt::BrushStyle style );
165  bool bufferStyleIsSet() const;
166  Qt::BrushStyle bufferStyle() const;
167 
168  /* Border */
169  void setBorderColor( const QColor &color );
170  bool borderColorIsSet() const;
171  QColor borderColor() const;
172 
173  void setBorderWidth( int width );
174  bool borderWidthIsSet() const;
175  int borderWidth() const;
176 
177  void setBorderStyle( Qt::PenStyle style );
178  bool borderStyleIsSet() const;
179  Qt::PenStyle borderStyle() const;
180 
181  bool multilineEnabled() const;
182  void setMultilineEnabled( bool useMultiline );
183 
184  /* label only selected features */
185  bool selectedOnly() const;
186  void setSelectedOnly( bool selectedonly );
187 
188  protected:
189  /* Text */
192 
200 
203  double mSize;
205 
209 
212  double mXOffset;
213  double mYOffset;
215 
217  double mAngle;
220 
224 
229  double mBufferSize;
231 
236 
242 
245 
248 };
249 
250 #endif
bool mSelectedOnly
Label only selected.
int mAlignment
Alignment.
QBrush mBufferBrush
Buffer brush (color, style)
int mSizeType
Font size, size type.
double mAngle
Angle (degrees)
bool mBufferEnabledFlag
Buffer enablement.
bool mMultilineEnabledFlag
Multiline enablement.
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)
QFont mFont
Font (family, weight, italic, underline, strikeout)
QPen mBorderPen
Border pen (color, width, style)
int mBufferSizeType
Buffer size, size type.
A class to store attributes needed for label rendering.