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
QgsRenderer Class Reference

Abstract base class for renderers. More...

#include <qgsrenderer.h>

Inheritance diagram for QgsRenderer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 QgsRenderer ()
 Default ctor sets up selection color from project properties.
virtual ~QgsRenderer ()
 Virtual destructor because we have virtual methods...
virtual bool willRenderFeature (QgsFeature *f)
 Determines if a feature will be rendered or not.
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.
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.
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.
virtual bool writeXML (QDomNode &layer_node, QDomDocument &document, const QgsVectorLayer &vl) const =0
 Writes the contents of the renderer to a configuration file.
virtual bool needsAttributes () const =0
 Returns true, if attribute values are used by the renderer and false otherwise.
virtual QgsAttributeList classificationAttributes () const =0
 Returns a list with indexes of classification attributes.
virtual QString name () const =0
 Returns the renderers name.
virtual const QList< QgsSymbol * > symbols () const =0
 Return symbology items.
virtual QgsRendererclone () const =0
 Returns a copy of the renderer (a deep copy on the heap)
virtual bool containsPixmap () const
 Returns true if this renderer returns a pixmap in the render method (e.g.
virtual bool usesTransparency () const
 Returns true if this renderer uses its own transparency settings, e.g.
virtual QgsSymbolsymbolForFeature (const QgsFeature *f)
 Returns renderer symbol for a feature.

Static Public Member Functions

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

Protected Attributes

QGis::GeometryType mGeometryType
 Layer type.

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.

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().

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: