Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsrenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrenderer.h - description
3  -------------------
4  begin : Sat Jan 4 2003
5  copyright : (C) 2003 by Gary E.Sherman
6  email : sherman at mrcc.com
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$ */
18 #ifndef QGSRENDERER_H
19 #define QGSRENDERER_H
20 
21 class QgsFeature;
22 class QgsVectorLayer;
23 class QPainter;
24 class QImage;
25 class QDomNode;
26 class QDomDocument;
27 class QColor;
28 
29 #include "qgis.h"
30 #include "qgsrendercontext.h"
31 #include <QList>
32 
33 class QgsSymbol;
34 class QBrush;
35 
36 typedef QList<int> QgsAttributeList;
37 
38 
40 class CORE_EXPORT QgsRenderer
41 {
42  public:
44  QgsRenderer();
46  virtual ~QgsRenderer();
49  virtual bool willRenderFeature( QgsFeature *f )
50  {
51  //prevent unused var warnings
52  if ( !f )
53  {
54  return true;
55  }
56  return true;
57  }
66  void renderFeature( QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0 )
67  {
69  r.setPainter( p );
70  r.setScaleFactor( widthScale );
71  r.setRasterScaleFactor( rasterScaleFactor );
72  renderFeature( r, f, img, selected );
73  }
74 
77  void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected )
78  {
79  renderFeature( renderContext, f, pic, selected, 1.0 );
80  }
81 
82  virtual void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected, double opacity ) = 0;
83 
88  virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl ) = 0;
89 
91  // virtual void writeXML(std::ostream& xml)=0;
94  virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const = 0;
96  virtual bool needsAttributes() const = 0;
98  virtual QgsAttributeList classificationAttributes() const = 0;
100  virtual QString name() const = 0;
102  virtual const QList<QgsSymbol*> symbols() const = 0;
104  virtual QgsRenderer* clone() const = 0;
106  static void setSelectionColor( QColor color );
108  static QColor selectionColor();
110  virtual bool containsPixmap() const;
113  virtual bool usesTransparency() const {return false;}
114 
117  virtual QgsSymbol* symbolForFeature( const QgsFeature* f ) { return 0;}
118 
120  static void scaleBrush( QBrush& b, double rasterScaleFactor );
121 
122  protected:
125  static QColor mSelectionColor;
126 
129 };
130 
131 #endif // QGSRENDERER_H