16#ifndef QGSLINESYMBOLLAYER_H
17#define QGSLINESYMBOLLAYER_H
33#define DEFAULT_SIMPLELINE_COLOR QColor(35,35,35)
34#define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH
35#define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine
36#define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin
37#define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap
73 QString layerType() const override;
74 Qgis::SymbolLayerFlags flags() const override;
79 void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings,
QgsSymbolRenderContext &context ) override;
80 QVariantMap properties() const override;
82 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
83 QString ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor ) const override;
84 void setOutputUnit(
Qgis::RenderUnit unit ) override;
85 Qgis::RenderUnit outputUnit() const override;
86 bool usesMapUnits() const override;
90 QVector<qreal> dxfCustomDashPattern(
Qgis::RenderUnit &unit ) const override;
91 Qt::PenStyle dxfPenStyle() const override;
95 bool canCauseArtifactsBetweenAdjacentTiles() const override;
102 Qt::PenStyle penStyle()
const {
return mPenStyle; }
466 bool alignDashPattern()
const;
477 void setAlignDashPattern(
bool enabled );
489 bool tweakDashPatternOnCorners()
const;
501 void setTweakDashPatternOnCorners(
bool enabled );
505 Qt::PenStyle mPenStyle = Qt::SolidLine;
511 bool mUseCustomDashPattern =
false;
515 double mDashPatternOffset = 0;
519 double mTrimDistanceStart = 0;
523 double mTrimDistanceEnd = 0;
528 QVector<qreal> mCustomDashVector;
530 bool mAlignDashPattern =
false;
531 bool mPatternCartographicTweakOnSharpCorners =
false;
533 bool mDrawInsidePolygon =
false;
536 void applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QPen &pen, QPen &selPen,
double &offset );
537 void drawPathWithDashPatternTweaks( QPainter *painter,
const QPolygonF &points, QPen pen )
const;
542#define DEFAULT_MARKERLINE_ROTATE true
543#define DEFAULT_MARKERLINE_INTERVAL 3
566 double interval = 3 );
640 Q_DECL_DEPRECATED
void setPlacement(
Qgis::MarkerLinePlacement placement )
SIP_DEPRECATED;
647 Qgis::MarkerLinePlacements placements()
const {
return mPlacements; }
808 void setOutputUnit(
Qgis::RenderUnit unit ) override;
811 QVariantMap properties() const override;
812 bool canCauseArtifactsBetweenAdjacentTiles() const override;
825 virtual
void setSymbolLineAngle(
double angle ) = 0;
830 virtual
double symbolAngle() const = 0;
835 virtual
void setSymbolAngle(
double angle ) = 0;
849 virtual
void renderSymbol( const QPointF &point, const
QgsFeature *feature,
QgsRenderContext &context,
int layer = -1,
bool selected = false ) = 0;
864 void renderPolylineInterval( const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageAngleOver );
865 void renderPolylineVertex( const QPolygonF &points,
QgsSymbolRenderContext &context,
Qgis::MarkerLinePlacement placement =
Qgis::MarkerLinePlacement::Vertex );
866 void renderPolylineCentral( const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageAngleOver );
867 double markerAngle( const QPolygonF &points,
bool isRing,
int vertex );
881 void renderOffsetVertexAlongLine( const QPolygonF &points,
int vertex,
double distance,
QgsSymbolRenderContext &context,
882 Qgis::MarkerLinePlacement placement );
885 static
void collectOffsetPoints( const QVector< QPointF> &points,
886 QVector< QPointF> &dest,
double intervalPainterUnits,
double initialOffset,
double initialLag = 0,
887 int numberPointsRequired = -1 );
889 bool mRotateSymbols = true;
890 double mInterval = 3;
891 Qgis::RenderUnit mIntervalUnit =
Qgis::RenderUnit::Millimeters;
893 Qgis::MarkerLinePlacements mPlacements =
Qgis::MarkerLinePlacement::Interval;
894 double mOffsetAlongLine = 0;
895 Qgis::RenderUnit mOffsetAlongLineUnit =
Qgis::RenderUnit::Millimeters;
897 double mAverageAngleLength = 4;
898 Qgis::RenderUnit mAverageAngleLengthUnit =
Qgis::RenderUnit::Millimeters;
900 bool mPlaceOnEveryPart = true;
902 bool mRenderingFeature = false;
903 bool mHasRenderedFirstPart = false;
904 QPointF mFinalVertex;
905 bool mCurrentFeatureIsSelected = false;
906 double mFeatureSymbolOpacity = 1;
908 friend class TestQgsMarkerLineSymbol;
949 QString layerType() const override;
953 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
954 void setColor( const QColor &color ) override;
955 QColor color() const override;
958 void setWidth(
double width ) override;
959 double width() const override;
962 void setOutputUnit(
Qgis::RenderUnit unit ) override;
963 bool usesMapUnits() const override;
964 QSet<QString> usedAttributes( const
QgsRenderContext &context ) const override;
965 bool hasDataDefinedProperties() const override;
974 Q_DECL_DEPRECATED
bool rotateMarker() const
SIP_DEPRECATED {
return rotateSymbols(); }
988 void setSymbolLineAngle(
double angle )
override;
989 double symbolAngle()
const override;
990 void setSymbolAngle(
double angle )
override;
991 void renderSymbol(
const QPointF &point,
const QgsFeature *feature,
QgsRenderContext &context,
int layer = -1,
bool selected =
false )
override;
1023 double interval = 3 );
1034 QString layerType() const override;
1037 QVariantMap properties() const override;
1039 void setColor( const QColor &color ) override;
1040 QColor color() const override;
1043 void setWidth(
double width ) override;
1044 double width() const override;
1047 void setOutputUnit(
Qgis::RenderUnit unit ) override;
1048 QSet<QString> usedAttributes( const
QgsRenderContext &context ) const override;
1049 bool hasDataDefinedProperties() const override;
1051 bool usesMapUnits() const override;
1058 double hashAngle() const;
1065 void setHashAngle(
double angle );
1072 double hashLength()
const {
return mHashLength; }
1115 void setSymbolLineAngle(
double angle )
override;
1116 double symbolAngle()
const override;
1117 void setSymbolAngle(
double angle )
override;
1118 void renderSymbol(
const QPointF &point,
const QgsFeature *feature,
QgsRenderContext &context,
int layer = -1,
bool selected =
false )
override;
1125 std::unique_ptr< QgsLineSymbol > mHashSymbol;
1127 double mSymbolLineAngle = 0;
1128 double mSymbolAngle = 0;
1130 double mHashAngle = 0;
1131 double mHashLength = 3;
1183 void renderPolylineUsingBrush(
const QPolygonF &points,
QgsSymbolRenderContext &context,
const QBrush &brush,
1184 double patternThickness,
double patternLength );
1186 Qt::PenJoinStyle mPenJoinStyle = Qt::PenJoinStyle::RoundJoin;
1187 Qt::PenCapStyle mPenCapStyle = Qt::PenCapStyle::RoundCap;
1190 void renderLine(
const QPolygonF &points,
QgsSymbolRenderContext &context,
const double lineThickness,
const double patternLength,
const QBrush &sourceBrush );
1224 static
void resolvePaths( QVariantMap &properties, const
QgsPathResolver &pathResolver,
bool saving );
1230 QString path()
const {
return mPath; }
1236 void setPath(
const QString &path );
1259 void setOutputUnit(
Qgis::RenderUnit unit ) override;
1260 Qgis::RenderUnit outputUnit() const override;
1261 bool usesMapUnits() const override;
1265 QColor color() const override;
1269 double mOpacity = 1.0;
1294 const QColor &color2 = Qt::white );
1304 QString layerType() const override;
1305 Qgis::SymbolLayerFlags flags() const override;
1309 QVariantMap properties() const override;
1311 void setOutputUnit(
Qgis::RenderUnit unit ) override;
1312 Qgis::RenderUnit outputUnit() const override;
1313 bool usesMapUnits() const override;
1323 Qgis::GradientColorSource gradientColorType()
const {
return mGradientColorType; }
1361 void setColor2(
const QColor &color2 ) { mColor2 = color2; }
1400 QString layerType() const override;
1404 QVariantMap properties() const override;
1408 bool hasDataDefinedProperties() const override;
1409 void setColor( const QColor &
c ) override;
1410 QColor color() const override;
1411 void setOutputUnit(
Qgis::RenderUnit unit ) override;
1412 Qgis::RenderUnit outputUnit() const override;
1413 bool usesMapUnits() const override;
1417 QSet<QString> usedAttributes( const
QgsRenderContext &context ) const override;
1424 Qt::PenJoinStyle penJoinStyle()
const {
return mPenJoinStyle; }
1454 std::unique_ptr< QgsFillSymbol > mFill;
The Qgis class provides global constants for use throughout the application.
MarkerLinePlacement
Defines how/where the symbols should be placed on a line.
GradientColorSource
Gradient color sources.
@ SimpleTwoColor
Simple two color gradient.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
QFlags< MarkerLinePlacement > MarkerLinePlacements
Base class for line symbol layer types which draws line sections using a QBrush.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
Abstract base class for color ramps.
Exports QGIS layers to the DXF format.
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol layer type which fills a stroked line with a QgsFillSymbol.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
~QgsFilledLineSymbolLayer() override
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
Line symbol layer type which draws repeating line sections along a line feature.
void setHashLength(double length)
Sets the length of hash symbols.
const QgsMapUnitScale & hashLengthMapUnitScale() const
Returns the map unit scale for the hash length.
void setHashLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the hash length.
Qgis::RenderUnit hashLengthUnit() const
Returns the units for the length of hash symbols.
~QgsHashedLineSymbolLayer() override
void setHashLengthUnit(Qgis::RenderUnit unit)
Sets the unit for the length of hash symbols.
Abstract base class for line symbol layers.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
virtual void renderPolygonStroke(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context)
Renders the line symbol layer along the outline of polygon, using the given render context.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Renders the line symbol layer along the line joining points, using the given render context.
double offset() const
Returns the line's offset.
A line symbol type, for rendering LineString and MultiLineString geometries.
Line symbol layer type which draws a gradient pattern perpendicularly along a line.
std::unique_ptr< QgsColorRamp > mGradientRamp
QColor color2() const
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoC...
~QgsLineburstSymbolLayer() override
void setGradientColorType(Qgis::GradientColorSource gradientColorType)
Sets the gradient color mode, which controls how gradient color stops are created.
void setColor2(const QColor &color2)
Sets the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColo...
Struct for storing maximum and minimum scales for measurements in map units.
Line symbol layer type which draws repeating marker symbols along a line feature.
std::unique_ptr< QgsMarkerSymbol > mMarker
~QgsMarkerLineSymbolLayer() override
Q_DECL_DEPRECATED void setRotateMarker(bool rotate)
Shall the marker be rotated.
A marker symbol type, for rendering Point and MultiPoint geometries.
Resolves relative paths into absolute paths and vice versa.
A store for object properties.
Line symbol layer type which draws line sections using a raster image file.
double opacity() const
Returns the line opacity.
void setOpacity(double opacity)
Set the line opacity.
virtual ~QgsRasterLineSymbolLayer()
Contains information about the context of a rendering operation.
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
void setDrawInsidePolygon(bool drawInsidePolygon)
Sets whether the line should only be drawn inside polygons, and any portion of the line which falls o...
const QgsMapUnitScale & customDashPatternMapUnitScale() const
Returns the map unit scale for lengths used in the custom dash pattern.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
const QgsMapUnitScale & trimDistanceEndMapUnitScale() const
Returns the map unit scale for the trim distance for the end of the line.
QVector< qreal > customDashVector() const
Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ...
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
const QgsMapUnitScale & trimDistanceStartMapUnitScale() const
Returns the map unit scale for the trim distance for the start of the line.
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for lengths used in the custom dash pattern.
void setTrimDistanceEndMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the end of the line.
void setTrimDistanceEnd(double distance)
Sets the trim distance for the end of the line, which dictates a length from the end of the line at w...
double trimDistanceStart() const
Returns the trim distance for the start of the line, which dictates a length from the start of the li...
~QgsSimpleLineSymbolLayer() override
void setUseCustomDashPattern(bool b)
Sets whether the line uses a custom dash pattern.
Qgis::RenderUnit customDashPatternUnit() const
Returns the units for lengths used in the custom dash pattern.
double trimDistanceEnd() const
Returns the trim distance for the end of the line, which dictates a length from the end of the line a...
Qgis::RenderUnit dashPatternOffsetUnit() const
Returns the units for the dash pattern offset.
const QgsMapUnitScale & dashPatternOffsetMapUnitScale() const
Returns the map unit scale for the dash pattern offset value.
void setCustomDashVector(const QVector< qreal > &vector)
Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ren...
bool useCustomDashPattern() const
Returns true if the line uses a custom dash pattern.
void setDashPatternOffset(double offset)
Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start ...
void setDashPatternOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the dash pattern offset.
void setPenStyle(Qt::PenStyle style)
Sets the pen style used to render the line (e.g.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
double dashPatternOffset() const
Returns the dash pattern offset, which dictates how far along the dash pattern the pattern should sta...
void setTrimDistanceStartMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the start of the line.
Qgis::RenderUnit trimDistanceStartUnit() const
Returns the unit for the trim distance for the start of the line.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
void setTrimDistanceEndUnit(Qgis::RenderUnit unit)
Sets the unit for the trim distance for the end of the line.
void setDashPatternOffsetUnit(Qgis::RenderUnit unit)
Sets the unit for the dash pattern offset.
bool drawInsidePolygon() const
Returns true if the line should only be drawn inside polygons, and any portion of the line which fall...
void setTrimDistanceStart(double distance)
Sets the trim distance for the start of the line, which dictates a length from the start of the line ...
void setTrimDistanceStartUnit(Qgis::RenderUnit unit)
Sets the unit for the trim distance for the start of the line.
Qgis::RenderUnit trimDistanceEndUnit() const
Returns the unit for the trim distance for the end of the line.
void setCustomDashPatternUnit(Qgis::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
Property
Data definable properties.
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 Qgis::SymbolLayerFlags flags() const
Returns flags which control the symbol layer's behavior.
Abstract base class for all rendered symbols.
Base class for templated line symbols, e.g.
bool rotateSymbols() const
Returns true if the repeating symbols be rotated to match their line segment orientation.
bool placeOnEveryPart() const
Returns true if the placement applies for every part of multi-part feature geometries.
double averageAngleLength() const
Returns the length of line over which the line's direction is averaged when calculating individual sy...
void setRotateSymbols(bool rotate)
Sets whether the repeating symbols should be rotated to match their line segment orientation.
void setIntervalUnit(Qgis::RenderUnit unit)
Sets the units for the interval between symbols.
void setAverageAngleUnit(Qgis::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
const QgsMapUnitScale & averageAngleMapUnitScale() const
Returns the map unit scale for the length over which the line's direction is averaged when calculatin...
double interval() const
Returns the interval between individual symbols.
void setOffsetAlongLineUnit(Qgis::RenderUnit unit)
Sets the unit used for calculating the offset along line for symbols.
void setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
double offsetAlongLine() const
Returns the offset along the line for the symbol placement.
~QgsTemplatedLineSymbolLayerBase() override
void setOffsetAlongLine(double offsetAlongLine)
Sets the the offset along the line for the symbol placement.
Qgis::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for symbols.
void setInterval(double interval)
Sets the interval between individual symbols.
Qgis::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
void setPlaceOnEveryPart(bool respect)
Sets whether the placement applies for every part of multi-part feature geometries.
void setPlacements(Qgis::MarkerLinePlacements placements)
Sets the placement of the symbols.
Qgis::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for symbols.
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the interval between symbols.
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for symbols.
void setAverageAngleLength(double length)
Sets the length of line over which the line's direction is averaged when calculating individual symbo...
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 DEFAULT_MARKERLINE_INTERVAL
#define DEFAULT_SIMPLELINE_WIDTH
#define DEFAULT_MARKERLINE_ROTATE
#define DEFAULT_SIMPLELINE_PENSTYLE
#define DEFAULT_SIMPLELINE_JOINSTYLE
#define DEFAULT_SIMPLELINE_COLOR
#define DEFAULT_SIMPLELINE_CAPSTYLE