QGIS API Documentation  2.99.0-Master (9ed189e)
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 "qgis_core.h"
22 #include "qgssymbollayer.h"
23 
27 {
28  public:
30  {
31  Cartesian = 0,
33  Height
34  };
35 
37  {
38  ClockwiseFromNorth = 0,
39  CounterclockwiseFromEast
40  };
41 
43  {
44  Degrees = 0,
45  Radians
46  };
47 
50 
51  static QgsSymbolLayer* create( const QgsStringMap& properties = QgsStringMap() );
52  static QgsSymbolLayer* createFromSld( QDomElement &element );
53 
54  QString layerType() const override { return QStringLiteral( "VectorField" ); }
55 
56  bool setSubSymbol( QgsSymbol* symbol ) override;
57  QgsSymbol* subSymbol() override { return mLineSymbol; }
58 
59  void setColor( const QColor& color ) override;
60  virtual QColor color() const override;
61 
62  void renderPoint( QPointF point, QgsSymbolRenderContext& context ) override;
63  void startRender( QgsSymbolRenderContext& context ) override;
64  void stopRender( QgsSymbolRenderContext& context ) override;
65 
66  QgsVectorFieldSymbolLayer* clone() const override;
67  QgsStringMap properties() const override;
68 
69  void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
70 
71  void drawPreviewIcon( QgsSymbolRenderContext& context, QSize size ) override;
72 
73  QSet<QString> usedAttributes( const QgsRenderContext& context ) 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( QgsUnitTypes::RenderUnit unit ) override;
90  QgsUnitTypes::RenderUnit outputUnit() const override;
91 
92  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
93  QgsMapUnitScale mapUnitScale() const override;
94 
99  void setDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mDistanceUnit = unit; }
100 
104  QgsUnitTypes::RenderUnit distanceUnit() const { return mDistanceUnit; }
105 
106  void setDistanceMapUnitScale( const QgsMapUnitScale& scale ) { mDistanceMapUnitScale = scale; }
107  const QgsMapUnitScale& distanceMapUnitScale() const { return mDistanceMapUnitScale; }
108 
109  // TODO - implement properly
110  virtual QRectF bounds( QPointF, QgsSymbolRenderContext& ) override { return QRectF(); }
111 
112  private:
113  QString mXAttribute;
114  QString mYAttribute;
115  QgsUnitTypes::RenderUnit mDistanceUnit;
116  QgsMapUnitScale mDistanceMapUnitScale;
117  double mScale;
118  VectorFieldType mVectorFieldType;
119  AngleOrientation mAngleOrientation;
120  AngleUnits mAngleUnits;
121 
122  QgsLineSymbol* mLineSymbol = nullptr;
123 
124  //Attribute indices are resolved in startRender method
125  int mXIndex;
126  int mYIndex;
127 
128  //Converts length/angle to cartesian x/y
129  void convertPolarToCartesian( double length, double angle, double& x, double& y ) const;
130 };
131 
132 #endif // QGSVECTORFIELDSYMBOLLAYER_H
133 
134 
QgsMapUnitScale mapUnitScale() const override
void setXAttribute(const QString &attribute)
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:330
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.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Contains information about the context of a rendering operation.
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:92
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override