QGIS API Documentation 3.43.0-Master (ac9f54ad1f7)
qgslinesymbollayer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslinesymbollayer.h
3 ---------------------
4 begin : November 2009
5 copyright : (C) 2009 by Martin Dobias
6 email : wonder dot sk at gmail 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 QGSLINESYMBOLLAYER_H
17#define QGSLINESYMBOLLAYER_H
18
19#include "qgis_core.h"
20#include "qgis.h"
21#include "qgssymbollayer.h"
22
23#include <QPen>
24#include <QVector>
25
26class QgsExpression;
27class QgsMarkerSymbol;
28class QgsLineSymbol;
29class QgsPathResolver;
30class QgsColorRamp;
31class QgsFillSymbol;
32
33#define DEFAULT_SIMPLELINE_COLOR QColor(35,35,35)
34#define DEFAULT_SIMPLELINE_WIDTH Qgis::DEFAULT_LINE_WIDTH
35#define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine
36#define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin
37#define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap
38
45{
46 public:
47
54 double width = DEFAULT_SIMPLELINE_WIDTH,
55 Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE );
56
58
59 // static stuff
60
66 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
67
71 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
72
73 QString layerType() const override;
74 Qgis::SymbolLayerFlags flags() const override;
75 void startRender( QgsSymbolRenderContext &context ) override;
76 void stopRender( QgsSymbolRenderContext &context ) override;
77 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
78 //overridden so that clip path can be set when using draw inside polygon option
79 void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
80 QVariantMap properties() const override;
81 QgsSimpleLineSymbolLayer *clone() const override SIP_FACTORY;
82 Q_DECL_DEPRECATED void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
83 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
84 QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
85 void setOutputUnit( Qgis::RenderUnit unit ) override;
86 Qgis::RenderUnit outputUnit() const override;
87 bool usesMapUnits() const override;
88 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
89 QgsMapUnitScale mapUnitScale() const override;
90 double estimateMaxBleed( const QgsRenderContext &context ) const override;
91 QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const override;
92 Qt::PenStyle dxfPenStyle() const override;
93 double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
94 double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
95 QColor dxfColor( QgsSymbolRenderContext &context ) const override;
96 bool canCauseArtifactsBetweenAdjacentTiles() const override;
97
103 Qt::PenStyle penStyle() const { return mPenStyle; }
104
110 void setPenStyle( Qt::PenStyle style ) { mPenStyle = style; }
111
117 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
118
124 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
125
131 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
132
138 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
139
146 bool useCustomDashPattern() const { return mUseCustomDashPattern; }
147
154 void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; }
155
160 void setCustomDashPatternUnit( Qgis::RenderUnit unit ) { mCustomDashPatternUnit = unit; }
161
166 Qgis::RenderUnit customDashPatternUnit() const { return mCustomDashPatternUnit; }
167
172 const QgsMapUnitScale &customDashPatternMapUnitScale() const { return mCustomDashPatternMapUnitScale; }
173
178 void setCustomDashPatternMapUnitScale( const QgsMapUnitScale &scale ) { mCustomDashPatternMapUnitScale = scale; }
179
192 QVector<qreal> customDashVector() const { return mCustomDashVector; }
193
206 void setCustomDashVector( const QVector<qreal> &vector ) { mCustomDashVector = vector; }
207
220 double dashPatternOffset() const { return mDashPatternOffset; }
221
234 void setDashPatternOffset( double offset ) { mDashPatternOffset = offset; }
235
245 void setDashPatternOffsetUnit( Qgis::RenderUnit unit ) { mDashPatternOffsetUnit = unit; }
246
256 Qgis::RenderUnit dashPatternOffsetUnit() const { return mDashPatternOffsetUnit; }
257
267 const QgsMapUnitScale &dashPatternOffsetMapUnitScale() const { return mDashPatternOffsetMapUnitScale; }
268
278 void setDashPatternOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mDashPatternOffsetMapUnitScale = scale; }
279
293 double trimDistanceStart() const { return mTrimDistanceStart; }
294
308 void setTrimDistanceStart( double distance ) { mTrimDistanceStart = distance; }
309
320 void setTrimDistanceStartUnit( Qgis::RenderUnit unit ) { mTrimDistanceStartUnit = unit; }
321
332 Qgis::RenderUnit trimDistanceStartUnit() const { return mTrimDistanceStartUnit; }
333
344 const QgsMapUnitScale &trimDistanceStartMapUnitScale() const { return mTrimDistanceStartMapUnitScale; }
345
356 void setTrimDistanceStartMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceStartMapUnitScale = scale; }
357
371 double trimDistanceEnd() const { return mTrimDistanceEnd; }
372
386 void setTrimDistanceEnd( double distance ) { mTrimDistanceEnd = distance; }
387
398 void setTrimDistanceEndUnit( Qgis::RenderUnit unit ) { mTrimDistanceEndUnit = unit; }
399
410 Qgis::RenderUnit trimDistanceEndUnit() const { return mTrimDistanceEndUnit; }
411
422 const QgsMapUnitScale &trimDistanceEndMapUnitScale() const { return mTrimDistanceEndMapUnitScale; }
423
434 void setTrimDistanceEndMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceEndMapUnitScale = scale; }
435
445 bool drawInsidePolygon() const { return mDrawInsidePolygon; }
446
456 void setDrawInsidePolygon( bool drawInsidePolygon ) { mDrawInsidePolygon = drawInsidePolygon; }
457
467 bool alignDashPattern() const;
468
478 void setAlignDashPattern( bool enabled );
479
490 bool tweakDashPatternOnCorners() const;
491
502 void setTweakDashPatternOnCorners( bool enabled );
503
504 private:
505
506 Qt::PenStyle mPenStyle = Qt::SolidLine;
507 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_SIMPLELINE_JOINSTYLE;
508 Qt::PenCapStyle mPenCapStyle = DEFAULT_SIMPLELINE_CAPSTYLE;
509 QPen mPen;
510 QPen mSelPen;
511
512 bool mUseCustomDashPattern = false;
513 Qgis::RenderUnit mCustomDashPatternUnit = Qgis::RenderUnit::Millimeters;
514 QgsMapUnitScale mCustomDashPatternMapUnitScale;
515
516 double mDashPatternOffset = 0;
517 Qgis::RenderUnit mDashPatternOffsetUnit = Qgis::RenderUnit::Millimeters;
518 QgsMapUnitScale mDashPatternOffsetMapUnitScale;
519
520 double mTrimDistanceStart = 0;
521 Qgis::RenderUnit mTrimDistanceStartUnit = Qgis::RenderUnit::Millimeters;
522 QgsMapUnitScale mTrimDistanceStartMapUnitScale;
523
524 double mTrimDistanceEnd = 0;
525 Qgis::RenderUnit mTrimDistanceEndUnit = Qgis::RenderUnit::Millimeters;
526 QgsMapUnitScale mTrimDistanceEndMapUnitScale;
527
529 QVector<qreal> mCustomDashVector;
530
531 bool mAlignDashPattern = false;
532 bool mPatternCartographicTweakOnSharpCorners = false;
533
534 bool mDrawInsidePolygon = false;
535
536 //helper functions for data defined symbology
537 void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QPen &pen, QPen &selPen, double &offset );
538 void drawPathWithDashPatternTweaks( QPainter *painter, const QPolygonF &points, QPen pen ) const;
539};
540
542
543#define DEFAULT_MARKERLINE_ROTATE true
544#define DEFAULT_MARKERLINE_INTERVAL 3
545
556{
557 public:
558
566 QgsTemplatedLineSymbolLayerBase( bool rotateSymbol = true,
567 double interval = 3 );
568
570
575 bool rotateSymbols() const { return mRotateSymbols; }
576
581 void setRotateSymbols( bool rotate ) { mRotateSymbols = rotate; }
582
588 double interval() const { return mInterval; }
589
596 void setInterval( double interval ) { mInterval = interval; }
597
604 void setIntervalUnit( Qgis::RenderUnit unit ) { mIntervalUnit = unit; }
605
611 Qgis::RenderUnit intervalUnit() const { return mIntervalUnit; }
612
619 void setIntervalMapUnitScale( const QgsMapUnitScale &scale ) { mIntervalMapUnitScale = scale; }
620
627 const QgsMapUnitScale &intervalMapUnitScale() const { return mIntervalMapUnitScale; }
628
634 Q_DECL_DEPRECATED Qgis::MarkerLinePlacement placement() const SIP_DEPRECATED;
635
641 Q_DECL_DEPRECATED void setPlacement( Qgis::MarkerLinePlacement placement ) SIP_DEPRECATED;
642
648 Qgis::MarkerLinePlacements placements() const { return mPlacements; }
649
655 void setPlacements( Qgis::MarkerLinePlacements placements ) { mPlacements = placements; }
656
671 bool placeOnEveryPart() const { return mPlaceOnEveryPart; }
672
687 void setPlaceOnEveryPart( bool respect ) { mPlaceOnEveryPart = respect; }
688
699 double offsetAlongLine() const { return mOffsetAlongLine; }
700
712 void setOffsetAlongLine( double offsetAlongLine ) { mOffsetAlongLine = offsetAlongLine; }
713
720 Qgis::RenderUnit offsetAlongLineUnit() const { return mOffsetAlongLineUnit; }
721
728 void setOffsetAlongLineUnit( Qgis::RenderUnit unit ) { mOffsetAlongLineUnit = unit; }
729
734 const QgsMapUnitScale &offsetAlongLineMapUnitScale() const { return mOffsetAlongLineMapUnitScale; }
735
740 void setOffsetAlongLineMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetAlongLineMapUnitScale = scale; }
741
752 double averageAngleLength() const { return mAverageAngleLength; }
753
764 void setAverageAngleLength( double length ) { mAverageAngleLength = length; }
765
774 void setAverageAngleUnit( Qgis::RenderUnit unit ) { mAverageAngleLengthUnit = unit; }
775
784 Qgis::RenderUnit averageAngleUnit() const { return mAverageAngleLengthUnit; }
785
794 void setAverageAngleMapUnitScale( const QgsMapUnitScale &scale ) { mAverageAngleLengthMapUnitScale = scale; }
795
804 const QgsMapUnitScale &averageAngleMapUnitScale() const { return mAverageAngleLengthMapUnitScale; }
805
806 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
807 void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) FINAL;
809 void setOutputUnit( Qgis::RenderUnit unit ) override;
810 void setMapUnitScale( const QgsMapUnitScale &scale ) FINAL;
811 QgsMapUnitScale mapUnitScale() const FINAL;
812 QVariantMap properties() const override;
813 bool canCauseArtifactsBetweenAdjacentTiles() const override;
814
815 void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
816 void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
817
818 protected:
819
826 virtual void setSymbolLineAngle( double angle ) = 0;
827
831 virtual double symbolAngle() const = 0;
832
836 virtual void setSymbolAngle( double angle ) = 0;
837
850 virtual void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) = 0;
851
855 void copyTemplateSymbolProperties( QgsTemplatedLineSymbolLayerBase *destLayer ) const;
856
861 static void setCommonProperties( QgsTemplatedLineSymbolLayerBase *destLayer, const QVariantMap &properties );
862
863 private:
864
865 void renderPolylineInterval( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
866 void renderPolylineVertex( const QPolygonF &points, QgsSymbolRenderContext &context, Qgis::MarkerLinePlacement placement = Qgis::MarkerLinePlacement::Vertex );
867 void renderPolylineCentral( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
868 double markerAngle( const QPolygonF &points, bool isRing, int vertex );
869
882 void renderOffsetVertexAlongLine( const QPolygonF &points, int vertex, double distance, QgsSymbolRenderContext &context,
883 Qgis::MarkerLinePlacement placement );
884
885
886 static void collectOffsetPoints( const QVector< QPointF> &points,
887 QVector< QPointF> &dest, double intervalPainterUnits, double initialOffset, double initialLag = 0,
888 int numberPointsRequired = -1 );
889
890 bool mRotateSymbols = true;
891 double mInterval = 3;
892 Qgis::RenderUnit mIntervalUnit = Qgis::RenderUnit::Millimeters;
893 QgsMapUnitScale mIntervalMapUnitScale;
894 Qgis::MarkerLinePlacements mPlacements = Qgis::MarkerLinePlacement::Interval;
895 double mOffsetAlongLine = 0; //distance to offset along line before marker is drawn
896 Qgis::RenderUnit mOffsetAlongLineUnit = Qgis::RenderUnit::Millimeters; //unit for offset along line
897 QgsMapUnitScale mOffsetAlongLineMapUnitScale;
898 double mAverageAngleLength = 4;
899 Qgis::RenderUnit mAverageAngleLengthUnit = Qgis::RenderUnit::Millimeters;
900 QgsMapUnitScale mAverageAngleLengthMapUnitScale;
901 bool mPlaceOnEveryPart = true;
902
903 bool mRenderingFeature = false;
904 bool mHasRenderedFirstPart = false;
905 QPointF mFinalVertex;
906 bool mCurrentFeatureIsSelected = false;
907 double mFeatureSymbolOpacity = 1;
908
909 friend class TestQgsMarkerLineSymbol;
910
911};
912
919{
920 public:
921
930 double interval = DEFAULT_MARKERLINE_INTERVAL );
931
933
934 // static stuff
935
941 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
942
946 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
947
948 // implemented from base classes
949
950 QString layerType() const override;
951 void startRender( QgsSymbolRenderContext &context ) override;
952 void stopRender( QgsSymbolRenderContext &context ) override;
953 QgsMarkerLineSymbolLayer *clone() const override SIP_FACTORY;
954 Q_DECL_DEPRECATED void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
955 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
956 void setColor( const QColor &color ) override;
957 QColor color() const override;
958 QgsSymbol *subSymbol() override;
959 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
960 void setWidth( double width ) override;
961 double width() const override;
962 double width( const QgsRenderContext &context ) const override;
963 double estimateMaxBleed( const QgsRenderContext &context ) const override;
964 void setOutputUnit( Qgis::RenderUnit unit ) override;
965 bool usesMapUnits() const override;
966 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
967 bool hasDataDefinedProperties() const override;
968 void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
969
976 Q_DECL_DEPRECATED bool rotateMarker() const SIP_DEPRECATED { return rotateSymbols(); }
977
982 Q_DECL_DEPRECATED void setRotateMarker( bool rotate ) SIP_DEPRECATED { setRotateSymbols( rotate ); }
983
984 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
985
986 protected:
987
988 std::unique_ptr< QgsMarkerSymbol > mMarker;
989
990 void setSymbolLineAngle( double angle ) override;
991 double symbolAngle() const override;
992 void setSymbolAngle( double angle ) override;
993 void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
994
995 private:
996
997#ifdef SIP_RUN
999#endif
1000
1001
1002};
1003
1004
1014{
1015 public:
1016
1024 QgsHashedLineSymbolLayer( bool rotateSymbol = true,
1025 double interval = 3 );
1026
1028
1034 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1035
1036 QString layerType() const override;
1037 void startRender( QgsSymbolRenderContext &context ) override;
1038 void stopRender( QgsSymbolRenderContext &context ) override;
1039 QVariantMap properties() const override;
1040 QgsHashedLineSymbolLayer *clone() const override SIP_FACTORY;
1041 void setColor( const QColor &color ) override;
1042 QColor color() const override;
1043 QgsSymbol *subSymbol() override;
1044 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1045 void setWidth( double width ) override;
1046 double width() const override;
1047 double width( const QgsRenderContext &context ) const override;
1048 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1049 void setOutputUnit( Qgis::RenderUnit unit ) override;
1050 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1051 bool hasDataDefinedProperties() const override;
1052 void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
1053 bool usesMapUnits() const override;
1054
1060 double hashAngle() const;
1061
1067 void setHashAngle( double angle );
1068
1074 double hashLength() const { return mHashLength; }
1075
1081 void setHashLength( double length ) { mHashLength = length; }
1082
1088 void setHashLengthUnit( Qgis::RenderUnit unit ) { mHashLengthUnit = unit; }
1089
1095 Qgis::RenderUnit hashLengthUnit() const { return mHashLengthUnit; }
1096
1103 void setHashLengthMapUnitScale( const QgsMapUnitScale &scale ) { mHashLengthMapUnitScale = scale; }
1104
1111 const QgsMapUnitScale &hashLengthMapUnitScale() const { return mHashLengthMapUnitScale; }
1112
1113 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1114
1115 protected:
1116
1117 void setSymbolLineAngle( double angle ) override;
1118 double symbolAngle() const override;
1119 void setSymbolAngle( double angle ) override;
1120 void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
1121
1122 private:
1123#ifdef SIP_RUN
1125#endif
1126
1127 std::unique_ptr< QgsLineSymbol > mHashSymbol;
1128
1129 double mSymbolLineAngle = 0;
1130 double mSymbolAngle = 0;
1131
1132 double mHashAngle = 0;
1133 double mHashLength = 3;
1135 QgsMapUnitScale mHashLengthMapUnitScale;
1136
1137};
1138
1139
1149{
1150 public:
1151
1157 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1158
1164 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1165
1171 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
1172
1178 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
1179
1180 protected:
1181
1185 void renderPolylineUsingBrush( const QPolygonF &points, QgsSymbolRenderContext &context, const QBrush &brush,
1186 double patternThickness, double patternLength );
1187
1188 Qt::PenJoinStyle mPenJoinStyle = Qt::PenJoinStyle::RoundJoin;
1189 Qt::PenCapStyle mPenCapStyle = Qt::PenCapStyle::RoundCap;
1190
1191 private:
1192 void renderLine( const QPolygonF &points, QgsSymbolRenderContext &context, const double lineThickness, const double patternLength, const QBrush &sourceBrush );
1193};
1194
1195
1196
1206{
1207 public:
1208
1212 QgsRasterLineSymbolLayer( const QString &path = QString() );
1214
1220 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1221
1226 static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
1227
1232 QString path() const { return mPath; }
1233
1238 void setPath( const QString &path );
1239
1245 double opacity() const { return mOpacity; }
1246
1252 void setOpacity( double opacity ) { mOpacity = opacity; }
1253
1254 QString layerType() const override;
1255 Qgis::SymbolLayerFlags flags() const override;
1256 void startRender( QgsSymbolRenderContext &context ) override;
1257 void stopRender( QgsSymbolRenderContext &context ) override;
1258 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1259 QVariantMap properties() const override;
1260 QgsRasterLineSymbolLayer *clone() const override SIP_FACTORY;
1261 void setOutputUnit( Qgis::RenderUnit unit ) override;
1262 Qgis::RenderUnit outputUnit() const override;
1263 bool usesMapUnits() const override;
1264 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1265 QgsMapUnitScale mapUnitScale() const override;
1266 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1267 QColor color() const override;
1268
1269 protected:
1270 QString mPath;
1271 double mOpacity = 1.0;
1272 QImage mLineImage;
1273
1274};
1275
1276
1289{
1290 public:
1291
1296 const QColor &color2 = Qt::white );
1298
1304 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1305
1306 QString layerType() const override;
1307 Qgis::SymbolLayerFlags flags() const override;
1308 void startRender( QgsSymbolRenderContext &context ) override;
1309 void stopRender( QgsSymbolRenderContext &context ) override;
1310 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1311 QVariantMap properties() const override;
1312 QgsLineburstSymbolLayer *clone() const override SIP_FACTORY;
1313 void setOutputUnit( Qgis::RenderUnit unit ) override;
1314 Qgis::RenderUnit outputUnit() const override;
1315 bool usesMapUnits() const override;
1316 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1317 QgsMapUnitScale mapUnitScale() const override;
1318 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1319
1325 Qgis::GradientColorSource gradientColorType() const { return mGradientColorType; }
1326
1332 void setGradientColorType( Qgis::GradientColorSource gradientColorType ) { mGradientColorType = gradientColorType; }
1333
1340 QgsColorRamp *colorRamp();
1341
1349 void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
1350
1356 QColor color2() const { return mColor2; }
1357
1363 void setColor2( const QColor &color2 ) { mColor2 = color2; }
1364
1365 protected:
1367 QColor mColor2;
1368 std::unique_ptr< QgsColorRamp > mGradientRamp;
1369
1370};
1371
1372
1382{
1383 public:
1384
1392 QgsFilledLineSymbolLayer( double width = DEFAULT_SIMPLELINE_WIDTH, QgsFillSymbol *fillSymbol SIP_TRANSFER = nullptr );
1394
1400 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1401
1402 QString layerType() const override;
1403 void startRender( QgsSymbolRenderContext &context ) override;
1404 void stopRender( QgsSymbolRenderContext &context ) override;
1405 void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
1406 void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
1407 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1408 QVariantMap properties() const override;
1409 QgsFilledLineSymbolLayer *clone() const override SIP_FACTORY;
1410 QgsSymbol *subSymbol() override;
1411 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1412 bool hasDataDefinedProperties() const override;
1413 void setColor( const QColor &c ) override;
1414 QColor color() const override;
1415 void setOutputUnit( Qgis::RenderUnit unit ) override;
1416 Qgis::RenderUnit outputUnit() const override;
1417 bool usesMapUnits() const override;
1418 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1419 QgsMapUnitScale mapUnitScale() const override;
1420 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1421 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1422
1428 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1429
1435 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1436
1442 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
1443
1449 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
1450
1451 private:
1452
1453#ifdef SIP_RUN
1455#endif
1456
1458 std::unique_ptr< QgsFillSymbol > mFill;
1459 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_SIMPLELINE_JOINSTYLE;
1460 Qt::PenCapStyle mPenCapStyle = DEFAULT_SIMPLELINE_CAPSTYLE;
1461
1462
1463};
1464
1465#endif
1466
1467
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:54
MarkerLinePlacement
Defines how/where the symbols should be placed on a line.
Definition qgis.h:3023
GradientColorSource
Gradient color sources.
Definition qgis.h:3072
@ SimpleTwoColor
Simple two color gradient.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
Definition qgis.h:851
RenderUnit
Rendering size units.
Definition qgis.h:5029
@ Millimeters
Millimeters.
QFlags< MarkerLinePlacement > MarkerLinePlacements
Definition qgis.h:3034
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.
Handles 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...
Definition qgsfeature.h:58
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.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
Abstract base class for symbol layers.
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.
Encapsulates the context in which a symbol is being rendered.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
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.
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 SIP_DEPRECATED
Definition qgis_sip.h:106
#define FINAL
Definition qgis_sip.h:242
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
#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