QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
26 class QgsExpression;
27 class QgsMarkerSymbol;
28 class QgsLineSymbol;
29 class QgsPathResolver;
30 class QgsColorRamp;
31 
32 #define DEFAULT_SIMPLELINE_COLOR QColor(35,35,35)
33 #define DEFAULT_SIMPLELINE_WIDTH DEFAULT_LINE_WIDTH
34 #define DEFAULT_SIMPLELINE_PENSTYLE Qt::SolidLine
35 #define DEFAULT_SIMPLELINE_JOINSTYLE Qt::BevelJoin
36 #define DEFAULT_SIMPLELINE_CAPSTYLE Qt::SquareCap
37 
43 class CORE_EXPORT QgsSimpleLineSymbolLayer : public QgsLineSymbolLayer
44 {
45  public:
46 
53  double width = DEFAULT_SIMPLELINE_WIDTH,
54  Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE );
55 
57 
58  // static stuff
59 
65  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
66 
70  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
71 
72  QString layerType() const override;
73  void startRender( QgsSymbolRenderContext &context ) override;
74  void stopRender( QgsSymbolRenderContext &context ) override;
75  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
76  //overridden so that clip path can be set when using draw inside polygon option
77  void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) override;
78  QVariantMap properties() const override;
79  QgsSimpleLineSymbolLayer *clone() const override SIP_FACTORY;
80  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
81  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
82  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
83  QgsUnitTypes::RenderUnit outputUnit() const override;
84  bool usesMapUnits() const override;
85  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
86  QgsMapUnitScale mapUnitScale() const override;
87  double estimateMaxBleed( const QgsRenderContext &context ) const override;
88  QVector<qreal> dxfCustomDashPattern( QgsUnitTypes::RenderUnit &unit ) const override;
89  Qt::PenStyle dxfPenStyle() const override;
90  double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
91  double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
92  QColor dxfColor( QgsSymbolRenderContext &context ) const override;
93  bool canCauseArtifactsBetweenAdjacentTiles() const override;
94 
100  Qt::PenStyle penStyle() const { return mPenStyle; }
101 
107  void setPenStyle( Qt::PenStyle style ) { mPenStyle = style; }
108 
114  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
115 
121  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
122 
128  Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
129 
135  void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
136 
143  bool useCustomDashPattern() const { return mUseCustomDashPattern; }
144 
151  void setUseCustomDashPattern( bool b ) { mUseCustomDashPattern = b; }
152 
157  void setCustomDashPatternUnit( QgsUnitTypes::RenderUnit unit ) { mCustomDashPatternUnit = unit; }
158 
163  QgsUnitTypes::RenderUnit customDashPatternUnit() const { return mCustomDashPatternUnit; }
164 
169  const QgsMapUnitScale &customDashPatternMapUnitScale() const { return mCustomDashPatternMapUnitScale; }
170 
175  void setCustomDashPatternMapUnitScale( const QgsMapUnitScale &scale ) { mCustomDashPatternMapUnitScale = scale; }
176 
189  QVector<qreal> customDashVector() const { return mCustomDashVector; }
190 
203  void setCustomDashVector( const QVector<qreal> &vector ) { mCustomDashVector = vector; }
204 
217  double dashPatternOffset() const { return mDashPatternOffset; }
218 
231  void setDashPatternOffset( double offset ) { mDashPatternOffset = offset; }
232 
242  void setDashPatternOffsetUnit( QgsUnitTypes::RenderUnit unit ) { mDashPatternOffsetUnit = unit; }
243 
253  QgsUnitTypes::RenderUnit dashPatternOffsetUnit() const { return mDashPatternOffsetUnit; }
254 
264  const QgsMapUnitScale &dashPatternOffsetMapUnitScale() const { return mDashPatternOffsetMapUnitScale; }
265 
275  void setDashPatternOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mDashPatternOffsetMapUnitScale = scale; }
276 
290  double trimDistanceStart() const { return mTrimDistanceStart; }
291 
305  void setTrimDistanceStart( double distance ) { mTrimDistanceStart = distance; }
306 
317  void setTrimDistanceStartUnit( QgsUnitTypes::RenderUnit unit ) { mTrimDistanceStartUnit = unit; }
318 
329  QgsUnitTypes::RenderUnit trimDistanceStartUnit() const { return mTrimDistanceStartUnit; }
330 
341  const QgsMapUnitScale &trimDistanceStartMapUnitScale() const { return mTrimDistanceStartMapUnitScale; }
342 
353  void setTrimDistanceStartMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceStartMapUnitScale = scale; }
354 
368  double trimDistanceEnd() const { return mTrimDistanceEnd; }
369 
383  void setTrimDistanceEnd( double distance ) { mTrimDistanceEnd = distance; }
384 
395  void setTrimDistanceEndUnit( QgsUnitTypes::RenderUnit unit ) { mTrimDistanceEndUnit = unit; }
396 
407  QgsUnitTypes::RenderUnit trimDistanceEndUnit() const { return mTrimDistanceEndUnit; }
408 
419  const QgsMapUnitScale &trimDistanceEndMapUnitScale() const { return mTrimDistanceEndMapUnitScale; }
420 
431  void setTrimDistanceEndMapUnitScale( const QgsMapUnitScale &scale ) { mTrimDistanceEndMapUnitScale = scale; }
432 
442  bool drawInsidePolygon() const { return mDrawInsidePolygon; }
443 
453  void setDrawInsidePolygon( bool drawInsidePolygon ) { mDrawInsidePolygon = drawInsidePolygon; }
454 
464  bool alignDashPattern() const;
465 
475  void setAlignDashPattern( bool enabled );
476 
487  bool tweakDashPatternOnCorners() const;
488 
499  void setTweakDashPatternOnCorners( bool enabled );
500 
501  private:
502 
503  Qt::PenStyle mPenStyle = Qt::SolidLine;
504  Qt::PenJoinStyle mPenJoinStyle = DEFAULT_SIMPLELINE_JOINSTYLE;
505  Qt::PenCapStyle mPenCapStyle = DEFAULT_SIMPLELINE_CAPSTYLE;
506  QPen mPen;
507  QPen mSelPen;
508 
509  bool mUseCustomDashPattern = false;
511  QgsMapUnitScale mCustomDashPatternMapUnitScale;
512 
513  double mDashPatternOffset = 0;
515  QgsMapUnitScale mDashPatternOffsetMapUnitScale;
516 
517  double mTrimDistanceStart = 0;
519  QgsMapUnitScale mTrimDistanceStartMapUnitScale;
520 
521  double mTrimDistanceEnd = 0;
523  QgsMapUnitScale mTrimDistanceEndMapUnitScale;
524 
526  QVector<qreal> mCustomDashVector;
527 
528  bool mAlignDashPattern = false;
529  bool mPatternCartographicTweakOnSharpCorners = false;
530 
531  bool mDrawInsidePolygon = false;
532 
533  //helper functions for data defined symbology
534  void applyDataDefinedSymbology( QgsSymbolRenderContext &context, QPen &pen, QPen &selPen, double &offset );
535  void drawPathWithDashPatternTweaks( QPainter *painter, const QPolygonF &points, QPen pen ) const;
536 };
537 
539 
540 #define DEFAULT_MARKERLINE_ROTATE true
541 #define DEFAULT_MARKERLINE_INTERVAL 3
542 
553 {
554  public:
555 
563  QgsTemplatedLineSymbolLayerBase( bool rotateSymbol = true,
564  double interval = 3 );
565 
567 
572  bool rotateSymbols() const { return mRotateSymbols; }
573 
578  void setRotateSymbols( bool rotate ) { mRotateSymbols = rotate; }
579 
585  double interval() const { return mInterval; }
586 
593  void setInterval( double interval ) { mInterval = interval; }
594 
601  void setIntervalUnit( QgsUnitTypes::RenderUnit unit ) { mIntervalUnit = unit; }
602 
608  QgsUnitTypes::RenderUnit intervalUnit() const { return mIntervalUnit; }
609 
616  void setIntervalMapUnitScale( const QgsMapUnitScale &scale ) { mIntervalMapUnitScale = scale; }
617 
624  const QgsMapUnitScale &intervalMapUnitScale() const { return mIntervalMapUnitScale; }
625 
631  Q_DECL_DEPRECATED Qgis::MarkerLinePlacement placement() const SIP_DEPRECATED;
632 
638  Q_DECL_DEPRECATED void setPlacement( Qgis::MarkerLinePlacement placement ) SIP_DEPRECATED;
639 
645  Qgis::MarkerLinePlacements placements() const { return mPlacements; }
646 
652  void setPlacements( Qgis::MarkerLinePlacements placements ) { mPlacements = placements; }
653 
668  bool placeOnEveryPart() const { return mPlaceOnEveryPart; }
669 
684  void setPlaceOnEveryPart( bool respect ) { mPlaceOnEveryPart = respect; }
685 
696  double offsetAlongLine() const { return mOffsetAlongLine; }
697 
709  void setOffsetAlongLine( double offsetAlongLine ) { mOffsetAlongLine = offsetAlongLine; }
710 
717  QgsUnitTypes::RenderUnit offsetAlongLineUnit() const { return mOffsetAlongLineUnit; }
718 
725  void setOffsetAlongLineUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetAlongLineUnit = unit; }
726 
731  const QgsMapUnitScale &offsetAlongLineMapUnitScale() const { return mOffsetAlongLineMapUnitScale; }
732 
737  void setOffsetAlongLineMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetAlongLineMapUnitScale = scale; }
738 
749  double averageAngleLength() const { return mAverageAngleLength; }
750 
761  void setAverageAngleLength( double length ) { mAverageAngleLength = length; }
762 
771  void setAverageAngleUnit( QgsUnitTypes::RenderUnit unit ) { mAverageAngleLengthUnit = unit; }
772 
781  QgsUnitTypes::RenderUnit averageAngleUnit() const { return mAverageAngleLengthUnit; }
782 
791  void setAverageAngleMapUnitScale( const QgsMapUnitScale &scale ) { mAverageAngleLengthMapUnitScale = scale; }
792 
801  const QgsMapUnitScale &averageAngleMapUnitScale() const { return mAverageAngleLengthMapUnitScale; }
802 
803  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
804  void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) FINAL;
806  void setMapUnitScale( const QgsMapUnitScale &scale ) FINAL;
807  QgsMapUnitScale mapUnitScale() const FINAL;
808  QVariantMap properties() const override;
809  bool canCauseArtifactsBetweenAdjacentTiles() const override;
810 
811  void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
812  void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
813 
814  protected:
815 
822  virtual void setSymbolLineAngle( double angle ) = 0;
823 
827  virtual double symbolAngle() const = 0;
828 
832  virtual void setSymbolAngle( double angle ) = 0;
833 
846  virtual void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) = 0;
847 
851  void copyTemplateSymbolProperties( QgsTemplatedLineSymbolLayerBase *destLayer ) const;
852 
857  static void setCommonProperties( QgsTemplatedLineSymbolLayerBase *destLayer, const QVariantMap &properties );
858 
859  private:
860 
861  void renderPolylineInterval( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
862  void renderPolylineVertex( const QPolygonF &points, QgsSymbolRenderContext &context, Qgis::MarkerLinePlacement placement = Qgis::MarkerLinePlacement::Vertex );
863  void renderPolylineCentral( const QPolygonF &points, QgsSymbolRenderContext &context, double averageAngleOver );
864  double markerAngle( const QPolygonF &points, bool isRing, int vertex );
865 
878  void renderOffsetVertexAlongLine( const QPolygonF &points, int vertex, double distance, QgsSymbolRenderContext &context,
879  Qgis::MarkerLinePlacement placement );
880 
881 
882  static void collectOffsetPoints( const QVector< QPointF> &points,
883  QVector< QPointF> &dest, double intervalPainterUnits, double initialOffset, double initialLag = 0,
884  int numberPointsRequired = -1 );
885 
886  bool mRotateSymbols = true;
887  double mInterval = 3;
888  QgsUnitTypes::RenderUnit mIntervalUnit = QgsUnitTypes::RenderMillimeters;
889  QgsMapUnitScale mIntervalMapUnitScale;
890  Qgis::MarkerLinePlacements mPlacements = Qgis::MarkerLinePlacement::Interval;
891  double mOffsetAlongLine = 0; //distance to offset along line before marker is drawn
892  QgsUnitTypes::RenderUnit mOffsetAlongLineUnit = QgsUnitTypes::RenderMillimeters; //unit for offset along line
893  QgsMapUnitScale mOffsetAlongLineMapUnitScale;
894  double mAverageAngleLength = 4;
895  QgsUnitTypes::RenderUnit mAverageAngleLengthUnit = QgsUnitTypes::RenderMillimeters;
896  QgsMapUnitScale mAverageAngleLengthMapUnitScale;
897  bool mPlaceOnEveryPart = true;
898 
899  bool mRenderingFeature = false;
900  bool mHasRenderedFirstPart = false;
901  QPointF mFinalVertex;
902  bool mCurrentFeatureIsSelected = false;
903  double mFeatureSymbolOpacity = 1;
904 
905  friend class TestQgsMarkerLineSymbol;
906 
907 };
908 
915 {
916  public:
917 
926  double interval = DEFAULT_MARKERLINE_INTERVAL );
927 
929 
930  // static stuff
931 
937  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
938 
942  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
943 
944  // implemented from base classes
945 
946  QString layerType() const override;
947  void startRender( QgsSymbolRenderContext &context ) override;
948  void stopRender( QgsSymbolRenderContext &context ) override;
949  QgsMarkerLineSymbolLayer *clone() const override SIP_FACTORY;
950  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
951  void setColor( const QColor &color ) override;
952  QColor color() const override;
953  QgsSymbol *subSymbol() override;
954  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
955  void setWidth( double width ) override;
956  double width() const override;
957  double width( const QgsRenderContext &context ) const override;
958  double estimateMaxBleed( const QgsRenderContext &context ) const override;
959  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
960  bool usesMapUnits() const override;
961  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
962  bool hasDataDefinedProperties() const override;
963  void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
964 
971  Q_DECL_DEPRECATED bool rotateMarker() const SIP_DEPRECATED { return rotateSymbols(); }
972 
977  Q_DECL_DEPRECATED void setRotateMarker( bool rotate ) SIP_DEPRECATED { setRotateSymbols( rotate ); }
978 
979  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
980 
981  protected:
982 
983  std::unique_ptr< QgsMarkerSymbol > mMarker;
984 
985  void setSymbolLineAngle( double angle ) override;
986  double symbolAngle() const override;
987  void setSymbolAngle( double angle ) override;
988  void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
989 
990  private:
991 
992 #ifdef SIP_RUN
994 #endif
995 
996 
997 };
998 
999 
1009 {
1010  public:
1011 
1019  QgsHashedLineSymbolLayer( bool rotateSymbol = true,
1020  double interval = 3 );
1021 
1023 
1029  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1030 
1031  QString layerType() const override;
1032  void startRender( QgsSymbolRenderContext &context ) override;
1033  void stopRender( QgsSymbolRenderContext &context ) override;
1034  QVariantMap properties() const override;
1035  QgsHashedLineSymbolLayer *clone() const override SIP_FACTORY;
1036  void setColor( const QColor &color ) override;
1037  QColor color() const override;
1038  QgsSymbol *subSymbol() override;
1039  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
1040  void setWidth( double width ) override;
1041  double width() const override;
1042  double width( const QgsRenderContext &context ) const override;
1043  double estimateMaxBleed( const QgsRenderContext &context ) const override;
1044  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1045  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
1046  bool hasDataDefinedProperties() const override;
1047  void setDataDefinedProperty( QgsSymbolLayer::Property key, const QgsProperty &property ) override;
1048  bool usesMapUnits() const override;
1049 
1055  double hashAngle() const;
1056 
1062  void setHashAngle( double angle );
1063 
1069  double hashLength() const { return mHashLength; }
1070 
1076  void setHashLength( double length ) { mHashLength = length; }
1077 
1083  void setHashLengthUnit( QgsUnitTypes::RenderUnit unit ) { mHashLengthUnit = unit; }
1084 
1090  QgsUnitTypes::RenderUnit hashLengthUnit() const { return mHashLengthUnit; }
1091 
1098  void setHashLengthMapUnitScale( const QgsMapUnitScale &scale ) { mHashLengthMapUnitScale = scale; }
1099 
1106  const QgsMapUnitScale &hashLengthMapUnitScale() const { return mHashLengthMapUnitScale; }
1107 
1108  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1109 
1110  protected:
1111 
1112  void setSymbolLineAngle( double angle ) override;
1113  double symbolAngle() const override;
1114  void setSymbolAngle( double angle ) override;
1115  void renderSymbol( const QPointF &point, const QgsFeature *feature, QgsRenderContext &context, int layer = -1, bool selected = false ) override;
1116 
1117  private:
1118 #ifdef SIP_RUN
1120 #endif
1121 
1122  std::unique_ptr< QgsLineSymbol > mHashSymbol;
1123 
1124  double mSymbolLineAngle = 0;
1125  double mSymbolAngle = 0;
1126 
1127  double mHashAngle = 0;
1128  double mHashLength = 3;
1130  QgsMapUnitScale mHashLengthMapUnitScale;
1131 
1132 };
1133 
1134 
1144 {
1145  public:
1146 
1152  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1153 
1159  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1160 
1166  Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
1167 
1173  void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
1174 
1175  protected:
1176 
1180  void renderPolylineUsingBrush( const QPolygonF &points, QgsSymbolRenderContext &context, const QBrush &brush,
1181  double patternThickness, double patternLength );
1182 
1183  Qt::PenJoinStyle mPenJoinStyle = Qt::PenJoinStyle::RoundJoin;
1184  Qt::PenCapStyle mPenCapStyle = Qt::PenCapStyle::RoundCap;
1185 
1186  private:
1187  void renderLine( const QPolygonF &points, QgsSymbolRenderContext &context, const double lineThickness, const double patternLength, const QBrush &sourceBrush );
1188 };
1189 
1190 
1191 
1201 {
1202  public:
1203 
1207  QgsRasterLineSymbolLayer( const QString &path = QString() );
1209 
1215  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1216 
1221  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
1222 
1227  QString path() const { return mPath; }
1228 
1233  void setPath( const QString &path );
1234 
1240  double opacity() const { return mOpacity; }
1241 
1247  void setOpacity( double opacity ) { mOpacity = opacity; }
1248 
1249  QString layerType() const override;
1250  void startRender( QgsSymbolRenderContext &context ) override;
1251  void stopRender( QgsSymbolRenderContext &context ) override;
1252  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1253  QVariantMap properties() const override;
1254  QgsRasterLineSymbolLayer *clone() const override SIP_FACTORY;
1255  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1256  QgsUnitTypes::RenderUnit outputUnit() const override;
1257  bool usesMapUnits() const override;
1258  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1259  QgsMapUnitScale mapUnitScale() const override;
1260  double estimateMaxBleed( const QgsRenderContext &context ) const override;
1261  QColor color() const override;
1262 
1263  protected:
1264  QString mPath;
1265  double mOpacity = 1.0;
1266  QImage mLineImage;
1267 
1268 };
1269 
1270 
1283 {
1284  public:
1285 
1289  QgsLineburstSymbolLayer( const QColor &color = DEFAULT_SIMPLELINE_COLOR,
1290  const QColor &color2 = Qt::white );
1292 
1298  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
1299 
1300  QString layerType() const override;
1301  void startRender( QgsSymbolRenderContext &context ) override;
1302  void stopRender( QgsSymbolRenderContext &context ) override;
1303  void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
1304  QVariantMap properties() const override;
1305  QgsLineburstSymbolLayer *clone() const override SIP_FACTORY;
1306  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
1307  QgsUnitTypes::RenderUnit outputUnit() const override;
1308  bool usesMapUnits() const override;
1309  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1310  QgsMapUnitScale mapUnitScale() const override;
1311  double estimateMaxBleed( const QgsRenderContext &context ) const override;
1312  QColor color() const override;
1313 
1319  Qgis::GradientColorSource gradientColorType() const { return mGradientColorType; }
1320 
1326  void setGradientColorType( Qgis::GradientColorSource gradientColorType ) { mGradientColorType = gradientColorType; }
1327 
1334  QgsColorRamp *colorRamp();
1335 
1343  void setColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
1344 
1350  QColor color2() const { return mColor2; }
1351 
1357  void setColor2( const QColor &color2 ) { mColor2 = color2; }
1358 
1359  protected:
1361  QColor mColor2;
1362  std::unique_ptr< QgsColorRamp > mGradientRamp;
1363 
1364 };
1365 
1366 #endif
1367 
1368 
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:64
MarkerLinePlacement
Defines how/where the symbols should be placed on a line.
Definition: qgis.h:1083
GradientColorSource
Gradient color sources.
Definition: qgis.h:1105
@ SimpleTwoColor
Simple two color gradient.
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.
Definition: qgscolorramp.h:30
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:65
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
Line symbol layer type which draws repeating line sections along a line feature.
void setHashLength(double length)
Sets the length of hash symbols.
QgsUnitTypes::RenderUnit hashLengthUnit() const
Returns the units for the length of hash symbols.
const QgsMapUnitScale & hashLengthMapUnitScale() const
Returns the map unit scale for the hash length.
void setHashLengthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length of hash symbols.
void setHashLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the hash length.
~QgsHashedLineSymbolLayer() override
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.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
double offset() const
Returns the line's offset.
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
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.
Definition: qgsproperty.h:231
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....
QgsUnitTypes::RenderUnit dashPatternOffsetUnit() const
Returns the units for the dash pattern offset.
void setDrawInsidePolygon(bool drawInsidePolygon)
Sets whether the line should only be drawn inside polygons, and any portion of the line which falls o...
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap 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.
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
void setDashPatternOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the dash pattern offset.
QgsUnitTypes::RenderUnit trimDistanceStartUnit() const
Returns the unit 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.
QgsUnitTypes::RenderUnit customDashPatternUnit() const
Returns the units 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.
QVector< qreal > customDashVector() const
Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ...
void setTrimDistanceEnd(double distance)
Sets the trim distance for the end of the line, which dictates a length from the end of the line at w...
void setCustomDashPatternUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
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.
double trimDistanceEnd() const
Returns the trim distance for the end of the line, which dictates a length from the end of the line a...
void 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.
QgsUnitTypes::RenderUnit trimDistanceEndUnit() const
Returns the unit for the trim distance for the end of the line.
void setDashPatternOffset(double offset)
Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start ...
const QgsMapUnitScale & dashPatternOffsetMapUnitScale() const
Returns the map unit scale for the dash pattern offset value.
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 setTrimDistanceStartUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the trim distance for the start of the line.
void setTrimDistanceStartMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the start of the line.
void setTrimDistanceEndUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the trim distance for the end of the line.
Qt::PenCapStyle penCapStyle() const
Returns 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.
const QgsMapUnitScale & customDashPatternMapUnitScale() const
Returns the map unit scale for lengths used in the custom dash pattern.
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 ...
Property
Data definable properties.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
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:38
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...
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
void setRotateSymbols(bool rotate)
Sets whether the repeating symbols should be rotated to match their line segment orientation.
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 setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
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.
void setOffsetAlongLineUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit used for calculating the offset along line for symbols.
void setInterval(double interval)
Sets the interval between individual symbols.
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for symbols.
QgsUnitTypes::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
void setPlaceOnEveryPart(bool respect)
Sets whether the placement applies for every part of multi-part feature geometries.
QgsUnitTypes::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for symbols.
void setPlacements(Qgis::MarkerLinePlacements placements)
Sets the placement of the symbols.
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
void setAverageAngleUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
void setIntervalUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the interval between 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...
Helper functions for various unit types.
Definition: qgsunittypes.h:39
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define FINAL
Definition: qgis_sip.h:228
#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