QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
26 {
27  public:
29  {
30  Cartesian = 0,
32  Height
33  };
34 
36  {
37  ClockwiseFromNorth = 0,
38  CounterclockwiseFromEast
39  };
40 
42  {
43  Degrees = 0,
44  Radians
45  };
46 
49 
50  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
51  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
52 
53  QString layerType() const override { return "VectorField"; }
54 
55  bool setSubSymbol( QgsSymbolV2* symbol ) override;
56  QgsSymbolV2* subSymbol() override { return mLineSymbol; }
57 
58  void setColor( const QColor& color ) override;
59  virtual QColor color() const override;
60 
61  void renderPoint( QPointF point, QgsSymbolV2RenderContext& context ) override;
62  void startRender( QgsSymbolV2RenderContext& context ) override;
63  void stopRender( QgsSymbolV2RenderContext& context ) override;
64 
65  QgsVectorFieldSymbolLayer* clone() const override;
66  QgsStringMap properties() const override;
67 
69  void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
70 
71  void drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size ) override;
72 
73  QSet<QString> usedAttributes() const override;
74 
75  //setters and getters
76  void setXAttribute( const QString& attribute ) { mXAttribute = attribute; }
77  QString xAttribute() const { return mXAttribute; }
78  void setYAttribute( const QString& attribute ) { mYAttribute = attribute; }
79  QString yAttribute() const { return mYAttribute; }
80  void setScale( double s ) { mScale = s; }
81  double scale() const { return mScale; }
82  void setVectorFieldType( VectorFieldType type ) { mVectorFieldType = type; }
83  VectorFieldType vectorFieldType() const { return mVectorFieldType; }
84  void setAngleOrientation( AngleOrientation orientation ) { mAngleOrientation = orientation; }
85  AngleOrientation angleOrientation() const { return mAngleOrientation; }
86  void setAngleUnits( AngleUnits units ) { mAngleUnits = units; }
87  AngleUnits angleUnits() const { return mAngleUnits; }
88 
89  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
90  QgsSymbolV2::OutputUnit outputUnit() const override;
91 
92  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
93  QgsMapUnitScale mapUnitScale() const override;
94 
95  void setDistanceUnit( QgsSymbolV2::OutputUnit unit ) { mDistanceUnit = unit; }
96  QgsSymbolV2::OutputUnit distanceUnit() const { return mDistanceUnit; }
97 
98  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
99  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
100 
101  private:
102  QString mXAttribute;
103  QString mYAttribute;
104  QgsSymbolV2::OutputUnit mDistanceUnit;
105  QgsMapUnitScale mDistanceMapUnitScale;
106  double mScale;
107  VectorFieldType mVectorFieldType;
108  AngleOrientation mAngleOrientation;
109  AngleUnits mAngleUnits;
110 
111  QgsLineSymbolV2* mLineSymbol;
112 
113  //Attribute indices are resolved in startRender method
114  int mXIndex;
115  int mYIndex;
116 
117  //Converts length/angle to cartesian x/y
118  void convertPolarToCartesian( double length, double angle, double& x, double& y ) const;
119 };
120 
121 #endif // QGSVECTORFIELDSYMBOLLAYER_H
122 
123 
virtual void renderPoint(QPointF point, QgsSymbolV2RenderContext &context)=0
Renders a marker at the specified point.
void setXAttribute(const QString &attribute)
QgsSymbolV2::OutputUnit outputUnit() const override
QgsSymbolV2 * subSymbol() override
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
void setYAttribute(const QString &attribute)
virtual QgsSymbolLayerV2 * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setAngleUnits(AngleUnits units)
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
AngleOrientation angleOrientation() const
QgsSymbolV2::OutputUnit distanceUnit() const
QMap< QString, QString > QgsStringMap
Definition: qgis.h:492
void setMapUnitScale(const QgsMapUnitScale &scale) override
QString layerType() const override
Returns a string that represents this layer type.
A symbol layer class for displaying displacement arrows based on point layer attributes.
const QgsMapUnitScale & distanceMapUnitScale() const
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
virtual QColor color() const
The fill color.
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 startRender(QgsSymbolV2RenderContext &context) override
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
Struct for storing maximum and minimum scales for measurements in map units.
QgsMapUnitScale mapUnitScale() const override
void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size) override
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
void setAngleOrientation(AngleOrientation orientation)
virtual void setColor(const QColor &color)
The fill color.
Abstract base class for marker symbol layers.
VectorFieldType vectorFieldType() const
QgsSymbolV2::SymbolType type() const
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
set layer&#39;s subsymbol. takes ownership of the passed symbol
void setVectorFieldType(VectorFieldType type)
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override