~ubuntu-branches/ubuntu/hardy/qgis/hardy

« back to all changes in this revision

Viewing changes to src/qgslabelattributes.h

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
/* $Id: qgslabelattributes.h,v 1.5 2004/11/30 01:32:44 mcoletti Exp $ */
17
 
#ifndef QGSLABELATTRIBUTES_H
18
 
#define QGSLABELATTRIBUTES_H
19
 
 
20
 
#include <qnamespace.h>
21
 
#include <qpen.h>
22
 
class QString;
23
 
class QFont;
24
 
class QColor;
25
 
class QPen;
26
 
class QBrush;
27
 
 
28
 
/** This class can be used to store attributes needed for label rendering. 
29
 
 *
30
 
 *  Label attributes:
31
 
 *                         border (color, width, style)
32
 
 *                        /
33
 
 *                       /     text bounding box
34
 
 *                      /     /
35
 
 *               +-----------/--+  buffer (color, pattern)                
36
 
 *               |          /   | /                                       
37
 
 *               |    +----+    |/  --+                                   
38
 
 *               |    |Text|    /     |--- text size                      
39
 
 *               |    +----+   /|   --+
40
 
 *               |              |
41
 
 *               +--------------+
42
 
 *               |         |    |  
43
 
 *               |        >|----|<--- buffer width
44
 
 *               |
45
 
 *              >|<--- border width 
46
 
 *
47
 
 *   Text:            
48
 
 *   - font family
49
 
 *   - size type (map units, points)
50
 
 *   - size (in points - device independent)
51
 
 *   - bold
52
 
 *   - italic
53
 
 *   - underline
54
 
 *   - color
55
 
 *
56
 
 *   Position:
57
 
 *   - (coordinates)
58
 
 *   - offset type (map units, points)
59
 
 *   - x offset, y offset (measured in text coordinate system, not in map coordinate system)
60
 
 *   - angle
61
 
 *   - alignment (from a point calculated by angle and offset)
62
 
 *   
63
 
 *   Buffer:
64
 
 *   - buffer size type (map units, points)
65
 
 *   - buffer size
66
 
 *   - buffer color
67
 
 *   - buffer brush
68
 
 *
69
 
 *   Border:
70
 
 *   - border width
71
 
 *   - border color
72
 
 *   - border style
73
 
 *
74
 
 *   Each attribute is either se or unset.
75
 
 */
76
 
 
77
 
class QgsLabelAttributes
78
 
{
79
 
public:
80
 
    /** Constructor.
81
 
     *  @param def if true, defaults are set, if false all all attributes are unset
82
 
     */
83
 
    QgsLabelAttributes ( bool def = true );
84
 
 
85
 
    ~QgsLabelAttributes();
86
 
 
87
 
    /* Units type */
88
 
    enum Units { 
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 ( void ) const;
102
 
    const QString text ( void ) const;
103
 
 
104
 
    /* Font */
105
 
    void setFamily ( const QString & family );
106
 
    bool familyIsSet ( void ) const;
107
 
    const QString family ( void ) const;
108
 
 
109
 
    void setBold ( bool enable );
110
 
    bool boldIsSet ( void ) const;
111
 
    bool bold ( void ) const;
112
 
 
113
 
    void setItalic ( bool enable );
114
 
    bool italicIsSet ( void ) const;
115
 
    bool italic ( void ) const;
116
 
 
117
 
    void setUnderline ( bool enable );
118
 
    bool underlineIsSet ( void ) const;
119
 
    bool underline ( void ) const; 
120
 
    
121
 
    void   setSize ( double size, int type );
122
 
    bool   sizeIsSet ( void ) const;
123
 
    int    sizeType ( void ) const;
124
 
    double size ( void ) const;
125
 
 
126
 
    void  setColor ( const QColor &color );
127
 
    bool  colorIsSet ( void ) const;
128
 
    const QColor & color ( void ) const;
129
 
 
130
 
    /* Offset */
131
 
    void   setOffset ( double x, double y, int type );
132
 
    bool   offsetIsSet ( void ) const;
133
 
    int    offsetType ( void ) const;
134
 
    double xOffset ( void ) const;
135
 
    double yOffset ( void ) const;
136
 
 
137
 
    /* Angle */
138
 
    void   setAngle ( double angle );
139
 
    bool   angleIsSet ( void ) const;
140
 
    double angle ( void ) const;
141
 
 
142
 
    /* Alignment */
143
 
    void setAlignment ( int alignment );
144
 
    bool alignmentIsSet ( void ) const;
145
 
    int  alignment ( void ) const;
146
 
 
147
 
    /* Buffer */
148
 
    bool   bufferEnabled() const;
149
 
    void   setBufferEnabled(bool useBufferFlag);
150
 
    void   setBufferSize ( double size, int type );
151
 
    bool   bufferSizeIsSet ( void ) const;
152
 
    int    bufferSizeType ( void ) const;
153
 
    double bufferSize ( void ) const;
154
 
 
155
 
    void  setBufferColor ( const QColor &color );
156
 
    bool  bufferColorIsSet ( void ) const;
157
 
    const QColor & bufferColor ( void ) const;
158
 
 
159
 
    void  setBufferStyle ( Qt::BrushStyle style );
160
 
    bool  bufferStyleIsSet ( void ) const;
161
 
    Qt::BrushStyle bufferStyle ( void ) const;
162
 
 
163
 
    /* Border */
164
 
    void  setBorderColor ( const QColor &color );
165
 
    bool  borderColorIsSet ( void ) const;
166
 
    const QColor & borderColor ( void ) const;
167
 
 
168
 
    void  setBorderWidth ( int width );
169
 
    bool  borderWidthIsSet ( void ) const;
170
 
    int   borderWidth ( void ) const;
171
 
    
172
 
    void  setBorderStyle ( Qt::PenStyle style );
173
 
    bool  borderStyleIsSet ( void ) const;
174
 
    Qt::PenStyle   borderStyle ( void ) const;
175
 
    
176
 
 protected:
177
 
    /* Text */
178
 
    QString mText;
179
 
    bool mTextIsSet;
180
 
 
181
 
    /** Font (family, weight, italic, underline) */
182
 
    QFont mFont;
183
 
    bool mFamilyIsSet;
184
 
    bool mBoldIsSet;
185
 
    bool mItalicIsSet;
186
 
    bool mUnderlineIsSet;
187
 
 
188
 
    /** Font size, size type */
189
 
    int  mSizeType;
190
 
    double mSize;
191
 
    bool   mSizeIsSet;
192
 
 
193
 
    /** Color */
194
 
    QColor mColor;
195
 
    bool   mColorIsSet;
196
 
 
197
 
    /** Offset */
198
 
    int    mOffsetType;
199
 
    double mXOffset;
200
 
    double mYOffset;
201
 
    bool   mOffsetIsSet;
202
 
 
203
 
    /** Angle (degrees) */
204
 
    double mAngle;
205
 
    bool   mAngleIsSet;
206
 
 
207
 
    /** Alignment */
208
 
    int  mAlignment;
209
 
    bool mAlignmentIsSet;            
210
 
 
211
 
    /** Buffer enablement */
212
 
    bool mBufferEnabledFlag;
213
 
    /** Buffer size, size type */
214
 
    int    mBufferSizeType;
215
 
    double mBufferSize;
216
 
    bool   mBufferSizeIsSet;
217
 
    
218
 
    /** Buffer brush (color, style) */
219
 
    QBrush mBufferBrush;
220
 
    bool   mBufferColorIsSet;
221
 
    bool   mBufferStyleIsSet;
222
 
 
223
 
    /** Border pen (color, width, style) */
224
 
    QPen mBorderPen;
225
 
    bool mBorderColorIsSet;
226
 
    bool mBorderWidthIsSet;
227
 
    bool mBorderStyleIsSet;
228
 
};
229
 
 
230
 
#endif