Quantum GIS API Documentation
1.8
|
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 #ifndef QGSRENDERER_H 00018 #define QGSRENDERER_H 00019 00020 class QgsFeature; 00021 class QgsVectorLayer; 00022 class QPainter; 00023 class QImage; 00024 class QDomDocument; 00025 class QColor; 00026 00027 #include "qgis.h" 00028 #include "qgsrendercontext.h" 00029 #include <QList> 00030 #include <QDomNode> 00031 00032 class QgsSymbol; 00033 class QBrush; 00034 00035 typedef QList<int> QgsAttributeList; 00036 00037 00039 class CORE_EXPORT QgsRenderer 00040 { 00041 public: 00043 QgsRenderer(); 00045 virtual ~QgsRenderer(); 00048 virtual bool willRenderFeature( QgsFeature *f ) 00049 { 00050 //prevent unused var warnings 00051 if ( !f ) 00052 { 00053 return true; 00054 } 00055 return true; 00056 } 00065 void renderFeature( QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0 ) 00066 { 00067 QgsRenderContext r; 00068 r.setPainter( p ); 00069 r.setScaleFactor( widthScale ); 00070 r.setRasterScaleFactor( rasterScaleFactor ); 00071 renderFeature( r, f, img, selected ); 00072 } 00073 00076 void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected ) 00077 { 00078 renderFeature( renderContext, f, pic, selected, 1.0 ); 00079 } 00080 00081 virtual void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected, double opacity ) = 0; 00082 00087 virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl ) = 0; 00088 00090 // virtual void writeXML(std::ostream& xml)=0; 00093 virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const = 0; 00095 virtual bool needsAttributes() const = 0; 00097 virtual QgsAttributeList classificationAttributes() const = 0; 00099 virtual QString name() const = 0; 00101 virtual const QList<QgsSymbol*> symbols() const = 0; 00103 virtual QgsRenderer* clone() const = 0; 00105 static void setSelectionColor( QColor color ); 00107 static QColor selectionColor(); 00109 virtual bool containsPixmap() const; 00112 virtual bool usesTransparency() const {return false;} 00113 00116 virtual QgsSymbol* symbolForFeature( const QgsFeature* f ) { Q_UNUSED( f ); return 0;} 00117 00119 static void scaleBrush( QBrush& b, double rasterScaleFactor ); 00120 00121 protected: 00124 static QColor mSelectionColor; 00125 00127 QGis::GeometryType mGeometryType; 00128 }; 00129 00130 #endif // QGSRENDERER_H