1
/***************************************************************************
2
qgsgraduatedsymbolrenderer.h - description
5
copyright : (C) 2003 by Marco Hugentobler
6
email : mhugent@geo.unizh.ch
7
***************************************************************************/
9
/***************************************************************************
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. *
16
***************************************************************************/
17
/* $Id: qgsgraduatedsymbolrenderer.h 5371 2006-04-25 01:52:13Z wonder $ */
19
#ifndef QGSGRADUATEDSYMBOLRENDERER_H
20
#define QGSGRADUATEDSYMBOLRENDERER_H
22
#include "qgsrenderer.h"
26
/**This class contains the information for graduate symbol rendering*/
27
class CORE_EXPORT QgsGraduatedSymbolRenderer: public QgsRenderer
36
QgsGraduatedSymbolRenderer( QGis::GeometryType type, Mode theMode = EqualInterval );
37
QgsGraduatedSymbolRenderer( const QgsGraduatedSymbolRenderer& other );
38
QgsGraduatedSymbolRenderer& operator=( const QgsGraduatedSymbolRenderer& other );
39
virtual ~QgsGraduatedSymbolRenderer();
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
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
53
void setMode( Mode theMode );
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 );
59
/**Returns the indes of the classification field*/
60
int classificationField() const;
62
/**Removes all symbols*/
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 );
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
74
void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* img, bool selected, double opacity = 1.0 );
76
/**Sets the classicifation field by index
77
\param field the number of the field to classify*/
78
void setClassificationField( int );
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
85
virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl );
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;
92
bool needsAttributes() const;
94
/**Returns a list of all needed attributes*/
95
QgsAttributeList classificationAttributes() const;
97
void updateSymbolAttributes();
99
/**Returns the renderers name*/
100
QString name() const;
102
/**Returns the symbols of the items*/
103
const QList<QgsSymbol*> symbols() const;
105
/**Returns a copy of the renderer (a deep copy on the heap)*/
106
QgsRenderer* clone() const;
109
/** The graduation mode */
112
/**Index of the classification field (it must be a numerical field)*/
113
int mClassificationField;
115
/**List holding the symbols for the individual classes*/
116
QList<QgsSymbol*> mSymbols;
118
QgsSymbol *symbolForFeature( const QgsFeature* f );
120
/**Cached copy of all underlying symbols required attribute fields*/
121
QgsAttributeList mSymbolAttributes;
126
inline void QgsGraduatedSymbolRenderer::addSymbol( QgsSymbol* sy )
128
mSymbols.push_back( sy );
131
inline int QgsGraduatedSymbolRenderer::classificationField() const
133
return mClassificationField;
136
inline void QgsGraduatedSymbolRenderer::setClassificationField( int index )
138
mClassificationField = index;
141
inline bool QgsGraduatedSymbolRenderer::needsAttributes() const