QGIS API Documentation 4.1.0-Master (26185ffb827)
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.h"
22#include "qgis_core.h"
23#include "qgsfields.h"
26
27#include <QColor>
28#include <QDomDocument>
29#include <QDomElement>
30#include <QImage>
31#include <QMap>
32#include <QPainterPath>
33#include <QPointF>
34#include <QSet>
35
36class QPainter;
37class QSize;
38class QPolygonF;
39
40class QgsDxfExport;
41class QgsExpression;
43class QgsPaintEffect;
46
47#ifndef SIP_RUN
48typedef QMap<QString, QString> QgsStringMap;
49#endif
50
56class CORE_EXPORT QgsSymbolLayer
57{
58 //SIP_TYPEHEADER_INCLUDE( "qgslinesymbollayer.h" );
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 if ( sipCpp->layerType() == "LinearReferencing" )
104 sipType = sipType_QgsLinearReferencingSymbolLayer;
105 else if ( sipCpp->layerType() == "FilledLine" )
106 sipType = sipType_QgsFilledLineSymbolLayer;
107 else
108 sipType = sipType_QgsLineSymbolLayer;
109 break;
110
112 if ( sipCpp->layerType() == "SimpleFill" )
113 sipType = sipType_QgsSimpleFillSymbolLayer;
114 else if ( sipCpp->layerType() == "LinePatternFill" )
115 sipType = sipType_QgsLinePatternFillSymbolLayer;
116 else if ( sipCpp->layerType() == "PointPatternFill" )
117 sipType = sipType_QgsPointPatternFillSymbolLayer;
118 else if ( sipCpp->layerType() == "SVGFill" )
119 sipType = sipType_QgsSVGFillSymbolLayer;
120 else if ( sipCpp->layerType() == "RasterFill" )
121 sipType = sipType_QgsRasterFillSymbolLayer;
122 else if ( sipCpp->layerType() == "CentroidFill" )
123 sipType = sipType_QgsCentroidFillSymbolLayer;
124 else if ( sipCpp->layerType() == "GradientFill" )
125 sipType = sipType_QgsGradientFillSymbolLayer;
126 else if ( sipCpp->layerType() == "ShapeburstFill" )
127 sipType = sipType_QgsShapeburstFillSymbolLayer;
128 else if ( sipCpp->layerType() == "RandomMarkerFill" )
129 sipType = sipType_QgsRandomMarkerFillSymbolLayer;
130 else
131 sipType = sipType_QgsFillSymbolLayer;
132 break;
133
135 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
136 break;
137 }
138 SIP_END
139#endif
140 public:
141
142 // *INDENT-OFF*
143
148 {
149 Size SIP_MONKEYPATCH_COMPAT_NAME( PropertySize ) = 0,
150 Angle SIP_MONKEYPATCH_COMPAT_NAME( PropertyAngle ),
151 Name SIP_MONKEYPATCH_COMPAT_NAME( PropertyName ),
152 FillColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillColor ),
153 StrokeColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeColor ),
154 StrokeWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeWidth ),
155 StrokeStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeStyle ),
156 Offset SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffset ),
157 Character SIP_MONKEYPATCH_COMPAT_NAME( PropertyCharacter ),
158 Width SIP_MONKEYPATCH_COMPAT_NAME( PropertyWidth ),
159 Height SIP_MONKEYPATCH_COMPAT_NAME( PropertyHeight ),
160 PreserveAspectRatio SIP_MONKEYPATCH_COMPAT_NAME( PropertyPreserveAspectRatio ),
161 FillStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillStyle ),
162 JoinStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyJoinStyle ),
163 SecondaryColor SIP_MONKEYPATCH_COMPAT_NAME( PropertySecondaryColor ),
164 LineAngle SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineAngle ),
165 LineDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineDistance ),
166 GradientType SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientType ),
167 CoordinateMode SIP_MONKEYPATCH_COMPAT_NAME( PropertyCoordinateMode ),
168 GradientSpread SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientSpread ),
169 GradientReference1X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1X ),
170 GradientReference1Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1Y ),
171 GradientReference2X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2X ),
172 GradientReference2Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2Y ),
173 GradientReference1IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1IsCentroid ),
174 GradientReference2IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2IsCentroid ),
175 BlurRadius SIP_MONKEYPATCH_COMPAT_NAME( PropertyBlurRadius ),
176 ShapeburstUseWholeShape SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstUseWholeShape ),
177 ShapeburstMaxDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstMaxDistance ),
178 ShapeburstIgnoreRings SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstIgnoreRings ),
179 File SIP_MONKEYPATCH_COMPAT_NAME( PropertyFile ),
180 DistanceX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceX ),
181 DistanceY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceY ),
182 DisplacementX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementX ),
183 DisplacementY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementY ),
184 Opacity SIP_MONKEYPATCH_COMPAT_NAME( PropertyOpacity ),
185 CustomDash SIP_MONKEYPATCH_COMPAT_NAME( PropertyCustomDash ),
186 CapStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyCapStyle ),
187 Placement SIP_MONKEYPATCH_COMPAT_NAME( PropertyPlacement ),
188 Interval SIP_MONKEYPATCH_COMPAT_NAME( PropertyInterval ),
189 OffsetAlongLine SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetAlongLine ),
190 AverageAngleLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyAverageAngleLength ),
191 HorizontalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyHorizontalAnchor ),
192 VerticalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyVerticalAnchor ),
193 LayerEnabled SIP_MONKEYPATCH_COMPAT_NAME( PropertyLayerEnabled ),
194 ArrowWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowWidth ),
195 ArrowStartWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowStartWidth ),
196 ArrowHeadLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadLength ),
197 ArrowHeadThickness SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadThickness ),
198 ArrowHeadType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadType ),
199 ArrowType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowType ),
200 OffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetX ),
201 OffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetY ),
202 PointCount SIP_MONKEYPATCH_COMPAT_NAME( PropertyPointCount ),
203 RandomSeed SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomSeed ),
204 ClipPoints SIP_MONKEYPATCH_COMPAT_NAME( PropertyClipPoints ),
205 DensityArea SIP_MONKEYPATCH_COMPAT_NAME( PropertyDensityArea ),
206 FontFamily SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontFamily ),
207 FontStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontStyle ),
208 DashPatternOffset SIP_MONKEYPATCH_COMPAT_NAME( PropertyDashPatternOffset ),
209 TrimStart SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimStart ),
210 TrimEnd SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimEnd ),
211 LineStartWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartWidthValue ),
212 LineEndWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndWidthValue ),
213 LineStartColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartColorValue ),
214 LineEndColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndColorValue ),
215 MarkerClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyMarkerClipping ),
216 RandomOffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetX ),
217 RandomOffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetY ),
218 LineClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineClipping ),
219 SkipMultiples,
220 ShowMarker,
221 BlankSegments,
222 ExtraItems,
223 };
224 // *INDENT-ON*
225
229 static const QgsPropertiesDefinition &propertyDefinitions();
230
232
233 QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;
234
240 virtual Qgis::SymbolLayerFlags flags() const;
241
246 bool enabled() const { return mEnabled; }
247
254 void setEnabled( bool enabled ) { mEnabled = enabled; }
255
262 Qgis::SymbolLayerUserFlags userFlags() const;
263
270 void setUserFlags( Qgis::SymbolLayerUserFlags flags );
271
286 virtual QColor color() const;
287
299 virtual void setColor( const QColor &color );
300
311 virtual void setStrokeColor( const QColor &color );
312
324 virtual QColor strokeColor() const;
325
336 virtual void setFillColor( const QColor &color );
337
349 virtual QColor fillColor() const;
350
355 virtual QString layerType() const = 0;
356
369 virtual void startRender( QgsSymbolRenderContext &context ) = 0;
370
382 virtual void stopRender( QgsSymbolRenderContext &context ) = 0;
383
402 virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
403
422 virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
423
427 virtual QgsSymbolLayer *clone() const = 0 SIP_FACTORY;
428
434 Q_DECL_DEPRECATED virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const SIP_DEPRECATED;
435
443 virtual bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const;
444
445 virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const
446 {
447 Q_UNUSED( mmScaleFactor )
448 Q_UNUSED( mapUnitScaleFactor );
449 return QString();
450 }
451
457 virtual QVariantMap properties() const = 0;
458
459 virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) = 0;
460
464 virtual QgsSymbol *subSymbol();
465
467 virtual bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER );
468
469 Qgis::SymbolType type() const { return mType; }
470
472 virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
473
487 virtual bool rendersIdenticallyTo( const QgsSymbolLayer *other ) const;
488
497 virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
498
506 void setLocked( bool locked ) { mLocked = locked; }
507
513 bool isLocked() const { return mLocked; }
514
522 virtual double estimateMaxBleed( const QgsRenderContext &context ) const
523 {
524 Q_UNUSED( context )
525 return 0;
526 }
527
536 virtual void setOutputUnit( Qgis::RenderUnit unit ) { Q_UNUSED( unit ) }
537
547
553 virtual bool usesMapUnits() const;
554
555 virtual void setMapUnitScale( const QgsMapUnitScale &scale ) { Q_UNUSED( scale ) }
556 virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); }
557
564 void setRenderingPass( int renderingPass );
565
572 int renderingPass() const;
573
578 virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
579
586 virtual void setDataDefinedProperty( Property key, const QgsProperty &property );
587
589 virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
590
595 Q_DECL_DEPRECATED virtual double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const SIP_DEPRECATED;
596
601 virtual double dxfWidth( QgsSymbolRenderContext &context ) const;
602
607 Q_DECL_DEPRECATED virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const SIP_DEPRECATED;
608
613 virtual double dxfSize( QgsSymbolRenderContext &context ) const;
614
619 Q_DECL_DEPRECATED virtual double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const SIP_DEPRECATED;
620
625 virtual double dxfOffset( QgsSymbolRenderContext &context ) const;
626
628 virtual QColor dxfColor( QgsSymbolRenderContext &context ) const;
629
631 virtual double dxfAngle( QgsSymbolRenderContext &context ) const;
632
634 virtual QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const;
635
637 virtual Qt::PenStyle dxfPenStyle() const;
638
640 virtual QColor dxfBrushColor( QgsSymbolRenderContext &context ) const;
641
643 virtual Qt::BrushStyle dxfBrushStyle() const;
644
650 QgsPaintEffect *paintEffect() const;
651
657 void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
658
664 virtual void prepareExpressions( const QgsSymbolRenderContext &context );
665
672
678
685
691 virtual bool hasDataDefinedProperties() const;
692
698 virtual QList<QgsSymbolLayerReference> masks() const;
699
710 QString selectiveMaskingSourceSetId() const;
711
722 void setSelectiveMaskingSourceSetId( const QString &id );
723
731 virtual void prepareMasks( const QgsSymbolRenderContext &context );
732
738 void setId( const QString &id );
739
745 QString id() const;
746
762 bool installMasks( QgsRenderContext &context, bool recursive, const QRectF &rect = QRectF() );
763
764 protected:
765 QgsSymbolLayer( const QgsSymbolLayer &other ) SIP_SKIP;
766
772 QgsSymbolLayer( Qgis::SymbolType type, bool locked = false );
773
775
777 bool mEnabled = true;
778
781
782 bool mLocked = false;
783 QColor mColor;
785 QString mId;
787
789
790 std::unique_ptr< QgsPaintEffect > mPaintEffect;
792
793 // clip path to be used during rendering
794 QPainterPath mClipPath;
795
796 // Configuration of selected symbology implementation
798 static const bool SELECTION_IS_OPAQUE = true;
800 static const bool SELECT_FILL_BORDER = false;
802 static const bool SELECT_FILL_STYLE = false;
803
807 void restoreOldDataDefinedProperties( const QVariantMap &stringMap );
808
816 void copyCommonProperties( QgsSymbolLayer *destLayer ) const;
817
824 void copyDataDefinedProperties( QgsSymbolLayer *destLayer ) const;
825
832 void copyPaintEffect( QgsSymbolLayer *destLayer ) const;
833
841 void removeMasks( QgsRenderContext &context, bool recursive );
842
849 bool shouldRenderUsingSelectionColor( const QgsSymbolRenderContext &context ) const;
850
851 private:
852 static void initPropertyDefinitions();
853
855 static QgsPropertiesDefinition sPropertyDefinitions;
856
857#ifdef SIP_RUN
858 QgsSymbolLayer( const QgsSymbolLayer &other );
859#endif
860};
861
863
869class CORE_EXPORT QgsMarkerSymbolLayer : public QgsSymbolLayer
870{
871 public:
873
874 void startRender( QgsSymbolRenderContext &context ) override;
875
876 void stopRender( QgsSymbolRenderContext &context ) override;
877
884 virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
885
886 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
887
894 void setAngle( double angle ) { mAngle = angle; }
895
900 double angle() const { return mAngle; }
901
910 void setLineAngle( double lineAngle ) { mLineAngle = lineAngle; }
911
919 virtual void setSize( double size ) { mSize = size; }
920
927 double size() const { return mSize; }
928
936 void setSizeUnit( Qgis::RenderUnit unit ) { mSizeUnit = unit; }
937
945
953 void setSizeMapUnitScale( const QgsMapUnitScale &scale ) { mSizeMapUnitScale = scale; }
954
962
969
975
984 void setOffset( QPointF offset ) { mOffset = offset; }
985
993 QPointF offset() const { return mOffset; }
994
1003
1011
1020
1028
1037
1045
1054
1062
1064 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
1065
1073 Q_DECL_DEPRECATED virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const SIP_DEPRECATED;
1074
1082 virtual bool writeSldMarker( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const;
1083
1084 void setOutputUnit( Qgis::RenderUnit unit ) override;
1085 Qgis::RenderUnit outputUnit() const override;
1086 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1087 QgsMapUnitScale mapUnitScale() const override;
1089 double dxfSize( QgsSymbolRenderContext &context ) const override;
1090 double dxfAngle( QgsSymbolRenderContext &context ) const override;
1091
1097 virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) = 0;
1098
1099 protected:
1101
1106 QgsMarkerSymbolLayer( bool locked = false );
1107
1115 void markerOffset( QgsSymbolRenderContext &context, double &offsetX, double &offsetY ) const;
1116
1127 void markerOffset( QgsSymbolRenderContext &context, double width, double height, double &offsetX, double &offsetY ) const SIP_PYNAME( markerOffsetWithWidthAndHeight );
1128
1142 void markerOffset(
1143 QgsSymbolRenderContext &context,
1144 double width,
1145 double height,
1146 Qgis::RenderUnit widthUnit,
1147 Qgis::RenderUnit heightUnit,
1148 double &offsetX,
1149 double &offsetY,
1150 const QgsMapUnitScale &widthMapUnitScale,
1151 const QgsMapUnitScale &heightMapUnitScale
1152 ) const SIP_PYNAME( markerOffset2 );
1153
1160 static QPointF _rotatedOffset( QPointF offset, double angle );
1161
1163 double mAngle = 0;
1165 double mLineAngle = 0;
1167 double mSize = 2.0;
1173 QPointF mOffset;
1184
1185 private:
1186 static Qgis::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString &str );
1187 static Qgis::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString &str );
1188
1189#ifdef SIP_RUN
1191#endif
1192};
1193
1200class CORE_EXPORT QgsLineSymbolLayer : public QgsSymbolLayer
1201{
1202 public:
1210
1211 QgsLineSymbolLayer( const QgsLineSymbolLayer &other ) = delete;
1213
1214 void setOutputUnit( Qgis::RenderUnit unit ) override;
1215 Qgis::RenderUnit outputUnit() const override;
1216 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1217 QgsMapUnitScale mapUnitScale() const override;
1218 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1220 double dxfWidth( QgsSymbolRenderContext &context ) const override;
1221
1226 virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) = 0;
1227
1236 virtual void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1237
1251 virtual void setWidth( double width ) { mWidth = width; }
1252
1262 virtual double width() const { return mWidth; }
1263
1274 virtual double width( const QgsRenderContext &context ) const;
1275
1285 double offset() const { return mOffset; }
1286
1296 void setOffset( double offset ) { mOffset = offset; }
1297
1305
1313
1321
1329
1330 // TODO QGIS 5.0 - setWidthUnit(), widthUnit(), setWidthUnitScale(), widthUnitScale()
1331 // only apply to simple line symbol layers and do not belong here.
1332
1339
1345
1348
1359 RenderRingFilter ringFilter() const;
1360
1371 void setRingFilter( QgsLineSymbolLayer::RenderRingFilter filter );
1372
1373 protected:
1374 QgsLineSymbolLayer( bool locked = false );
1375
1376 double mWidth = 0;
1379 double mOffset = 0;
1382
1384
1385 private:
1386#ifdef SIP_RUN
1387 QgsLineSymbolLayer( const QgsLineSymbolLayer &other );
1388#endif
1389};
1390
1396class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
1397{
1398 public:
1399 QgsFillSymbolLayer( const QgsFillSymbolLayer &other ) = delete;
1401
1407 virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) = 0;
1408
1409 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1410
1418 void setAngle( double angle ) { mAngle = angle; }
1419
1427 double angle() const { return mAngle; }
1428
1439 virtual QImage toTiledPatternImage() const;
1440
1441 protected:
1442 QgsFillSymbolLayer( bool locked = false );
1444 void _renderPolygon( QPainter *p, const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1445
1446 double mAngle = 0.0;
1447
1448 private:
1449#ifdef SIP_RUN
1450 QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
1451#endif
1452};
1453
1454class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
1455
1456#endif
ScaleMethod
Scale methods.
Definition qgis.h:651
@ ScaleDiameter
Calculate scale by the diameter.
Definition qgis.h:653
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
Definition qgis.h:935
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
Definition qgis.h:958
VerticalAnchorPoint
Marker symbol vertical anchor points.
Definition qgis.h:862
@ Center
Align to vertical center of symbol.
Definition qgis.h:864
RenderUnit
Rendering size units.
Definition qgis.h:5586
@ Millimeters
Millimeters.
Definition qgis.h:5587
@ Unknown
Mixed or unknown units.
Definition qgis.h:5593
SymbolType
Symbol types.
Definition qgis.h:637
@ Marker
Marker symbol.
Definition qgis.h:638
@ Line
Line symbol.
Definition qgis.h:639
@ Fill
Fill symbol.
Definition qgis.h:640
@ Hybrid
Hybrid symbol.
Definition qgis.h:641
HorizontalAnchorPoint
Marker symbol horizontal anchor points.
Definition qgis.h:848
@ Center
Align to horizontal center of symbol.
Definition qgis.h:850
Exports QGIS layers to the DXF format.
Handles parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Container of fields for a vector layer.
Definition qgsfields.h:46
Abstract base class for fill symbol layers.
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 drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
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
Abstract base class for line symbol layers.
const QgsMapUnitScale & widthMapUnitScale() const
Qgis::RenderUnit mOffsetUnit
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.
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
QgsLineSymbolLayer(const QgsLineSymbolLayer &other)=delete
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
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.
Qgis::RenderUnit mWidthUnit
void setOffset(double offset)
Sets the line's offset.
double dxfWidth(QgsSymbolRenderContext &context) const override
Gets line width.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Renders the line symbol layer along the line joining points, using the given render context.
RenderRingFilter mRingFilter
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.
QgsMapUnitScale mapUnitScale() const override
void setMapUnitScale(const QgsMapUnitScale &scale) override
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.
double mSize
Marker size.
virtual void setSize(double size)
Sets the symbol size.
void setVerticalAnchorPoint(Qgis::VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QgsMarkerSymbolLayer(const QgsMarkerSymbolLayer &other)
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
Qgis::RenderUnit mOffsetUnit
Offset units.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
double mLineAngle
Line rotation angle (see setLineAngle() for details).
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.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QPointF mOffset
Marker offset.
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.
Qgis::VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
Qgis::VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
void setHorizontalAnchorPoint(Qgis::HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
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.
Qgis::ScaleMethod mScaleMethod
Marker size scaling method.
Qgis::HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
QgsMarkerSymbolLayer & operator=(const QgsMarkerSymbolLayer &other)=delete
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Qgis::RenderUnit mSizeUnit
Marker size unit.
Qgis::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
Qgis::HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double mAngle
Marker rotation angle, in degrees clockwise from north.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
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 an integer key value.
A store for object properties.
Contains information about the context of a rendering operation.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
Type used to refer to a specific symbol layer in a symbol of a layer.
Abstract base class for widgets used to configure QgsSymbolLayer classes.
Abstract base class for symbol layers.
void copyCommonProperties(QgsSymbolLayer *destLayer) const
Copies all common base class properties from this layer to another symbol layer.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
bool shouldRenderUsingSelectionColor(const QgsSymbolRenderContext &context) const
Returns true if the symbol layer should be rendered using the selection color from the render context...
Qgis::SymbolType type() const
virtual void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called before the layer will be rendered for a particular feature.
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...
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
virtual Q_DECL_DEPRECATED double dxfSize(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets marker size.
virtual QgsMapUnitScale mapUnitScale() const
Qgis::SymbolType mType
void removeMasks(QgsRenderContext &context, bool recursive)
When rendering, remove previously installed masks from context painter if recursive is true masks are...
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
Property
Data definable properties.
void restoreOldDataDefinedProperties(const QVariantMap &stringMap)
Restores older data defined properties from string map.
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.
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...
static const bool SELECT_FILL_BORDER
Whether fill styles for selected features also highlight symbol stroke.
std::unique_ptr< QgsPaintEffect > mPaintEffect
QString mSelectiveMaskingSourceSetId
bool mEnabled
True if layer is enabled and should be drawn.
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 Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Saves the symbol layer as SLD.
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.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
virtual void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called after the layer has been rendered for a particular feature.
virtual Q_DECL_DEPRECATED double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
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.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
virtual void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size)=0
virtual Qgis::SymbolLayerFlags flags() const
Returns flags which control the symbol layer's behavior.
QgsPropertyCollection mDataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
static const bool SELECT_FILL_STYLE
Whether fill styles for selected features uses symbol layer style.
QgsSymbolLayer & operator=(const QgsSymbolLayer &other)=delete
QgsSymbolLayer(const QgsSymbolLayer &other)
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
Encapsulates the context in which a symbol is being rendered.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:227
QMap< QString, QString > QgsStringMap
Definition qgis.h:7772
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:198
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:265
#define SIP_PYNAME(name)
Definition qgis_sip.h:88
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_END
Definition qgis_sip.h:215
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:267
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.