QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 QGSARROWSYMBOLLAYER_H
17 #define QGSARROWSYMBOLLAYER_H
18 
19 #include "qgis_core.h"
20 #include "qgis.h"
21 #include "qgssymbollayer.h"
22 
23 
31 class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
32 {
33  public:
36 
44  static QgsSymbolLayer *create( const QgsStringMap &properties = QgsStringMap() ) SIP_FACTORY;
45 
46  QgsArrowSymbolLayer *clone() const override SIP_FACTORY;
47  QgsSymbol *subSymbol() override { return mSymbol.get(); }
48  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
49  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
50  bool hasDataDefinedProperties() const override;
51 
53  double arrowWidth() const { return mArrowWidth; }
55  void setArrowWidth( double width ) { mArrowWidth = width; }
57  QgsUnitTypes::RenderUnit arrowWidthUnit() const { return mArrowWidthUnit; }
59  void setArrowWidthUnit( QgsUnitTypes::RenderUnit unit ) { mArrowWidthUnit = unit; }
61  QgsMapUnitScale arrowWidthUnitScale() const { return mArrowWidthUnitScale; }
63  void setArrowWidthUnitScale( const QgsMapUnitScale &scale ) { mArrowWidthUnitScale = scale; }
64 
66  double arrowStartWidth() const { return mArrowStartWidth; }
68  void setArrowStartWidth( double width ) { mArrowStartWidth = width; }
70  QgsUnitTypes::RenderUnit arrowStartWidthUnit() const { return mArrowStartWidthUnit; }
72  void setArrowStartWidthUnit( QgsUnitTypes::RenderUnit unit ) { mArrowStartWidthUnit = unit; }
74  QgsMapUnitScale arrowStartWidthUnitScale() const { return mArrowStartWidthUnitScale; }
76  void setArrowStartWidthUnitScale( const QgsMapUnitScale &scale ) { mArrowStartWidthUnitScale = scale; }
77 
79  double headLength() const { return mHeadLength; }
81  void setHeadLength( double length ) { mHeadLength = length; }
83  QgsUnitTypes::RenderUnit headLengthUnit() const { return mHeadLengthUnit; }
85  void setHeadLengthUnit( QgsUnitTypes::RenderUnit unit ) { mHeadLengthUnit = unit; }
87  QgsMapUnitScale headLengthUnitScale() const { return mHeadLengthUnitScale; }
89  void setHeadLengthUnitScale( const QgsMapUnitScale &scale ) { mHeadLengthUnitScale = scale; }
90 
92  double headThickness() const { return mHeadThickness; }
94  void setHeadThickness( double thickness ) { mHeadThickness = thickness; }
96  QgsUnitTypes::RenderUnit headThicknessUnit() const { return mHeadThicknessUnit; }
98  void setHeadThicknessUnit( QgsUnitTypes::RenderUnit unit ) { mHeadThicknessUnit = unit; }
100  QgsMapUnitScale headThicknessUnitScale() const { return mHeadThicknessUnitScale; }
102  void setHeadThicknessUnitScale( const QgsMapUnitScale &scale ) { mHeadThicknessUnitScale = scale; }
103 
105  bool isCurved() const { return mIsCurved; }
107  void setIsCurved( bool isCurved ) { mIsCurved = isCurved; }
108 
110  bool isRepeated() const { return mIsRepeated; }
112  void setIsRepeated( bool isRepeated ) { mIsRepeated = isRepeated; }
113 
115  enum HeadType
116  {
117  HeadSingle, //< One single head at the end
118  HeadReversed, //< One single head at the beginning
119  HeadDouble //< Two heads
120  };
121 
123  HeadType headType() const { return mHeadType; }
125  void setHeadType( HeadType type ) { mHeadType = type; }
126 
129  {
130  ArrowPlain, //< Regular arrow
131  ArrowLeftHalf, //< Halved arrow, only the left side of the arrow is rendered (for straight arrows) or the side toward the exterior (for curved arrows)
132  ArrowRightHalf //< Halved arrow, only the right side of the arrow is rendered (for straight arrows) or the side toward the interior (for curved arrows)
133  };
134 
136  ArrowType arrowType() const { return mArrowType; }
138  void setArrowType( ArrowType type ) { mArrowType = type; }
139 
140  QgsStringMap properties() const override;
141  QString layerType() const override;
142  void startRender( QgsSymbolRenderContext &context ) override;
143  void stopRender( QgsSymbolRenderContext &context ) override;
144  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
145  void setColor( const QColor &c ) override;
146  QColor color() const override;
147 
148  private:
149 #ifdef SIP_RUN
151 #endif
152 
154  std::unique_ptr<QgsFillSymbol> mSymbol;
155 
156  double mArrowWidth = 1.0;
158  QgsMapUnitScale mArrowWidthUnitScale;
159 
160  double mArrowStartWidth = 1.0;
162  QgsMapUnitScale mArrowStartWidthUnitScale;
163 
164  double mHeadLength = 1.5;
166  QgsMapUnitScale mHeadLengthUnitScale;
167  double mHeadThickness = 1.5;
169  QgsMapUnitScale mHeadThicknessUnitScale;
170 
171  HeadType mHeadType = HeadSingle;
172  ArrowType mArrowType = ArrowPlain;
173  bool mIsCurved = true;
174  bool mIsRepeated = true;
175 
176  double mScaledArrowWidth = 1.0;
177  double mScaledArrowStartWidth = 1.0;
178  double mScaledHeadLength = 1.5;
179  double mScaledHeadThickness = 1.5;
180  double mScaledOffset = 0.0;
181  HeadType mComputedHeadType = HeadSingle;
182  ArrowType mComputedArrowType = ArrowPlain;
183 
184  std::unique_ptr<QgsExpressionContextScope> mExpressionScope;
185 
186  void _resolveDataDefined( QgsSymbolRenderContext & );
187 };
188 
189 #endif
190 
191 
QgsArrowSymbolLayer::headThicknessUnitScale
QgsMapUnitScale headThicknessUnitScale() const
Gets the scale for the head height.
Definition: qgsarrowsymbollayer.h:100
QgsLineSymbolLayer
Definition: qgssymbollayer.h:894
QgsArrowSymbolLayer::ArrowType
ArrowType
Possible arrow types.
Definition: qgsarrowsymbollayer.h:128
QgsSymbolLayer::setSubSymbol
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Definition: qgssymbollayer.h:351
QgsArrowSymbolLayer::headType
HeadType headType() const
Gets the current head type.
Definition: qgsarrowsymbollayer.h:123
QgsArrowSymbolLayer::HeadSingle
@ HeadSingle
Definition: qgsarrowsymbollayer.h:117
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:166
QgsLineSymbolLayer::renderPolyline
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Renders the line symbol layer along the line joining points, using the given render context.
QgsLineSymbolLayer::width
virtual double width() const
Returns the estimated width for the line symbol layer.
Definition: qgssymbollayer.h:959
QgsArrowSymbolLayer::arrowStartWidthUnit
QgsUnitTypes::RenderUnit arrowStartWidthUnit() const
Gets the unit for the arrow start width.
Definition: qgsarrowsymbollayer.h:70
QgsArrowSymbolLayer::setArrowStartWidth
void setArrowStartWidth(double width)
Sets the arrow start width.
Definition: qgsarrowsymbollayer.h:68
QgsArrowSymbolLayer::setHeadThicknessUnit
void setHeadThicknessUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the head height.
Definition: qgsarrowsymbollayer.h:98
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
The fill color.
Definition: qgssymbollayer.h:231
QgsSymbolLayer::color
virtual QColor color() const
The fill color.
Definition: qgssymbollayer.h:226
QgsArrowSymbolLayer::setHeadLengthUnit
void setHeadLengthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the head length.
Definition: qgsarrowsymbollayer.h:85
QgsArrowSymbolLayer::arrowWidthUnit
QgsUnitTypes::RenderUnit arrowWidthUnit() const
Gets the unit for the arrow width.
Definition: qgsarrowsymbollayer.h:57
QgsArrowSymbolLayer::HeadReversed
@ HeadReversed
Definition: qgsarrowsymbollayer.h:118
QgsSymbolLayer::hasDataDefinedProperties
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Definition: qgssymbollayer.cpp:215
qgis.h
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsArrowSymbolLayer::headLengthUnit
QgsUnitTypes::RenderUnit headLengthUnit() const
Gets the unit for the head length.
Definition: qgsarrowsymbollayer.h:83
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsSymbol
Definition: qgssymbol.h:63
QgsArrowSymbolLayer::setArrowStartWidthUnitScale
void setArrowStartWidthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the arrow start width.
Definition: qgsarrowsymbollayer.h:76
QgsArrowSymbolLayer::headLength
double headLength() const
Gets the current arrow head length.
Definition: qgsarrowsymbollayer.h:79
QgsArrowSymbolLayer::setIsRepeated
void setIsRepeated(bool isRepeated)
Sets whether the arrow is repeated along the line.
Definition: qgsarrowsymbollayer.h:112
QgsArrowSymbolLayer::setHeadThicknessUnitScale
void setHeadThicknessUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the head height.
Definition: qgsarrowsymbollayer.h:102
QgsSymbolLayer::properties
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSymbolRenderContext
Definition: qgssymbol.h:681
QgsArrowSymbolLayer::setHeadThickness
void setHeadThickness(double thickness)
Sets the arrow head height.
Definition: qgsarrowsymbollayer.h:94
QgsArrowSymbolLayer
Line symbol layer used for representing lines as arrows.
Definition: qgsarrowsymbollayer.h:31
QgsSymbolLayer::clone
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolLayer
Definition: qgssymbollayer.h:52
QgsArrowSymbolLayer::subSymbol
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Definition: qgsarrowsymbollayer.h:47
QgsArrowSymbolLayer::HeadType
HeadType
Possible head types.
Definition: qgsarrowsymbollayer.h:115
QgsArrowSymbolLayer::arrowStartWidth
double arrowStartWidth() const
Gets current arrow start width. Only meaningful for single headed arrows.
Definition: qgsarrowsymbollayer.h:66
QgsArrowSymbolLayer::ArrowPlain
@ ArrowPlain
Definition: qgsarrowsymbollayer.h:130
QgsArrowSymbolLayer::headThickness
double headThickness() const
Gets the current arrow head height.
Definition: qgsarrowsymbollayer.h:92
QgsArrowSymbolLayer::setHeadLengthUnitScale
void setHeadLengthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the head length.
Definition: qgsarrowsymbollayer.h:89
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgssymbollayer.h
QgsArrowSymbolLayer::arrowStartWidthUnitScale
QgsMapUnitScale arrowStartWidthUnitScale() const
Gets the scale for the arrow start width.
Definition: qgsarrowsymbollayer.h:74
QgsArrowSymbolLayer::headThicknessUnit
QgsUnitTypes::RenderUnit headThicknessUnit() const
Gets the unit for the head height.
Definition: qgsarrowsymbollayer.h:96
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:37
QgsArrowSymbolLayer::arrowWidthUnitScale
QgsMapUnitScale arrowWidthUnitScale() const
Gets the scale for the arrow width.
Definition: qgsarrowsymbollayer.h:61
QgsArrowSymbolLayer::setHeadType
void setHeadType(HeadType type)
Sets the head type.
Definition: qgsarrowsymbollayer.h:125
QgsArrowSymbolLayer::ArrowLeftHalf
@ ArrowLeftHalf
Definition: qgsarrowsymbollayer.h:131
QgsSymbolLayer::usedAttributes
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Definition: qgssymbollayer.cpp:246
QgsArrowSymbolLayer::setArrowWidthUnitScale
void setArrowWidthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the arrow width.
Definition: qgsarrowsymbollayer.h:63
QgsArrowSymbolLayer::isCurved
bool isCurved() const
Returns whether it is a curved arrow or a straight one.
Definition: qgsarrowsymbollayer.h:105
QgsArrowSymbolLayer::setArrowType
void setArrowType(ArrowType type)
Sets the arrow type.
Definition: qgsarrowsymbollayer.h:138
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:714
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsArrowSymbolLayer::setArrowStartWidthUnit
void setArrowStartWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the arrow start width.
Definition: qgsarrowsymbollayer.h:72
QgsSymbolLayer::stopRender
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
QgsSymbolLayer::type
QgsSymbol::SymbolType type() const
Definition: qgssymbollayer.h:353
QgsSymbolLayer::layerType
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsArrowSymbolLayer::setArrowWidthUnit
void setArrowWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the arrow width.
Definition: qgsarrowsymbollayer.h:59
QgsArrowSymbolLayer::setArrowWidth
void setArrowWidth(double width)
Sets the arrow width.
Definition: qgsarrowsymbollayer.h:55
QgsSymbolLayer::startRender
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
QgsArrowSymbolLayer::isRepeated
bool isRepeated() const
Returns whether the arrow is repeated along the line or not.
Definition: qgsarrowsymbollayer.h:110
QgsArrowSymbolLayer::arrowType
ArrowType arrowType() const
Gets the current arrow type.
Definition: qgsarrowsymbollayer.h:136
QgsArrowSymbolLayer::setHeadLength
void setHeadLength(double length)
Sets the arrow head length.
Definition: qgsarrowsymbollayer.h:81
QgsArrowSymbolLayer::arrowWidth
double arrowWidth() const
Gets current arrow width.
Definition: qgsarrowsymbollayer.h:53
QgsArrowSymbolLayer::setIsCurved
void setIsCurved(bool isCurved)
Sets whether it is a curved arrow or a straight one.
Definition: qgsarrowsymbollayer.h:107
QgsArrowSymbolLayer::headLengthUnitScale
QgsMapUnitScale headLengthUnitScale() const
Gets the scale for the head length.
Definition: qgsarrowsymbollayer.h:87