Quantum GIS API Documentation  1.7.4
src/core/symbology-ng/qgssymbollayerv2.h
Go to the documentation of this file.
00001 #ifndef QGSSYMBOLLAYERV2_H
00002 #define QGSSYMBOLLAYERV2_H
00003 
00004 #include <QMap>
00005 
00006 #include <QColor>
00007 #include <QPointF>
00008 
00009 #include "qgssymbolv2.h"
00010 
00011 #include "qgssymbollayerv2utils.h" // QgsStringMap
00012 
00013 class QPainter;
00014 class QSize;
00015 class QPolygonF;
00016 
00017 class QgsRenderContext;
00018 class QgsSymbolV2;
00019 
00020 
00021 class CORE_EXPORT QgsSymbolLayerV2
00022 {
00023   public:
00024 
00025     // not necessarily supported by all symbol layers...
00026     virtual void setColor( const QColor& color ) { mColor = color; }
00027     virtual QColor color() const { return mColor; }
00028 
00029     virtual ~QgsSymbolLayerV2() {}
00030 
00031     virtual QString layerType() const = 0;
00032 
00033     virtual void startRender( QgsSymbolV2RenderContext& context ) = 0;
00034     virtual void stopRender( QgsSymbolV2RenderContext& context ) = 0;
00035 
00036     virtual QgsSymbolLayerV2* clone() const = 0;
00037 
00038     virtual QgsStringMap properties() const = 0;
00039 
00040     virtual void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) = 0;
00041 
00042     virtual QgsSymbolV2* subSymbol() { return NULL; }
00043     // set layer's subsymbol. takes ownership of the passed symbol
00044     virtual bool setSubSymbol( QgsSymbolV2* symbol ) { delete symbol; return false; }
00045 
00046     QgsSymbolV2::SymbolType type() const { return mType; }
00047 
00048     void setLocked( bool locked ) { mLocked = locked; }
00049     bool isLocked() const { return mLocked; }
00050 
00051     // used only with rending with symbol levels is turned on (0 = first pass, 1 = second, ...)
00052     void setRenderingPass( int renderingPass ) { mRenderingPass = renderingPass; }
00053     int renderingPass() const { return mRenderingPass; }
00054 
00055   protected:
00056     QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false )
00057         : mType( type ), mLocked( locked ), mRenderingPass( 0 ) {}
00058 
00059     QgsSymbolV2::SymbolType mType;
00060     bool mLocked;
00061     QColor mColor;
00062     int mRenderingPass;
00063 
00064     // Configuration of selected symbology implementation
00065     static const bool selectionIsOpaque = true;  // Selection ignores symbol alpha
00066     static const bool selectFillBorder = false;  // Fill symbol layer also selects border symbology
00067     static const bool selectFillStyle = false;   // Fill symbol uses symbol layer style..
00068 
00069 };
00070 
00072 
00073 class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2
00074 {
00075   public:
00076     virtual void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) = 0;
00077 
00078     void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
00079 
00080     void setAngle( double angle ) { mAngle = angle; }
00081     double angle() const { return mAngle; }
00082 
00083     void setSize( double size ) { mSize = size; }
00084     double size() const { return mSize; }
00085 
00086     void setOffset( QPointF offset ) { mOffset = offset; }
00087     QPointF offset() { return mOffset; }
00088 
00089   protected:
00090     QgsMarkerSymbolLayerV2( bool locked = false );
00091 
00092     double mAngle;
00093     double mSize;
00094     QPointF mOffset;
00095 };
00096 
00097 class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2
00098 {
00099   public:
00100     virtual void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) = 0;
00101 
00103     virtual void renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
00104 
00105     virtual void setWidth( double width ) { mWidth = width; }
00106     virtual double width() const { return mWidth; }
00107 
00108     void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
00109 
00110   protected:
00111     QgsLineSymbolLayerV2( bool locked = false );
00112 
00113     double mWidth;
00114 };
00115 
00116 class CORE_EXPORT QgsFillSymbolLayerV2 : public QgsSymbolLayerV2
00117 {
00118   public:
00119     virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) = 0;
00120 
00121     void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
00122 
00123     void setAngle( double angle ) { mAngle = angle; }
00124     double angle() const { return mAngle; }
00125 
00126   protected:
00127     QgsFillSymbolLayerV2( bool locked = false );
00129     void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings );
00130 
00131     double mAngle;
00132 };
00133 
00134 class QgsSymbolLayerV2Widget;
00135 
00136 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines