QGIS API Documentation 3.41.0-Master (25ec5511245)
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 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 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
83 QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
84 void setOutputUnit( Qgis::RenderUnit unit ) override;
85 Qgis::RenderUnit outputUnit() const override;
86 bool usesMapUnits() const override;
87 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
88 QgsMapUnitScale mapUnitScale() const override;
89 double estimateMaxBleed( const QgsRenderContext &context ) const override;
90 QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const override;
91 Qt::PenStyle dxfPenStyle() const override;
92 double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
93 double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
94 QColor dxfColor( QgsSymbolRenderContext &context ) const override;
95 bool canCauseArtifactsBetweenAdjacentTiles() const override;
96
102 Qt::PenStyle penStyle() const { return mPenStyle; }
103
109 void setPenStyle( Qt::PenStyle style ) { mPenStyle = style; }
110
116 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
117
123 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
124
130 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
131
137 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
138
145 bool useCustomDashPattern() const { return mUseCustomDashPattern; }
146
153 void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; }
154
159 void setCustomDashPatternUnit( Qgis::RenderUnit unit ) { mCustomDashPatternUnit = unit; }
160
165 Qgis::RenderUnit customDashPatternUnit() const { return mCustomDashPatternUnit; }
166
171 const QgsMapUnitScale &customDashPatternMapUnitScale() const { return mCustomDashPatternMapUnitScale; }
172
177 void setCustomDashPatternMapUnitScale( const QgsMapUnitScale &scale ) { mCustomDashPatternMapUnitScale = scale; }
178
191 QVector<qreal> customDashVector() const { return mCustomDashVector; }
192
205 void setCustomDashVector( const QVector<qreal> &vector ) { mCustomDashVector = vector; }
206
219 double dashPatternOffset() const { return mDashPatternOffset; }
220
233 void setDashPatternOffset( double offset ) { mDashPatternOffset = offset; }
234
244 void setDashPatternOffsetUnit( Qgis::RenderUnit unit ) { mDashPatternOffsetUnit = unit; }
245
255 Qgis::RenderUnit dashPatternOffsetUnit() const { return mDashPatternOffsetUnit; }
256
266 const QgsMapUnitScale &dashPatternOffsetMapUnitScale() const { return mDashPatternOffsetMapUnitScale; }
267
277 void setDashPatternOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mDashPatternOffsetMapUnitScale = scale; }
278
292 double trimDistanceStart() const { return mTrimDistanceStart; }
293
307 void setTrimDistanceStart( double distance ) { mTrimDistanceStart = distance; }
308
319 void setTrimDistanceStartUnit( Qgis::RenderUnit unit ) { mTrimDistanceStartUnit = unit; }
320
331 Qgis::RenderUnit trimDistanceStartUnit() const { return mTrimDistanceStartUnit; }
332
343 const QgsMapUnitScale &trimDistanceStartMapUnitScale() const { return mTrimDistanceStartMapUnitScale; }
344
355 void setTrimDistanceStartMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceStartMapUnitScale = scale; }
356
370 double trimDistanceEnd() const { return mTrimDistanceEnd; }
371
385 void setTrimDistanceEnd( double distance ) { mTrimDistanceEnd = distance; }
386
397 void setTrimDistanceEndUnit( Qgis::RenderUnit unit ) { mTrimDistanceEndUnit = unit; }
398
409 Qgis::RenderUnit trimDistanceEndUnit() const { return mTrimDistanceEndUnit; }
410
421 const QgsMapUnitScale &trimDistanceEndMapUnitScale() const { return mTrimDistanceEndMapUnitScale; }
422
433 void setTrimDistanceEndMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceEndMapUnitScale = scale; }
434
444 bool drawInsidePolygon() const { return mDrawInsidePolygon; }
445
455 void setDrawInsidePolygon( bool drawInsidePolygon ) { mDrawInsidePolygon = drawInsidePolygon; }
456
466 bool alignDashPattern() const;
467
477 void setAlignDashPattern( bool enabled );
478
489 bool tweakDashPatternOnCorners() const;
490
501 void setTweakDashPatternOnCorners( bool enabled );
502
503 private:
504
505 Qt::PenStyle mPenStyle = Qt::SolidLine;
506 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_SIMPLELINE_JOINSTYLE;
507 Qt::PenCapStyle mPenCapStyle = DEFAULT_SIMPLELINE_CAPSTYLE;
508 QPen mPen;
509 QPen mSelPen;
510
511 bool mUseCustomDashPattern = false;
512 Qgis::RenderUnit mCustomDashPatternUnit = Qgis::RenderUnit::Millimeters;
513 QgsMapUnitScale mCustomDashPatternMapUnitScale;
514
515 double mDashPatternOffset = 0;
516 Qgis::RenderUnit mDashPatternOffsetUnit = Qgis::RenderUnit::Millimeters;
517 QgsMapUnitScale mDashPatternOffsetMapUnitScale;
518
519 double mTrimDistanceStart = 0;
520 Qgis::RenderUnit mTrimDistanceStartUnit = Qgis::RenderUnit::Millimeters;
521 QgsMapUnitScale mTrimDistanceStartMapUnitScale;
522
523 double mTrimDistanceEnd = 0;
524 Qgis::RenderUnit mTrimDistanceEndUnit = Qgis::RenderUnit::Millimeters;
525 QgsMapUnitScale mTrimDistanceEndMapUnitScale;
526
528 QVector<qreal> mCustomDashVector;
529
530 bool mAlignDashPattern = false;
531 bool mPatternCartographicTweakOnSharpCorners = false;
532
533 bool mDrawInsidePolygon = false;
534
535 //helper functions for data defined symbology
536 void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QPen &pen, QPen &selPen, double &offset );
537 void drawPathWithDashPatternTweaks( QPainter *painter, const QPolygonF &points, QPen pen ) const;
538};
539
541
542#define DEFAULT_MARKERLINE_ROTATE true
543#define DEFAULT_MARKERLINE_INTERVAL 3
544
555{
556 public:
557
565 QgsTemplatedLineSymbolLayerBase( bool rotateSymbol = true,
566 double interval = 3 );
567
569
574 bool rotateSymbols() const { return mRotateSymbols; }
575
580 void setRotateSymbols( bool rotate ) { mRotateSymbols = rotate; }
581
587 double interval() const { return mInterval; }
588
595 void setInterval( double interval ) { mInterval = interval; }
596
603 void setIntervalUnit( Qgis::RenderUnit unit ) { mIntervalUnit = unit; }
604
610 Qgis::RenderUnit intervalUnit() const { return mIntervalUnit; }
611
618 void setIntervalMapUnitScale( const QgsMapUnitScale &scale ) { mIntervalMapUnitScale = scale; }
619
626 const QgsMapUnitScale &intervalMapUnitScale() const { return mIntervalMapUnitScale; }
627
633 Q_DECL_DEPRECATED Qgis::MarkerLinePlacement placement() const SIP_DEPRECATED;
634
640 Q_DECL_DEPRECATED void setPlacement( Qgis::MarkerLinePlacement placement ) SIP_DEPRECATED;
641
647 Qgis::MarkerLinePlacements placements() const { return mPlacements; }
648
654 void setPlacements( Qgis::MarkerLinePlacements placements ) { mPlacements = placements; }
655
670 bool placeOnEveryPart() const { return mPlaceOnEveryPart; }
671
686 void setPlaceOnEveryPart( bool respect ) { mPlaceOnEveryPart = respect; }
687
698 double offsetAlongLine() const { return mOffsetAlongLine; }
699
711 void setOffsetAlongLine( double offsetAlongLine ) { mOffsetAlongLine = offsetAlongLine; }
712
719 Qgis::RenderUnit offsetAlongLineUnit() const { return mOffsetAlongLineUnit; }
720
727 void setOffsetAlongLineUnit( Qgis::RenderUnit unit ) { mOffsetAlongLineUnit = unit; }
728
733 const QgsMapUnitScale &offsetAlongLineMapUnitScale() const { return mOffsetAlongLineMapUnitScale; }
734
739 void setOffsetAlongLineMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetAlongLineMapUnitScale = scale; }
740
751 double averageAngleLength() const { return mAverageAngleLength; }
752
763 void setAverageAngleLength( double length ) { mAverageAngleLength = length; }
764
773 void setAverageAngleUnit( Qgis::RenderUnit unit ) { mAverageAngleLengthUnit = unit; }
774
783 Qgis::RenderUnit averageAngleUnit() const { return mAverageAngleLengthUnit; }
784
793 void setAverageAngleMapUnitScale( const QgsMapUnitScale &scale ) { mAverageAngleLengthMapUnitScale = scale; }
794
803 const QgsMapUnitScale &averageAngleMapUnitScale() const { return mAverageAngleLengthMapUnitScale; }
804
805 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
806 void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) FINAL;
808 void setOutputUnit( Qgis::RenderUnit unit ) override;
809 void setMapUnitScale( const QgsMapUnitScale &scale ) FINAL;
810 QgsMapUnitScale mapUnitScale() const FINAL;
811 QVariantMap properties() const override;
812 bool canCauseArtifactsBetweenAdjacentTiles() const override;
813
814 void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
815 void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
816
817 protected:
818
825 virtual void setSymbolLineAngle( double angle ) = 0;
826
830 virtual double symbolAngle() const = 0;
831
835 virtual void setSymbolAngle( double angle ) = 0;
836
849 virtual void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) = 0;
850
854 void copyTemplateSymbolProperties( QgsTemplatedLineSymbolLayerBase *destLayer ) const;
855
860 static void setCommonProperties( QgsTemplatedLineSymbolLayerBase *destLayer, const QVariantMap &properties );
861
862 private:
863
864 void renderPolylineInterval( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
865 void renderPolylineVertex( const QPolygonF &points, QgsSymbolRenderContext &context, Qgis::MarkerLinePlacement placement = Qgis::MarkerLinePlacement::Vertex );
866 void renderPolylineCentral( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
867 double markerAngle( const QPolygonF &points, bool isRing, int vertex );
868
881 void renderOffsetVertexAlongLine( const QPolygonF &points, int vertex, double distance, QgsSymbolRenderContext &context,
882 Qgis::MarkerLinePlacement placement );
883
884
885 static void collectOffsetPoints( const QVector< QPointF> &points,
886 QVector< QPointF> &dest, double intervalPainterUnits, double initialOffset, double initialLag = 0,
887 int numberPointsRequired = -1 );
888
889 bool mRotateSymbols = true;
890 double mInterval = 3;
891 Qgis::RenderUnit mIntervalUnit = Qgis::RenderUnit::Millimeters;
892 QgsMapUnitScale mIntervalMapUnitScale;
893 Qgis::MarkerLinePlacements mPlacements = Qgis::MarkerLinePlacement::Interval;
894 double mOffsetAlongLine = 0; //distance to offset along line before marker is drawn
895 Qgis::RenderUnit mOffsetAlongLineUnit = Qgis::RenderUnit::Millimeters; //unit for offset along line
896 QgsMapUnitScale mOffsetAlongLineMapUnitScale;
897 double mAverageAngleLength = 4;
898 Qgis::RenderUnit mAverageAngleLengthUnit = Qgis::RenderUnit::Millimeters;
899 QgsMapUnitScale mAverageAngleLengthMapUnitScale;
900 bool mPlaceOnEveryPart = true;
901
902 bool mRenderingFeature = false;
903 bool mHasRenderedFirstPart = false;
904 QPointF mFinalVertex;
905 bool mCurrentFeatureIsSelected = false;
906 double mFeatureSymbolOpacity = 1;
907
908 friend class TestQgsMarkerLineSymbol;
909
910};
911
918{
919 public:
920
929 double interval = DEFAULT_MARKERLINE_INTERVAL );
930
932
933 // static stuff
934
940 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
941
945 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
946
947 // implemented from base classes
948
949 QString layerType() const override;
950 void startRender( QgsSymbolRenderContext &context ) override;
951 void stopRender( QgsSymbolRenderContext &context ) override;
952 QgsMarkerLineSymbolLayer *clone() const override SIP_FACTORY;
953 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
954 void setColor( const QColor &color ) override;
955 QColor color() const override;
956 QgsSymbol *subSymbol() override;
957 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
958 void setWidth( double width ) override;
959 double width() const override;
960 double width( const QgsRenderContext &context ) const override;
961 double estimateMaxBleed( const QgsRenderContext &context ) const override;
962 void setOutputUnit( Qgis::RenderUnit unit ) override;
963 bool usesMapUnits() const override;
964 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
965 bool hasDataDefinedProperties() const override;
966 void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
967
974 Q_DECL_DEPRECATED bool rotateMarker() const SIP_DEPRECATED { return rotateSymbols(); }
975
980 Q_DECL_DEPRECATED void setRotateMarker( bool rotate ) SIP_DEPRECATED { setRotateSymbols( rotate ); }
981
982 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
983
984 protected:
985
986 std::unique_ptr< QgsMarkerSymbol > mMarker;
987
988 void setSymbolLineAngle( double angle ) override;
989 double symbolAngle() const override;
990 void setSymbolAngle( double angle ) override;
991 void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
992
993 private:
994
995#ifdef SIP_RUN
997#endif
998
999
1000};
1001
1002
1012{
1013 public:
1014
1022 QgsHashedLineSymbolLayer( bool rotateSymbol = true,
1023 double interval = 3 );
1024
1026
1032 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1033
1034 QString layerType() const override;
1035 void startRender( QgsSymbolRenderContext &context ) override;
1036 void stopRender( QgsSymbolRenderContext &context ) override;
1037 QVariantMap properties() const override;
1038 QgsHashedLineSymbolLayer *clone() const override SIP_FACTORY;
1039 void setColor( const QColor &color ) override;
1040 QColor color() const override;
1041 QgsSymbol *subSymbol() override;
1042 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1043 void setWidth( double width ) override;
1044 double width() const override;
1045 double width( const QgsRenderContext &context ) const override;
1046 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1047 void setOutputUnit( Qgis::RenderUnit unit ) override;
1048 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1049 bool hasDataDefinedProperties() const override;
1050 void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
1051 bool usesMapUnits() const override;
1052
1058 double hashAngle() const;
1059
1065 void setHashAngle( double angle );
1066
1072 double hashLength() const { return mHashLength; }
1073
1079 void setHashLength( double length ) { mHashLength = length; }
1080
1086 void setHashLengthUnit( Qgis::RenderUnit unit ) { mHashLengthUnit = unit; }
1087
1093 Qgis::RenderUnit hashLengthUnit() const { return mHashLengthUnit; }
1094
1101 void setHashLengthMapUnitScale( const QgsMapUnitScale &scale ) { mHashLengthMapUnitScale = scale; }
1102
1109 const QgsMapUnitScale &hashLengthMapUnitScale() const { return mHashLengthMapUnitScale; }
1110
1111 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1112
1113 protected:
1114
1115 void setSymbolLineAngle( double angle ) override;
1116 double symbolAngle() const override;
1117 void setSymbolAngle( double angle ) override;
1118 void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
1119
1120 private:
1121#ifdef SIP_RUN
1123#endif
1124
1125 std::unique_ptr< QgsLineSymbol > mHashSymbol;
1126
1127 double mSymbolLineAngle = 0;
1128 double mSymbolAngle = 0;
1129
1130 double mHashAngle = 0;
1131 double mHashLength = 3;
1133 QgsMapUnitScale mHashLengthMapUnitScale;
1134
1135};
1136
1137
1147{
1148 public:
1149
1155 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1156
1162 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1163
1169 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
1170
1176 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
1177
1178 protected:
1179
1183 void renderPolylineUsingBrush( const QPolygonF &points, QgsSymbolRenderContext &context, const QBrush &brush,
1184 double patternThickness, double patternLength );
1185
1186 Qt::PenJoinStyle mPenJoinStyle = Qt::PenJoinStyle::RoundJoin;
1187 Qt::PenCapStyle mPenCapStyle = Qt::PenCapStyle::RoundCap;
1188
1189 private:
1190 void renderLine( const QPolygonF &points, QgsSymbolRenderContext &context, const double lineThickness, const double patternLength, const QBrush &sourceBrush );
1191};
1192
1193
1194
1204{
1205 public:
1206
1210 QgsRasterLineSymbolLayer( const QString &path = QString() );
1212
1218 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1219
1224 static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
1225
1230 QString path() const { return mPath; }
1231
1236 void setPath( const QString &path );
1237
1243 double opacity() const { return mOpacity; }
1244
1250 void setOpacity( double opacity ) { mOpacity = opacity; }
1251
1252 QString layerType() const override;
1253 Qgis::SymbolLayerFlags flags() const override;
1254 void startRender( QgsSymbolRenderContext &context ) override;
1255 void stopRender( QgsSymbolRenderContext &context ) override;
1256 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1257 QVariantMap properties() const override;
1258 QgsRasterLineSymbolLayer *clone() const override SIP_FACTORY;
1259 void setOutputUnit( Qgis::RenderUnit unit ) override;
1260 Qgis::RenderUnit outputUnit() const override;
1261 bool usesMapUnits() const override;
1262 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1263 QgsMapUnitScale mapUnitScale() const override;
1264 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1265 QColor color() const override;
1266
1267 protected:
1268 QString mPath;
1269 double mOpacity = 1.0;
1270 QImage mLineImage;
1271
1272};
1273
1274
1287{
1288 public:
1289
1294 const QColor &color2 = Qt::white );
1296
1302 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1303
1304 QString layerType() const override;
1305 Qgis::SymbolLayerFlags flags() const override;
1306 void startRender( QgsSymbolRenderContext &context ) override;
1307 void stopRender( QgsSymbolRenderContext &context ) override;
1308 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1309 QVariantMap properties() const override;
1310 QgsLineburstSymbolLayer *clone() const override SIP_FACTORY;
1311 void setOutputUnit( Qgis::RenderUnit unit ) override;
1312 Qgis::RenderUnit outputUnit() const override;
1313 bool usesMapUnits() const override;
1314 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1315 QgsMapUnitScale mapUnitScale() const override;
1316 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1317
1323 Qgis::GradientColorSource gradientColorType() const { return mGradientColorType; }
1324
1330 void setGradientColorType( Qgis::GradientColorSource gradientColorType ) { mGradientColorType = gradientColorType; }
1331
1338 QgsColorRamp *colorRamp();
1339
1347 void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
1348
1354 QColor color2() const { return mColor2; }
1355
1361 void setColor2( const QColor &color2 ) { mColor2 = color2; }
1362
1363 protected:
1365 QColor mColor2;
1366 std::unique_ptr< QgsColorRamp > mGradientRamp;
1367
1368};
1369
1370
1380{
1381 public:
1382
1390 QgsFilledLineSymbolLayer( double width = DEFAULT_SIMPLELINE_WIDTH, QgsFillSymbol *fillSymbol SIP_TRANSFER = nullptr );
1392
1398 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1399
1400 QString layerType() const override;
1401 void startRender( QgsSymbolRenderContext &context ) override;
1402 void stopRender( QgsSymbolRenderContext &context ) override;
1403 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1404 QVariantMap properties() const override;
1405 QgsFilledLineSymbolLayer *clone() const override SIP_FACTORY;
1406 QgsSymbol *subSymbol() override;
1407 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1408 bool hasDataDefinedProperties() const override;
1409 void setColor( const QColor &c ) override;
1410 QColor color() const override;
1411 void setOutputUnit( Qgis::RenderUnit unit ) override;
1412 Qgis::RenderUnit outputUnit() const override;
1413 bool usesMapUnits() const override;
1414 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1415 QgsMapUnitScale mapUnitScale() const override;
1416 double estimateMaxBleed( const QgsRenderContext &context ) const override;
1417 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1418
1424 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1425
1431 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1432
1438 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
1439
1445 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
1446
1447 private:
1448
1449#ifdef SIP_RUN
1451#endif
1452
1454 std::unique_ptr< QgsFillSymbol > mFill;
1455 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_SIMPLELINE_JOINSTYLE;
1456 Qt::PenCapStyle mPenCapStyle = DEFAULT_SIMPLELINE_CAPSTYLE;
1457
1458
1459};
1460
1461#endif
1462
1463
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:2898
GradientColorSource
Gradient color sources.
Definition qgis.h:2947
@ SimpleTwoColor
Simple two color gradient.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
Definition qgis.h:821
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ Millimeters
Millimeters.
QFlags< MarkerLinePlacement > MarkerLinePlacements
Definition qgis.h:2909
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: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.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
Property
Data definable properties.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
virtual Qgis::SymbolLayerFlags flags() const
Returns flags which control the symbol layer's behavior.
Abstract base class for all rendered symbols.
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