Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgssymbollayerv2.h 00003 --------------------- 00004 begin : November 2009 00005 copyright : (C) 2009 by Martin Dobias 00006 email : wonder.sk at gmail.com 00007 *************************************************************************** 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 ***************************************************************************/ 00015 #ifndef QGSSYMBOLLAYERV2_H 00016 #define QGSSYMBOLLAYERV2_H 00017 00018 00019 00020 #include <QColor> 00021 #include <QMap> 00022 #include <QPointF> 00023 #include <QSet> 00024 #include <QDomDocument> 00025 #include <QDomElement> 00026 00027 #include "qgssymbolv2.h" 00028 00029 #include "qgssymbollayerv2utils.h" // QgsStringMap 00030 00031 class QPainter; 00032 class QSize; 00033 class QPolygonF; 00034 00035 class QgsRenderContext; 00036 00037 class CORE_EXPORT QgsSymbolLayerV2 00038 { 00039 public: 00040 00041 // not necessarily supported by all symbol layers... 00042 virtual void setColor( const QColor& color ) { mColor = color; } 00043 virtual QColor color() const { return mColor; } 00044 00045 virtual ~QgsSymbolLayerV2() {} 00046 00047 virtual QString layerType() const = 0; 00048 00049 virtual void startRender( QgsSymbolV2RenderContext& context ) = 0; 00050 virtual void stopRender( QgsSymbolV2RenderContext& context ) = 0; 00051 00052 virtual QgsSymbolLayerV2* clone() const = 0; 00053 00054 virtual void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const 00055 { Q_UNUSED( props ); element.appendChild( doc.createComment( QString( "SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); } 00056 00057 virtual QgsStringMap properties() const = 0; 00058 00059 virtual void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) = 0; 00060 00061 virtual QgsSymbolV2* subSymbol() { return NULL; } 00062 // set layer's subsymbol. takes ownership of the passed symbol 00063 virtual bool setSubSymbol( QgsSymbolV2* symbol ) { delete symbol; return false; } 00064 00065 QgsSymbolV2::SymbolType type() const { return mType; } 00066 00067 void setLocked( bool locked ) { mLocked = locked; } 00068 bool isLocked() const { return mLocked; } 00069 00070 // used only with rending with symbol levels is turned on (0 = first pass, 1 = second, ...) 00071 void setRenderingPass( int renderingPass ) { mRenderingPass = renderingPass; } 00072 int renderingPass() const { return mRenderingPass; } 00073 00074 // symbol layers normally only use additional attributes to provide data defined settings 00075 virtual QSet<QString> usedAttributes() const { return QSet<QString>(); } 00076 00077 protected: 00078 QgsSymbolLayerV2( QgsSymbolV2::SymbolType type, bool locked = false ) 00079 : mType( type ), mLocked( locked ), mRenderingPass( 0 ) {} 00080 00081 QgsSymbolV2::SymbolType mType; 00082 bool mLocked; 00083 QColor mColor; 00084 int mRenderingPass; 00085 00086 // Configuration of selected symbology implementation 00087 static const bool selectionIsOpaque = true; // Selection ignores symbol alpha 00088 static const bool selectFillBorder = false; // Fill symbol layer also selects border symbology 00089 static const bool selectFillStyle = false; // Fill symbol uses symbol layer style.. 00090 00091 }; 00092 00094 00095 class CORE_EXPORT QgsMarkerSymbolLayerV2 : public QgsSymbolLayerV2 00096 { 00097 public: 00098 virtual void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context ) = 0; 00099 00100 void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ); 00101 00102 void setAngle( double angle ) { mAngle = angle; } 00103 double angle() const { return mAngle; } 00104 00105 void setSize( double size ) { mSize = size; } 00106 double size() const { return mSize; } 00107 00108 void setOffset( QPointF offset ) { mOffset = offset; } 00109 QPointF offset() { return mOffset; } 00110 00111 virtual void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00112 00113 virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const 00114 { Q_UNUSED( props ); element.appendChild( doc.createComment( QString( "QgsMarkerSymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); } 00115 00116 protected: 00117 QgsMarkerSymbolLayerV2( bool locked = false ); 00118 00119 double mAngle; 00120 double mSize; 00121 QPointF mOffset; 00122 }; 00123 00124 class CORE_EXPORT QgsLineSymbolLayerV2 : public QgsSymbolLayerV2 00125 { 00126 public: 00127 virtual void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) = 0; 00128 00130 virtual void renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ); 00131 00132 virtual void setWidth( double width ) { mWidth = width; } 00133 virtual double width() const { return mWidth; } 00134 00135 void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ); 00136 00137 protected: 00138 QgsLineSymbolLayerV2( bool locked = false ); 00139 00140 double mWidth; 00141 }; 00142 00143 class CORE_EXPORT QgsFillSymbolLayerV2 : public QgsSymbolLayerV2 00144 { 00145 public: 00146 virtual void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ) = 0; 00147 00148 void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ); 00149 00150 void setAngle( double angle ) { mAngle = angle; } 00151 double angle() const { return mAngle; } 00152 00153 protected: 00154 QgsFillSymbolLayerV2( bool locked = false ); 00156 void _renderPolygon( QPainter* p, const QPolygonF& points, const QList<QPolygonF>* rings ); 00157 00158 double mAngle; 00159 }; 00160 00161 class QgsSymbolLayerV2Widget; 00162 00163 #endif