QGIS API Documentation 3.41.0-Master (88383c3d16f)
Loading...
Searching...
No Matches
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
23class QgsFillSymbol;
24
25
32class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
33{
34 public:
38
46 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
47
48 QgsArrowSymbolLayer *clone() const override SIP_FACTORY;
49 QgsSymbol *subSymbol() override;
50 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
51 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
52 bool hasDataDefinedProperties() const override;
53 bool usesMapUnits() const override;
54 void setOutputUnit( Qgis::RenderUnit unit ) override;
55
57 double arrowWidth() const { return mArrowWidth; }
59 void setArrowWidth( double width ) { mArrowWidth = width; }
61 Qgis::RenderUnit arrowWidthUnit() const { return mArrowWidthUnit; }
63 void setArrowWidthUnit( Qgis::RenderUnit unit ) { mArrowWidthUnit = unit; }
65 QgsMapUnitScale arrowWidthUnitScale() const { return mArrowWidthUnitScale; }
67 void setArrowWidthUnitScale( const QgsMapUnitScale &scale ) { mArrowWidthUnitScale = scale; }
68
70 double arrowStartWidth() const { return mArrowStartWidth; }
72 void setArrowStartWidth( double width ) { mArrowStartWidth = width; }
74 Qgis::RenderUnit arrowStartWidthUnit() const { return mArrowStartWidthUnit; }
76 void setArrowStartWidthUnit( Qgis::RenderUnit unit ) { mArrowStartWidthUnit = unit; }
78 QgsMapUnitScale arrowStartWidthUnitScale() const { return mArrowStartWidthUnitScale; }
80 void setArrowStartWidthUnitScale( const QgsMapUnitScale &scale ) { mArrowStartWidthUnitScale = scale; }
81
83 double headLength() const { return mHeadLength; }
85 void setHeadLength( double length ) { mHeadLength = length; }
87 Qgis::RenderUnit headLengthUnit() const { return mHeadLengthUnit; }
89 void setHeadLengthUnit( Qgis::RenderUnit unit ) { mHeadLengthUnit = unit; }
91 QgsMapUnitScale headLengthUnitScale() const { return mHeadLengthUnitScale; }
93 void setHeadLengthUnitScale( const QgsMapUnitScale &scale ) { mHeadLengthUnitScale = scale; }
94
96 double headThickness() const { return mHeadThickness; }
98 void setHeadThickness( double thickness ) { mHeadThickness = thickness; }
100 Qgis::RenderUnit headThicknessUnit() const { return mHeadThicknessUnit; }
102 void setHeadThicknessUnit( Qgis::RenderUnit unit ) { mHeadThicknessUnit = unit; }
104 QgsMapUnitScale headThicknessUnitScale() const { return mHeadThicknessUnitScale; }
106 void setHeadThicknessUnitScale( const QgsMapUnitScale &scale ) { mHeadThicknessUnitScale = scale; }
107
109 bool isCurved() const { return mIsCurved; }
111 void setIsCurved( bool isCurved ) { mIsCurved = isCurved; }
112
114 bool isRepeated() const { return mIsRepeated; }
116 void setIsRepeated( bool isRepeated ) { mIsRepeated = isRepeated; }
117
120 {
121 HeadSingle, //< One single head at the end
122 HeadReversed, //< One single head at the beginning
123 HeadDouble //< Two heads
124 };
125
127 HeadType headType() const { return mHeadType; }
129 void setHeadType( HeadType type ) { mHeadType = type; }
130
133 {
134 ArrowPlain, //< Regular arrow
135 ArrowLeftHalf, //< Halved arrow, only the left side of the arrow is rendered (for straight arrows) or the side toward the exterior (for curved arrows)
136 ArrowRightHalf //< Halved arrow, only the right side of the arrow is rendered (for straight arrows) or the side toward the interior (for curved arrows)
137 };
138
140 ArrowType arrowType() const { return mArrowType; }
142 void setArrowType( ArrowType type ) { mArrowType = type; }
143
144 QVariantMap properties() const override;
145 QString layerType() const override;
146 void startRender( QgsSymbolRenderContext &context ) override;
147 void stopRender( QgsSymbolRenderContext &context ) override;
148 void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
149 void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
150 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
151 void setColor( const QColor &c ) override;
152 QColor color() const override;
153 bool canCauseArtifactsBetweenAdjacentTiles() const override;
154
155 private:
156#ifdef SIP_RUN
158#endif
159
161 std::unique_ptr<QgsFillSymbol> mSymbol;
162
163 double mArrowWidth = 1.0;
165 QgsMapUnitScale mArrowWidthUnitScale;
166
167 double mArrowStartWidth = 1.0;
168 Qgis::RenderUnit mArrowStartWidthUnit = Qgis::RenderUnit::Millimeters;
169 QgsMapUnitScale mArrowStartWidthUnitScale;
170
171 double mHeadLength = 1.5;
173 QgsMapUnitScale mHeadLengthUnitScale;
174 double mHeadThickness = 1.5;
176 QgsMapUnitScale mHeadThicknessUnitScale;
177
178 HeadType mHeadType = HeadSingle;
179 ArrowType mArrowType = ArrowPlain;
180 bool mIsCurved = true;
181 bool mIsRepeated = true;
182
183 double mScaledArrowWidth = 1.0;
184 double mScaledArrowStartWidth = 1.0;
185 double mScaledHeadLength = 1.5;
186 double mScaledHeadThickness = 1.5;
187 double mScaledOffset = 0.0;
188 HeadType mComputedHeadType = HeadSingle;
189 ArrowType mComputedArrowType = ArrowPlain;
190
191 std::unique_ptr<QgsExpressionContextScope> mExpressionScope;
192
193 void _resolveDataDefined( QgsSymbolRenderContext & );
194};
195
196#endif
197
198
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
RenderUnit
Rendering size units.
Definition qgis.h:4930
@ Millimeters
Millimeters.
Line symbol layer used for representing lines as arrows.
bool isCurved() const
Returns whether it is a curved arrow or a straight one.
ArrowType arrowType() const
Gets the current arrow type.
HeadType
Possible head types.
HeadType headType() const
Gets the current head type.
void setArrowStartWidth(double width)
Sets the arrow start width.
bool isRepeated() const
Returns whether the arrow is repeated along the line or not.
void setArrowWidth(double width)
Sets the arrow width.
void setArrowType(ArrowType type)
Sets the arrow type.
void setHeadLengthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the head length.
~QgsArrowSymbolLayer() override
QgsMapUnitScale headThicknessUnitScale() const
Gets the scale for the head height.
Qgis::RenderUnit arrowWidthUnit() const
Gets the unit for the arrow width.
Qgis::RenderUnit headLengthUnit() const
Gets the unit for the head length.
Qgis::RenderUnit headThicknessUnit() const
Gets the unit for the head height.
void setArrowWidthUnit(Qgis::RenderUnit unit)
Sets the unit for the arrow width.
void setIsCurved(bool isCurved)
Sets whether it is a curved arrow or a straight one.
void setHeadThickness(double thickness)
Sets the arrow head height.
void setHeadLengthUnit(Qgis::RenderUnit unit)
Sets the unit for the head length.
void setIsRepeated(bool isRepeated)
Sets whether the arrow is repeated along the line.
double arrowStartWidth() const
Gets current arrow start width. Only meaningful for single headed arrows.
void setArrowStartWidthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the arrow start width.
void setHeadThicknessUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the head height.
void setHeadType(HeadType type)
Sets the head type.
QgsMapUnitScale arrowStartWidthUnitScale() const
Gets the scale for the arrow start width.
double headThickness() const
Gets the current arrow head height.
void setArrowWidthUnitScale(const QgsMapUnitScale &scale)
Sets the scale for the arrow width.
ArrowType
Possible arrow types.
QgsMapUnitScale arrowWidthUnitScale() const
Gets the scale for the arrow width.
void setArrowStartWidthUnit(Qgis::RenderUnit unit)
Sets the unit for the arrow start width.
Qgis::RenderUnit arrowStartWidthUnit() const
Gets the unit for the arrow start width.
QgsMapUnitScale headLengthUnitScale() const
Gets the scale for the head length.
void setHeadLength(double length)
Sets the arrow head length.
double headLength() const
Gets the current arrow head length.
void setHeadThicknessUnit(Qgis::RenderUnit unit)
Sets the unit for the head height.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Abstract base class for line symbol layers.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Renders the line symbol layer along the line joining points, using the given render context.
virtual double width() const
Returns the estimated width for the line symbol layer.
Struct for storing maximum and minimum scales for measurements in map units.
Contains information about the context of a rendering operation.
Qgis::SymbolType type() const
virtual void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called before the layer will be rendered for a particular feature.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
virtual void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called after the layer has been rendered for a particular feature.
virtual bool canCauseArtifactsBetweenAdjacentTiles() const
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
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
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76