Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
QgsRenderer Class Referenceabstract

Abstract base class for renderers. More...

#include <qgsrenderer.h>

Inheritance diagram for QgsRenderer:
Inheritance graph
[legend]

Public Member Functions

 QgsRenderer ()
 Default ctor sets up selection color from project properties. More...
 
virtual ~QgsRenderer ()
 Virtual destructor because we have virtual methods... More...
 
virtual bool willRenderFeature (QgsFeature *f)
 Determines if a feature will be rendered or not. More...
 
void renderFeature (QPainter *p, QgsFeature &f, QImage *img, bool selected, double widthScale=1.0, double rasterScaleFactor=1.0)
 A vector layer passes features to a renderer object to change the brush and pen of the qpainter. More...
 
void renderFeature (QgsRenderContext &renderContext, QgsFeature &f, QImage *pic, bool selected)
 A vector layer passes features to a renderer object to change the brush and pen of the qpainter. More...
 
virtual void renderFeature (QgsRenderContext &renderContext, QgsFeature &f, QImage *pic, bool selected, double opacity)=0
 
virtual int readXML (const QDomNode &rnode, QgsVectorLayer &vl)=0
 Reads the renderer configuration from an XML file. More...
 
virtual bool writeXML (QDomNode &layer_node, QDomDocument &document, const QgsVectorLayer &vl) const =0
 Writes the contents of the renderer to a configuration file. More...
 
virtual bool needsAttributes () const =0
 Returns true, if attribute values are used by the renderer and false otherwise. More...
 
virtual QgsAttributeList classificationAttributes () const =0
 Returns a list with indexes of classification attributes. More...
 
virtual QString name () const =0
 Returns the renderers name. More...
 
virtual const QList< QgsSymbol * > symbols () const =0
 Return symbology items. More...
 
virtual QgsRendererclone () const =0
 Returns a copy of the renderer (a deep copy on the heap) More...
 
virtual bool containsPixmap () const
 Returns true if this renderer returns a pixmap in the render method (e.g. More...
 
virtual bool usesTransparency () const
 Returns true if this renderer uses its own transparency settings, e.g. More...
 
virtual QgsSymbolsymbolForFeature (const QgsFeature *f)
 Returns renderer symbol for a feature. More...
 

Static Public Member Functions

static void setSelectionColor (QColor color)
 Change selection color. More...
 
static QColor selectionColor ()
 Get selection color. More...
 
static void scaleBrush (QBrush &b, double rasterScaleFactor)
 Scales a brush to a given raster scale factor (e.g. More...
 

Protected Attributes

QGis::GeometryType mGeometryType
 Layer type. More...
 

Static Protected Attributes

static QColor mSelectionColor = QColor( 0, 0, 0 )
 Color to draw selected features - static so we can change it in proj props and automatically all renderers are updated. More...
 

Detailed Description

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

Definition at line 40 of file qgsrenderer.h.

Constructor & Destructor Documentation

QgsRenderer::QgsRenderer ( )

Default ctor sets up selection color from project properties.

Definition at line 28 of file qgsrenderer.cpp.

QgsRenderer::~QgsRenderer ( )
virtual

Virtual destructor because we have virtual methods...

Definition at line 33 of file qgsrenderer.cpp.

Member Function Documentation

virtual QgsAttributeList QgsRenderer::classificationAttributes ( ) const
pure virtual
virtual QgsRenderer* QgsRenderer::clone ( ) const
pure virtual

Returns a copy of the renderer (a deep copy on the heap)

Implemented in QgsGraduatedSymbolRenderer, QgsContinuousColorRenderer, QgsUniqueValueRenderer, and QgsSingleSymbolRenderer.

Referenced by QgsVectorLayer::copySymbologySettings().

bool QgsRenderer::containsPixmap ( ) const
virtual

Returns true if this renderer returns a pixmap in the render method (e.g.

for point data or diagrams)

Definition at line 47 of file qgsrenderer.cpp.

References mGeometryType, and QGis::Point.

virtual QString QgsRenderer::name ( ) const
pure virtual
virtual bool QgsRenderer::needsAttributes ( ) const
pure virtual

Returns true, if attribute values are used by the renderer and false otherwise.

Implemented in QgsGraduatedSymbolRenderer, QgsContinuousColorRenderer, QgsSingleSymbolRenderer, and QgsUniqueValueRenderer.

virtual int QgsRenderer::readXML ( const QDomNode &  rnode,
QgsVectorLayer vl 
)
pure virtual

Reads the renderer configuration from an XML file.

Parameters
rnodethe Dom node to read
vlthe vector layer which will be associated with the renderer
Returns
0 in case of success, 1 if vector layer has no renderer, 2 if classification field not found

Implemented in QgsGraduatedSymbolRenderer, QgsContinuousColorRenderer, QgsSingleSymbolRenderer, and QgsUniqueValueRenderer.

Referenced by QgsVectorLayer::readSymbology().

void QgsRenderer::renderFeature ( QPainter *  p,
QgsFeature f,
QImage *  img,
bool  selected,
double  widthScale = 1.0,
double  rasterScaleFactor = 1.0 
)
inline

A vector layer passes features to a renderer object to change the brush and pen of the qpainter.

Parameters
pthe painter storing brush and pen
fa pointer to the feature to be rendered
imga pointer to picture
selectedfeature is selected
widthScalescale
rasterScaleFactorraster scale
Note
deprecated

Definition at line 66 of file qgsrenderer.h.

References QgsRenderContext::setPainter(), QgsRenderContext::setRasterScaleFactor(), and QgsRenderContext::setScaleFactor().

Referenced by QgsVectorLayer::draw().

void QgsRenderer::renderFeature ( QgsRenderContext renderContext,
QgsFeature f,
QImage *  pic,
bool  selected 
)
inline

A vector layer passes features to a renderer object to change the brush and pen of the qpainter.

Note
added in 1.2

Definition at line 77 of file qgsrenderer.h.

virtual void QgsRenderer::renderFeature ( QgsRenderContext renderContext,
QgsFeature f,
QImage *  pic,
bool  selected,
double  opacity 
)
pure virtual
void QgsRenderer::scaleBrush ( QBrush &  b,
double  rasterScaleFactor 
)
static

Scales a brush to a given raster scale factor (e.g.

for printing)

Definition at line 59 of file qgsrenderer.cpp.

Referenced by QgsComposerLegend::drawPolygonSymbol(), QgsUniqueValueRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), and QgsGraduatedSymbolRenderer::renderFeature().

QColor QgsRenderer::selectionColor ( )
static

Get selection color.

Added in QGIS v1.4

Definition at line 42 of file qgsrenderer.cpp.

References mSelectionColor.

Referenced by QgsVectorLayer::drawRendererV2Levels(), and QgsSymbolV2RenderContext::selectionColor().

void QgsRenderer::setSelectionColor ( QColor  color)
static

Change selection color.

Definition at line 37 of file qgsrenderer.cpp.

References mSelectionColor.

virtual QgsSymbol* QgsRenderer::symbolForFeature ( const QgsFeature f)
inlinevirtual

Returns renderer symbol for a feature.

Note
: this method was added in version 1.6

Reimplemented in QgsGraduatedSymbolRenderer, QgsUniqueValueRenderer, and QgsSingleSymbolRenderer.

Definition at line 117 of file qgsrenderer.h.

virtual const QList<QgsSymbol*> QgsRenderer::symbols ( ) const
pure virtual
virtual bool QgsRenderer::usesTransparency ( ) const
inlinevirtual

Returns true if this renderer uses its own transparency settings, e.g.

differentiated by classification. This is a hint for QgsVectorLayer to not use the transparency setting on layer level in this cases

Definition at line 113 of file qgsrenderer.h.

Referenced by QgsVectorLayer::draw(), QgsVectorLayer::drawLineString(), and QgsVectorLayer::drawPolygon().

virtual bool QgsRenderer::willRenderFeature ( QgsFeature f)
inlinevirtual

Determines if a feature will be rendered or not.

Parameters
fa pointer to the feature to determine if rendering will happen

Reimplemented in QgsGraduatedSymbolRenderer, and QgsUniqueValueRenderer.

Definition at line 49 of file qgsrenderer.h.

Referenced by QgsVectorLayer::draw(), and QgsVectorLayer::drawLabels().

virtual bool QgsRenderer::writeXML ( QDomNode &  layer_node,
QDomDocument &  document,
const QgsVectorLayer vl 
) const
pure virtual

Writes the contents of the renderer to a configuration file.

Writes the contents of the renderer to a configuration file @ return true in case of success

Implemented in QgsGraduatedSymbolRenderer, QgsContinuousColorRenderer, QgsSingleSymbolRenderer, and QgsUniqueValueRenderer.

Referenced by QgsVectorLayer::writeSymbology().

Member Data Documentation

QGis::GeometryType QgsRenderer::mGeometryType
protected
QColor QgsRenderer::mSelectionColor = QColor( 0, 0, 0 )
staticprotected

Color to draw selected features - static so we can change it in proj props and automatically all renderers are updated.

Definition at line 125 of file qgsrenderer.h.

Referenced by QgsUniqueValueRenderer::renderFeature(), QgsContinuousColorRenderer::renderFeature(), QgsSingleSymbolRenderer::renderFeature(), QgsGraduatedSymbolRenderer::renderFeature(), selectionColor(), and setSelectionColor().


The documentation for this class was generated from the following files: