QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgsvectorfieldsymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorfieldsymbollayer.h
3  -------------------------
4  begin : Octorer 25, 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSVECTORFIELDSYMBOLLAYER_H
19 #define QGSVECTORFIELDSYMBOLLAYER_H
20 
21 #include "qgssymbollayerv2.h"
22 
25 {
26  public:
28  {
29  Cartesian = 0,
31  Height
32  };
33 
35  {
36  ClockwiseFromNorth = 0,
37  CounterclockwiseFromEast
38  };
39 
41  {
42  Degrees = 0,
43  Radians
44  };
45 
48 
49  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
50  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
51 
52  QString layerType() const { return "VectorField"; }
53 
54  bool setSubSymbol( QgsSymbolV2* symbol );
55  QgsSymbolV2* subSymbol() { return mLineSymbol; }
56 
57  void renderPoint( const QPointF& point, QgsSymbolV2RenderContext& context );
58  void startRender( QgsSymbolV2RenderContext& context );
59  void stopRender( QgsSymbolV2RenderContext& context );
60 
61  QgsSymbolLayerV2* clone() const;
62  QgsStringMap properties() const;
63 
64  void toSld( QDomDocument& doc, QDomElement &element, QgsStringMap props ) const;
65 
66  void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size );
67 
68  QSet<QString> usedAttributes() const;
69 
70  //setters and getters
71  void setXAttribute( const QString& attribute ) { mXAttribute = attribute; }
72  QString xAttribute() const { return mXAttribute; }
73  void setYAttribute( const QString& attribute ) { mYAttribute = attribute; }
74  QString yAttribute() const { return mYAttribute; }
75  void setScale( double s ) { mScale = s; }
76  double scale() const { return mScale; }
77  void setVectorFieldType( VectorFieldType type ) { mVectorFieldType = type; }
78  VectorFieldType vectorFieldType() const { return mVectorFieldType; }
79  void setAngleOrientation( AngleOrientation orientation ) { mAngleOrientation = orientation; }
80  AngleOrientation angleOrientation() const { return mAngleOrientation; }
81  void setAngleUnits( AngleUnits units ) { mAngleUnits = units; }
82  AngleUnits angleUnits() const { return mAngleUnits; }
83 
86 
87  void setMapUnitScale( const QgsMapUnitScale& scale );
89 
90  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
91  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
92 
93  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
94  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
95 
96  private:
97  QString mXAttribute;
98  QString mYAttribute;
99  QgsSymbolV2::OutputUnit mDistanceUnit;
100  QgsMapUnitScale mDistanceMapUnitScale;
101  double mScale;
102  VectorFieldType mVectorFieldType;
103  AngleOrientation mAngleOrientation;
104  AngleUnits mAngleUnits;
105 
106  QgsLineSymbolV2* mLineSymbol;
107 
108  //Attribute indices are resolved in startRender method
109  int mXIndex;
110  int mYIndex;
111 
112  //Converts length/angle to cartesian x/y
113  void convertPolarToCartesian( double length, double angle, double& x, double& y ) const;
114 };
115 
116 #endif // QGSVECTORFIELDSYMBOLLAYER_H
117 
118 
virtual QSet< QString > usedAttributes() const
Definition: qgssymbollayerv2.cpp:153
void setScale(double s)
Definition: qgsvectorfieldsymbollayer.h:75
void setXAttribute(const QString &attribute)
Definition: qgsvectorfieldsymbollayer.h:71
OutputUnit
Definition: qgssymbolv2.h:47
QString xAttribute() const
Definition: qgsvectorfieldsymbollayer.h:72
QgsSymbolV2::OutputUnit outputUnit() const
Definition: qgssymbollayerv2.cpp:356
void setYAttribute(const QString &attribute)
Definition: qgsvectorfieldsymbollayer.h:73
virtual QgsSymbolLayerV2 * clone() const =0
void setMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgssymbollayerv2.cpp:365
void setAngleUnits(AngleUnits units)
Definition: qgsvectorfieldsymbollayer.h:81
VectorFieldType
Definition: qgsvectorfieldsymbollayer.h:27
void startRender(QgsSymbolV2RenderContext &context)
Definition: qgssymbollayerv2.cpp:230
virtual void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
Definition: qgssymbollayerv2.cpp:480
AngleOrientation angleOrientation() const
Definition: qgsvectorfieldsymbollayer.h:80
const QgsMapUnitScale & distanceMapUnitScale() const
Definition: qgsvectorfieldsymbollayer.h:94
Definition: qgssymbollayerv2.h:45
void setOutputUnit(QgsSymbolV2::OutputUnit unit)
Definition: qgssymbollayerv2.cpp:350
VectorFieldType vectorFieldType() const
Definition: qgsvectorfieldsymbollayer.h:78
QMap< QString, QString > QgsStringMap
Definition: qgis.h:416
AngleOrientation
Definition: qgsvectorfieldsymbollayer.h:34
double scale() const
Definition: qgsvectorfieldsymbollayer.h:76
A symbol layer class for displaying displacement arrows based on point layer attributes.
Definition: qgsvectorfieldsymbollayer.h:24
virtual void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context)=0
Definition: qgssymbolv2.h:256
virtual QgsStringMap properties() const =0
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsvectorfieldsymbollayer.h:93
Definition: qgssymbolv2.h:43
QgsMapUnitScale mapUnitScale() const
Definition: qgssymbollayerv2.cpp:371
Definition: qgsvectorfieldsymbollayer.h:30
QgsSymbolV2::SymbolType type() const
Definition: qgssymbollayerv2.h:87
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size)
Definition: qgssymbollayerv2.cpp:238
QgsSymbolV2::OutputUnit distanceUnit() const
Definition: qgsvectorfieldsymbollayer.h:91
QString yAttribute() const
Definition: qgsvectorfieldsymbollayer.h:74
QString layerType() const
Definition: qgsvectorfieldsymbollayer.h:52
AngleUnits
Definition: qgsvectorfieldsymbollayer.h:40
Definition: qgsmapunitscale.h:24
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
Definition: qgsvectorfieldsymbollayer.h:90
void setAngleOrientation(AngleOrientation orientation)
Definition: qgsvectorfieldsymbollayer.h:79
Definition: qgssymbollayerv2.h:160
Definition: qgssymbolv2.h:167
double size
Definition: qgssvgcache.cpp:77
AngleUnits angleUnits() const
Definition: qgsvectorfieldsymbollayer.h:82
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
Definition: qgssymbollayerv2.h:85
void setVectorFieldType(VectorFieldType type)
Definition: qgsvectorfieldsymbollayer.h:77
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
QgsSymbolV2 * subSymbol()
Definition: qgsvectorfieldsymbollayer.h:55