QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsarrowsymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsarrowsymbollayer.h
3  ---------------------
4  begin : January 2016
5  copyright : (C) 2016 by Hugo Mercier
6  email : hugo dot mercier at oslandia 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 QGSARROWSYMBOLLAYERV2_H
17 #define QGSARROWSYMBOLLAYERV2_H
18 
19 #include "qgssymbollayerv2.h"
20 
21 
28 class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayerV2
29 {
30  public:
33 
41  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
42 
44  virtual QgsArrowSymbolLayer* clone() const override;
45 
47  virtual QgsSymbolV2* subSymbol() override { return mSymbol.data(); }
48 
50  virtual bool setSubSymbol( QgsSymbolV2* symbol ) override;
51 
53  virtual QSet<QString> usedAttributes() const override;
54 
56  double arrowWidth() const { return mArrowWidth; }
58  void setArrowWidth( double width ) { mArrowWidth = width; }
60  QgsSymbolV2::OutputUnit arrowWidthUnit() const { return mArrowWidthUnit; }
62  void setArrowWidthUnit( QgsSymbolV2::OutputUnit unit ) { mArrowWidthUnit = unit; }
64  QgsMapUnitScale arrowWidthUnitScale() const { return mArrowWidthUnitScale; }
66  void setArrowWidthUnitScale( const QgsMapUnitScale& scale ) { mArrowWidthUnitScale = scale; }
67 
69  double arrowStartWidth() const { return mArrowStartWidth; }
71  void setArrowStartWidth( double width ) { mArrowStartWidth = width; }
73  QgsSymbolV2::OutputUnit arrowStartWidthUnit() const { return mArrowStartWidthUnit; }
75  void setArrowStartWidthUnit( QgsSymbolV2::OutputUnit unit ) { mArrowStartWidthUnit = unit; }
77  QgsMapUnitScale arrowStartWidthUnitScale() const { return mArrowStartWidthUnitScale; }
79  void setArrowStartWidthUnitScale( const QgsMapUnitScale& scale ) { mArrowStartWidthUnitScale = scale; }
80 
82  double headLength() const { return mHeadLength; }
84  void setHeadLength( double length ) { mHeadLength = length; }
86  QgsSymbolV2::OutputUnit headLengthUnit() const { return mHeadLengthUnit; }
88  void setHeadLengthUnit( QgsSymbolV2::OutputUnit unit ) { mHeadLengthUnit = unit; }
90  QgsMapUnitScale headLengthUnitScale() const { return mHeadLengthUnitScale; }
92  void setHeadLengthUnitScale( const QgsMapUnitScale& scale ) { mHeadLengthUnitScale = scale; }
93 
95  double headThickness() const { return mHeadThickness; }
97  void setHeadThickness( double thickness ) { mHeadThickness = thickness; }
99  QgsSymbolV2::OutputUnit headThicknessUnit() const { return mHeadThicknessUnit; }
101  void setHeadThicknessUnit( QgsSymbolV2::OutputUnit unit ) { mHeadThicknessUnit = unit; }
103  QgsMapUnitScale headThicknessUnitScale() const { return mHeadThicknessUnitScale; }
105  void setHeadThicknessUnitScale( const QgsMapUnitScale& scale ) { mHeadThicknessUnitScale = scale; }
106 
108  bool isCurved() const { return mIsCurved; }
110  void setIsCurved( bool isCurved ) { mIsCurved = isCurved; }
111 
113  bool isRepeated() const { return mIsRepeated; }
115  void setIsRepeated( bool isRepeated ) { mIsRepeated = isRepeated; }
116 
118  enum HeadType
119  {
120  HeadSingle, //< One single head at the end
121  HeadReversed, //< One single head at the beginning
122  HeadDouble //< Two heads
123  };
124 
126  HeadType headType() const { return mHeadType; }
128  void setHeadType( HeadType type ) { mHeadType = type; }
129 
132  {
133  ArrowPlain, //< Regular arrow
134  ArrowLeftHalf, //< Halved arrow, only the left side of the arrow is rendered (for straight arrows) or the side toward the exterior (for curved arrows)
135  ArrowRightHalf //< Halved arrow, only the right side of the arrow is rendered (for straight arrows) or the side toward the interior (for curved arrows)
136  };
137 
139  ArrowType arrowType() const { return mArrowType; }
141  void setArrowType( ArrowType type ) { mArrowType = type; }
142 
148  QgsStringMap properties() const override;
149 
154  QString layerType() const override;
155 
157  void startRender( QgsSymbolV2RenderContext& context ) override;
158 
160  void stopRender( QgsSymbolV2RenderContext& context ) override;
161 
163  void renderPolyline( const QPolygonF& points, QgsSymbolV2RenderContext& context ) override;
164 
165  void setColor( const QColor& c ) override;
166  virtual QColor color() const override;
167 
168  private:
171 
172  double mArrowWidth;
173  QgsSymbolV2::OutputUnit mArrowWidthUnit;
174  QgsMapUnitScale mArrowWidthUnitScale;
175 
176  double mArrowStartWidth;
177  QgsSymbolV2::OutputUnit mArrowStartWidthUnit;
178  QgsMapUnitScale mArrowStartWidthUnitScale;
179 
180  double mHeadLength;
181  QgsSymbolV2::OutputUnit mHeadLengthUnit;
182  QgsMapUnitScale mHeadLengthUnitScale;
183  double mHeadThickness;
184  QgsSymbolV2::OutputUnit mHeadThicknessUnit;
185  QgsMapUnitScale mHeadThicknessUnitScale;
186 
187  HeadType mHeadType;
188  ArrowType mArrowType;
189  bool mIsCurved;
190  bool mIsRepeated;
191 
192  double mScaledArrowWidth;
193  double mScaledArrowStartWidth;
194  double mScaledHeadLength;
195  double mScaledHeadThickness;
196  double mScaledOffset;
197  HeadType mComputedHeadType;
198  ArrowType mComputedArrowType;
199 
201 
202  void _resolveDataDefined( QgsSymbolV2RenderContext& );
203 };
204 
205 #endif
206 
207 
void setHeadThicknessUnitScale(const QgsMapUnitScale &scale)
Set the scale for the head height.
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
virtual QgsSymbolLayerV2 * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
double arrowStartWidth() const
Get current arrow start width.
double arrowWidth() const
Get current arrow width.
QgsSymbolV2::OutputUnit headThicknessUnit() const
Get the unit for the head height.
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
QgsMapUnitScale arrowStartWidthUnitScale() const
Get the scale for the arrow start width.
QgsMapUnitScale headLengthUnitScale() const
Get the scale for the head length.
void setArrowWidthUnit(QgsSymbolV2::OutputUnit unit)
Set the unit for the arrow width.
ArrowType arrowType() const
Get the current arrow type.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:492
virtual void startRender(QgsSymbolV2RenderContext &context)=0
bool isRepeated() const
Return whether the arrow is repeated along the line or not.
virtual double width() const
void setHeadLength(double length)
Set the arrow head length.
void setHeadThickness(double thickness)
Set the arrow head height.
virtual QgsSymbolV2 * subSymbol() override
Get the sub symbol used for filling.
void setHeadThicknessUnit(QgsSymbolV2::OutputUnit unit)
Set the unit for the head height.
void setArrowWidth(double width)
Set the arrow width.
ArrowType
Possible arrow types.
bool isCurved() const
Return whether it is a curved arrow or a straight one.
double headLength() const
Get the current arrow head length.
void setIsRepeated(bool isRepeated)
Set whether the arrow is repeated along the line.
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale arrowWidthUnitScale() const
Get the scale for the arrow width.
virtual QColor color() const
The fill color.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolV2RenderContext &context)=0
virtual QString layerType() const =0
Returns a string that represents this layer type.
void setIsCurved(bool isCurved)
Set whether it is a curved arrow or a straight one.
void setHeadLengthUnitScale(const QgsMapUnitScale &scale)
Set the scale for the head length.
void setArrowType(ArrowType type)
Set the arrow type.
Struct for storing maximum and minimum scales for measurements in map units.
QgsSymbolV2::OutputUnit headLengthUnit() const
Get the unit for the head length.
void setArrowWidthUnitScale(const QgsMapUnitScale &scale)
Set the scale for the arrow width.
void setArrowStartWidthUnit(QgsSymbolV2::OutputUnit unit)
Set the unit for the arrow start width.
void setHeadType(HeadType type)
Set the head type.
virtual void setColor(const QColor &color)
The fill color.
QgsSymbolV2::OutputUnit arrowStartWidthUnit() const
Get the unit for the arrow start width.
void setHeadLengthUnit(QgsSymbolV2::OutputUnit unit)
Set the unit for the head length.
QgsMapUnitScale headThicknessUnitScale() const
Get the scale for the head height.
Line symbol layer used for representing lines as arrows.
HeadType
Possible head types.
QgsSymbolV2::OutputUnit arrowWidthUnit() const
Get the unit for the arrow width.
QgsSymbolV2::SymbolType type() const
HeadType headType() const
Get the current head type.
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
set layer&#39;s subsymbol. takes ownership of the passed symbol
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void setArrowStartWidth(double width)
Set the arrow start width.
void setArrowStartWidthUnitScale(const QgsMapUnitScale &scale)
Set the scale for the arrow start width.
double headThickness() const
Get the current arrow head height.