QGIS API Documentation  2.3.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgslinesymbollayerv2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgslinesymbollayerv2.h
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSLINESYMBOLLAYERV2_H
17 #define QGSLINESYMBOLLAYERV2_H
18 
19 #include "qgssymbollayerv2.h"
20 
21 #include <QPen>
22 #include <QVector>
23 
24 class QgsExpression;
25 
26 #define DEFAULT_SIMPLELINE_COLOR QColor(0,0,0)
27 #define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH
28 #define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine
29 #define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin
30 #define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap
31 
32 
34 {
35  public:
37  double width = DEFAULT_SIMPLELINE_WIDTH,
38  Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE );
39 
40  // static stuff
41 
42  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
43  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
44 
45  // implemented from base classes
46 
47  QString layerType() const;
48 
49  void startRender( QgsSymbolV2RenderContext& context );
50 
51  void stopRender( QgsSymbolV2RenderContext& context );
52 
53  void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
54 
55  //overriden so that clip path can be set when using draw inside polygon option
56  void renderPolygonOutline( const QPolygonF& points, QList<QPolygonF>* rings, QgsSymbolV2RenderContext& context );
57 
58  QgsStringMap properties() const;
59 
60  QgsSymbolLayerV2* clone() const;
61 
62  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
63 
64  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const;
65 
68 
69  double estimateMaxBleed() const;
70 
71  // new stuff
72 
73  Qt::PenStyle penStyle() const { return mPenStyle; }
74  void setPenStyle( Qt::PenStyle style ) { mPenStyle = style; }
75 
76  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
77  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
78 
79  Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
80  void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
81 
82  double offset() const { return mOffset; }
83  void setOffset( double offset ) { mOffset = offset; }
84 
85  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
86  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
87 
88  bool useCustomDashPattern() const { return mUseCustomDashPattern; }
89  void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; }
90 
91  QgsSymbolV2::OutputUnit customDashPatternUnit() const { return mCustomDashPatternUnit; }
92  void setCustomDashPatternUnit( QgsSymbolV2::OutputUnit unit ) { mCustomDashPatternUnit = unit; }
93 
94  QVector<qreal> customDashVector() const { return mCustomDashVector; }
95  void setCustomDashVector( const QVector<qreal>& vector ) { mCustomDashVector = vector; }
96 
97  //Returns true if the line should only be drawn inside the polygon
98  bool drawInsidePolygon() const { return mDrawInsidePolygon; }
99  //Set to true if the line should only be drawn inside the polygon
100  void setDrawInsidePolygon( bool drawInsidePolygon ) { mDrawInsidePolygon = drawInsidePolygon; }
101 
102  QVector<qreal> dxfCustomDashPattern( QgsSymbolV2::OutputUnit& unit ) const;
103  Qt::PenStyle dxfPenStyle() const;
104 
105  double dxfWidth( const QgsDxfExport& e, const QgsSymbolV2RenderContext& context ) const;
106  QColor dxfColor( const QgsSymbolV2RenderContext& context ) const;
107 
108  protected:
109  Qt::PenStyle mPenStyle;
110  Qt::PenJoinStyle mPenJoinStyle;
111  Qt::PenCapStyle mPenCapStyle;
112  QPen mPen;
113  QPen mSelPen;
114  double mOffset;
116 
117  //use a custom dash dot pattern instead of the predefined ones
120 
122  QVector<qreal> mCustomDashVector;
123 
125 
126  private:
127  //helper functions for data defined symbology
128  void applyDataDefinedSymbology( QgsSymbolV2RenderContext& context, QPen& pen, QPen& selPen, double& offset );
129 };
130 
132 
133 #define DEFAULT_MARKERLINE_ROTATE true
134 #define DEFAULT_MARKERLINE_INTERVAL 3
135 
137 {
138  public:
140  double interval = DEFAULT_MARKERLINE_INTERVAL );
141 
143 
145  {
150  CentralPoint
151  };
152 
153  // static stuff
154 
155  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
156  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
157 
158  // implemented from base classes
159 
160  QString layerType() const;
161 
162  void startRender( QgsSymbolV2RenderContext& context );
163 
164  void stopRender( QgsSymbolV2RenderContext& context );
165 
166  void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context );
167 
168  QgsStringMap properties() const;
169 
170  QgsSymbolLayerV2* clone() const;
171 
172  void toSld( QDomDocument &doc, QDomElement &element, QgsStringMap props ) const;
173 
174  void setColor( const QColor& color );
175 
177  bool setSubSymbol( QgsSymbolV2* symbol );
178 
179  virtual void setWidth( double width );
180  virtual double width() const;
181 
182  double estimateMaxBleed() const;
183 
184  // new stuff
185 
186  bool rotateMarker() const { return mRotateMarker; }
187  void setRotateMarker( bool rotate ) { mRotateMarker = rotate; }
188 
189  double interval() const { return mInterval; }
190  void setInterval( double interval ) { mInterval = interval; }
191 
192  double offset() const { return mOffset; }
193  void setOffset( double offset ) { mOffset = offset; }
194 
195  Placement placement() const { return mPlacement; }
196  void setPlacement( Placement p ) { mPlacement = p; }
197 
198  QgsSymbolV2::OutputUnit intervalUnit() const { return mIntervalUnit; }
199  void setIntervalUnit( QgsSymbolV2::OutputUnit unit ) { mIntervalUnit = unit; }
200 
201  QgsSymbolV2::OutputUnit offsetUnit() const { return mOffsetUnit; }
202  void setOffsetUnit( QgsSymbolV2::OutputUnit unit ) { mOffsetUnit = unit; }
203 
206 
207  protected:
208 
209  void renderPolylineInterval( const QPolygonF& points, QgsSymbolV2RenderContext& context );
210  void renderPolylineVertex( const QPolygonF& points, QgsSymbolV2RenderContext& context, Placement placement = Vertex );
211  void renderPolylineCentral( const QPolygonF& points, QgsSymbolV2RenderContext& context );
212  double markerAngle( const QPolygonF& points, bool isRing, int vertex );
213 
215  double mInterval;
218  double mOffset;
221 };
222 
223 #endif
void setIntervalUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit customDashPatternUnit() const
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:89
QgsSymbolV2::OutputUnit intervalUnit() const
#define DEFAULT_SIMPLELINE_PENSTYLE
#define DEFAULT_MARKERLINE_ROTATE
virtual QgsSymbolV2::OutputUnit outputUnit() const
virtual void setOutputUnit(QgsSymbolV2::OutputUnit unit)
virtual Qt::PenStyle dxfPenStyle() const
virtual QgsSymbolLayerV2 * clone() const =0
virtual double width() const
#define DEFAULT_MARKERLINE_INTERVAL
void setCustomDashPatternUnit(QgsSymbolV2::OutputUnit unit)
QVector< qreal > customDashVector() const
void setPenJoinStyle(Qt::PenJoinStyle style)
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
QMap< QString, QString > QgsStringMap
Definition: qgis.h:416
Qt::PenStyle penStyle() const
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
virtual void startRender(QgsSymbolV2RenderContext &context)=0
void setInterval(double interval)
QgsSymbolV2::OutputUnit mOffsetUnit
void setDrawInsidePolygon(bool drawInsidePolygon)
QgsSymbolV2::OutputUnit mIntervalUnit
virtual void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
virtual QVector< qreal > dxfCustomDashPattern(QgsSymbolV2::OutputUnit &unit) const
QVector< qreal > mCustomDashVector
Vector with an even number of entries for the.
#define DEFAULT_SIMPLELINE_WIDTH
virtual void setWidth(double width)
virtual QgsStringMap properties() const =0
virtual void renderPolygonOutline(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
void setPenCapStyle(Qt::PenCapStyle style)
void setCustomDashVector(const QVector< qreal > &vector)
QgsSymbolV2::OutputUnit offsetUnit() const
virtual QColor dxfColor(const QgsSymbolV2RenderContext &context) const
virtual void renderPolyline(const QPolygonF &points, QgsSymbolV2RenderContext &context)=0
QgsSymbolV2::OutputUnit mCustomDashPatternUnit
virtual QString layerType() const =0
virtual QgsSymbolV2 * subSymbol()
#define DEFAULT_SIMPLELINE_COLOR
void setPenStyle(Qt::PenStyle style)
virtual void setColor(const QColor &color)
QgsSymbolV2::OutputUnit mOffsetUnit
virtual double dxfWidth(const QgsDxfExport &e, const QgsSymbolV2RenderContext &context) const
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
QgsSymbolV2::OutputUnit offsetUnit() const
Qt::PenJoinStyle penJoinStyle() const
Qt::PenCapStyle penCapStyle() const