|
QGIS API Documentation
master-3f58142
|
00001 /*************************************************************************** 00002 qgslinesymbollayerv2.h 00003 --------------------- 00004 begin : November 2009 00005 copyright : (C) 2009 by Martin Dobias 00006 email : wonder dot sk at gmail dot 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 class QgsExpression; 00025 00026 #define DEFAULT_SIMPLELINE_COLOR QColor(0,0,0) 00027 #define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH 00028 #define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine 00029 #define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin 00030 #define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap 00031 00032 00033 class CORE_EXPORT QgsSimpleLineSymbolLayerV2 : public QgsLineSymbolLayerV2 00034 { 00035 public: 00036 QgsSimpleLineSymbolLayerV2( QColor color = DEFAULT_SIMPLELINE_COLOR, 00037 double width = DEFAULT_SIMPLELINE_WIDTH, 00038 Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE ); 00039 00040 // static stuff 00041 00042 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00043 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00044 00045 // implemented from base classes 00046 00047 QString layerType() const; 00048 00049 void startRender( QgsSymbolV2RenderContext& context ); 00050 00051 void stopRender( QgsSymbolV2RenderContext& context ); 00052 00053 void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00054 00055 QgsStringMap properties() const; 00056 00057 QgsSymbolLayerV2* clone() const; 00058 00059 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00060 00061 QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const; 00062 00063 void setOutputUnit( QgsSymbolV2::OutputUnit unit ); 00064 QgsSymbolV2::OutputUnit outputUnit() const; 00065 00066 // new stuff 00067 00068 Qt::PenStyle penStyle() const { return mPenStyle; } 00069 void setPenStyle( Qt::PenStyle style ) { mPenStyle = style; } 00070 00071 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; } 00072 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; } 00073 00074 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; } 00075 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; } 00076 00077 double offset() const { return mOffset; } 00078 void setOffset( double offset ) { mOffset = offset; } 00079 00080 QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; } 00081 void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; } 00082 00083 bool useCustomDashPattern() const { return mUseCustomDashPattern; } 00084 void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; } 00085 00086 QgsSymbolV2::OutputUnit customDashPatternUnit() const { return mCustomDashPatternUnit; } 00087 void setCustomDashPatternUnit( QgsSymbolV2::OutputUnit unit ) { mCustomDashPatternUnit = unit; } 00088 00089 QVector<qreal> customDashVector() const { return mCustomDashVector; } 00090 void setCustomDashVector( const QVector<qreal>& vector ) { mCustomDashVector = vector; } 00091 00092 protected: 00093 Qt::PenStyle mPenStyle; 00094 Qt::PenJoinStyle mPenJoinStyle; 00095 Qt::PenCapStyle mPenCapStyle; 00096 QPen mPen; 00097 QPen mSelPen; 00098 double mOffset; 00099 QgsSymbolV2::OutputUnit mOffsetUnit; 00100 00101 //use a custom dash dot pattern instead of the predefined ones 00102 bool mUseCustomDashPattern; 00103 QgsSymbolV2::OutputUnit mCustomDashPatternUnit; 00104 00106 QVector<qreal> mCustomDashVector; 00107 00108 private: 00109 //helper functions for data defined symbology 00110 void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset ); 00111 }; 00112 00114 00115 #define DEFAULT_MARKERLINE_ROTATE true 00116 #define DEFAULT_MARKERLINE_INTERVAL 3 00117 00118 class CORE_EXPORT QgsMarkerLineSymbolLayerV2 : public QgsLineSymbolLayerV2 00119 { 00120 public: 00121 QgsMarkerLineSymbolLayerV2( bool rotateMarker = DEFAULT_MARKERLINE_ROTATE, 00122 double interval = DEFAULT_MARKERLINE_INTERVAL ); 00123 00124 ~QgsMarkerLineSymbolLayerV2(); 00125 00126 enum Placement 00127 { 00128 Interval, 00129 Vertex, 00130 LastVertex, 00131 FirstVertex, 00132 CentralPoint 00133 }; 00134 00135 // static stuff 00136 00137 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00138 static QgsSymbolLayerV2* createFromSld( QDomElement &element ); 00139 00140 // implemented from base classes 00141 00142 QString layerType() const; 00143 00144 void startRender( QgsSymbolV2RenderContext& context ); 00145 00146 void stopRender( QgsSymbolV2RenderContext& context ); 00147 00148 void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00149 00150 QgsStringMap properties() const; 00151 00152 QgsSymbolLayerV2* clone() const; 00153 00154 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00155 00156 void setColor( const QColor& color ); 00157 00158 QgsSymbolV2* subSymbol(); 00159 bool setSubSymbol( QgsSymbolV2* symbol ); 00160 00161 virtual void setWidth( double width ); 00162 virtual double width() const; 00163 00164 // new stuff 00165 00166 bool rotateMarker() const { return mRotateMarker; } 00167 void setRotateMarker( bool rotate ) { mRotateMarker = rotate; } 00168 00169 double interval() const { return mInterval; } 00170 void setInterval( double interval ) { mInterval = interval; } 00171 00172 double offset() const { return mOffset; } 00173 void setOffset( double offset ) { mOffset = offset; } 00174 00175 Placement placement() const { return mPlacement; } 00176 void setPlacement( Placement p ) { mPlacement = p; } 00177 00178 QgsSymbolV2::OutputUnit intervalUnit() const { return mIntervalUnit; } 00179 void setIntervalUnit( QgsSymbolV2::OutputUnit unit ) { mIntervalUnit = unit; } 00180 00181 QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; } 00182 void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; } 00183 00184 void setOutputUnit( QgsSymbolV2::OutputUnit unit ); 00185 QgsSymbolV2::OutputUnit outputUnit() const; 00186 00187 protected: 00188 00189 void renderPolylineInterval( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00190 void renderPolylineVertex( const QPolygonF& points, QgsSymbolV2RenderContext& context, Placement placement = Vertex ); 00191 void renderPolylineCentral( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00192 00193 bool mRotateMarker; 00194 double mInterval; 00195 QgsSymbolV2::OutputUnit mIntervalUnit; 00196 QgsMarkerSymbolV2* mMarker; 00197 double mOffset; 00198 QgsSymbolV2::OutputUnit mOffsetUnit; 00199 Placement mPlacement; 00200 }; 00201 00203 00204 #define DEFAULT_LINEDECORATION_COLOR QColor(0,0,0) 00205 #define DEFAULT_LINEDECORATION_WIDTH DEFAULT_LINE_WIDTH 00206 00207 class CORE_EXPORT QgsLineDecorationSymbolLayerV2 : public QgsLineSymbolLayerV2 00208 { 00209 public: 00210 QgsLineDecorationSymbolLayerV2( QColor color = DEFAULT_LINEDECORATION_COLOR, 00211 double width = DEFAULT_LINEDECORATION_WIDTH ); 00212 00213 ~QgsLineDecorationSymbolLayerV2(); 00214 00215 // static stuff 00216 00217 static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() ); 00218 00219 // implemented from base classes 00220 00221 QString layerType() const; 00222 00223 void startRender( QgsSymbolV2RenderContext& context ); 00224 00225 void stopRender( QgsSymbolV2RenderContext& context ); 00226 00227 void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ); 00228 00229 QgsStringMap properties() const; 00230 00231 QgsSymbolLayerV2* clone() const; 00232 00233 void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const; 00234 00235 void setOutputUnit( QgsSymbolV2::OutputUnit unit ); 00236 QgsSymbolV2::OutputUnit outputUnit() const; 00237 00238 protected: 00239 QPen mPen; 00240 QPen mSelPen; 00241 00242 }; 00243 00244 #endif