QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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 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 void startRender( QgsSymbolRenderContext &context ) override;
75 void stopRender( QgsSymbolRenderContext &context ) override;
76 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
77 //overridden so that clip path can be set when using draw inside polygon option
78 void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
79 QVariantMap properties() const override;
80 QgsSimpleLineSymbolLayer *clone() const override SIP_FACTORY;
81 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
82 QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
83 void setOutputUnit( Qgis::RenderUnit unit ) override;
84 Qgis::RenderUnit outputUnit() const override;
85 bool usesMapUnits() const override;
86 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
87 QgsMapUnitScale mapUnitScale() const override;
88 double estimateMaxBleed( const QgsRenderContext &context ) const override;
89 QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const override;
90 Qt::PenStyle dxfPenStyle() const override;
91 double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
92 double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
93 QColor dxfColor( QgsSymbolRenderContext &context ) const override;
94 bool canCauseArtifactsBetweenAdjacentTiles() const override;
95
101 Qt::PenStyle penStyle() const { return mPenStyle; }
102
108 void setPenStyle( Qt::PenStyle style ) { mPenStyle = style; }
109
115 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
116
122 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
123
129 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
130
136 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
137
144 bool useCustomDashPattern() const { return mUseCustomDashPattern; }
145
152 void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; }
153
158 void setCustomDashPatternUnit( Qgis::RenderUnit unit ) { mCustomDashPatternUnit = unit; }
159
164 Qgis::RenderUnit customDashPatternUnit() const { return mCustomDashPatternUnit; }
165
170 const QgsMapUnitScale &customDashPatternMapUnitScale() const { return mCustomDashPatternMapUnitScale; }
171
176 void setCustomDashPatternMapUnitScale( const QgsMapUnitScale &scale ) { mCustomDashPatternMapUnitScale = scale; }
177
190 QVector<qreal> customDashVector() const { return mCustomDashVector; }
191
204 void setCustomDashVector( const QVector<qreal> &vector ) { mCustomDashVector = vector; }
205
218 double dashPatternOffset() const { return mDashPatternOffset; }
219
232 void setDashPatternOffset( double offset ) { mDashPatternOffset = offset; }
233
243 void setDashPatternOffsetUnit( Qgis::RenderUnit unit ) { mDashPatternOffsetUnit = unit; }
244
254 Qgis::RenderUnit dashPatternOffsetUnit() const { return mDashPatternOffsetUnit; }
255
265 const QgsMapUnitScale &dashPatternOffsetMapUnitScale() const { return mDashPatternOffsetMapUnitScale; }
266
276 void setDashPatternOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mDashPatternOffsetMapUnitScale = scale; }
277
291 double trimDistanceStart() const { return mTrimDistanceStart; }
292
306 void setTrimDistanceStart( double distance ) { mTrimDistanceStart = distance; }
307
318 void setTrimDistanceStartUnit( Qgis::RenderUnit unit ) { mTrimDistanceStartUnit = unit; }
319
330 Qgis::RenderUnit trimDistanceStartUnit() const { return mTrimDistanceStartUnit; }
331
342 const QgsMapUnitScale &trimDistanceStartMapUnitScale() const { return mTrimDistanceStartMapUnitScale; }
343
354 void setTrimDistanceStartMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceStartMapUnitScale = scale; }
355
369 double trimDistanceEnd() const { return mTrimDistanceEnd; }
370
384 void setTrimDistanceEnd( double distance ) { mTrimDistanceEnd = distance; }
385
396 void setTrimDistanceEndUnit( Qgis::RenderUnit unit ) { mTrimDistanceEndUnit = unit; }
397
408 Qgis::RenderUnit trimDistanceEndUnit() const { return mTrimDistanceEndUnit; }
409
420 const QgsMapUnitScale &trimDistanceEndMapUnitScale() const { return mTrimDistanceEndMapUnitScale; }
421
432 void setTrimDistanceEndMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceEndMapUnitScale = scale; }
433
443 bool drawInsidePolygon() const { return mDrawInsidePolygon; }
444
454 void setDrawInsidePolygon( bool drawInsidePolygon ) { mDrawInsidePolygon = drawInsidePolygon; }
455
465 bool alignDashPattern() const;
466
476 void setAlignDashPattern( bool enabled );
477
488 bool tweakDashPatternOnCorners() const;
489
500 void setTweakDashPatternOnCorners( bool enabled );
501
502 private:
503
504 Qt::PenStyle mPenStyle = Qt::SolidLine;
505 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_SIMPLELINE_JOINSTYLE;
506 Qt::PenCapStyle mPenCapStyle = DEFAULT_SIMPLELINE_CAPSTYLE;
507 QPen mPen;
508 QPen mSelPen;
509
510 bool mUseCustomDashPattern = false;
511 Qgis::RenderUnit mCustomDashPatternUnit = Qgis::RenderUnit::Millimeters;
512 QgsMapUnitScale mCustomDashPatternMapUnitScale;
513
514 double mDashPatternOffset = 0;
515 Qgis::RenderUnit mDashPatternOffsetUnit = Qgis::RenderUnit::Millimeters;
516 QgsMapUnitScale mDashPatternOffsetMapUnitScale;
517
518 double mTrimDistanceStart = 0;
519 Qgis::RenderUnit mTrimDistanceStartUnit = Qgis::RenderUnit::Millimeters;
520 QgsMapUnitScale mTrimDistanceStartMapUnitScale;
521
522 double mTrimDistanceEnd = 0;
523 Qgis::RenderUnit mTrimDistanceEndUnit = Qgis::RenderUnit::Millimeters;
524 QgsMapUnitScale mTrimDistanceEndMapUnitScale;
525
527 QVector<qreal> mCustomDashVector;
528
529 bool mAlignDashPattern = false;
530 bool mPatternCartographicTweakOnSharpCorners = false;
531
532 bool mDrawInsidePolygon = false;
533
534 //helper functions for data defined symbology
535 void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QPen &pen, QPen &selPen, double &offset );
536 void drawPathWithDashPatternTweaks( QPainter *painter, const QPolygonF &points, QPen pen ) const;
537};
538
540
541#define DEFAULT_MARKERLINE_ROTATE true
542#define DEFAULT_MARKERLINE_INTERVAL 3
543
554{
555 public:
556
564 QgsTemplatedLineSymbolLayerBase( bool rotateSymbol = true,
565 double interval = 3 );
566
568
573 bool rotateSymbols() const { return mRotateSymbols; }
574
579 void setRotateSymbols( bool rotate ) { mRotateSymbols = rotate; }
580
586 double interval() const { return mInterval; }
587
594 void setInterval( double interval ) { mInterval = interval; }
595
602 void setIntervalUnit( Qgis::RenderUnit unit ) { mIntervalUnit = unit; }
603
609 Qgis::RenderUnit intervalUnit() const { return mIntervalUnit; }
610
617 void setIntervalMapUnitScale( const QgsMapUnitScale &scale ) { mIntervalMapUnitScale = scale; }
618
625 const QgsMapUnitScale &intervalMapUnitScale() const { return mIntervalMapUnitScale; }
626
632 Q_DECL_DEPRECATED Qgis::MarkerLinePlacement placement() const SIP_DEPRECATED;
633
639 Q_DECL_DEPRECATED void setPlacement( Qgis::MarkerLinePlacement placement ) SIP_DEPRECATED;
640
646 Qgis::MarkerLinePlacements placements() const { return mPlacements; }
647
653 void setPlacements( Qgis::MarkerLinePlacements placements ) { mPlacements = placements; }
654
669 bool placeOnEveryPart() const { return mPlaceOnEveryPart; }
670
685 void setPlaceOnEveryPart( bool respect ) { mPlaceOnEveryPart = respect; }
686
697 double offsetAlongLine() const { return mOffsetAlongLine; }
698
710 void setOffsetAlongLine( double offsetAlongLine ) { mOffsetAlongLine = offsetAlongLine; }
711
718 Qgis::RenderUnit offsetAlongLineUnit() const { return mOffsetAlongLineUnit; }
719
726 void setOffsetAlongLineUnit( Qgis::RenderUnit unit ) { mOffsetAlongLineUnit = unit; }
727
732 const QgsMapUnitScale &offsetAlongLineMapUnitScale() const { return mOffsetAlongLineMapUnitScale; }
733
738 void setOffsetAlongLineMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetAlongLineMapUnitScale = scale; }
739
750 double averageAngleLength() const { return mAverageAngleLength; }
751
762 void setAverageAngleLength( double length ) { mAverageAngleLength = length; }
763
772 void setAverageAngleUnit( Qgis::RenderUnit unit ) { mAverageAngleLengthUnit = unit; }
773
782 Qgis::RenderUnit averageAngleUnit() const { return mAverageAngleLengthUnit; }
783
792 void setAverageAngleMapUnitScale( const QgsMapUnitScale &scale ) { mAverageAngleLengthMapUnitScale = scale; }
793
802 const QgsMapUnitScale &averageAngleMapUnitScale() const { return mAverageAngleLengthMapUnitScale; }
803
804 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
805 void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) FINAL;
807 void setOutputUnit( Qgis::RenderUnit unit ) override;
808 void setMapUnitScale( const QgsMapUnitScale &scale ) FINAL;
809 QgsMapUnitScale mapUnitScale() const FINAL;
810 QVariantMap properties() const override;
811 bool canCauseArtifactsBetweenAdjacentTiles() const override;
812
813 void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
814 void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
815
816 protected:
817
824 virtual void setSymbolLineAngle( double angle ) = 0;
825
829 virtual double symbolAngle() const = 0;
830
834 virtual void setSymbolAngle( double angle ) = 0;
835
848 virtual void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) = 0;
849
853 void copyTemplateSymbolProperties( QgsTemplatedLineSymbolLayerBase *destLayer ) const;
854
859 static void setCommonProperties( QgsTemplatedLineSymbolLayerBase *destLayer, const QVariantMap &properties );
860
861 private:
862
863 void renderPolylineInterval( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
864 void renderPolylineVertex( const QPolygonF &points, QgsSymbolRenderContext &context, Qgis::MarkerLinePlacement placement = Qgis::MarkerLinePlacement::Vertex );
865 void renderPolylineCentral( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
866 double markerAngle( const QPolygonF &points, bool isRing, int vertex );
867
880 void renderOffsetVertexAlongLine( const QPolygonF &points, int vertex, double distance, QgsSymbolRenderContext &context,
881 Qgis::MarkerLinePlacement placement );
882
883
884 static void collectOffsetPoints( const QVector< QPointF> &points,
885 QVector< QPointF> &dest, double intervalPainterUnits, double initialOffset, double initialLag = 0,
886 int numberPointsRequired = -1 );
887
888 bool mRotateSymbols = true;
889 double mInterval = 3;
890 Qgis::RenderUnit mIntervalUnit = Qgis::RenderUnit::Millimeters;
891 QgsMapUnitScale mIntervalMapUnitScale;
892 Qgis::MarkerLinePlacements mPlacements = Qgis::MarkerLinePlacement::Interval;
893 double mOffsetAlongLine = 0; //distance to offset along line before marker is drawn
894 Qgis::RenderUnit mOffsetAlongLineUnit = Qgis::RenderUnit::Millimeters; //unit for offset along line
895 QgsMapUnitScale mOffsetAlongLineMapUnitScale;
896 double mAverageAngleLength = 4;
897 Qgis::RenderUnit mAverageAngleLengthUnit = Qgis::RenderUnit::Millimeters;
898 QgsMapUnitScale mAverageAngleLengthMapUnitScale;
899 bool mPlaceOnEveryPart = true;
900
901 bool mRenderingFeature = false;
902 bool mHasRenderedFirstPart = false;
903 QPointF mFinalVertex;
904 bool mCurrentFeatureIsSelected = false;
905 double mFeatureSymbolOpacity = 1;
906
907 friend class TestQgsMarkerLineSymbol;
908
909};
910
917{
918 public:
919
928 double interval = DEFAULT_MARKERLINE_INTERVAL );
929
931
932 // static stuff
933
939 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
940
944 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
945
946 // implemented from base classes
947
948 QString layerType() const override;
949 void startRender( QgsSymbolRenderContext &context ) override;
950 void stopRender( QgsSymbolRenderContext &context ) override;
951 QgsMarkerLineSymbolLayer *clone() const override SIP_FACTORY;
952 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
953 void setColor( const QColor &color ) override;
954 QColor color() const override;
955 QgsSymbol *subSymbol() override;
956 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
957 void setWidth( double width ) override;
958 double width() const override;
959 double width( const QgsRenderContext &context ) const override;
960 double estimateMaxBleed( const QgsRenderContext &context ) const override;
961 void setOutputUnit( Qgis::RenderUnit unit ) override;
962 bool usesMapUnits() const override;
963 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
964 bool hasDataDefinedProperties() const override;
965 void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
966
973 Q_DECL_DEPRECATED bool rotateMarker() const SIP_DEPRECATED { return rotateSymbols(); }
974
979 Q_DECL_DEPRECATED void setRotateMarker( bool rotate ) SIP_DEPRECATED { setRotateSymbols( rotate ); }
980
981 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
982
983 protected:
984
985 std::unique_ptr< QgsMarkerSymbol > mMarker;
986
987 void setSymbolLineAngle( double angle ) override;
988 double symbolAngle() const override;
989 void setSymbolAngle( double angle ) override;
990 void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
991
992 private:
993
994#ifdef SIP_RUN
996#endif
997
998
999};
1000
1001
1011{
1012 public:
1013
1021 QgsHashedLineSymbolLayer( bool rotateSymbol = true,
1022 double interval = 3 );
1023
1025
1031 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1032
1033 QString layerType() const override;
1034 void startRender( QgsSymbolRenderContext &context ) override;
1035 void stopRender( QgsSymbolRenderContext &context ) override;
1036 QVariantMap properties() const override;
1037 QgsHashedLineSymbolLayer *clone() const override SIP_FACTORY;
1038 void setColor( const QColor &color ) override;
1039 QColor color() const override;
1040 QgsSymbol *subSymbol() override;
1041 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1042 void setWidth( double width ) override;
1043 double width() const override;
1044 double width( const QgsRenderContext &context ) const override;
1045 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1046 void setOutputUnit( Qgis::RenderUnit unit ) override;
1047 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1048 bool hasDataDefinedProperties() const override;
1049 void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
1050 bool usesMapUnits() const override;
1051
1057 double hashAngle() const;
1058
1064 void setHashAngle( double angle );
1065
1071 double hashLength() const { return mHashLength; }
1072
1078 void setHashLength( double length ) { mHashLength = length; }
1079
1085 void setHashLengthUnit( Qgis::RenderUnit unit ) { mHashLengthUnit = unit; }
1086
1092 Qgis::RenderUnit hashLengthUnit() const { return mHashLengthUnit; }
1093
1100 void setHashLengthMapUnitScale( const QgsMapUnitScale &scale ) { mHashLengthMapUnitScale = scale; }
1101
1108 const QgsMapUnitScale &hashLengthMapUnitScale() const { return mHashLengthMapUnitScale; }
1109
1110 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1111
1112 protected:
1113
1114 void setSymbolLineAngle( double angle ) override;
1115 double symbolAngle() const override;
1116 void setSymbolAngle( double angle ) override;
1117 void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
1118
1119 private:
1120#ifdef SIP_RUN
1122#endif
1123
1124 std::unique_ptr< QgsLineSymbol > mHashSymbol;
1125
1126 double mSymbolLineAngle = 0;
1127 double mSymbolAngle = 0;
1128
1129 double mHashAngle = 0;
1130 double mHashLength = 3;
1132 QgsMapUnitScale mHashLengthMapUnitScale;
1133
1134};
1135
1136
1146{
1147 public:
1148
1154 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1155
1161 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1162
1168 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
1169
1175 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
1176
1177 protected:
1178
1182 void renderPolylineUsingBrush( const QPolygonF &points, QgsSymbolRenderContext &context, const QBrush &brush,
1183 double patternThickness, double patternLength );
1184
1185 Qt::PenJoinStyle mPenJoinStyle = Qt::PenJoinStyle::RoundJoin;
1186 Qt::PenCapStyle mPenCapStyle = Qt::PenCapStyle::RoundCap;
1187
1188 private:
1189 void renderLine( const QPolygonF &points, QgsSymbolRenderContext &context, const double lineThickness, const double patternLength, const QBrush &sourceBrush );
1190};
1191
1192
1193
1203{
1204 public:
1205
1209 QgsRasterLineSymbolLayer( const QString &path = QString() );
1211
1217 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1218
1223 static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
1224
1229 QString path() const { return mPath; }
1230
1235 void setPath( const QString &path );
1236
1242 double opacity() const { return mOpacity; }
1243
1249 void setOpacity( double opacity ) { mOpacity = opacity; }
1250
1251 QString layerType() const override;
1252 void startRender( QgsSymbolRenderContext &context ) override;
1253 void stopRender( QgsSymbolRenderContext &context ) override;
1254 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1255 QVariantMap properties() const override;
1256 QgsRasterLineSymbolLayer *clone() const override SIP_FACTORY;
1257 void setOutputUnit( Qgis::RenderUnit unit ) override;
1258 Qgis::RenderUnit outputUnit() const override;
1259 bool usesMapUnits() const override;
1260 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1261 QgsMapUnitScale mapUnitScale() const override;
1262 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1263 QColor color() const override;
1264
1265 protected:
1266 QString mPath;
1267 double mOpacity = 1.0;
1268 QImage mLineImage;
1269
1270};
1271
1272
1285{
1286 public:
1287
1292 const QColor &color2 = Qt::white );
1294
1300 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1301
1302 QString layerType() const override;
1303 void startRender( QgsSymbolRenderContext &context ) override;
1304 void stopRender( QgsSymbolRenderContext &context ) override;
1305 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1306 QVariantMap properties() const override;
1307 QgsLineburstSymbolLayer *clone() const override SIP_FACTORY;
1308 void setOutputUnit( Qgis::RenderUnit unit ) override;
1309 Qgis::RenderUnit outputUnit() const override;
1310 bool usesMapUnits() const override;
1311 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1312 QgsMapUnitScale mapUnitScale() const override;
1313 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1314
1320 Qgis::GradientColorSource gradientColorType() const { return mGradientColorType; }
1321
1327 void setGradientColorType( Qgis::GradientColorSource gradientColorType ) { mGradientColorType = gradientColorType; }
1328
1335 QgsColorRamp *colorRamp();
1336
1344 void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
1345
1351 QColor color2() const { return mColor2; }
1352
1358 void setColor2( const QColor &color2 ) { mColor2 = color2; }
1359
1360 protected:
1362 QColor mColor2;
1363 std::unique_ptr< QgsColorRamp > mGradientRamp;
1364
1365};
1366
1367
1377{
1378 public:
1379
1387 QgsFilledLineSymbolLayer( double width = DEFAULT_SIMPLELINE_WIDTH, QgsFillSymbol *fillSymbol SIP_TRANSFER = nullptr );
1389
1395 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1396
1397 QString layerType() const override;
1398 void startRender( QgsSymbolRenderContext &context ) override;
1399 void stopRender( QgsSymbolRenderContext &context ) override;
1400 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1401 QVariantMap properties() const override;
1402 QgsFilledLineSymbolLayer *clone() const override SIP_FACTORY;
1403 QgsSymbol *subSymbol() override;
1404 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1405 bool hasDataDefinedProperties() const override;
1406 void setColor( const QColor &c ) override;
1407 QColor color() const override;
1408 void setOutputUnit( Qgis::RenderUnit unit ) override;
1409 Qgis::RenderUnit outputUnit() const override;
1410 bool usesMapUnits() const override;
1411 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1412 QgsMapUnitScale mapUnitScale() const override;
1413 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1414 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1415
1421 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1422
1428 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1429
1435 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
1436
1442 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
1443
1444 private:
1445
1446#ifdef SIP_RUN
1448#endif
1449
1451 std::unique_ptr< QgsFillSymbol > mFill;
1452 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_SIMPLELINE_JOINSTYLE;
1453 Qt::PenCapStyle mPenCapStyle = DEFAULT_SIMPLELINE_CAPSTYLE;
1454
1455
1456};
1457
1458#endif
1459
1460
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
MarkerLinePlacement
Defines how/where the symbols should be placed on a line.
Definition qgis.h:2518
GradientColorSource
Gradient color sources.
Definition qgis.h:2540
@ SimpleTwoColor
Simple two color gradient.
RenderUnit
Rendering size units.
Definition qgis.h:4193
@ Millimeters
Millimeters.
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...
Definition qgsfeature.h:56
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.
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.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:94
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