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

« back to all changes in this revision

Viewing changes to src/qgslabel.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
 
                         qgslabel.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: qgslabel.h,v 1.9.2.1 2005/06/03 09:42:55 g_j_m Exp $ */
17
 
#ifndef QGSLABEL_H
18
 
#define QGSLABEL_H
19
 
 
20
 
#include <vector>
21
 
#include <list>
22
 
#include <qdom.h>
23
 
 
24
 
class QString;
25
 
class QWidget;
26
 
class QPainter;
27
 
class QPaintDevice;
28
 
 
29
 
class QgsPoint;
30
 
class QgsFeature;
31
 
class QgsField;
32
 
class QgsMapCanvas;
33
 
class QgsLabelAttributes;
34
 
class QgsRect;
35
 
class QgsMapToPixel;
36
 
class QgsCoordinateTransform;
37
 
 
38
 
/** Render class to display labels */
39
 
class QgsLabel
40
 
{
41
 
public:
42
 
    QgsLabel ( std::vector<QgsField> const & fields  );
43
 
 
44
 
    ~QgsLabel();
45
 
 
46
 
    /* Fields */
47
 
    enum LabelField {
48
 
        Text = 0,
49
 
        Family,
50
 
        Size,
51
 
        Bold,
52
 
        Italic,
53
 
        Underline,
54
 
        Color,
55
 
        XCoordinate,
56
 
        YCoordinate,
57
 
        XOffset,
58
 
        YOffset,
59
 
        Angle,
60
 
        Alignment,
61
 
        BufferEnabled,
62
 
        BufferSize,
63
 
        BufferColor,
64
 
        BufferBrush,
65
 
        BorderWidth,
66
 
        BorderColor,
67
 
        BorderStyle,
68
 
        LabelFieldCount
69
 
    };
70
 
 
71
 
    void dialog( QWidget * parent = 0 );
72
 
 
73
 
    /** \brief render label
74
 
     *  \param sizeScale global scale factor for size in pixels, labels in map units are not scaled
75
 
     */
76
 
    void renderLabel ( QPainter* painter, QgsRect* viewExtent, 
77
 
                       const QgsCoordinateTransform& coordTransform,
78
 
                       bool doCoordTransform,
79
 
                       QgsMapToPixel *transform, QPaintDevice *device,
80
 
                       QgsFeature *feature, bool selected, QgsLabelAttributes *classAttributes=0, double sizeScale = 1.);
81
 
    
82
 
    /** Reads the renderer configuration from an XML file
83
 
     @param rnode the DOM node to read 
84
 
    */
85
 
    void readXML(const QDomNode& node);
86
 
 
87
 
    /** Writes the contents of the renderer to a configuration file */
88
 
    void writeXML(std::ostream& xml);
89
 
 
90
 
    //! add vector of required fields to existing list of fields
91
 
    void addRequiredFields ( std::list<int> *fields );
92
 
 
93
 
    //! Available vector fields
94
 
    std::vector<QgsField> & QgsLabel::fields ( void );
95
 
 
96
 
    //! Pointer to default attributes
97
 
    QgsLabelAttributes *layerAttributes ( void );
98
 
 
99
 
    //! Set label field
100
 
    void setLabelField ( int attr, const QString str );
101
 
 
102
 
    //! label field
103
 
    QString labelField ( int attr );
104
 
 
105
 
    /** Get field value if : 1) field name is not empty
106
 
     *                       2) field exists
107
 
     *                       3) value is defined
108
 
     *  otherwise returns empty string
109
 
    */
110
 
    QString fieldValue ( int attr, QgsFeature *feature );
111
 
 
112
 
private:
113
 
    /** Get label point for simple feature in map units */
114
 
    QgsPoint labelPoint ( QgsFeature *feature );
115
 
    
116
 
    /** Color to draw selected features */
117
 
    QColor mSelectionColor;
118
 
    
119
 
    //! Default layer attributes
120
 
    QgsLabelAttributes *mLabelAttributes;
121
 
    
122
 
    //! Available layer fields
123
 
    std::vector<QgsField> mField;
124
 
 
125
 
    //! Label fields
126
 
    std::vector<QString> mLabelField;
127
 
 
128
 
    //! Label field indexes
129
 
    std::vector<int> mLabelFieldIdx;
130
 
};
131
 
 
132
 
#endif