QGIS API Documentation  2.99.0-Master (6a61179)
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 "qgssymbollayer.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 QgsSymbolLayer* create( const QgsStringMap& properties = QgsStringMap() );
51  static QgsSymbolLayer* createFromSld( QDomElement &element );
52 
53  QString layerType() const override { return QStringLiteral( "VectorField" ); }
54 
55  bool setSubSymbol( QgsSymbol* symbol ) override;
56  QgsSymbol* subSymbol() override { return mLineSymbol; }
57 
58  void setColor( const QColor& color ) override;
59  virtual QColor color() const override;
60 
61  void renderPoint( QPointF point, QgsSymbolRenderContext& context ) override;
62  void startRender( QgsSymbolRenderContext& context ) override;
63  void stopRender( QgsSymbolRenderContext& context ) override;
64 
65  QgsVectorFieldSymbolLayer* clone() const override;
66  QgsStringMap properties() const override;
67 
68  void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
69 
70  void drawPreviewIcon( QgsSymbolRenderContext& context, QSize size ) override;
71 
72  QSet<QString> usedAttributes() const override;
73 
74  //setters and getters
75  void setXAttribute( const QString& attribute ) { mXAttribute = attribute; }
76  QString xAttribute() const { return mXAttribute; }
77  void setYAttribute( const QString& attribute ) { mYAttribute = attribute; }
78  QString yAttribute() const { return mYAttribute; }
79  void setScale( double s ) { mScale = s; }
80  double scale() const { return mScale; }
81  void setVectorFieldType( VectorFieldType type ) { mVectorFieldType = type; }
82  VectorFieldType vectorFieldType() const { return mVectorFieldType; }
83  void setAngleOrientation( AngleOrientation orientation ) { mAngleOrientation = orientation; }
84  AngleOrientation angleOrientation() const { return mAngleOrientation; }
85  void setAngleUnits( AngleUnits units ) { mAngleUnits = units; }
86  AngleUnits angleUnits() const { return mAngleUnits; }
87 
88  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
89  QgsUnitTypes::RenderUnit outputUnit() const override;
90 
91  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
92  QgsMapUnitScale mapUnitScale() const override;
93 
98  void setDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceUnit = unit; }
99 
103  QgsUnitTypes::RenderUnit distanceUnit() const { return mDistanceUnit; }
104 
105  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
106  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
107 
108  // TODO - implement properly
109  virtual QRectF bounds( QPointF, QgsSymbolRenderContext& ) override { return QRectF(); }
110 
111  private:
112  QString mXAttribute;
113  QString mYAttribute;
114  QgsUnitTypes::RenderUnit mDistanceUnit;
115  QgsMapUnitScale mDistanceMapUnitScale;
116  double mScale;
117  VectorFieldType mVectorFieldType;
118  AngleOrientation mAngleOrientation;
119  AngleUnits mAngleUnits;
120 
121  QgsLineSymbol* mLineSymbol;
122 
123  //Attribute indices are resolved in startRender method
124  int mXIndex;
125  int mYIndex;
126 
127  //Converts length/angle to cartesian x/y
128  void convertPolarToCartesian( double length, double angle, double& x, double& y ) const;
129 };
130 
131 #endif // QGSVECTORFIELDSYMBOLLAYER_H
132 
133 
QgsMapUnitScale mapUnitScale() const override
void setXAttribute(const QString &attribute)
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
void setYAttribute(const QString &attribute)
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setAngleUnits(AngleUnits units)
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the distance.
virtual QRectF bounds(QPointF, QgsSymbolRenderContext &) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
AngleOrientation angleOrientation() const
void startRender(QgsSymbolRenderContext &context) override
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QMap< QString, QString > QgsStringMap
Definition: qgis.h:328
QString layerType() const override
Returns a string that represents this layer type.
virtual void setColor(const QColor &color)
The fill color.
A symbol layer class for displaying displacement arrows based on point layer attributes.
virtual bool setSubSymbol(QgsSymbol *symbol)
set layer&#39;s subsymbol. takes ownership of the passed symbol
const QgsMapUnitScale & distanceMapUnitScale() const
QgsSymbol * subSymbol() override
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QColor color() const
The fill color.
QgsSymbol::SymbolType type() const
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the units for the distance.
Abstract base class for marker symbol layers.
Struct for storing maximum and minimum scales for measurements in map units.
virtual void stopRender(QgsSymbolRenderContext &context)=0
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setAngleOrientation(AngleOrientation orientation)
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
VectorFieldType vectorFieldType() const
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)
Definition: MathUtils.cc:857
void setVectorFieldType(VectorFieldType type)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:91
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override