QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
qgssymbollayer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssymbollayer.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#ifndef QGSSYMBOLLAYER_H
16#define QGSSYMBOLLAYER_H
17
18#define DEG2RAD(x) ((x)*M_PI/180)
19#define DEFAULT_SCALE_METHOD Qgis::ScaleMethod::ScaleDiameter
20
21#include "qgis_core.h"
22#include "qgis.h"
23#include "qgsfields.h"
26
27#include <QColor>
28#include <QMap>
29#include <QPointF>
30#include <QSet>
31#include <QDomDocument>
32#include <QDomElement>
33#include <QPainterPath>
34#include <QImage>
35
36class QPainter;
37class QSize;
38class QPolygonF;
39
40class QgsDxfExport;
41class QgsExpression;
43class QgsPaintEffect;
45
46#ifndef SIP_RUN
47typedef QMap<QString, QString> QgsStringMap;
48#endif
49
54class CORE_EXPORT QgsSymbolLayer
55{
56#ifdef SIP_RUN
57#include <qgslinesymbollayer.h>
58#endif
59
60
61#ifdef SIP_RUN
63 switch ( sipCpp->type() )
64 {
66 if ( sipCpp->layerType() == "EllipseMarker" )
67 sipType = sipType_QgsEllipseSymbolLayer;
68 else if ( sipCpp->layerType() == "FontMarker" )
69 sipType = sipType_QgsFontMarkerSymbolLayer;
70 else if ( sipCpp->layerType() == "SimpleMarker" )
71 sipType = sipType_QgsSimpleMarkerSymbolLayer;
72 else if ( sipCpp->layerType() == "FilledMarker" )
73 sipType = sipType_QgsFilledMarkerSymbolLayer;
74 else if ( sipCpp->layerType() == "SvgMarker" )
75 sipType = sipType_QgsSvgMarkerSymbolLayer;
76 else if ( sipCpp->layerType() == "RasterMarker" )
77 sipType = sipType_QgsRasterMarkerSymbolLayer;
78 else if ( sipCpp->layerType() == "AnimatedMarker" )
79 sipType = sipType_QgsAnimatedMarkerSymbolLayer;
80 else if ( sipCpp->layerType() == "VectorField" )
81 sipType = sipType_QgsVectorFieldSymbolLayer;
82 else if ( sipCpp->layerType() == "MaskMarker" )
83 sipType = sipType_QgsMaskMarkerSymbolLayer;
84 else
85 sipType = sipType_QgsMarkerSymbolLayer;
86 break;
87
89 if ( sipCpp->layerType() == "MarkerLine" )
90 sipType = sipType_QgsMarkerLineSymbolLayer;
91 else if ( sipCpp->layerType() == "SimpleLine" )
92 sipType = sipType_QgsSimpleLineSymbolLayer;
93 else if ( sipCpp->layerType() == "HashLine" )
94 sipType = sipType_QgsHashedLineSymbolLayer;
95 else if ( sipCpp->layerType() == "ArrowLine" )
96 sipType = sipType_QgsArrowSymbolLayer;
97 else if ( sipCpp->layerType() == "InterpolatedLine" )
98 sipType = sipType_QgsInterpolatedLineSymbolLayer;
99 else if ( sipCpp->layerType() == "RasterLine" )
100 sipType = sipType_QgsRasterLineSymbolLayer;
101 else if ( sipCpp->layerType() == "Lineburst" )
102 sipType = sipType_QgsLineburstSymbolLayer;
103 else
104 sipType = sipType_QgsLineSymbolLayer;
105 break;
106
108 if ( sipCpp->layerType() == "SimpleFill" )
109 sipType = sipType_QgsSimpleFillSymbolLayer;
110 else if ( sipCpp->layerType() == "LinePatternFill" )
111 sipType = sipType_QgsLinePatternFillSymbolLayer;
112 else if ( sipCpp->layerType() == "PointPatternFill" )
113 sipType = sipType_QgsPointPatternFillSymbolLayer;
114 else if ( sipCpp->layerType() == "SVGFill" )
115 sipType = sipType_QgsSVGFillSymbolLayer;
116 else if ( sipCpp->layerType() == "RasterFill" )
117 sipType = sipType_QgsRasterFillSymbolLayer;
118 else if ( sipCpp->layerType() == "CentroidFill" )
119 sipType = sipType_QgsCentroidFillSymbolLayer;
120 else if ( sipCpp->layerType() == "GradientFill" )
121 sipType = sipType_QgsGradientFillSymbolLayer;
122 else if ( sipCpp->layerType() == "ShapeburstFill" )
123 sipType = sipType_QgsShapeburstFillSymbolLayer;
124 else if ( sipCpp->layerType() == "RandomMarkerFill" )
125 sipType = sipType_QgsRandomMarkerFillSymbolLayer;
126 else
127 sipType = sipType_QgsFillSymbolLayer;
128 break;
129
131 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
132 break;
133 }
134 SIP_END
135#endif
136 public:
137
138 // *INDENT-OFF*
139
144 {
145 Size SIP_MONKEYPATCH_COMPAT_NAME( PropertySize ) = 0,
146 Angle SIP_MONKEYPATCH_COMPAT_NAME( PropertyAngle ),
147 Name SIP_MONKEYPATCH_COMPAT_NAME( PropertyName ),
148 FillColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillColor ),
149 StrokeColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeColor ),
150 StrokeWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeWidth ),
151 StrokeStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeStyle ),
152 Offset SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffset ),
153 Character SIP_MONKEYPATCH_COMPAT_NAME( PropertyCharacter ),
154 Width SIP_MONKEYPATCH_COMPAT_NAME( PropertyWidth ),
155 Height SIP_MONKEYPATCH_COMPAT_NAME( PropertyHeight ),
156 PreserveAspectRatio SIP_MONKEYPATCH_COMPAT_NAME( PropertyPreserveAspectRatio ),
157 FillStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillStyle ),
158 JoinStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyJoinStyle ),
159 SecondaryColor SIP_MONKEYPATCH_COMPAT_NAME( PropertySecondaryColor ),
160 LineAngle SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineAngle ),
161 LineDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineDistance ),
162 GradientType SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientType ),
163 CoordinateMode SIP_MONKEYPATCH_COMPAT_NAME( PropertyCoordinateMode ),
164 GradientSpread SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientSpread ),
165 GradientReference1X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1X ),
166 GradientReference1Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1Y ),
167 GradientReference2X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2X ),
168 GradientReference2Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2Y ),
169 GradientReference1IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1IsCentroid ),
170 GradientReference2IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2IsCentroid ),
171 BlurRadius SIP_MONKEYPATCH_COMPAT_NAME( PropertyBlurRadius ),
172 ShapeburstUseWholeShape SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstUseWholeShape ),
173 ShapeburstMaxDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstMaxDistance ),
174 ShapeburstIgnoreRings SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstIgnoreRings ),
175 File SIP_MONKEYPATCH_COMPAT_NAME( PropertyFile ),
176 DistanceX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceX ),
177 DistanceY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceY ),
178 DisplacementX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementX ),
179 DisplacementY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementY ),
180 Opacity SIP_MONKEYPATCH_COMPAT_NAME( PropertyOpacity ),
181 CustomDash SIP_MONKEYPATCH_COMPAT_NAME( PropertyCustomDash ),
182 CapStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyCapStyle ),
183 Placement SIP_MONKEYPATCH_COMPAT_NAME( PropertyPlacement ),
184 Interval SIP_MONKEYPATCH_COMPAT_NAME( PropertyInterval ),
185 OffsetAlongLine SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetAlongLine ),
186 AverageAngleLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyAverageAngleLength ),
187 HorizontalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyHorizontalAnchor ),
188 VerticalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyVerticalAnchor ),
189 LayerEnabled SIP_MONKEYPATCH_COMPAT_NAME( PropertyLayerEnabled ),
190 ArrowWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowWidth ),
191 ArrowStartWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowStartWidth ),
192 ArrowHeadLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadLength ),
193 ArrowHeadThickness SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadThickness ),
194 ArrowHeadType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadType ),
195 ArrowType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowType ),
196 OffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetX ),
197 OffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetY ),
198 PointCount SIP_MONKEYPATCH_COMPAT_NAME( PropertyPointCount ),
199 RandomSeed SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomSeed ),
200 ClipPoints SIP_MONKEYPATCH_COMPAT_NAME( PropertyClipPoints ),
201 DensityArea SIP_MONKEYPATCH_COMPAT_NAME( PropertyDensityArea ),
202 FontFamily SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontFamily ),
203 FontStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontStyle ),
204 DashPatternOffset SIP_MONKEYPATCH_COMPAT_NAME( PropertyDashPatternOffset ),
205 TrimStart SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimStart ),
206 TrimEnd SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimEnd ),
207 LineStartWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartWidthValue ),
208 LineEndWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndWidthValue ),
209 LineStartColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartColorValue ),
210 LineEndColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndColorValue ),
211 MarkerClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyMarkerClipping ),
212 RandomOffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetX ),
213 RandomOffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetY ),
214 LineClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineClipping ),
215 };
216 // *INDENT-ON*
217
221 static const QgsPropertiesDefinition &propertyDefinitions();
222
224
225 QgsSymbolLayer( const QgsSymbolLayer &other ) = delete;
226 QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;
227
233 virtual Qgis::SymbolLayerFlags flags() const;
234
239 bool enabled() const { return mEnabled; }
240
247 void setEnabled( bool enabled ) { mEnabled = enabled; }
248
255 Qgis::SymbolLayerUserFlags userFlags() const;
256
263 void setUserFlags( Qgis::SymbolLayerUserFlags flags );
264
279 virtual QColor color() const;
280
292 virtual void setColor( const QColor &color );
293
304 virtual void setStrokeColor( const QColor &color );
305
317 virtual QColor strokeColor() const;
318
329 virtual void setFillColor( const QColor &color );
330
342 virtual QColor fillColor() const;
343
348 virtual QString layerType() const = 0;
349
362 virtual void startRender( QgsSymbolRenderContext &context ) = 0;
363
375 virtual void stopRender( QgsSymbolRenderContext &context ) = 0;
376
395 virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
396
415 virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
416
420 virtual QgsSymbolLayer *clone() const = 0 SIP_FACTORY;
421
423 virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
424 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
425
426 virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor ); return QString(); }
427
433 virtual QVariantMap properties() const = 0;
434
435 virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) = 0;
436
440 virtual QgsSymbol *subSymbol();
441
443 virtual bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER );
444
445 Qgis::SymbolType type() const { return mType; }
446
448 virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
449
458 virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
459
467 void setLocked( bool locked ) { mLocked = locked; }
468
474 bool isLocked() const { return mLocked; }
475
483 virtual double estimateMaxBleed( const QgsRenderContext &context ) const { Q_UNUSED( context ) return 0; }
484
493 virtual void setOutputUnit( Qgis::RenderUnit unit ) { Q_UNUSED( unit ) }
494
504
510 virtual bool usesMapUnits() const;
511
512 virtual void setMapUnitScale( const QgsMapUnitScale &scale ) { Q_UNUSED( scale ) }
513 virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); }
514
521 void setRenderingPass( int renderingPass );
522
529 int renderingPass() const;
530
535 virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
536
543 virtual void setDataDefinedProperty( Property key, const QgsProperty &property );
544
546 virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
547
549 virtual double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
550
552 virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
553
555 virtual double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
556
558 virtual QColor dxfColor( QgsSymbolRenderContext &context ) const;
559
561 virtual double dxfAngle( QgsSymbolRenderContext &context ) const;
562
564 virtual QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const;
565
567 virtual Qt::PenStyle dxfPenStyle() const;
568
570 virtual QColor dxfBrushColor( QgsSymbolRenderContext &context ) const;
571
573 virtual Qt::BrushStyle dxfBrushStyle() const;
574
580 QgsPaintEffect *paintEffect() const;
581
587 void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
588
594 virtual void prepareExpressions( const QgsSymbolRenderContext &context );
595
601 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
602
607 const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
608
614 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
615
621 virtual bool hasDataDefinedProperties() const;
622
628 virtual QList<QgsSymbolLayerReference> masks() const;
629
637 virtual void prepareMasks( const QgsSymbolRenderContext &context );
638
644 void setId( const QString &id );
645
651 QString id() const;
652
668 bool installMasks( QgsRenderContext &context, bool recursive, const QRectF &rect = QRectF() );
669
670 protected:
671
677 QgsSymbolLayer( Qgis::SymbolType type, bool locked = false );
678
680
682 bool mEnabled = true;
683
686
687 bool mLocked = false;
688 QColor mColor;
689 int mRenderingPass = 0;
690 QString mId;
692
693 std::unique_ptr< QgsPaintEffect > mPaintEffect;
695
696 // clip path to be used during rendering
697 QPainterPath mClipPath;
698
699 // Configuration of selected symbology implementation
701 static const bool SELECTION_IS_OPAQUE = true;
703 static const bool SELECT_FILL_BORDER = false;
705 static const bool SELECT_FILL_STYLE = false;
706
710 void restoreOldDataDefinedProperties( const QVariantMap &stringMap );
711
716 void copyDataDefinedProperties( QgsSymbolLayer *destLayer ) const;
717
722 void copyPaintEffect( QgsSymbolLayer *destLayer ) const;
723
731 void removeMasks( QgsRenderContext &context, bool recursive );
732
739 bool shouldRenderUsingSelectionColor( const QgsSymbolRenderContext &context ) const;
740
741 private:
742 static void initPropertyDefinitions();
743
745 static QgsPropertiesDefinition sPropertyDefinitions;
746
747#ifdef SIP_RUN
748 QgsSymbolLayer( const QgsSymbolLayer &other );
749#endif
750
751};
752
754
760class CORE_EXPORT QgsMarkerSymbolLayer : public QgsSymbolLayer
761{
762 public:
763
771
779
782
783 void startRender( QgsSymbolRenderContext &context ) override;
784
785 void stopRender( QgsSymbolRenderContext &context ) override;
786
793 virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
794
795 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
796
803 void setAngle( double angle ) { mAngle = angle; }
804
809 double angle() const { return mAngle; }
810
819 void setLineAngle( double lineAngle ) { mLineAngle = lineAngle; }
820
828 virtual void setSize( double size ) { mSize = size; }
829
836 double size() const { return mSize; }
837
845 void setSizeUnit( Qgis::RenderUnit unit ) { mSizeUnit = unit; }
846
853 Qgis::RenderUnit sizeUnit() const { return mSizeUnit; }
854
862 void setSizeMapUnitScale( const QgsMapUnitScale &scale ) { mSizeMapUnitScale = scale; }
863
870 const QgsMapUnitScale &sizeMapUnitScale() const { return mSizeMapUnitScale; }
871
877 void setScaleMethod( Qgis::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
878
883 Qgis::ScaleMethod scaleMethod() const { return mScaleMethod; }
884
893 void setOffset( QPointF offset ) { mOffset = offset; }
894
902 QPointF offset() const { return mOffset; }
903
911 void setOffsetUnit( Qgis::RenderUnit unit ) { mOffsetUnit = unit; }
912
919 Qgis::RenderUnit offsetUnit() const { return mOffsetUnit; }
920
928 void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
929
936 const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
937
945 void setHorizontalAnchorPoint( HorizontalAnchorPoint h ) { mHorizontalAnchorPoint = h; }
946
953 HorizontalAnchorPoint horizontalAnchorPoint() const { return mHorizontalAnchorPoint; }
954
962 void setVerticalAnchorPoint( VerticalAnchorPoint v ) { mVerticalAnchorPoint = v; }
963
970 VerticalAnchorPoint verticalAnchorPoint() const { return mVerticalAnchorPoint; }
971
972 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
973
980 virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
981 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "QgsMarkerSymbolLayer %1 not implemented yet" ).arg( layerType() ) ) ); }
982
983 void setOutputUnit( Qgis::RenderUnit unit ) override;
984 Qgis::RenderUnit outputUnit() const override;
985 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
986 QgsMapUnitScale mapUnitScale() const override;
987 virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
988 virtual double dxfAngle( QgsSymbolRenderContext &context ) const override;
989
995 virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) = 0;
996
997 protected:
998
1003 QgsMarkerSymbolLayer( bool locked = false );
1004
1012 void markerOffset( QgsSymbolRenderContext &context, double &offsetX, double &offsetY ) const;
1013
1024 void markerOffset( QgsSymbolRenderContext &context, double width, double height, double &offsetX, double &offsetY ) const SIP_PYNAME( markerOffsetWithWidthAndHeight );
1025
1027 void markerOffset( QgsSymbolRenderContext &context, double width, double height,
1028 Qgis::RenderUnit widthUnit, Qgis::RenderUnit heightUnit,
1029 double &offsetX, double &offsetY,
1030 const QgsMapUnitScale &widthMapUnitScale, const QgsMapUnitScale &heightMapUnitScale ) const SIP_PYNAME( markerOffset2 );
1031
1038 static QPointF _rotatedOffset( QPointF offset, double angle );
1039
1041 double mAngle = 0;
1043 double mLineAngle = 0;
1045 double mSize = 2.0;
1051 QPointF mOffset;
1059 HorizontalAnchorPoint mHorizontalAnchorPoint = HCenter;
1061 VerticalAnchorPoint mVerticalAnchorPoint = VCenter;
1062
1063 private:
1064 static QgsMarkerSymbolLayer::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString &str );
1065 static QgsMarkerSymbolLayer::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString &str );
1066
1067#ifdef SIP_RUN
1069#endif
1070};
1071
1076class CORE_EXPORT QgsLineSymbolLayer : public QgsSymbolLayer
1077{
1078 public:
1079
1087
1088 QgsLineSymbolLayer( const QgsLineSymbolLayer &other ) = delete;
1090
1091 void setOutputUnit( Qgis::RenderUnit unit ) override;
1092 Qgis::RenderUnit outputUnit() const override;
1093 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1094 QgsMapUnitScale mapUnitScale() const override;
1095 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1096 double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
1097
1102 virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) = 0;
1103
1112 virtual void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1113
1127 virtual void setWidth( double width ) { mWidth = width; }
1128
1138 virtual double width() const { return mWidth; }
1139
1150 virtual double width( const QgsRenderContext &context ) const;
1151
1161 double offset() const { return mOffset; }
1162
1172 void setOffset( double offset ) { mOffset = offset; }
1173
1180 void setOffsetUnit( Qgis::RenderUnit unit ) { mOffsetUnit = unit; }
1181
1188 Qgis::RenderUnit offsetUnit() const { return mOffsetUnit; }
1189
1196 void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
1197
1204 const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
1205
1206 // TODO QGIS 4.0 - setWidthUnit(), widthUnit(), setWidthUnitScale(), widthUnitScale()
1207 // only apply to simple line symbol layers and do not belong here.
1208
1214 void setWidthUnit( Qgis::RenderUnit unit ) { mWidthUnit = unit; }
1215
1220 Qgis::RenderUnit widthUnit() const { return mWidthUnit; }
1221
1222 void setWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWidthMapUnitScale = scale; }
1223 const QgsMapUnitScale &widthMapUnitScale() const { return mWidthMapUnitScale; }
1224
1235 RenderRingFilter ringFilter() const;
1236
1247 void setRingFilter( QgsLineSymbolLayer::RenderRingFilter filter );
1248
1249 protected:
1250 QgsLineSymbolLayer( bool locked = false );
1251
1252 double mWidth = 0;
1255 double mOffset = 0;
1258
1259 RenderRingFilter mRingFilter = AllRings;
1260
1261 private:
1262#ifdef SIP_RUN
1263 QgsLineSymbolLayer( const QgsLineSymbolLayer &other );
1264#endif
1265};
1266
1271class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
1272{
1273 public:
1274
1275 QgsFillSymbolLayer( const QgsFillSymbolLayer &other ) = delete;
1277
1283 virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) = 0;
1284
1285 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1286
1294 void setAngle( double angle ) { mAngle = angle; }
1295
1303 double angle() const { return mAngle; }
1304
1315 virtual QImage toTiledPatternImage( ) const;
1316
1317 protected:
1318 QgsFillSymbolLayer( bool locked = false );
1320 void _renderPolygon( QPainter *p, const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1321
1322 double mAngle = 0.0;
1323
1324 private:
1325#ifdef SIP_RUN
1326 QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
1327#endif
1328};
1329
1330class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
1331
1332#endif
ScaleMethod
Scale methods.
Definition qgis.h:514
@ ScaleDiameter
Calculate scale by the diameter.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
Definition qgis.h:724
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
Definition qgis.h:747
RenderUnit
Rendering size units.
Definition qgis.h:4594
@ Millimeters
Millimeters.
@ Unknown
Mixed or unknown units.
SymbolType
Symbol types.
Definition qgis.h:500
@ Marker
Marker symbol.
@ Line
Line symbol.
@ Fill
Fill symbol.
@ Hybrid
Hybrid symbol.
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
Container of fields for a vector layer.
Definition qgsfields.h:46
virtual void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context)=0
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
double angle() const
Returns the rotation angle of the fill symbol, in degrees clockwise.
void setAngle(double angle)
Sets the rotation angle of the pattern, in degrees clockwise.
QgsFillSymbolLayer & operator=(const QgsFillSymbolLayer &other)=delete
QgsFillSymbolLayer(const QgsFillSymbolLayer &other)=delete
const QgsMapUnitScale & widthMapUnitScale() const
RenderRingFilter
Options for filtering rings when the line symbol layer is being used to render a polygon's rings.
@ ExteriorRingOnly
Render the exterior ring only.
@ InteriorRingsOnly
Render the interior rings only.
@ AllRings
Render both exterior and interior rings.
QgsLineSymbolLayer & operator=(const QgsLineSymbolLayer &other)=delete
QgsMapUnitScale mWidthMapUnitScale
virtual void setWidth(double width)
Sets the width of the line symbol layer.
QgsLineSymbolLayer(const QgsLineSymbolLayer &other)=delete
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
void setOffset(double offset)
Sets the line's offset.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Renders the line symbol layer along the line joining points, using the given render context.
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the unit for the line's offset.
void setWidthUnit(Qgis::RenderUnit unit)
Sets the units for the line's width.
virtual double width() const
Returns the estimated width for the line symbol layer.
QgsMapUnitScale mOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the line's offset.
double offset() const
Returns the line's offset.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the line's offset.
Qgis::RenderUnit offsetUnit() const
Returns the units for the line's offset.
Qgis::RenderUnit widthUnit() const
Returns the units for the line's width.
Struct for storing maximum and minimum scales for measurements in map units.
Abstract base class for marker symbol layers.
virtual void setSize(double size)
Sets the symbol size.
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
HorizontalAnchorPoint
Symbol horizontal anchor points.
@ Right
Align to right side of symbol.
@ HCenter
Align to horizontal center of symbol.
@ Left
Align to left side of symbol.
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's offset.
void setAngle(double angle)
Sets the rotation angle for the marker.
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QPointF mOffset
Marker offset.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
double size() const
Returns the symbol size.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
QgsMarkerSymbolLayer(const QgsMarkerSymbolLayer &other)=delete
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
Qgis::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
QgsMarkerSymbolLayer & operator=(const QgsMarkerSymbolLayer &other)=delete
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Qgis::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
VerticalAnchorPoint
Symbol vertical anchor points.
@ VCenter
Align to vertical center of symbol.
@ Bottom
Align to bottom of symbol.
@ Top
Align to top of symbol.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Writes the symbol layer definition as a SLD XML element.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
Base class for visual effects which can be applied to QPicture drawings.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
A store for object properties.
Contains information about the context of a rendering operation.
Type used to refer to a specific symbol layer in a symbol of a layer.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qgis::SymbolType type() const
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the symbol layer's property collection, used for data defined overrides.
QPainterPath mClipPath
bool isLocked() const
Returns true if the symbol layer colors are locked and the layer will ignore any symbol-level color c...
virtual QgsMapUnitScale mapUnitScale() const
Qgis::SymbolType mType
Property
Data definable properties.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Saves the symbol layer as SLD.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
QgsSymbolLayer(const QgsSymbolLayer &other)=delete
void setEnabled(bool enabled)
Sets whether symbol layer is enabled and should be drawn.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
std::unique_ptr< QgsPaintEffect > mPaintEffect
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
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 QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
virtual Qgis::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
Qgis::SymbolLayerUserFlags mUserFlags
User controlled flags.
void setLocked(bool locked)
Sets whether the layer's colors are locked.
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
virtual ~QgsSymbolLayer()
virtual void setOutputUnit(Qgis::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
virtual void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size)=0
QgsPropertyCollection mDataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
QgsSymbolLayer & operator=(const QgsSymbolLayer &other)=delete
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:94
#define str(x)
Definition qgis.cpp:38
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:271
#define SIP_PYNAME(name)
Definition qgis_sip.h:81
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:273
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
QMap< QString, QString > QgsStringMap