~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to src/gui/qgscontinuouscolorrenderer.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
                         qgscontinuouscolorrenderer.h  -  description
 
3
                             -------------------
 
4
    begin                : Nov 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: qgscontinuouscolorrenderer.h 5823 2006-09-13 04:46:36Z g_j_m $ */
 
18
#ifndef QGSCONTINUOUSCOLORRENDERER_H
 
19
#define QGSCONTINUOUSCOLORRENDERER_H
 
20
 
 
21
#include "qgsrenderer.h"
 
22
#include "qgsmaptopixel.h"
 
23
#include "qgspoint.h"
 
24
#include "qgsfeature.h"
 
25
 
 
26
class QgsSymbol;
 
27
class QPainter;
 
28
class QPixmap;
 
29
 
 
30
/**Renderer class which interpolates rgb values linear between the minimum and maximum value of the classification field*/
 
31
class QgsContinuousColorRenderer: public QgsRenderer
 
32
{
 
33
 public:
 
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;
 
63
    /** Returns true*/
 
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*/
 
68
    QString name() const;
 
69
    /**Return symbology items*/
 
70
    const std::list<QgsSymbol*> symbols() const;
 
71
    QgsRenderer* clone() const;
 
72
 protected:
 
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;
 
81
};
 
82
 
 
83
inline int QgsContinuousColorRenderer::classificationField() const
 
84
{
 
85
    return mClassificationField;
 
86
}
 
87
 
 
88
inline void QgsContinuousColorRenderer::setClassificationField(int id)
 
89
{
 
90
    mClassificationField=id;
 
91
}
 
92
 
 
93
inline const QgsSymbol* QgsContinuousColorRenderer::minimumSymbol() const
 
94
{
 
95
    return mMinimumSymbol;
 
96
}
 
97
 
 
98
inline const QgsSymbol* QgsContinuousColorRenderer::maximumSymbol() const
 
99
{
 
100
    return mMaximumSymbol;
 
101
}
 
102
 
 
103
inline bool QgsContinuousColorRenderer::needsAttributes() const
 
104
{
 
105
  return true;
 
106
}
 
107
 
 
108
 
 
109
#endif