QGIS API Documentation 4.3.0-Master (ca159e4aeaf)
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;
47
48#ifndef SIP_RUN
49typedef QMap<QString, QString> QgsStringMap;
50#endif
51
57class CORE_EXPORT QgsSymbolLayer
58{
59 //SIP_TYPEHEADER_INCLUDE( "qgslinesymbollayer.h" );
60
61
62#ifdef SIP_RUN
64 switch ( sipCpp->type() )
65 {
67 if ( sipCpp->layerType() == "EllipseMarker" )
68 sipType = sipType_QgsEllipseSymbolLayer;
69 else if ( sipCpp->layerType() == "FontMarker" )
70 sipType = sipType_QgsFontMarkerSymbolLayer;
71 else if ( sipCpp->layerType() == "SimpleMarker" )
72 sipType = sipType_QgsSimpleMarkerSymbolLayer;
73 else if ( sipCpp->layerType() == "FilledMarker" )
74 sipType = sipType_QgsFilledMarkerSymbolLayer;
75 else if ( sipCpp->layerType() == "SvgMarker" )
76 sipType = sipType_QgsSvgMarkerSymbolLayer;
77 else if ( sipCpp->layerType() == "RasterMarker" )
78 sipType = sipType_QgsRasterMarkerSymbolLayer;
79 else if ( sipCpp->layerType() == "AnimatedMarker" )
80 sipType = sipType_QgsAnimatedMarkerSymbolLayer;
81 else if ( sipCpp->layerType() == "VectorField" )
82 sipType = sipType_QgsVectorFieldSymbolLayer;
83 else if ( sipCpp->layerType() == "MaskMarker" )
84 sipType = sipType_QgsMaskMarkerSymbolLayer;
85 else
86 sipType = sipType_QgsMarkerSymbolLayer;
87 break;
88
90 if ( sipCpp->layerType() == "MarkerLine" )
91 sipType = sipType_QgsMarkerLineSymbolLayer;
92 else if ( sipCpp->layerType() == "SimpleLine" )
93 sipType = sipType_QgsSimpleLineSymbolLayer;
94 else if ( sipCpp->layerType() == "HashLine" )
95 sipType = sipType_QgsHashedLineSymbolLayer;
96 else if ( sipCpp->layerType() == "ArrowLine" )
97 sipType = sipType_QgsArrowSymbolLayer;
98 else if ( sipCpp->layerType() == "InterpolatedLine" )
99 sipType = sipType_QgsInterpolatedLineSymbolLayer;
100 else if ( sipCpp->layerType() == "RasterLine" )
101 sipType = sipType_QgsRasterLineSymbolLayer;
102 else if ( sipCpp->layerType() == "Lineburst" )
103 sipType = sipType_QgsLineburstSymbolLayer;
104 else if ( sipCpp->layerType() == "LinearReferencing" )
105 sipType = sipType_QgsLinearReferencingSymbolLayer;
106 else if ( sipCpp->layerType() == "FilledLine" )
107 sipType = sipType_QgsFilledLineSymbolLayer;
108 else
109 sipType = sipType_QgsLineSymbolLayer;
110 break;
111
113 if ( sipCpp->layerType() == "SimpleFill" )
114 sipType = sipType_QgsSimpleFillSymbolLayer;
115 else if ( sipCpp->layerType() == "LinePatternFill" )
116 sipType = sipType_QgsLinePatternFillSymbolLayer;
117 else if ( sipCpp->layerType() == "PointPatternFill" )
118 sipType = sipType_QgsPointPatternFillSymbolLayer;
119 else if ( sipCpp->layerType() == "SVGFill" )
120 sipType = sipType_QgsSVGFillSymbolLayer;
121 else if ( sipCpp->layerType() == "RasterFill" )
122 sipType = sipType_QgsRasterFillSymbolLayer;
123 else if ( sipCpp->layerType() == "CentroidFill" )
124 sipType = sipType_QgsCentroidFillSymbolLayer;
125 else if ( sipCpp->layerType() == "GradientFill" )
126 sipType = sipType_QgsGradientFillSymbolLayer;
127 else if ( sipCpp->layerType() == "ShapeburstFill" )
128 sipType = sipType_QgsShapeburstFillSymbolLayer;
129 else if ( sipCpp->layerType() == "RandomMarkerFill" )
130 sipType = sipType_QgsRandomMarkerFillSymbolLayer;
131 else
132 sipType = sipType_QgsFillSymbolLayer;
133 break;
134
136 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
137 break;
138 }
139 SIP_END
140#endif
141 public:
142
143 // *INDENT-OFF*
144
149 {
150 Size SIP_MONKEYPATCH_COMPAT_NAME( PropertySize ) = 0,
151 Angle SIP_MONKEYPATCH_COMPAT_NAME( PropertyAngle ),
152 Name SIP_MONKEYPATCH_COMPAT_NAME( PropertyName ),
153 FillColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillColor ),
154 StrokeColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeColor ),
155 StrokeWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeWidth ),
156 StrokeStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeStyle ),
157 Offset SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffset ),
158 Character SIP_MONKEYPATCH_COMPAT_NAME( PropertyCharacter ),
159 Width SIP_MONKEYPATCH_COMPAT_NAME( PropertyWidth ),
160 Height SIP_MONKEYPATCH_COMPAT_NAME( PropertyHeight ),
161 PreserveAspectRatio SIP_MONKEYPATCH_COMPAT_NAME( PropertyPreserveAspectRatio ),
162 FillStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillStyle ),
163 JoinStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyJoinStyle ),
164 SecondaryColor SIP_MONKEYPATCH_COMPAT_NAME( PropertySecondaryColor ),
165 LineAngle SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineAngle ),
166 LineDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineDistance ),
167 GradientType SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientType ),
168 CoordinateMode SIP_MONKEYPATCH_COMPAT_NAME( PropertyCoordinateMode ),
169 GradientSpread SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientSpread ),
170 GradientReference1X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1X ),
171 GradientReference1Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1Y ),
172 GradientReference2X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2X ),
173 GradientReference2Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2Y ),
174 GradientReference1IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1IsCentroid ),
175 GradientReference2IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2IsCentroid ),
176 BlurRadius SIP_MONKEYPATCH_COMPAT_NAME( PropertyBlurRadius ),
177 ShapeburstUseWholeShape SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstUseWholeShape ),
178 ShapeburstMaxDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstMaxDistance ),
179 ShapeburstIgnoreRings SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstIgnoreRings ),
180 File SIP_MONKEYPATCH_COMPAT_NAME( PropertyFile ),
181 DistanceX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceX ),
182 DistanceY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceY ),
183 DisplacementX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementX ),
184 DisplacementY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementY ),
185 Opacity SIP_MONKEYPATCH_COMPAT_NAME( PropertyOpacity ),
186 CustomDash SIP_MONKEYPATCH_COMPAT_NAME( PropertyCustomDash ),
187 CapStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyCapStyle ),
188 Placement SIP_MONKEYPATCH_COMPAT_NAME( PropertyPlacement ),
189 Interval SIP_MONKEYPATCH_COMPAT_NAME( PropertyInterval ),
190 OffsetAlongLine SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetAlongLine ),
191 AverageAngleLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyAverageAngleLength ),
192 HorizontalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyHorizontalAnchor ),
193 VerticalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyVerticalAnchor ),
194 LayerEnabled SIP_MONKEYPATCH_COMPAT_NAME( PropertyLayerEnabled ),
195 ArrowWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowWidth ),
196 ArrowStartWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowStartWidth ),
197 ArrowHeadLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadLength ),
198 ArrowHeadThickness SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadThickness ),
199 ArrowHeadType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadType ),
200 ArrowType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowType ),
201 OffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetX ),
202 OffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetY ),
203 PointCount SIP_MONKEYPATCH_COMPAT_NAME( PropertyPointCount ),
204 RandomSeed SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomSeed ),
205 ClipPoints SIP_MONKEYPATCH_COMPAT_NAME( PropertyClipPoints ),
206 DensityArea SIP_MONKEYPATCH_COMPAT_NAME( PropertyDensityArea ),
207 FontFamily SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontFamily ),
208 FontStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontStyle ),
209 DashPatternOffset SIP_MONKEYPATCH_COMPAT_NAME( PropertyDashPatternOffset ),
210 TrimStart SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimStart ),
211 TrimEnd SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimEnd ),
212 LineStartWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartWidthValue ),
213 LineEndWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndWidthValue ),
214 LineStartColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartColorValue ),
215 LineEndColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndColorValue ),
216 MarkerClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyMarkerClipping ),
217 RandomOffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetX ),
218 RandomOffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetY ),
219 LineClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineClipping ),
220 SkipMultiples,
221 ShowMarker,
222 BlankSegments,
223 ExtraItems,
224 };
225 // *INDENT-ON*
226
230 static const QgsPropertiesDefinition &propertyDefinitions();
231
233
234 QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;
235
241 virtual Qgis::SymbolLayerFlags flags() const;
242
247 bool enabled() const { return mEnabled; }
248
255 void setEnabled( bool enabled ) { mEnabled = enabled; }
256
263 Qgis::SymbolLayerUserFlags userFlags() const;
264
271 void setUserFlags( Qgis::SymbolLayerUserFlags flags );
272
287 virtual QColor color() const;
288
300 virtual void setColor( const QColor &color );
301
312 virtual void setStrokeColor( const QColor &color );
313
325 virtual QColor strokeColor() const;
326
337 virtual void setFillColor( const QColor &color );
338
350 virtual QColor fillColor() const;
351
356 virtual QString layerType() const = 0;
357
370 virtual void startRender( QgsSymbolRenderContext &context ) = 0;
371
383 virtual void stopRender( QgsSymbolRenderContext &context ) = 0;
384
403 virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
404
423 virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
424
428 virtual QgsSymbolLayer *clone() const = 0 SIP_FACTORY;
429
435 Q_DECL_DEPRECATED virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const SIP_DEPRECATED;
436
444 virtual bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const;
445
446 virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const
447 {
448 Q_UNUSED( mmScaleFactor )
449 Q_UNUSED( mapUnitScaleFactor );
450 return QString();
451 }
452
458 virtual QVariantMap properties() const = 0;
459
460 virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) = 0;
461
465 virtual QgsSymbol *subSymbol();
466
468 virtual bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER );
469
470 Qgis::SymbolType type() const { return mType; }
471
473 virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
474
488 virtual bool rendersIdenticallyTo( const QgsSymbolLayer *other ) const;
489
498 virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
499
507 void setLocked( bool locked ) { mLocked = locked; }
508
514 bool isLocked() const { return mLocked; }
515
523 virtual double estimateMaxBleed( const QgsRenderContext &context ) const
524 {
525 Q_UNUSED( context )
526 return 0;
527 }
528
537 virtual void setOutputUnit( Qgis::RenderUnit unit ) { Q_UNUSED( unit ) }
538
548
554 virtual bool usesMapUnits() const;
555
556 virtual void setMapUnitScale( const QgsMapUnitScale &scale ) { Q_UNUSED( scale ) }
557 virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); }
558
565 void setRenderingPass( int renderingPass );
566
573 int renderingPass() const;
574
579 virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
580
587 virtual void setDataDefinedProperty( Property key, const QgsProperty &property );
588
590 virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
591
596 Q_DECL_DEPRECATED virtual double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const SIP_DEPRECATED;
597
602 virtual double dxfWidth( QgsSymbolRenderContext &context ) const;
603
608 Q_DECL_DEPRECATED virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const SIP_DEPRECATED;
609
614 virtual double dxfSize( QgsSymbolRenderContext &context ) const;
615
620 Q_DECL_DEPRECATED virtual double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const SIP_DEPRECATED;
621
626 virtual double dxfOffset( QgsSymbolRenderContext &context ) const;
627
629 virtual QColor dxfColor( QgsSymbolRenderContext &context ) const;
630
632 virtual double dxfAngle( QgsSymbolRenderContext &context ) const;
633
635 virtual QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const;
636
638 virtual Qt::PenStyle dxfPenStyle() const;
639
641 virtual QColor dxfBrushColor( QgsSymbolRenderContext &context ) const;
642
644 virtual Qt::BrushStyle dxfBrushStyle() const;
645
651 QgsPaintEffect *paintEffect() const;
652
658 void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
659
665 virtual void prepareExpressions( const QgsSymbolRenderContext &context );
666
673
679
686
692 virtual bool hasDataDefinedProperties() const;
693
699 virtual QList<QgsSymbolLayerReference> masks() const;
700
711 QString selectiveMaskingSourceSetId() const;
712
723 void setSelectiveMaskingSourceSetId( const QString &id );
724
732 virtual void prepareMasks( const QgsSymbolRenderContext &context );
733
739 void setId( const QString &id );
740
746 QString id() const;
747
748 protected:
749 QgsSymbolLayer( const QgsSymbolLayer &other ) SIP_SKIP;
750
756 QgsSymbolLayer( Qgis::SymbolType type, bool locked = false );
757
759
761 bool mEnabled = true;
762
765
766 bool mLocked = false;
767 QColor mColor;
769 QString mId;
771
773
774 std::unique_ptr< QgsPaintEffect > mPaintEffect;
776
777 // clip path to be used during rendering
778 QPainterPath mClipPath;
779 std::unique_ptr< QgsScopedQPainterState > mStateBeforeInstallingMaskClipPaths;
780
781 // Configuration of selected symbology implementation
783 static const bool SELECTION_IS_OPAQUE = true;
785 static const bool SELECT_FILL_BORDER = false;
787 static const bool SELECT_FILL_STYLE = false;
788
792 void restoreOldDataDefinedProperties( const QVariantMap &stringMap );
793
801 void copyCommonProperties( QgsSymbolLayer *destLayer ) const;
802
809 void copyDataDefinedProperties( QgsSymbolLayer *destLayer ) const;
810
817 void copyPaintEffect( QgsSymbolLayer *destLayer ) const;
818
834 bool installMasks( QgsRenderContext &context, bool recursive, const QRectF &rect = QRectF() );
835
843 void removeMasks( QgsRenderContext &context, bool recursive );
844
851 bool shouldRenderUsingSelectionColor( const QgsSymbolRenderContext &context ) const;
852
853 private:
854 static void initPropertyDefinitions();
855
857 static QgsPropertiesDefinition sPropertyDefinitions;
858
859#ifdef SIP_RUN
860 QgsSymbolLayer( const QgsSymbolLayer &other );
861#endif
862
863 friend class QgsSymbol;
864};
865
867
873class CORE_EXPORT QgsMarkerSymbolLayer : public QgsSymbolLayer
874{
875 public:
877
878 void startRender( QgsSymbolRenderContext &context ) override;
879
880 void stopRender( QgsSymbolRenderContext &context ) override;
881
888 virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
889
890 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
891
898 void setAngle( double angle ) { mAngle = angle; }
899
904 double angle() const { return mAngle; }
905
914 void setLineAngle( double lineAngle ) { mLineAngle = lineAngle; }
915
923 virtual void setSize( double size ) { mSize = size; }
924
931 double size() const { return mSize; }
932
940 void setSizeUnit( Qgis::RenderUnit unit ) { mSizeUnit = unit; }
941
949
957 void setSizeMapUnitScale( const QgsMapUnitScale &scale ) { mSizeMapUnitScale = scale; }
958
966
973
979
988 void setOffset( QPointF offset ) { mOffset = offset; }
989
997 QPointF offset() const { return mOffset; }
998
1007
1015
1024
1032
1041
1049
1058
1066
1068 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
1069
1077 Q_DECL_DEPRECATED virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const SIP_DEPRECATED;
1078
1086 virtual bool writeSldMarker( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const;
1087
1088 void setOutputUnit( Qgis::RenderUnit unit ) override;
1089 Qgis::RenderUnit outputUnit() const override;
1090 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1091 QgsMapUnitScale mapUnitScale() const override;
1093 double dxfSize( QgsSymbolRenderContext &context ) const override;
1094 double dxfAngle( QgsSymbolRenderContext &context ) const override;
1095
1101 virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) = 0;
1102
1103 protected:
1105
1110 QgsMarkerSymbolLayer( bool locked = false );
1111
1119 void markerOffset( QgsSymbolRenderContext &context, double &offsetX, double &offsetY ) const;
1120
1131 void markerOffset( QgsSymbolRenderContext &context, double width, double height, double &offsetX, double &offsetY ) const SIP_PYNAME( markerOffsetWithWidthAndHeight );
1132
1146 void markerOffset(
1147 QgsSymbolRenderContext &context,
1148 double width,
1149 double height,
1150 Qgis::RenderUnit widthUnit,
1151 Qgis::RenderUnit heightUnit,
1152 double &offsetX,
1153 double &offsetY,
1154 const QgsMapUnitScale &widthMapUnitScale,
1155 const QgsMapUnitScale &heightMapUnitScale
1156 ) const SIP_PYNAME( markerOffset2 );
1157
1164 static QPointF _rotatedOffset( QPointF offset, double angle );
1165
1167 double mAngle = 0;
1169 double mLineAngle = 0;
1171 double mSize = 2.0;
1177 QPointF mOffset;
1188
1189 private:
1190 static Qgis::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString &str );
1191 static Qgis::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString &str );
1192
1193#ifdef SIP_RUN
1195#endif
1196};
1197
1204class CORE_EXPORT QgsLineSymbolLayer : public QgsSymbolLayer
1205{
1206 public:
1214
1215 QgsLineSymbolLayer( const QgsLineSymbolLayer &other ) = delete;
1217
1218 void setOutputUnit( Qgis::RenderUnit unit ) override;
1219 Qgis::RenderUnit outputUnit() const override;
1220 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1221 QgsMapUnitScale mapUnitScale() const override;
1222 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1224 double dxfWidth( QgsSymbolRenderContext &context ) const override;
1225
1230 virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) = 0;
1231
1240 virtual void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1241
1255 virtual void setWidth( double width ) { mWidth = width; }
1256
1266 virtual double width() const { return mWidth; }
1267
1278 virtual double width( const QgsRenderContext &context ) const;
1279
1289 double offset() const { return mOffset; }
1290
1300 void setOffset( double offset ) { mOffset = offset; }
1301
1309
1317
1325
1333
1334 // TODO QGIS 5.0 - setWidthUnit(), widthUnit(), setWidthUnitScale(), widthUnitScale()
1335 // only apply to simple line symbol layers and do not belong here.
1336
1343
1349
1352
1363 RenderRingFilter ringFilter() const;
1364
1375 void setRingFilter( QgsLineSymbolLayer::RenderRingFilter filter );
1376
1377 protected:
1378 QgsLineSymbolLayer( bool locked = false );
1379
1380 double mWidth = 0;
1383 double mOffset = 0;
1386
1388
1389 private:
1390#ifdef SIP_RUN
1391 QgsLineSymbolLayer( const QgsLineSymbolLayer &other );
1392#endif
1393};
1394
1400class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
1401{
1402 public:
1403 QgsFillSymbolLayer( const QgsFillSymbolLayer &other ) = delete;
1405
1411 virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) = 0;
1412
1413 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1414
1422 void setAngle( double angle ) { mAngle = angle; }
1423
1431 double angle() const { return mAngle; }
1432
1443 virtual QImage toTiledPatternImage() const;
1444
1445 protected:
1446 QgsFillSymbolLayer( bool locked = false );
1448 void _renderPolygon( QPainter *p, const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1449
1450 double mAngle = 0.0;
1451
1452 private:
1453#ifdef SIP_RUN
1454 QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
1455#endif
1456};
1457
1458class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
1459
1460#endif
ScaleMethod
Scale methods.
Definition qgis.h:685
@ ScaleDiameter
Calculate scale by the diameter.
Definition qgis.h:687
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
Definition qgis.h:969
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
Definition qgis.h:992
VerticalAnchorPoint
Marker symbol vertical anchor points.
Definition qgis.h:896
@ Center
Align to vertical center of symbol.
Definition qgis.h:898
RenderUnit
Rendering size units.
Definition qgis.h:5758
@ Millimeters
Millimeters.
Definition qgis.h:5759
@ Unknown
Mixed or unknown units.
Definition qgis.h:5765
SymbolType
Symbol types.
Definition qgis.h:671
@ Marker
Marker symbol.
Definition qgis.h:672
@ Line
Line symbol.
Definition qgis.h:673
@ Fill
Fill symbol.
Definition qgis.h:674
@ Hybrid
Hybrid symbol.
Definition qgis.h:675
HorizontalAnchorPoint
Marker symbol horizontal anchor points.
Definition qgis.h:882
@ Center
Align to horizontal center of symbol.
Definition qgis.h:884
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:45
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.
Scoped object for saving and restoring a QPainter object's state.
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.
friend class QgsSymbol
std::unique_ptr< QgsScopedQPainterState > mStateBeforeInstallingMaskClipPaths
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.
bool installMasks(QgsRenderContext &context, bool recursive, const QRectF &rect=QRectF())
When rendering, install masks on context painter.
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:8332
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:203
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:270
#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:220
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition qgis_sip.h:272
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.