Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgslinesymbollayerv2.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 QGSLINESYMBOLLAYERV2_H 00017 #define QGSLINESYMBOLLAYERV2_H 00018 00019 #include "qgssymbollayerv2.h" 00020 00021 #include <QPen> 00022 #include <QVector> 00023 00024 #define DEFAULT_SIMPLELINE_COLOR QColor(0,0,0) 00025 #define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH 00026 #define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine 00027 #define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin 00028 #define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap 00029 00030 00031 class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2 00032 { 00033 public: 00034 QgsSimpleLineSymbolLayerV2( QColor color = DEFAULT_SIMPLELINE_COLOR, 00035 double width = DEFAULT_SIMPLELINE_WIDTH, 00036 Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE ); 00037 00038 // static stuff 00039 00040 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00041 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00042 00043 // implemented from base classes 00044 00045 QString layerType() const; 00046 00047 void startRender( QgsSymbolV2RenderContext& context ); 00048 00049 void stopRender( QgsSymbolV2RenderContext& context ); 00050 00051 void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00052 00053 QgsStringMap properties() const; 00054 00055 QgsSymbolLayerV2* clone() const; 00056 00057 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00058 00059 // new stuff 00060 00061 Qt::PenStyle penStyle() const { return mPenStyle; } 00062 void setPenStyle( Qt::PenStyle style ) { mPenStyle = style; } 00063 00064 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; } 00065 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; } 00066 00067 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; } 00068 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; } 00069 00070 double offset() const { return mOffset; } 00071 void setOffset( double offset ) { mOffset = offset; } 00072 00073 bool useCustomDashPattern() const { return mUseCustomDashPattern; } 00074 void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; } 00075 00076 QVector<qreal> customDashVector() const { return mCustomDashVector; } 00077 void setCustomDashVector( const QVector<qreal>& vector ) { mCustomDashVector = vector; } 00078 00079 protected: 00080 Qt::PenStyle mPenStyle; 00081 Qt::PenJoinStyle mPenJoinStyle; 00082 Qt::PenCapStyle mPenCapStyle; 00083 QPen mPen; 00084 QPen mSelPen; 00085 double mOffset; 00086 //use a custom dash dot pattern instead of the predefined ones 00087 bool mUseCustomDashPattern; 00089 QVector<qreal> mCustomDashVector; 00090 }; 00091 00093 00094 #define DEFAULT_MARKERLINE_ROTATE true 00095 #define DEFAULT_MARKERLINE_INTERVAL 3 00096 00097 class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2 00098 { 00099 public: 00100 QgsMarkerLineSymbolLayerV2( bool rotateMarker = DEFAULT_MARKERLINE_ROTATE, 00101 double interval = DEFAULT_MARKERLINE_INTERVAL ); 00102 00103 ~QgsMarkerLineSymbolLayerV2(); 00104 00105 enum Placement 00106 { 00107 Interval, 00108 Vertex, 00109 LastVertex, 00110 FirstVertex, 00111 CentralPoint 00112 }; 00113 00114 // static stuff 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 00125 void stopRender( QgsSymbolV2RenderContext& context ); 00126 00127 void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00128 00129 QgsStringMap properties() const; 00130 00131 QgsSymbolLayerV2* clone() const; 00132 00133 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00134 00135 void setColor( const QColor& color ); 00136 00137 QgsSymbolV2* subSymbol(); 00138 bool setSubSymbol( QgsSymbolV2* symbol ); 00139 00140 virtual void setWidth( double width ); 00141 virtual double width() const; 00142 00143 // new stuff 00144 00145 bool rotateMarker() const { return mRotateMarker; } 00146 void setRotateMarker( bool rotate ) { mRotateMarker = rotate; } 00147 00148 double interval() const { return mInterval; } 00149 void setInterval( double interval ) { mInterval = interval; } 00150 00151 double offset() const { return mOffset; } 00152 void setOffset( double offset ) { mOffset = offset; } 00153 00154 Placement placement() const { return mPlacement; } 00155 void setPlacement( Placement p ) { mPlacement = p; } 00156 00157 protected: 00158 00159 void renderPolylineInterval( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00160 void renderPolylineVertex( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00161 void renderPolylineCentral( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00162 00163 bool mRotateMarker; 00164 double mInterval; 00165 QgsMarkerSymbolV2* mMarker; 00166 double mOffset; 00167 Placement mPlacement; 00168 }; 00169 00171 00172 #define DEFAULT_LINEDECORATION_COLOR QColor(0,0,0) 00173 #define DEFAULT_LINEDECORATION_WIDTH DEFAULT_LINE_WIDTH 00174 00175 class CORE_EXPORT QgsLineDecorationSymbolLayerV2 : public QgsLineSymbolLayerV2 00176 { 00177 public: 00178 QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR, 00179 double width = DEFAULT_LINEDECORATION_WIDTH ); 00180 00181 ~QgsLineDecorationSymbolLayerV2(); 00182 00183 // static stuff 00184 00185 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00186 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00187 00188 // implemented from base classes 00189 00190 QString layerType() const; 00191 00192 void startRender( QgsSymbolV2RenderContext& context ); 00193 00194 void stopRender( QgsSymbolV2RenderContext& context ); 00195 00196 void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00197 00198 QgsStringMap properties() const; 00199 00200 QgsSymbolLayerV2* clone() const; 00201 00202 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00203 00204 protected: 00205 QPen mPen; 00206 QPen mSelPen; 00207 00208 }; 00209 00210 #endif