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
***************************************************************************/
17
/* $Id: qgsrenderer.h,v 1.24 2005/04/02 09:42:45 rabla Exp $ */
25
class QgsDlgVectorLayerProperties;
36
#include "qgsproject.h"
41
/**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*/
45
/** Default ctor sets up selection colour from project properties */
47
/**Sets the initial symbology configuration for a layer. Besides of applying default symbology settings, an instance of the corresponding renderer dialog is created and associated with the layer (or with the property dialog, if pr is not 0). Finally, a pixmap for the legend is drawn (or, if pr is not 0, it is stored in the property dialog, until the settings are applied).
48
@param layer the vector layer associated with the renderer
49
@param pr the property dialog. This is only needed if the renderer is created from the property dialog and not yet associated with the vector layer, otherwise 0*/
50
virtual void initializeSymbology(QgsVectorLayer* layer, QgsDlgVectorLayerProperties* pr=0)=0;
51
/**A vector layer passes features to a renderer object to change the brush and pen of the qpainter
52
@param p the painter storing brush and pen
53
@param f a pointer to the feature to be rendered
54
@param pic pointer to a marker from SVG (is only used by marker renderers)
55
@param scalefactor pointer to the scale factor for the marker image*/
56
virtual void renderFeature(QPainter* p, QgsFeature* f,QPicture* pic, double* scalefactor, bool selected, int oversampling = 1, double widthScale = 1.)=0;
57
/**Reads the renderer configuration from an XML file
58
@param rnode the DOM node to read
59
@param vl the vector layer which will be associated with the renderer*/
60
virtual void readXML(const QDomNode& rnode, QgsVectorLayer& vl)=0;
61
/**Writes the contents of the renderer to a configuration file*/
62
// virtual void writeXML(std::ostream& xml)=0;
63
/**Writes the contents of the renderer to a configuration file
64
@ return true in case of success*/
65
virtual bool writeXML( QDomNode & layer_node, QDomDocument & document )=0;
66
/** Returns true, if attribute values are used by the renderer and false otherwise*/
67
virtual bool needsAttributes()=0;
68
/**Returns a list with indexes of classification attributes*/
69
virtual std::list<int> classificationAttributes()=0;
70
/**Returns the renderers name*/
71
virtual QString name()=0;
72
/** Set up the selection color by reading approriate values from project props */
73
void initialiseSelectionColor();
74
/**Return symbology items*/
75
virtual const std::list<QgsRenderItem*> items() const=0;
76
/**Color to draw selected features - static so we can change it in proj props and automatically
77
all renderers are updated*/
78
static QColor mSelectionColor;
80
QGis::VectorType mVectorType;
84
inline void QgsRenderer::initialiseSelectionColor()
86
int myRedInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorRedPart",255);
87
int myGreenInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorGreenPart",255);
88
int myBlueInt = QgsProject::instance()->readNumEntry("Gui","/SelectionColorBluePart",0);
89
mSelectionColor = QColor(myRedInt,myGreenInt,myBlueInt);
91
#endif // QGSRENDERER_H