2007-01-09 02:39:15 +00:00
/**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*/
2007-05-31 00:19:27 +00:00
class QgsRenderer
2007-01-09 02:39:15 +00:00
{
%TypeHeaderCode
#include <qgsrenderer.h>
2010-01-05 14:09:31 +00:00
#include <qgssinglesymbolrenderer.h>
#include <qgsuniquevaluerenderer.h>
#include <qgsgraduatedsymbolrenderer.h>
#include <qgscontinuouscolorrenderer.h>
2007-01-09 02:39:15 +00:00
%End
2010-01-05 14:09:31 +00:00
%ConvertToSubClassCode
if (dynamic_cast<QgsSingleSymbolRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsSingleSymbolRenderer;
else if (dynamic_cast<QgsUniqueValueRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsUniqueValueRenderer;
else if (dynamic_cast<QgsGraduatedSymbolRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsGraduatedSymbolRenderer;
else if (dynamic_cast<QgsContinuousColorRenderer*>(sipCpp) != NULL)
sipClass = sipClass_QgsContinuousColorRenderer;
else
sipClass = 0;
%End
2012-09-24 02:28:15 +02:00
public:
2009-12-23 16:14:24 +00:00
/** Default ctor sets up selection color from project properties */
2007-01-09 02:39:15 +00:00
QgsRenderer();
/** Virtual destructor because we have virtual methods... */
virtual ~QgsRenderer();
2010-01-05 14:09:31 +00:00
/** Determines if a feature will be rendered or not
@param f a pointer to the feature to determine if rendering will happen*/
virtual bool willRenderFeature( QgsFeature *f );
2007-01-09 02:39:15 +00:00
/**A vector layer passes features to a renderer object to change the brush and pen of the qpainter
@param p the painter storing brush and pen
@param f a pointer to the feature to be rendered
2012-09-24 02:28:15 +02:00
@param img a pointer to picture
@param selected feature is selected
@param widthScale scale
@param rasterScaleFactor raster scale
@note deprecated */
void renderFeature( QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0 ) /Deprecated/;
2009-07-23 10:59:59 +00:00
/**A vector layer passes features to a renderer object to change the brush ans pen of the qpainter
2012-09-24 02:28:15 +02:00
@note added in 1.2 */
2009-08-05 16:43:33 +00:00
void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected );
virtual void renderFeature( QgsRenderContext &renderContext, QgsFeature& f, QImage* pic, bool selected, double opacity ) = 0;
2009-07-23 10:59:59 +00:00
2007-01-09 02:39:15 +00:00
/**Reads the renderer configuration from an XML file
2012-09-24 02:28:15 +02:00
@param rnode the Dom node to read
@param vl the vector layer which will be associated with the renderer
@return 0 in case of success, 1 if vector layer has no renderer, 2 if classification field not found*/
virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl ) = 0;
2007-01-09 02:39:15 +00:00
/**Writes the contents of the renderer to a configuration file
@ return true in case of success*/
2012-09-24 02:28:15 +02:00
virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const = 0;
2007-01-09 02:39:15 +00:00
/** Returns true, if attribute values are used by the renderer and false otherwise*/
2012-09-24 02:28:15 +02:00
virtual bool needsAttributes() const = 0;
2007-01-09 02:39:15 +00:00
/**Returns a list with indexes of classification attributes*/
2012-09-24 02:28:15 +02:00
virtual QList<int> classificationAttributes() const = 0;
2007-01-09 02:39:15 +00:00
/**Returns the renderers name*/
2012-09-24 02:28:15 +02:00
virtual QString name() const = 0;
2007-01-09 02:39:15 +00:00
/**Return symbology items*/
2012-09-24 02:28:15 +02:00
virtual const QList<QgsSymbol*> symbols() const = 0;
2007-01-09 02:39:15 +00:00
/**Returns a copy of the renderer (a deep copy on the heap)*/
2012-09-24 02:28:15 +02:00
virtual QgsRenderer* clone() const = 0 /Factory/;
2007-01-09 02:39:15 +00:00
/** Change selection color */
2012-09-24 02:28:15 +02:00
static void setSelectionColor( QColor color );
2009-11-16 11:53:50 +00:00
/** Get selection color. Added in QGIS v1.4 */
2009-11-16 10:36:24 +00:00
static QColor selectionColor();
2007-01-09 02:39:15 +00:00
/**Returns true if this renderer returns a pixmap in the render method (e.g. for point data or diagrams)*/
virtual bool containsPixmap() const;
2007-05-30 10:02:12 +00:00
/**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*/
virtual bool usesTransparency() const;
2010-01-05 14:09:31 +00:00
2012-09-24 02:28:15 +02:00
/**Returns renderer symbol for a feature.
@note: this method was added in version 1.6*/
virtual QgsSymbol* symbolForFeature( const QgsFeature* f );
2010-01-05 14:09:31 +00:00
/**Scales a brush to a given raster scale factor (e.g. for printing)*/
static void scaleBrush( QBrush& b, double rasterScaleFactor );
2007-01-09 02:39:15 +00:00
};