Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsfillsymbollayerv2.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 00016 #ifndef QGSFILLSYMBOLLAYERV2_H 00017 #define QGSFILLSYMBOLLAYERV2_H 00018 00019 #include "qgssymbollayerv2.h" 00020 00021 #define DEFAULT_SIMPLEFILL_COLOR QColor(0,0,255) 00022 #define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern 00023 #define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor(0,0,0) 00024 #define DEFAULT_SIMPLEFILL_BORDERSTYLE Qt::SolidLine 00025 #define DEFAULT_SIMPLEFILL_BORDERWIDTH DEFAULT_LINE_WIDTH 00026 00027 #include <QPen> 00028 #include <QBrush> 00029 00030 class CORE_EXPORT QgsSimpleFillSymbolLayerV2 : public QgsFillSymbolLayerV2 00031 { 00032 public: 00033 QgsSimpleFillSymbolLayerV2( QColor color = DEFAULT_SIMPLEFILL_COLOR, 00034 Qt::BrushStyle style = DEFAULT_SIMPLEFILL_STYLE, 00035 QColor borderColor = DEFAULT_SIMPLEFILL_BORDERCOLOR, 00036 Qt::PenStyle borderStyle = DEFAULT_SIMPLEFILL_BORDERSTYLE, 00037 double borderWidth = DEFAULT_SIMPLEFILL_BORDERWIDTH ); 00038 00039 // static stuff 00040 00041 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00042 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00043 00044 // implemented from base classes 00045 00046 QString layerType() const; 00047 00048 void startRender( QgsSymbolV2RenderContext& context ); 00049 00050 void stopRender( QgsSymbolV2RenderContext& context ); 00051 00052 void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ); 00053 00054 QgsStringMap properties() const; 00055 00056 QgsSymbolLayerV2* clone() const; 00057 00058 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00059 00060 Qt::BrushStyle brushStyle() const { return mBrushStyle; } 00061 void setBrushStyle( Qt::BrushStyle style ) { mBrushStyle = style; } 00062 00063 QColor borderColor() const { return mBorderColor; } 00064 void setBorderColor( QColor borderColor ) { mBorderColor = borderColor; } 00065 00066 Qt::PenStyle borderStyle() const { return mBorderStyle; } 00067 void setBorderStyle( Qt::PenStyle borderStyle ) { mBorderStyle = borderStyle; } 00068 00069 double borderWidth() const { return mBorderWidth; } 00070 void setBorderWidth( double borderWidth ) { mBorderWidth = borderWidth; } 00071 00072 void setOffset( QPointF offset ) { mOffset = offset; } 00073 QPointF offset() { return mOffset; } 00074 00075 protected: 00076 QBrush mBrush; 00077 QBrush mSelBrush; 00078 Qt::BrushStyle mBrushStyle; 00079 QColor mBorderColor; 00080 Qt::PenStyle mBorderStyle; 00081 double mBorderWidth; 00082 QPen mPen; 00083 00084 QPointF mOffset; 00085 }; 00086 00088 class CORE_EXPORT QgsImageFillSymbolLayer: public QgsFillSymbolLayerV2 00089 { 00090 public: 00091 QgsImageFillSymbolLayer(); 00092 virtual ~QgsImageFillSymbolLayer(); 00093 void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ); 00094 00095 virtual QgsSymbolV2* subSymbol() { return mOutline; } 00096 virtual bool setSubSymbol( QgsSymbolV2* symbol ); 00097 00098 protected: 00099 QBrush mBrush; 00100 00102 double mOutlineWidth; 00104 QgsLineSymbolV2* mOutline; 00105 }; 00106 00109 class CORE_EXPORT QgsSVGFillSymbolLayer: public QgsImageFillSymbolLayer 00110 { 00111 public: 00112 QgsSVGFillSymbolLayer( const QString& svgFilePath = "", double width = 20, double rotation = 0.0 ); 00113 QgsSVGFillSymbolLayer( const QByteArray& svgData, double width = 20, double rotation = 0.0 ); 00114 ~QgsSVGFillSymbolLayer(); 00115 00116 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00117 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00118 00119 // implemented from base classes 00120 00121 QString layerType() const; 00122 00123 void startRender( QgsSymbolV2RenderContext& context ); 00124 void stopRender( QgsSymbolV2RenderContext& context ); 00125 00126 QgsStringMap properties() const; 00127 00128 QgsSymbolLayerV2* clone() const; 00129 00130 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00131 00132 //getters and setters 00133 void setSvgFilePath( const QString& svgPath ); 00134 QString svgFilePath() const { return mSvgFilePath; } 00135 void setPatternWidth( double width ) { mPatternWidth = width;} 00136 double patternWidth() const { return mPatternWidth; } 00137 00138 void setSvgFillColor( const QColor& c ) { mSvgFillColor = c; } 00139 QColor svgFillColor() const { return mSvgFillColor; } 00140 void setSvgOutlineColor( const QColor& c ) { mSvgOutlineColor = c; } 00141 QColor svgOutlineColor() const { return mSvgOutlineColor; } 00142 void setSvgOutlineWidth( double w ) { mSvgOutlineWidth = w; } 00143 double svgOutlineWidth() const { return mSvgOutlineWidth; } 00144 00145 protected: 00147 double mPatternWidth; 00149 QByteArray mSvgData; 00151 QString mSvgFilePath; 00153 QRectF mSvgViewBox; 00154 00155 //param(fill), param(outline), param(outline-width) are going 00156 //to be replaced in memory 00157 QColor mSvgFillColor; 00158 QColor mSvgOutlineColor; 00159 double mSvgOutlineWidth; 00160 00161 private: 00163 void storeViewBox(); 00164 void setDefaultSvgParams(); //fills mSvgFillColor, mSvgOutlineColor, mSvgOutlineWidth with default values for mSvgFilePath 00165 }; 00166 00167 class CORE_EXPORT QgsLinePatternFillSymbolLayer: public QgsImageFillSymbolLayer 00168 { 00169 public: 00170 QgsLinePatternFillSymbolLayer(); 00171 ~QgsLinePatternFillSymbolLayer(); 00172 00173 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00174 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00175 00176 QString layerType() const; 00177 00178 void startRender( QgsSymbolV2RenderContext& context ); 00179 00180 void stopRender( QgsSymbolV2RenderContext& context ); 00181 00182 QgsStringMap properties() const; 00183 00184 QgsSymbolLayerV2* clone() const; 00185 00186 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00187 00188 //getters and setters 00189 void setLineAngle( double a ) { mLineAngle = a; } 00190 double lineAngle() const { return mLineAngle; } 00191 void setDistance( double d ) { mDistance = d; } 00192 double distance() const { return mDistance; } 00193 void setLineWidth( double w ) { mLineWidth = w; } 00194 double lineWidth() const { return mLineWidth; } 00195 void setColor( const QColor& c ) { mColor = c; } 00196 QColor color() const { return mColor; } 00197 void setOffset( double offset ) { mOffset = offset; } 00198 double offset() const { return mOffset; } 00199 00200 protected: 00202 double mDistance; 00204 double mLineWidth; 00205 QColor mColor; 00207 double mLineAngle; 00209 double mOffset; 00210 }; 00211 00212 class CORE_EXPORT QgsPointPatternFillSymbolLayer: public QgsImageFillSymbolLayer 00213 { 00214 public: 00215 QgsPointPatternFillSymbolLayer(); 00216 ~QgsPointPatternFillSymbolLayer(); 00217 00218 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00219 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00220 00221 QString layerType() const; 00222 00223 void startRender( QgsSymbolV2RenderContext& context ); 00224 00225 void stopRender( QgsSymbolV2RenderContext& context ); 00226 00227 QgsStringMap properties() const; 00228 00229 QgsSymbolLayerV2* clone() const; 00230 00231 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00232 00233 //getters and setters 00234 double distanceX() const { return mDistanceX; } 00235 void setDistanceX( double d ) { mDistanceX = d; } 00236 00237 double distanceY() const { return mDistanceY; } 00238 void setDistanceY( double d ) { mDistanceY = d; } 00239 00240 double displacementX() const { return mDisplacementX; } 00241 void setDisplacementX( double d ) { mDisplacementX = d; } 00242 00243 double displacementY() const { return mDisplacementY; } 00244 void setDisplacementY( double d ) { mDisplacementY = d; } 00245 00246 bool setSubSymbol( QgsSymbolV2* symbol ); 00247 virtual QgsSymbolV2* subSymbol() { return mMarkerSymbol; } 00248 00249 protected: 00250 QgsMarkerSymbolV2* mMarkerSymbol; 00251 double mDistanceX; 00252 double mDistanceY; 00253 double mDisplacementX; 00254 double mDisplacementY; 00255 }; 00256 00257 class CORE_EXPORT QgsCentroidFillSymbolLayerV2 : public QgsFillSymbolLayerV2 00258 { 00259 public: 00260 QgsCentroidFillSymbolLayerV2(); 00261 ~QgsCentroidFillSymbolLayerV2(); 00262 00263 // static stuff 00264 00265 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00266 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00267 00268 // implemented from base classes 00269 00270 QString layerType() const; 00271 00272 void startRender( QgsSymbolV2RenderContext& context ); 00273 00274 void stopRender( QgsSymbolV2RenderContext& context ); 00275 00276 void renderPolygon( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context ); 00277 00278 QgsStringMap properties() const; 00279 00280 QgsSymbolLayerV2* clone() const; 00281 00282 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00283 00284 void setColor( const QColor& color ); 00285 00286 QgsSymbolV2* subSymbol(); 00287 bool setSubSymbol( QgsSymbolV2* symbol ); 00288 00289 protected: 00290 QgsMarkerSymbolV2* mMarker; 00291 }; 00292 00293 #endif