Quantum GIS API Documentation  1.7.4
src/core/renderer/qgsrenderer.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                          qgsrenderer.h  -  description
00003                              -------------------
00004     begin                : Sat Jan 4 2003
00005     copyright            : (C) 2003 by Gary E.Sherman
00006     email                : sherman at mrcc.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 /* $Id$ */
00018 #ifndef QGSRENDERER_H
00019 #define QGSRENDERER_H
00020 
00021 class QgsFeature;
00022 class QgsVectorLayer;
00023 class QPainter;
00024 class QImage;
00025 class QDomNode;
00026 class QDomDocument;
00027 class QColor;
00028 
00029 #include "qgis.h"
00030 #include "qgsrendercontext.h"
00031 #include <QList>
00032 
00033 class QgsSymbol;
00034 class QBrush;
00035 
00036 typedef QList<int> QgsAttributeList;
00037 
00038 
00040 class CORE_EXPORT QgsRenderer
00041 {
00042   public:
00044     QgsRenderer();
00046     virtual ~QgsRenderer();
00049     virtual bool willRenderFeature( QgsFeature *f )
00050     {
00051       //prevent unused var warnings
00052       if ( !f )
00053       {
00054         return true;
00055       }
00056       return true;
00057     }
00066     void renderFeature( QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0 )
00067     {
00068       QgsRenderContext r;
00069       r.setPainter( p );
00070       r.setScaleFactor( widthScale );
00071       r.setRasterScaleFactor( rasterScaleFactor );
00072       renderFeature( r, f, img, selected );
00073     }
00074 
00077     void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected )
00078     {
00079       renderFeature( renderContext, f, pic, selected, 1.0 );
00080     }
00081 
00082     virtual void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected, double opacity ) = 0;
00083 
00088     virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl ) = 0;
00089 
00091     // virtual void writeXML(std::ostream& xml)=0;
00094     virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const = 0;
00096     virtual bool needsAttributes() const = 0;
00098     virtual QgsAttributeList classificationAttributes() const = 0;
00100     virtual QString name() const = 0;
00102     virtual const QList<QgsSymbol*> symbols() const = 0;
00104     virtual QgsRenderer* clone() const = 0;
00106     static void setSelectionColor( QColor color );
00108     static QColor selectionColor();
00110     virtual bool containsPixmap() const;
00113     virtual bool usesTransparency() const {return false;}
00114 
00117     virtual QgsSymbol* symbolForFeature( const QgsFeature* f ) { return 0;}
00118 
00120     static void scaleBrush( QBrush& b, double rasterScaleFactor );
00121 
00122   protected:
00125     static QColor mSelectionColor;
00126 
00128     QGis::GeometryType mGeometryType;
00129 };
00130 
00131 #endif // QGSRENDERER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines