QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 class QgsFillSymbol;
24 
25 
33 class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
34 {
35  public:
38  ~QgsArrowSymbolLayer() override;
39 
47  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
48 
49  QgsArrowSymbolLayer *clone() const override SIP_FACTORY;
50  QgsSymbol *subSymbol() override;
51  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
52  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
53  bool hasDataDefinedProperties() const override;
54  bool usesMapUnits() const override;
55  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
56 
58  double arrowWidth() const { return mArrowWidth; }
60  void setArrowWidth( double width ) { mArrowWidth = width; }
62  QgsUnitTypes::RenderUnit arrowWidthUnit() const { return mArrowWidthUnit; }
64  void setArrowWidthUnit( QgsUnitTypes::RenderUnit unit ) { mArrowWidthUnit = unit; }
66  QgsMapUnitScale arrowWidthUnitScale() const { return mArrowWidthUnitScale; }
68  void setArrowWidthUnitScale( const QgsMapUnitScale &scale ) { mArrowWidthUnitScale = scale; }
69 
71  double arrowStartWidth() const { return mArrowStartWidth; }
73  void setArrowStartWidth( double width ) { mArrowStartWidth = width; }
75  QgsUnitTypes::RenderUnit arrowStartWidthUnit() const { return mArrowStartWidthUnit; }
77  void setArrowStartWidthUnit( QgsUnitTypes::RenderUnit unit ) { mArrowStartWidthUnit = unit; }
79  QgsMapUnitScale arrowStartWidthUnitScale() const { return mArrowStartWidthUnitScale; }
81  void setArrowStartWidthUnitScale( const QgsMapUnitScale &scale ) { mArrowStartWidthUnitScale = scale; }
82 
84  double headLength() const { return mHeadLength; }
86  void setHeadLength( double length ) { mHeadLength = length; }
88  QgsUnitTypes::RenderUnit headLengthUnit() const { return mHeadLengthUnit; }
90  void setHeadLengthUnit( QgsUnitTypes::RenderUnit unit ) { mHeadLengthUnit = unit; }
92  QgsMapUnitScale headLengthUnitScale() const { return mHeadLengthUnitScale; }
94  void setHeadLengthUnitScale( const QgsMapUnitScale &scale ) { mHeadLengthUnitScale = scale; }
95 
97  double headThickness() const { return mHeadThickness; }
99  void setHeadThickness( double thickness ) { mHeadThickness = thickness; }
101  QgsUnitTypes::RenderUnit headThicknessUnit() const { return mHeadThicknessUnit; }
103  void setHeadThicknessUnit( QgsUnitTypes::RenderUnit unit ) { mHeadThicknessUnit = unit; }
105  QgsMapUnitScale headThicknessUnitScale() const { return mHeadThicknessUnitScale; }
107  void setHeadThicknessUnitScale( const QgsMapUnitScale &scale ) { mHeadThicknessUnitScale = scale; }
108 
110  bool isCurved() const { return mIsCurved; }
112  void setIsCurved( bool isCurved ) { mIsCurved = isCurved; }
113 
115  bool isRepeated() const { return mIsRepeated; }
117  void setIsRepeated( bool isRepeated ) { mIsRepeated = isRepeated; }
118 
120  enum HeadType
121  {
122  HeadSingle, //< One single head at the end
123  HeadReversed, //< One single head at the beginning
124  HeadDouble //< Two heads
125  };
126 
128  HeadType headType() const { return mHeadType; }
130  void setHeadType( HeadType type ) { mHeadType = type; }
131 
134  {
135  ArrowPlain, //< Regular arrow
136  ArrowLeftHalf, //< Halved arrow, only the left side of the arrow is rendered (for straight arrows) or the side toward the exterior (for curved arrows)
137  ArrowRightHalf //< Halved arrow, only the right side of the arrow is rendered (for straight arrows) or the side toward the interior (for curved arrows)
138  };
139 
141  ArrowType arrowType() const { return mArrowType; }
143  void setArrowType( ArrowType type ) { mArrowType = type; }
144 
145  QVariantMap properties() const override;
146  QString layerType() const override;
147  void startRender( QgsSymbolRenderContext &context ) override;
148  void stopRender( QgsSymbolRenderContext &context ) override;
149  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
150  void setColor( const QColor &c ) override;
151  QColor color() const override;
152  bool canCauseArtifactsBetweenAdjacentTiles() const override;
153 
154  private:
155 #ifdef SIP_RUN
157 #endif
158 
160  std::unique_ptr<QgsFillSymbol> mSymbol;
161 
162  double mArrowWidth = 1.0;
164  QgsMapUnitScale mArrowWidthUnitScale;
165 
166  double mArrowStartWidth = 1.0;
168  QgsMapUnitScale mArrowStartWidthUnitScale;
169 
170  double mHeadLength = 1.5;
172  QgsMapUnitScale mHeadLengthUnitScale;
173  double mHeadThickness = 1.5;
175  QgsMapUnitScale mHeadThicknessUnitScale;
176 
177  HeadType mHeadType = HeadSingle;
178  ArrowType mArrowType = ArrowPlain;
179  bool mIsCurved = true;
180  bool mIsRepeated = true;
181 
182  double mScaledArrowWidth = 1.0;
183  double mScaledArrowStartWidth = 1.0;
184  double mScaledHeadLength = 1.5;
185  double mScaledHeadThickness = 1.5;
186  double mScaledOffset = 0.0;
187  HeadType mComputedHeadType = HeadSingle;
188  ArrowType mComputedArrowType = ArrowPlain;
189 
190  std::unique_ptr<QgsExpressionContextScope> mExpressionScope;
191 
192  void _resolveDataDefined( QgsSymbolRenderContext & );
193 };
194 
195 #endif
196 
197 
QgsArrowSymbolLayer::headThicknessUnitScale
QgsMapUnitScale headThicknessUnitScale() const
Gets the scale for the head height.
Definition: qgsarrowsymbollayer.h:105
QgsLineSymbolLayer
Definition: qgssymbollayer.h:1024
QgsArrowSymbolLayer::ArrowType
ArrowType
Possible arrow types.
Definition: qgsarrowsymbollayer.h:133
QgsArrowSymbolLayer::headType
HeadType headType() const
Gets the current head type.
Definition: qgsarrowsymbollayer.h:128
QgsArrowSymbolLayer::HeadSingle
@ HeadSingle
Definition: qgsarrowsymbollayer.h:122
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
Definition: qgssymbollayer.cpp:252
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
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:1089
QgsArrowSymbolLayer::arrowStartWidthUnit
QgsUnitTypes::RenderUnit arrowStartWidthUnit() const
Gets the unit for the arrow start width.
Definition: qgsarrowsymbollayer.h:75
QgsArrowSymbolLayer::setArrowStartWidth
void setArrowStartWidth(double width)
Sets the arrow start width.
Definition: qgsarrowsymbollayer.h:73
QgsArrowSymbolLayer::setHeadThicknessUnit
void setHeadThicknessUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the head height.
Definition: qgsarrowsymbollayer.h:103
QgsSymbolLayer::subSymbol
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
Definition: qgssymbollayer.cpp:154
QgsArrowSymbolLayer::setHeadLengthUnit
void setHeadLengthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the head length.
Definition: qgsarrowsymbollayer.h:90
QgsArrowSymbolLayer::arrowWidthUnit
QgsUnitTypes::RenderUnit arrowWidthUnit() const
Gets the unit for the arrow width.
Definition: qgsarrowsymbollayer.h:62
QgsArrowSymbolLayer::HeadReversed
@ HeadReversed
Definition: qgsarrowsymbollayer.h:123
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:287
qgis.h
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsArrowSymbolLayer::headLengthUnit
QgsUnitTypes::RenderUnit headLengthUnit() const
Gets the unit for the head length.
Definition: qgsarrowsymbollayer.h:88
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:92
QgsArrowSymbolLayer::setArrowStartWidthUnitScale
void setArrowStartWidthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the arrow start width.
Definition: qgsarrowsymbollayer.h:81
QgsArrowSymbolLayer::headLength
double headLength() const
Gets the current arrow head length.
Definition: qgsarrowsymbollayer.h:84
QgsArrowSymbolLayer::setIsRepeated
void setIsRepeated(bool isRepeated)
Sets whether the arrow is repeated along the line.
Definition: qgsarrowsymbollayer.h:117
QgsArrowSymbolLayer::setHeadThicknessUnitScale
void setHeadThicknessUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the head height.
Definition: qgsarrowsymbollayer.h:107
QgsSymbolLayer::usesMapUnits
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
Definition: qgssymbollayer.cpp:313
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsSymbolRenderContext
Definition: qgssymbolrendercontext.h:35
QgsArrowSymbolLayer::setHeadThickness
void setHeadThickness(double thickness)
Sets the arrow head height.
Definition: qgsarrowsymbollayer.h:99
QgsArrowSymbolLayer
Line symbol layer used for representing lines as arrows.
Definition: qgsarrowsymbollayer.h:33
QgsSymbolLayer::clone
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolLayer
Definition: qgssymbollayer.h:54
QgsArrowSymbolLayer::HeadType
HeadType
Possible head types.
Definition: qgsarrowsymbollayer.h:120
QgsSymbolLayer::setSubSymbol
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Definition: qgssymbollayer.cpp:159
QgsArrowSymbolLayer::arrowStartWidth
double arrowStartWidth() const
Gets current arrow start width. Only meaningful for single headed arrows.
Definition: qgsarrowsymbollayer.h:71
QgsArrowSymbolLayer::ArrowPlain
@ ArrowPlain
Definition: qgsarrowsymbollayer.h:135
QgsArrowSymbolLayer::headThickness
double headThickness() const
Gets the current arrow head height.
Definition: qgsarrowsymbollayer.h:97
QgsArrowSymbolLayer::setHeadLengthUnitScale
void setHeadLengthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the head length.
Definition: qgsarrowsymbollayer.h:94
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsSymbolLayer::properties
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
qgssymbollayer.h
QgsArrowSymbolLayer::arrowStartWidthUnitScale
QgsMapUnitScale arrowStartWidthUnitScale() const
Gets the scale for the arrow start width.
Definition: qgsarrowsymbollayer.h:79
QgsArrowSymbolLayer::headThicknessUnit
QgsUnitTypes::RenderUnit headThicknessUnit() const
Gets the unit for the head height.
Definition: qgsarrowsymbollayer.h:101
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsArrowSymbolLayer::arrowWidthUnitScale
QgsMapUnitScale arrowWidthUnitScale() const
Gets the scale for the arrow width.
Definition: qgsarrowsymbollayer.h:66
QgsArrowSymbolLayer::setHeadType
void setHeadType(HeadType type)
Sets the head type.
Definition: qgsarrowsymbollayer.h:130
QgsSymbolLayer::canCauseArtifactsBetweenAdjacentTiles
virtual bool canCauseArtifactsBetweenAdjacentTiles() const
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
Definition: qgssymbollayer.cpp:308
QgsArrowSymbolLayer::ArrowLeftHalf
@ ArrowLeftHalf
Definition: qgsarrowsymbollayer.h:136
QgsSymbolLayer::usedAttributes
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Definition: qgssymbollayer.cpp:328
QgsArrowSymbolLayer::setArrowWidthUnitScale
void setArrowWidthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the arrow width.
Definition: qgsarrowsymbollayer.h:68
QgsArrowSymbolLayer::isCurved
bool isCurved() const
Returns whether it is a curved arrow or a straight one.
Definition: qgsarrowsymbollayer.h:110
QgsArrowSymbolLayer::setArrowType
void setArrowType(ArrowType type)
Sets the arrow type.
Definition: qgsarrowsymbollayer.h:143
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
QgsSymbolLayer::type
Qgis::SymbolType type() const
Definition: qgssymbollayer.h:437
QgsArrowSymbolLayer::setArrowStartWidthUnit
void setArrowStartWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the arrow start width.
Definition: qgsarrowsymbollayer.h:77
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:29
QgsLineSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:721
QgsSymbolLayer::stopRender
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
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:64
QgsSymbolLayer::color
virtual QColor color() const
Returns the "representative" color of the symbol layer.
Definition: qgssymbollayer.cpp:247
QgsArrowSymbolLayer::setArrowWidth
void setArrowWidth(double width)
Sets the arrow width.
Definition: qgsarrowsymbollayer.h:60
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:115
QgsArrowSymbolLayer::arrowType
ArrowType arrowType() const
Gets the current arrow type.
Definition: qgsarrowsymbollayer.h:141
QgsArrowSymbolLayer::setHeadLength
void setHeadLength(double length)
Sets the arrow head length.
Definition: qgsarrowsymbollayer.h:86
QgsArrowSymbolLayer::arrowWidth
double arrowWidth() const
Gets current arrow width.
Definition: qgsarrowsymbollayer.h:58
QgsArrowSymbolLayer::setIsCurved
void setIsCurved(bool isCurved)
Sets whether it is a curved arrow or a straight one.
Definition: qgsarrowsymbollayer.h:112
QgsArrowSymbolLayer::headLengthUnitScale
QgsMapUnitScale headLengthUnitScale() const
Gets the scale for the head length.
Definition: qgsarrowsymbollayer.h:92