00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef QGSGRADUATEDSYMBOLRENDERER_H
00020 #define QGSGRADUATEDSYMBOLRENDERER_H
00021
00022 #include "qgsrenderer.h"
00023
00024 class QgsVectorLayer;
00025
00027 class CORE_EXPORT QgsGraduatedSymbolRenderer: public QgsRenderer
00028 {
00029 public:
00030 enum Mode
00031 {
00032 EqualInterval,
00033 Quantile,
00034 Empty
00035 };
00036 QgsGraduatedSymbolRenderer( QGis::GeometryType type, Mode theMode = EqualInterval );
00037 QgsGraduatedSymbolRenderer( const QgsGraduatedSymbolRenderer& other );
00038 QgsGraduatedSymbolRenderer& operator=( const QgsGraduatedSymbolRenderer& other );
00039 virtual ~QgsGraduatedSymbolRenderer();
00040
00046 Mode mode() const;
00047
00053 void setMode( Mode theMode );
00054
00057 void addSymbol( QgsSymbol* sy );
00058
00060 int classificationField() const;
00061
00063 void removeSymbols();
00064
00067 virtual bool willRenderFeature( QgsFeature *f );
00068
00076 void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* img, bool selected, double opacity = 1.0 );
00077
00080 void setClassificationField( int field );
00081
00087 virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl );
00088
00091 virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const;
00092
00094 bool needsAttributes() const;
00095
00097 QgsAttributeList classificationAttributes() const;
00098
00099 void updateSymbolAttributes();
00100
00102 QString name() const;
00103
00105 const QList<QgsSymbol*> symbols() const;
00106
00108 QgsRenderer* clone() const;
00109
00110 protected:
00112 Mode mMode;
00113
00115 int mClassificationField;
00116
00118 QList<QgsSymbol*> mSymbols;
00119
00120 QgsSymbol *symbolForFeature( const QgsFeature* f );
00121
00123 QgsAttributeList mSymbolAttributes;
00124
00125
00126 };
00127
00128 inline void QgsGraduatedSymbolRenderer::addSymbol( QgsSymbol* sy )
00129 {
00130 mSymbols.push_back( sy );
00131 }
00132
00133 inline int QgsGraduatedSymbolRenderer::classificationField() const
00134 {
00135 return mClassificationField;
00136 }
00137
00138 inline void QgsGraduatedSymbolRenderer::setClassificationField( int index )
00139 {
00140 mClassificationField = index;
00141 }
00142
00143 inline bool QgsGraduatedSymbolRenderer::needsAttributes() const
00144 {
00145 return true;
00146 }
00147
00148
00149 #endif