~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/core/renderer/qgsgraduatedsymbolrenderer.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                         qgsgraduatedsymbolrenderer.h  -  description
 
3
                             -------------------
 
4
    begin                : Oct 2003
 
5
    copyright            : (C) 2003 by Marco Hugentobler
 
6
    email                : mhugent@geo.unizh.ch
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
/* $Id: qgsgraduatedsymbolrenderer.h 5371 2006-04-25 01:52:13Z wonder $ */
 
18
 
 
19
#ifndef QGSGRADUATEDSYMBOLRENDERER_H
 
20
#define QGSGRADUATEDSYMBOLRENDERER_H
 
21
 
 
22
#include "qgsrenderer.h"
 
23
 
 
24
class QgsVectorLayer;
 
25
 
 
26
/**This class contains the information for graduate symbol rendering*/
 
27
class CORE_EXPORT QgsGraduatedSymbolRenderer: public QgsRenderer
 
28
{
 
29
  public:
 
30
    enum Mode
 
31
    {
 
32
      EqualInterval,
 
33
      Quantile,
 
34
      Empty
 
35
    };
 
36
    QgsGraduatedSymbolRenderer( QGis::GeometryType type, Mode theMode = EqualInterval );
 
37
    QgsGraduatedSymbolRenderer( const QgsGraduatedSymbolRenderer& other );
 
38
    QgsGraduatedSymbolRenderer& operator=( const QgsGraduatedSymbolRenderer& other );
 
39
    virtual ~QgsGraduatedSymbolRenderer();
 
40
 
 
41
    /** Get the mode - which is only really used to be able to reinstate
 
42
     * the graduated dialog properties properly, so we
 
43
     * don't do anything else besides accessors and mutators in
 
44
     * this class.
 
45
     */
 
46
    Mode mode() const;
 
47
 
 
48
    /** Set the mode - which is only really used to be able to reinstate
 
49
     * the graduated dialog properties properly, so we
 
50
     * don't do anything else besides accessors and mutators in
 
51
     * this class.
 
52
     */
 
53
    void setMode( Mode theMode );
 
54
 
 
55
    /**Adds a new item
 
56
    \param sy a pointer to the QgsSymbol to be inserted. It has to be created using the new operator and is automatically destroyed when 'removeItems' is called or when this object is destroyed*/
 
57
    void addSymbol( QgsSymbol* sy );
 
58
 
 
59
    /**Returns the indes of the classification field*/
 
60
    int classificationField() const;
 
61
 
 
62
    /**Removes all symbols*/
 
63
    void removeSymbols();
 
64
 
 
65
    /** Determines if a feature will be rendered or not
 
66
    @param f a pointer to the feature to determine if rendering will happen*/
 
67
    virtual bool willRenderFeature( QgsFeature *f );
 
68
 
 
69
    /**Renders a feature
 
70
     \param p a painter (usually the one from the current map canvas)
 
71
     \param f a pointer to a feature to render
 
72
     \param t the transform object containing the information how to transform the map coordinates to screen coordinates
 
73
     \note added in 1.2 */
 
74
    void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* img, bool selected, double opacity = 1.0 );
 
75
 
 
76
    /**Sets the classicifation field by index
 
77
    \param field the number of the field to classify*/
 
78
    void setClassificationField( int );
 
79
 
 
80
    /**Reads the renderer configuration from an XML file
 
81
     @param rnode the Dom node to read
 
82
     @param vl the vector layer which will be associated with the renderer
 
83
     @return 0 in case of success, 1 if vector layer has no renderer, 2 if classification field not found
 
84
    */
 
85
    virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl );
 
86
 
 
87
    /**Writes the contents of the renderer to a configuration file
 
88
     @ return true in case of success*/
 
89
    virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const;
 
90
 
 
91
    /** Returns true*/
 
92
    bool needsAttributes() const;
 
93
 
 
94
    /**Returns a list of all needed attributes*/
 
95
    QgsAttributeList classificationAttributes() const;
 
96
 
 
97
    void updateSymbolAttributes();
 
98
 
 
99
    /**Returns the renderers name*/
 
100
    QString name() const;
 
101
 
 
102
    /**Returns the symbols of the items*/
 
103
    const QList<QgsSymbol*> symbols() const;
 
104
 
 
105
    /**Returns a copy of the renderer (a deep copy on the heap)*/
 
106
    QgsRenderer* clone() const;
 
107
 
 
108
  protected:
 
109
    /** The graduation mode */
 
110
    Mode mMode;
 
111
 
 
112
    /**Index of the classification field (it must be a numerical field)*/
 
113
    int mClassificationField;
 
114
 
 
115
    /**List holding the symbols for the individual classes*/
 
116
    QList<QgsSymbol*> mSymbols;
 
117
 
 
118
    QgsSymbol *symbolForFeature( const QgsFeature* f );
 
119
 
 
120
    /**Cached copy of all underlying symbols required attribute fields*/
 
121
    QgsAttributeList mSymbolAttributes;
 
122
 
 
123
 
 
124
};
 
125
 
 
126
inline void QgsGraduatedSymbolRenderer::addSymbol( QgsSymbol* sy )
 
127
{
 
128
  mSymbols.push_back( sy );
 
129
}
 
130
 
 
131
inline int QgsGraduatedSymbolRenderer::classificationField() const
 
132
{
 
133
  return mClassificationField;
 
134
}
 
135
 
 
136
inline void QgsGraduatedSymbolRenderer::setClassificationField( int index )
 
137
{
 
138
  mClassificationField = index;
 
139
}
 
140
 
 
141
inline bool QgsGraduatedSymbolRenderer::needsAttributes() const
 
142
{
 
143
  return true;
 
144
}
 
145
 
 
146
 
 
147
#endif