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"
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
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
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
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
00065 static const bool selectionIsOpaque = true;
00066 static const bool selectFillBorder = false;
00067 static const bool selectFillStyle = false;
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
00102 virtual void setWidth( double width ) { mWidth = width; }
00103 virtual double width() const { return mWidth; }
00104
00105 void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
00106
00107 protected:
00108 QgsLineSymbolLayerV2( bool locked = false );
00109
00110 double mWidth;
00111 };
00112
00113 class CORE_EXPORT QgsFillSymbolLayerV2 : public QgsSymbolLayerV2
00114 {
00115 public:
00116 virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) = 0;
00117
00118 void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
00119
00120 protected:
00121 QgsFillSymbolLayerV2( bool locked = false );
00123 void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings );
00124 };
00125
00126 class QgsSymbolLayerV2Widget;
00127
00128 #endif