QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
16 #ifndef QGSLINESYMBOLLAYER_H
17 #define QGSLINESYMBOLLAYER_H
19 #include "qgis_core.h"
32 #define DEFAULT_SIMPLELINE_COLOR QColor(35,35,35)
33 #define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH
34 #define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine
35 #define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin
36 #define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap
80 void toSld( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
81 QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const override;
100 Qt::PenStyle
penStyle()
const {
return mPenStyle; }
464 bool alignDashPattern()
const;
475 void setAlignDashPattern(
bool enabled );
487 bool tweakDashPatternOnCorners()
const;
499 void setTweakDashPatternOnCorners(
bool enabled );
503 Qt::PenStyle mPenStyle = Qt::SolidLine;
509 bool mUseCustomDashPattern =
false;
513 double mDashPatternOffset = 0;
517 double mTrimDistanceStart = 0;
521 double mTrimDistanceEnd = 0;
526 QVector<qreal> mCustomDashVector;
528 bool mAlignDashPattern =
false;
529 bool mPatternCartographicTweakOnSharpCorners =
false;
531 bool mDrawInsidePolygon =
false;
534 void applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QPen &pen, QPen &selPen,
double &offset );
535 void drawPathWithDashPatternTweaks( QPainter *painter,
const QPolygonF &points, QPen pen )
const;
540 #define DEFAULT_MARKERLINE_ROTATE true
541 #define DEFAULT_MARKERLINE_INTERVAL 3
564 double interval = 3 );
638 Q_DECL_DEPRECATED
void setPlacement(
Qgis::MarkerLinePlacement placement )
SIP_DEPRECATED;
645 Qgis::MarkerLinePlacements placements()
const {
return mPlacements; }
652 void setPlacements( Qgis::MarkerLinePlacements placements ) { mPlacements = placements; }
806 void setOutputUnit(
QgsUnitTypes::RenderUnit unit ) override;
809 QVariantMap properties() const override;
810 bool canCauseArtifactsBetweenAdjacentTiles() const override;
823 virtual
void setSymbolLineAngle(
double angle ) = 0;
828 virtual
double symbolAngle() const = 0;
833 virtual
void setSymbolAngle(
double angle ) = 0;
847 virtual
void renderSymbol( const QPointF &point, const
QgsFeature *feature,
QgsRenderContext &context,
int layer = -1,
bool selected = false ) = 0;
862 void renderPolylineInterval( const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageAngleOver );
863 void renderPolylineVertex( const QPolygonF &points,
QgsSymbolRenderContext &context,
Qgis::MarkerLinePlacement placement =
Qgis::MarkerLinePlacement::Vertex );
864 void renderPolylineCentral( const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageAngleOver );
865 double markerAngle( const QPolygonF &points,
bool isRing,
int vertex );
879 void renderOffsetVertexAlongLine( const QPolygonF &points,
int vertex,
double distance,
QgsSymbolRenderContext &context,
880 Qgis::MarkerLinePlacement placement );
883 static
void collectOffsetPoints( const QVector< QPointF> &points,
884 QVector< QPointF> &dest,
double intervalPainterUnits,
double initialOffset,
double initialLag = 0,
885 int numberPointsRequired = -1 );
887 bool mRotateSymbols = true;
888 double mInterval = 3;
891 Qgis::MarkerLinePlacements mPlacements =
Qgis::MarkerLinePlacement::Interval;
892 double mOffsetAlongLine = 0;
895 double mAverageAngleLength = 4;
898 bool mPlaceOnEveryPart = true;
900 bool mRenderingFeature = false;
901 bool mHasRenderedFirstPart = false;
902 QPointF mFinalVertex;
903 bool mCurrentFeatureIsSelected = false;
904 double mFeatureSymbolOpacity = 1;
906 friend class TestQgsMarkerLineSymbol;
951 void toSld( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
952 void setColor(
const QColor &color )
override;
953 QColor
color()
const override;
956 void setWidth(
double width )
override;
957 double width()
const override;
986 void setSymbolLineAngle(
double angle )
override;
987 double symbolAngle()
const override;
988 void setSymbolAngle(
double angle )
override;
989 void renderSymbol(
const QPointF &point,
const QgsFeature *feature,
QgsRenderContext &context,
int layer = -1,
bool selected =
false )
override;
1021 double interval = 3 );
1037 void setColor(
const QColor &color )
override;
1038 QColor
color()
const override;
1041 void setWidth(
double width )
override;
1042 double width()
const override;
1056 double hashAngle()
const;
1063 void setHashAngle(
double angle );
1123 std::unique_ptr< QgsLineSymbol > mHashSymbol;
1125 double mSymbolLineAngle = 0;
1126 double mSymbolAngle = 0;
1128 double mHashAngle = 0;
1129 double mHashLength = 3;
1181 void renderPolylineUsingBrush(
const QPolygonF &points,
QgsSymbolRenderContext &context,
const QBrush &brush,
1182 double patternThickness,
double patternLength );
1184 Qt::PenJoinStyle mPenJoinStyle = Qt::PenJoinStyle::RoundJoin;
1185 Qt::PenCapStyle mPenCapStyle = Qt::PenCapStyle::RoundCap;
1188 void renderLine(
const QPolygonF &points,
QgsSymbolRenderContext &context,
const double lineThickness,
const double patternLength,
const QBrush &sourceBrush );
1222 static void resolvePaths( QVariantMap &properties,
const QgsPathResolver &pathResolver,
bool saving );
1228 QString
path()
const {
return mPath; }
1234 void setPath(
const QString &path );
1256 void setOutputUnit(
QgsUnitTypes::RenderUnit unit ) override;
1258 bool usesMapUnits() const override;
1262 QColor color() const override;
1266 double mOpacity = 1.0;
1291 const QColor &color2 = Qt::white );
1313 QColor
color()
const override;
1358 void setColor2(
const QColor &color2 ) { mColor2 = color2; }
Line symbol layer type which draws line sections using a raster image file.
void setTrimDistanceStartMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the start of the line.
Abstract base class for color ramps.
const QgsMapUnitScale & trimDistanceStartMapUnitScale() const
Returns the map unit scale for the trim distance for the start of the line.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
const QgsMapUnitScale & dashPatternOffsetMapUnitScale() const
Returns the map unit scale for the dash pattern offset value.
double dashPatternOffset() const
Returns the dash pattern offset, which dictates how far along the dash pattern the pattern should sta...
void setOffsetAlongLine(double offsetAlongLine)
Sets the the offset along the line for the symbol placement.
const QgsMapUnitScale & averageAngleMapUnitScale() const
Returns the map unit scale for the length over which the line's direction is averaged when calculatin...
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
A store for object properties.
void setHashLengthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length of hash symbols.
bool placeOnEveryPart() const
Returns true if the placement applies for every part of multi-part feature geometries.
RenderUnit
Rendering size units.
Exports QGIS layers to the DXF format.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Renders the line symbol layer along the line joining points, using the given render context.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
virtual Qt::PenStyle dxfPenStyle() const
Gets pen style.
virtual double width() const
Returns the estimated width for the line symbol layer.
std::unique_ptr< QgsColorRamp > mGradientRamp
QgsUnitTypes::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for symbols.
virtual QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const
Gets dash pattern.
double opacity() const
Returns the line opacity.
Line symbol layer type which draws repeating line sections along a line feature.
#define DEFAULT_MARKERLINE_ROTATE
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for lengths used in the custom dash pattern.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
#define DEFAULT_MARKERLINE_INTERVAL
virtual void renderSymbol(const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer=-1, bool selected=false)=0
Renders the templated symbol at the specified point, using the given render context.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
void setHashLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the hash length.
Contains information about the context of a rendering operation.
bool drawInsidePolygon() const
Returns true if the line should only be drawn inside polygons, and any portion of the line which fall...
void setTrimDistanceEndUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the trim distance for the end of the line.
QgsUnitTypes::RenderUnit trimDistanceStartUnit() const
Returns the unit for the trim distance for the start of the line.
double hashLength() const
Returns the length of hash symbols.
bool useCustomDashPattern() const
Returns true if the line uses a custom dash pattern.
@ RenderMillimeters
Millimeters.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setDashPatternOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the dash pattern offset.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Abstract base class for all rendered symbols.
@ SimpleTwoColor
Simple two color gradient.
void setUseCustomDashPattern(bool b)
Sets whether the line uses a custom dash pattern.
Line symbol layer type which draws repeating marker symbols along a line feature.
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
QVector< qreal > customDashVector() const
Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ...
QgsMapUnitScale mapUnitScale() const override
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
#define DEFAULT_SIMPLELINE_CAPSTYLE
void setTrimDistanceEndMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the end of the line.
GradientColorSource
Gradient color sources.
#define DEFAULT_SIMPLELINE_COLOR
void setCustomDashVector(const QVector< qreal > &vector)
Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ren...
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the interval between symbols.
Qt::PenStyle penStyle() const
Returns the pen style used to render the line (e.g.
void setInterval(double interval)
Sets the interval between individual symbols.
#define DEFAULT_SIMPLELINE_JOINSTYLE
const QgsMapUnitScale & customDashPatternMapUnitScale() const
Returns the map unit scale for lengths used in the custom dash pattern.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setPenStyle(Qt::PenStyle style)
Sets the pen style used to render the line (e.g.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit hashLengthUnit() const
Returns the units for the length of hash symbols.
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets offset.
void setColor2(const QColor &color2)
Sets the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColo...
void setOffsetAlongLineUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit used for calculating the offset along line for symbols.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
void setHashLength(double length)
Sets the length of hash symbols.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Saves the symbol layer as SLD.
A marker symbol type, for rendering Point and MultiPoint geometries.
void setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
QgsUnitTypes::RenderUnit customDashPatternUnit() const
Returns the units for lengths used in the custom dash pattern.
Q_DECL_DEPRECATED void setRotateMarker(bool rotate)
Shall the marker be rotated.
Line symbol layer type which draws a gradient pattern perpendicularly along a line.
double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets line width.
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.
double interval() const
Returns the interval between individual symbols.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
double offsetAlongLine() const
Returns the offset along the line for the symbol placement.
A line symbol type, for rendering LineString and MultiLineString geometries.
virtual void setSymbolAngle(double angle)=0
Sets the symbol's angle, in degrees clockwise.
const QgsMapUnitScale & trimDistanceEndMapUnitScale() const
Returns the map unit scale for the trim distance for the end of the line.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setDrawInsidePolygon(bool drawInsidePolygon)
Sets whether the line should only be drawn inside polygons, and any portion of the line which falls o...
Helper functions for various unit types.
#define DEFAULT_SIMPLELINE_WIDTH
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for symbols.
#define DEFAULT_SIMPLELINE_PENSTYLE
Qgis::GradientColorSource gradientColorType() const
Returns the gradient color mode, which controls how gradient color stops are created.
Struct for storing maximum and minimum scales for measurements in map units.
double averageAngleLength() const
Returns the length of line over which the line's direction is averaged when calculating individual sy...
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 setGradientColorType(Qgis::GradientColorSource gradientColorType)
Sets the gradient color mode, which controls how gradient color stops are created.
Base class for templated line symbols, e.g. line symbols which draw markers or hash lines at interval...
void setDashPatternOffset(double offset)
Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start ...
virtual bool canCauseArtifactsBetweenAdjacentTiles() const
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for symbols.
QString path() const
Returns the raster image path.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
void setAverageAngleLength(double length)
Sets the length of line over which the line's direction is averaged when calculating individual symbo...
QgsUnitTypes::RenderUnit trimDistanceEndUnit() const
Returns the unit for the trim distance for the end of the line.
void setDashPatternOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the dash pattern offset.
const QgsMapUnitScale & hashLengthMapUnitScale() const
Returns the map unit scale for the hash length.
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...
void setRotateSymbols(bool rotate)
Sets whether the repeating symbols should be rotated to match their line segment orientation.
virtual void setSymbolLineAngle(double angle)=0
Sets the line angle modification for the symbol's angle.
bool rotateSymbols() const
Returns true if the repeating symbols be rotated to match their line segment orientation.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context) override
Renders the line symbol layer along the line joining points, using the given render context.
Property
Data definable properties.
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
void setPlaceOnEveryPart(bool respect)
Sets whether the placement applies for every part of multi-part feature geometries.
The Qgis class provides global constants for use throughout the application.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
std::unique_ptr< QgsMarkerSymbol > mMarker
double offset() const
Returns the line's offset.
double trimDistanceEnd() const
Returns the trim distance for the end of the line, which dictates a length from the end of the line a...
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
void setCustomDashPatternUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
Class for parsing and evaluation of expressions (formerly called "search strings")....
Base class for line symbol layer types which draws line sections using a QBrush.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QColor color2() const
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoC...
virtual double symbolAngle() const =0
Returns the symbol's current angle, in degrees clockwise.
void setTrimDistanceStartUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the trim distance for the start of the line.
Resolves relative paths into absolute paths and vice versa. Used for writing.
double trimDistanceStart() const
Returns the trim distance for the start of the line, which dictates a length from the start of the li...
void setAverageAngleUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
Q_DECL_DEPRECATED bool rotateMarker() const
Shall the marker be rotated.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setOpacity(double opacity)
Set the line opacity.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
QgsUnitTypes::RenderUnit dashPatternOffsetUnit() const
Returns the units for the dash pattern offset.
void setPlacements(Qgis::MarkerLinePlacements placements)
Sets the placement of the symbols.
MarkerLinePlacement
Defines how/where the symbols should be placed on a line.
QgsUnitTypes::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
void setIntervalUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the interval between symbols.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...