QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
16 #ifndef QGSLINESYMBOLLAYER_H
17 #define QGSLINESYMBOLLAYER_H
19 #include "qgis_core.h"
28 #define DEFAULT_SIMPLELINE_COLOR QColor(35,35,35)
29 #define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH
30 #define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine
31 #define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin
32 #define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap
74 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
75 QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const override;
92 Qt::PenStyle
penStyle()
const {
return mPenStyle; }
300 bool alignDashPattern()
const;
311 void setAlignDashPattern(
bool enabled );
323 bool tweakDashPatternOnCorners()
const;
335 void setTweakDashPatternOnCorners(
bool enabled );
339 Qt::PenStyle mPenStyle = Qt::SolidLine;
345 bool mUseCustomDashPattern =
false;
349 double mDashPatternOffset = 0;
354 QVector<qreal> mCustomDashVector;
356 bool mAlignDashPattern =
false;
357 bool mPatternCartographicTweakOnSharpCorners =
false;
359 bool mDrawInsidePolygon =
false;
362 void applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QPen &pen, QPen &selPen,
double &offset );
363 void drawPathWithDashPatternTweaks( QPainter *painter,
const QPolygonF &points, QPen pen )
const;
368 #define DEFAULT_MARKERLINE_ROTATE true
369 #define DEFAULT_MARKERLINE_INTERVAL 3
406 double interval = 3 );
610 virtual
void setSymbolLineAngle(
double angle ) = 0;
615 virtual
double symbolAngle() const = 0;
620 virtual
void setSymbolAngle(
double angle ) = 0;
634 virtual
void renderSymbol( const QPointF &point, const
QgsFeature *feature,
QgsRenderContext &context,
int layer = -1,
bool selected = false ) = 0;
649 void renderPolylineInterval( const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageAngleOver );
651 void renderPolylineCentral( const QPolygonF &points,
QgsSymbolRenderContext &context,
double averageAngleOver );
652 double markerAngle( const QPolygonF &points,
bool isRing,
int vertex );
665 void renderOffsetVertexAlongLine( const QPolygonF &points,
int vertex,
double distance,
QgsSymbolRenderContext &context );
668 static
void collectOffsetPoints( const QVector< QPointF> &points,
669 QVector< QPointF> &dest,
double intervalPainterUnits,
double initialOffset,
double initialLag = 0,
670 int numberPointsRequired = -1 );
672 bool mRotateSymbols = true;
673 double mInterval = 3;
677 double mOffsetAlongLine = 0;
680 double mAverageAngleLength = 4;
684 friend class TestQgsMarkerLineSymbol;
727 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
728 void setColor(
const QColor &color )
override;
729 QColor
color()
const override;
732 void setWidth(
double width )
override;
733 double width()
const override;
759 void setSymbolLineAngle(
double angle )
override;
760 double symbolAngle()
const override;
761 void setSymbolAngle(
double angle )
override;
762 void renderSymbol(
const QPointF &point,
const QgsFeature *feature,
QgsRenderContext &context,
int layer = -1,
bool selected =
false )
override;
794 double interval = 3 );
808 void setColor(
const QColor &color )
override;
809 QColor
color()
const override;
812 void setWidth(
double width )
override;
813 double width()
const override;
826 double hashAngle()
const;
833 void setHashAngle(
double angle );
891 std::unique_ptr< QgsLineSymbol > mHashSymbol;
893 double mSymbolLineAngle = 0;
894 double mSymbolAngle = 0;
896 double mHashAngle = 0;
897 double mHashLength = 3;
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
const QgsMapUnitScale & dashPatternOffsetMapUnitScale() const
Returns the map unit scale 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...
A store for object properties.
void setHashLengthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length of hash symbols.
RenderUnit
Rendering size units.
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.
QgsUnitTypes::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for symbols.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QVector< qreal > dxfCustomDashPattern(QgsUnitTypes::RenderUnit &unit) const
Gets dash pattern.
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.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
virtual void setColor(const QColor &color)
The fill color.
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
virtual QColor color() const
The fill color.
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.
@ Vertex
Place symbols on every vertex in the line.
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...
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 ...
Placement placement() const
Returns the placement of the symbols.
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.
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.
@ CurvePoint
Place symbols at every virtual curve point in the line (used when rendering curved geometry types onl...
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
void setPlacement(Placement placement)
Sets the placement of the symbols.
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
#define DEFAULT_SIMPLELINE_CAPSTYLE
Placement
Defines how/where the templated symbol should be placed on the line.
#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.
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.
QgsUnitTypes::RenderUnit hashLengthUnit() const
Returns the units for the length of hash symbols.
@ SegmentCenter
Place symbols at the center of every line segment.
virtual double dxfOffset(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets offset.
void setOffsetAlongLineUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit used for calculating the offset along line for symbols.
void setHashLength(double length)
Sets the length of hash 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...
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.
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.
virtual void setSymbolAngle(double angle)=0
Sets the symbol's angle, in degrees clockwise.
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.
@ Interval
Place symbols at regular intervals.
#define DEFAULT_SIMPLELINE_PENSTYLE
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...
Base class for templated line symbols, e.g.
void setDashPatternOffset(double offset)
Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start ...
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for symbols.
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...
QMap< QString, QString > QgsStringMap
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 setRotateSymbols(bool rotate)
Sets whether the repeating symbols should be rotated to match their line segment orientation.
@ LastVertex
Place symbols on the last vertex in the line.
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.
Property
Data definable properties.
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
virtual QString layerType() const =0
Returns a string that represents this layer type.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
std::unique_ptr< QgsMarkerSymbol > mMarker
double offset() const
Returns the line's offset.
@ FirstVertex
Place symbols on the first vertex in the line.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
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").
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)
virtual double symbolAngle() const =0
Returns the symbol's current angle, in degrees clockwise.
@ CentralPoint
Place symbols at the mid point of the line.
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
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.
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.