1
/***************************************************************************
2
qgscontinuouscolorrenderer.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: qgscontinuouscolorrenderer.h 5823 2006-09-13 04:46:36Z g_j_m $ */
18
#ifndef QGSCONTINUOUSCOLORRENDERER_H
19
#define QGSCONTINUOUSCOLORRENDERER_H
21
#include "qgsrenderer.h"
22
#include "qgsmaptopixel.h"
24
#include "qgsfeature.h"
30
/**Renderer class which interpolates rgb values linear between the minimum and maximum value of the classification field*/
31
class QgsContinuousColorRenderer: public QgsRenderer
34
QgsContinuousColorRenderer(QGis::VectorType type);
35
QgsContinuousColorRenderer(const QgsContinuousColorRenderer& other);
36
QgsContinuousColorRenderer& operator=(const QgsContinuousColorRenderer& other);
37
virtual ~QgsContinuousColorRenderer();
38
/**Renders the feature using the minimum and maximum value of the classification field*/
39
void renderFeature(QPainter* p, QgsFeature* f, QPixmap* pic, double* scalefactor, bool selected, double widthScale = 1.);
40
/**Returns the number of the classification field*/
41
int classificationField() const;
42
/**Sets the id of the classification field*/
43
void setClassificationField(int id);
44
/**Sets the symbol for the minimum value. The symbol has to be created using the new operator and is automatically deleted when inserting a new symbol or when the instance is destroyed*/
45
void setMinimumSymbol(QgsSymbol* sy);
46
/**Sets the symbol for the maximum value. The symbol has to be created using the new operator and is automatically deleted when inserting a new symbol or when the instance is destroyed*/
47
void setMaximumSymbol(QgsSymbol* sy);
48
/** Sets whether to draw the polygon outline*/
49
void setDrawPolygonOutline(bool draw) { mDrawPolygonOutline = draw;}
50
/**Returns the symbol for the minimum value*/
51
const QgsSymbol* minimumSymbol() const;
52
/**Returns the symbol for the maximum value*/
53
const QgsSymbol* maximumSymbol() const;
54
/** whether to draw a polygon outline*/
55
bool drawPolygonOutline() const { return mDrawPolygonOutline; }
56
/**Reads the renderer configuration from an XML file
57
@param rnode the DOM node to read
58
@param vl the vector layer which will be associated with the renderer*/
59
virtual void readXML(const QDomNode& rnode, QgsVectorLayer& vl);
60
/**Writes the contents of the renderer to a configuration file
61
@ return true in case of success*/
62
virtual bool writeXML( QDomNode & layer_node, QDomDocument & document ) const;
64
bool needsAttributes() const;
65
/**Returns a list with the index of the classification attribute*/
66
std::list<int> classificationAttributes() const;
67
/**Returns the renderers name*/
69
/**Return symbology items*/
70
const std::list<QgsSymbol*> symbols() const;
71
QgsRenderer* clone() const;
73
/**Number of the classification field (it must be a numerical field)*/
74
int mClassificationField;
75
/**Item for the minimum value*/
76
QgsSymbol* mMinimumSymbol;
77
/**Item for the maximum value*/
78
QgsSymbol* mMaximumSymbol;
79
/** Whether to draw the polygon outline or not */
80
bool mDrawPolygonOutline;
83
inline int QgsContinuousColorRenderer::classificationField() const
85
return mClassificationField;
88
inline void QgsContinuousColorRenderer::setClassificationField(int id)
90
mClassificationField=id;
93
inline const QgsSymbol* QgsContinuousColorRenderer::minimumSymbol() const
95
return mMinimumSymbol;
98
inline const QgsSymbol* QgsContinuousColorRenderer::maximumSymbol() const
100
return mMaximumSymbol;
103
inline bool QgsContinuousColorRenderer::needsAttributes() const