QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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
33class CORE_EXPORT QgsArrowSymbolLayer : public QgsLineSymbolLayer
34{
35 public:
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( Qgis::RenderUnit unit ) override;
56
58 double arrowWidth() const { return mArrowWidth; }
60 void setArrowWidth( double width ) { mArrowWidth = width; }
62 Qgis::RenderUnit arrowWidthUnit() const { return mArrowWidthUnit; }
64 void setArrowWidthUnit( Qgis::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 Qgis::RenderUnit arrowStartWidthUnit() const { return mArrowStartWidthUnit; }
77 void setArrowStartWidthUnit( Qgis::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 Qgis::RenderUnit headLengthUnit() const { return mHeadLengthUnit; }
90 void setHeadLengthUnit( Qgis::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 Qgis::RenderUnit headThicknessUnit() const { return mHeadThicknessUnit; }
103 void setHeadThicknessUnit( Qgis::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
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;
167 Qgis::RenderUnit mArrowStartWidthUnit = Qgis::RenderUnit::Millimeters;
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
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
RenderUnit
Rendering size units.
Definition qgis.h:3627
@ 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.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
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 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 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:94
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