1
/***************************************************************************
2
qgsrenderer.h - description
5
copyright : (C) 2003 by Gary E.Sherman
6
email : sherman at mrcc.com
7
***************************************************************************/
9
/***************************************************************************
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. *
16
***************************************************************************/
30
#include "qgsrendercontext.h"
36
typedef QList<int> QgsAttributeList;
39
/**Abstract base class for renderers. A renderer holds all the information necessary to draw the contents of a vector layer to a map canvas. The vector layer then passes each feature to paint to the renderer*/
40
class CORE_EXPORT QgsRenderer
43
/** Default ctor sets up selection color from project properties */
45
/** Virtual destructor because we have virtual methods... */
46
virtual ~QgsRenderer();
47
/** Determines if a feature will be rendered or not
48
@param f a pointer to the feature to determine if rendering will happen*/
49
virtual bool willRenderFeature( QgsFeature *f )
51
//prevent unused var warnings
58
/**A vector layer passes features to a renderer object to change the brush and pen of the qpainter
59
@param p the painter storing brush and pen
60
@param f a pointer to the feature to be rendered
61
@param pic pointer to an image (used for point symbols)
62
@param scalefactor pointer to the scale factor for the marker image
64
void renderFeature( QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0 )
68
r.setScaleFactor( widthScale );
69
r.setRasterScaleFactor( rasterScaleFactor );
70
renderFeature( r, f, img, selected );
73
/**A vector layer passes features to a renderer object to change the brush and pen of the qpainter
75
void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected )
77
renderFeature( renderContext, f, pic, selected, 1.0 );
80
virtual void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected, double opacity ) = 0;
82
/**Reads the renderer configuration from an XML file
83
@param rnode the Dom node to read
84
@param vl the vector layer which will be associated with the renderer
85
@return 0 in case of success, 1 if vector layer has no renderer, 2 if classification field not found*/
86
virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl ) = 0;
87
/**Writes the contents of the renderer to a configuration file*/
88
// virtual void writeXML(std::ostream& xml)=0;
89
/**Writes the contents of the renderer to a configuration file
90
@ return true in case of success*/
91
virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const = 0;
92
/** Returns true, if attribute values are used by the renderer and false otherwise*/
93
virtual bool needsAttributes() const = 0;
94
/**Returns a list with indexes of classification attributes*/
95
virtual QgsAttributeList classificationAttributes() const = 0;
96
/**Returns the renderers name*/
97
virtual QString name() const = 0;
98
/**Return symbology items*/
99
virtual const QList<QgsSymbol*> symbols() const = 0;
100
/**Returns a copy of the renderer (a deep copy on the heap)*/
101
virtual QgsRenderer* clone() const = 0;
102
/** Change selection color */
103
static void setSelectionColor( QColor color );
104
/** Get selection color. Added in QGIS v1.4 */
105
static QColor selectionColor();
106
/**Returns true if this renderer returns a pixmap in the render method (e.g. for point data or diagrams)*/
107
virtual bool containsPixmap() const;
108
/**Returns true if this renderer uses its own transparency settings, e.g. differentiated by classification.
109
This is a hint for QgsVectorLayer to not use the transparency setting on layer level in this cases*/
110
virtual bool usesTransparency() const {return false;}
112
/**Scales a brush to a given raster scale factor (e.g. for printing)*/
113
static void scaleBrush( QBrush& b, double rasterScaleFactor );
116
/**Color to draw selected features - static so we can change it in proj props and automatically
117
all renderers are updated*/
118
static QColor mSelectionColor;
121
QGis::GeometryType mGeometryType;
124
#endif // QGSRENDERER_H