QGIS API Documentation 3.39.0-Master (d0dedde5474)
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 if ( sipCpp->layerType() == "LinearReferencing" )
104 sipType = sipType_QgsLinearReferencingSymbolLayer;
105 else
106 sipType = sipType_QgsLineSymbolLayer;
107 break;
108
110 if ( sipCpp->layerType() == "SimpleFill" )
111 sipType = sipType_QgsSimpleFillSymbolLayer;
112 else if ( sipCpp->layerType() == "LinePatternFill" )
113 sipType = sipType_QgsLinePatternFillSymbolLayer;
114 else if ( sipCpp->layerType() == "PointPatternFill" )
115 sipType = sipType_QgsPointPatternFillSymbolLayer;
116 else if ( sipCpp->layerType() == "SVGFill" )
117 sipType = sipType_QgsSVGFillSymbolLayer;
118 else if ( sipCpp->layerType() == "RasterFill" )
119 sipType = sipType_QgsRasterFillSymbolLayer;
120 else if ( sipCpp->layerType() == "CentroidFill" )
121 sipType = sipType_QgsCentroidFillSymbolLayer;
122 else if ( sipCpp->layerType() == "GradientFill" )
123 sipType = sipType_QgsGradientFillSymbolLayer;
124 else if ( sipCpp->layerType() == "ShapeburstFill" )
125 sipType = sipType_QgsShapeburstFillSymbolLayer;
126 else if ( sipCpp->layerType() == "RandomMarkerFill" )
127 sipType = sipType_QgsRandomMarkerFillSymbolLayer;
128 else
129 sipType = sipType_QgsFillSymbolLayer;
130 break;
131
133 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
134 break;
135 }
136 SIP_END
137#endif
138 public:
139
140 // *INDENT-OFF*
141
146 {
147 Size SIP_MONKEYPATCH_COMPAT_NAME( PropertySize ) = 0,
148 Angle SIP_MONKEYPATCH_COMPAT_NAME( PropertyAngle ),
149 Name SIP_MONKEYPATCH_COMPAT_NAME( PropertyName ),
150 FillColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillColor ),
151 StrokeColor SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeColor ),
152 StrokeWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeWidth ),
153 StrokeStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyStrokeStyle ),
154 Offset SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffset ),
155 Character SIP_MONKEYPATCH_COMPAT_NAME( PropertyCharacter ),
156 Width SIP_MONKEYPATCH_COMPAT_NAME( PropertyWidth ),
157 Height SIP_MONKEYPATCH_COMPAT_NAME( PropertyHeight ),
158 PreserveAspectRatio SIP_MONKEYPATCH_COMPAT_NAME( PropertyPreserveAspectRatio ),
159 FillStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFillStyle ),
160 JoinStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyJoinStyle ),
161 SecondaryColor SIP_MONKEYPATCH_COMPAT_NAME( PropertySecondaryColor ),
162 LineAngle SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineAngle ),
163 LineDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineDistance ),
164 GradientType SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientType ),
165 CoordinateMode SIP_MONKEYPATCH_COMPAT_NAME( PropertyCoordinateMode ),
166 GradientSpread SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientSpread ),
167 GradientReference1X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1X ),
168 GradientReference1Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1Y ),
169 GradientReference2X SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2X ),
170 GradientReference2Y SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2Y ),
171 GradientReference1IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference1IsCentroid ),
172 GradientReference2IsCentroid SIP_MONKEYPATCH_COMPAT_NAME( PropertyGradientReference2IsCentroid ),
173 BlurRadius SIP_MONKEYPATCH_COMPAT_NAME( PropertyBlurRadius ),
174 ShapeburstUseWholeShape SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstUseWholeShape ),
175 ShapeburstMaxDistance SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstMaxDistance ),
176 ShapeburstIgnoreRings SIP_MONKEYPATCH_COMPAT_NAME( PropertyShapeburstIgnoreRings ),
177 File SIP_MONKEYPATCH_COMPAT_NAME( PropertyFile ),
178 DistanceX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceX ),
179 DistanceY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDistanceY ),
180 DisplacementX SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementX ),
181 DisplacementY SIP_MONKEYPATCH_COMPAT_NAME( PropertyDisplacementY ),
182 Opacity SIP_MONKEYPATCH_COMPAT_NAME( PropertyOpacity ),
183 CustomDash SIP_MONKEYPATCH_COMPAT_NAME( PropertyCustomDash ),
184 CapStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyCapStyle ),
185 Placement SIP_MONKEYPATCH_COMPAT_NAME( PropertyPlacement ),
186 Interval SIP_MONKEYPATCH_COMPAT_NAME( PropertyInterval ),
187 OffsetAlongLine SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetAlongLine ),
188 AverageAngleLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyAverageAngleLength ),
189 HorizontalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyHorizontalAnchor ),
190 VerticalAnchor SIP_MONKEYPATCH_COMPAT_NAME( PropertyVerticalAnchor ),
191 LayerEnabled SIP_MONKEYPATCH_COMPAT_NAME( PropertyLayerEnabled ),
192 ArrowWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowWidth ),
193 ArrowStartWidth SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowStartWidth ),
194 ArrowHeadLength SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadLength ),
195 ArrowHeadThickness SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadThickness ),
196 ArrowHeadType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowHeadType ),
197 ArrowType SIP_MONKEYPATCH_COMPAT_NAME( PropertyArrowType ),
198 OffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetX ),
199 OffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyOffsetY ),
200 PointCount SIP_MONKEYPATCH_COMPAT_NAME( PropertyPointCount ),
201 RandomSeed SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomSeed ),
202 ClipPoints SIP_MONKEYPATCH_COMPAT_NAME( PropertyClipPoints ),
203 DensityArea SIP_MONKEYPATCH_COMPAT_NAME( PropertyDensityArea ),
204 FontFamily SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontFamily ),
205 FontStyle SIP_MONKEYPATCH_COMPAT_NAME( PropertyFontStyle ),
206 DashPatternOffset SIP_MONKEYPATCH_COMPAT_NAME( PropertyDashPatternOffset ),
207 TrimStart SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimStart ),
208 TrimEnd SIP_MONKEYPATCH_COMPAT_NAME( PropertyTrimEnd ),
209 LineStartWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartWidthValue ),
210 LineEndWidthValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndWidthValue ),
211 LineStartColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineStartColorValue ),
212 LineEndColorValue SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineEndColorValue ),
213 MarkerClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyMarkerClipping ),
214 RandomOffsetX SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetX ),
215 RandomOffsetY SIP_MONKEYPATCH_COMPAT_NAME( PropertyRandomOffsetY ),
216 LineClipping SIP_MONKEYPATCH_COMPAT_NAME( PropertyLineClipping ),
217 SkipMultiples,
218 ShowMarker,
219 };
220 // *INDENT-ON*
221
225 static const QgsPropertiesDefinition &propertyDefinitions();
226
228
229 QgsSymbolLayer( const QgsSymbolLayer &other ) = delete;
230 QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;
231
237 virtual Qgis::SymbolLayerFlags flags() const;
238
243 bool enabled() const { return mEnabled; }
244
251 void setEnabled( bool enabled ) { mEnabled = enabled; }
252
259 Qgis::SymbolLayerUserFlags userFlags() const;
260
267 void setUserFlags( Qgis::SymbolLayerUserFlags flags );
268
283 virtual QColor color() const;
284
296 virtual void setColor( const QColor &color );
297
308 virtual void setStrokeColor( const QColor &color );
309
321 virtual QColor strokeColor() const;
322
333 virtual void setFillColor( const QColor &color );
334
346 virtual QColor fillColor() const;
347
352 virtual QString layerType() const = 0;
353
366 virtual void startRender( QgsSymbolRenderContext &context ) = 0;
367
379 virtual void stopRender( QgsSymbolRenderContext &context ) = 0;
380
399 virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
400
419 virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
420
424 virtual QgsSymbolLayer *clone() const = 0 SIP_FACTORY;
425
427 virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
428 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
429
430 virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor ); return QString(); }
431
437 virtual QVariantMap properties() const = 0;
438
439 virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) = 0;
440
444 virtual QgsSymbol *subSymbol();
445
447 virtual bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER );
448
449 Qgis::SymbolType type() const { return mType; }
450
452 virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
453
462 virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
463
471 void setLocked( bool locked ) { mLocked = locked; }
472
478 bool isLocked() const { return mLocked; }
479
487 virtual double estimateMaxBleed( const QgsRenderContext &context ) const { Q_UNUSED( context ) return 0; }
488
497 virtual void setOutputUnit( Qgis::RenderUnit unit ) { Q_UNUSED( unit ) }
498
508
514 virtual bool usesMapUnits() const;
515
516 virtual void setMapUnitScale( const QgsMapUnitScale &scale ) { Q_UNUSED( scale ) }
517 virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); }
518
525 void setRenderingPass( int renderingPass );
526
533 int renderingPass() const;
534
539 virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
540
547 virtual void setDataDefinedProperty( Property key, const QgsProperty &property );
548
550 virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
551
553 virtual double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
554
556 virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
557
559 virtual double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
560
562 virtual QColor dxfColor( QgsSymbolRenderContext &context ) const;
563
565 virtual double dxfAngle( QgsSymbolRenderContext &context ) const;
566
568 virtual QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const;
569
571 virtual Qt::PenStyle dxfPenStyle() const;
572
574 virtual QColor dxfBrushColor( QgsSymbolRenderContext &context ) const;
575
577 virtual Qt::BrushStyle dxfBrushStyle() const;
578
584 QgsPaintEffect *paintEffect() const;
585
591 void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
592
598 virtual void prepareExpressions( const QgsSymbolRenderContext &context );
599
605 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
606
611 const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
612
618 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
619
625 virtual bool hasDataDefinedProperties() const;
626
632 virtual QList<QgsSymbolLayerReference> masks() const;
633
641 virtual void prepareMasks( const QgsSymbolRenderContext &context );
642
648 void setId( const QString &id );
649
655 QString id() const;
656
672 bool installMasks( QgsRenderContext &context, bool recursive, const QRectF &rect = QRectF() );
673
674 protected:
675
681 QgsSymbolLayer( Qgis::SymbolType type, bool locked = false );
682
684
686 bool mEnabled = true;
687
690
691 bool mLocked = false;
692 QColor mColor;
693 int mRenderingPass = 0;
694 QString mId;
696
697 std::unique_ptr< QgsPaintEffect > mPaintEffect;
699
700 // clip path to be used during rendering
701 QPainterPath mClipPath;
702
703 // Configuration of selected symbology implementation
705 static const bool SELECTION_IS_OPAQUE = true;
707 static const bool SELECT_FILL_BORDER = false;
709 static const bool SELECT_FILL_STYLE = false;
710
714 void restoreOldDataDefinedProperties( const QVariantMap &stringMap );
715
720 void copyDataDefinedProperties( QgsSymbolLayer *destLayer ) const;
721
726 void copyPaintEffect( QgsSymbolLayer *destLayer ) const;
727
735 void removeMasks( QgsRenderContext &context, bool recursive );
736
743 bool shouldRenderUsingSelectionColor( const QgsSymbolRenderContext &context ) const;
744
745 private:
746 static void initPropertyDefinitions();
747
749 static QgsPropertiesDefinition sPropertyDefinitions;
750
751#ifdef SIP_RUN
752 QgsSymbolLayer( const QgsSymbolLayer &other );
753#endif
754
755};
756
758
764class CORE_EXPORT QgsMarkerSymbolLayer : public QgsSymbolLayer
765{
766 public:
767
775
783
786
787 void startRender( QgsSymbolRenderContext &context ) override;
788
789 void stopRender( QgsSymbolRenderContext &context ) override;
790
797 virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
798
799 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
800
807 void setAngle( double angle ) { mAngle = angle; }
808
813 double angle() const { return mAngle; }
814
823 void setLineAngle( double lineAngle ) { mLineAngle = lineAngle; }
824
832 virtual void setSize( double size ) { mSize = size; }
833
840 double size() const { return mSize; }
841
849 void setSizeUnit( Qgis::RenderUnit unit ) { mSizeUnit = unit; }
850
857 Qgis::RenderUnit sizeUnit() const { return mSizeUnit; }
858
866 void setSizeMapUnitScale( const QgsMapUnitScale &scale ) { mSizeMapUnitScale = scale; }
867
874 const QgsMapUnitScale &sizeMapUnitScale() const { return mSizeMapUnitScale; }
875
881 void setScaleMethod( Qgis::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
882
887 Qgis::ScaleMethod scaleMethod() const { return mScaleMethod; }
888
897 void setOffset( QPointF offset ) { mOffset = offset; }
898
906 QPointF offset() const { return mOffset; }
907
915 void setOffsetUnit( Qgis::RenderUnit unit ) { mOffsetUnit = unit; }
916
923 Qgis::RenderUnit offsetUnit() const { return mOffsetUnit; }
924
932 void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
933
940 const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
941
949 void setHorizontalAnchorPoint( HorizontalAnchorPoint h ) { mHorizontalAnchorPoint = h; }
950
957 HorizontalAnchorPoint horizontalAnchorPoint() const { return mHorizontalAnchorPoint; }
958
966 void setVerticalAnchorPoint( VerticalAnchorPoint v ) { mVerticalAnchorPoint = v; }
967
974 VerticalAnchorPoint verticalAnchorPoint() const { return mVerticalAnchorPoint; }
975
976 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
977
984 virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
985 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "QgsMarkerSymbolLayer %1 not implemented yet" ).arg( layerType() ) ) ); }
986
987 void setOutputUnit( Qgis::RenderUnit unit ) override;
988 Qgis::RenderUnit outputUnit() const override;
989 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
990 QgsMapUnitScale mapUnitScale() const override;
991 virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
992 virtual double dxfAngle( QgsSymbolRenderContext &context ) const override;
993
999 virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) = 0;
1000
1001 protected:
1002
1007 QgsMarkerSymbolLayer( bool locked = false );
1008
1016 void markerOffset( QgsSymbolRenderContext &context, double &offsetX, double &offsetY ) const;
1017
1028 void markerOffset( QgsSymbolRenderContext &context, double width, double height, double &offsetX, double &offsetY ) const SIP_PYNAME( markerOffsetWithWidthAndHeight );
1029
1031 void markerOffset( QgsSymbolRenderContext &context, double width, double height,
1032 Qgis::RenderUnit widthUnit, Qgis::RenderUnit heightUnit,
1033 double &offsetX, double &offsetY,
1034 const QgsMapUnitScale &widthMapUnitScale, const QgsMapUnitScale &heightMapUnitScale ) const SIP_PYNAME( markerOffset2 );
1035
1042 static QPointF _rotatedOffset( QPointF offset, double angle );
1043
1045 double mAngle = 0;
1047 double mLineAngle = 0;
1049 double mSize = 2.0;
1055 QPointF mOffset;
1063 HorizontalAnchorPoint mHorizontalAnchorPoint = HCenter;
1065 VerticalAnchorPoint mVerticalAnchorPoint = VCenter;
1066
1067 private:
1068 static QgsMarkerSymbolLayer::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString &str );
1069 static QgsMarkerSymbolLayer::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString &str );
1070
1071#ifdef SIP_RUN
1073#endif
1074};
1075
1082class CORE_EXPORT QgsLineSymbolLayer : public QgsSymbolLayer
1083{
1084 public:
1085
1093
1094 QgsLineSymbolLayer( const QgsLineSymbolLayer &other ) = delete;
1096
1097 void setOutputUnit( Qgis::RenderUnit unit ) override;
1098 Qgis::RenderUnit outputUnit() const override;
1099 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1100 QgsMapUnitScale mapUnitScale() const override;
1101 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1102 double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
1103
1108 virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) = 0;
1109
1118 virtual void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1119
1133 virtual void setWidth( double width ) { mWidth = width; }
1134
1144 virtual double width() const { return mWidth; }
1145
1156 virtual double width( const QgsRenderContext &context ) const;
1157
1167 double offset() const { return mOffset; }
1168
1178 void setOffset( double offset ) { mOffset = offset; }
1179
1186 void setOffsetUnit( Qgis::RenderUnit unit ) { mOffsetUnit = unit; }
1187
1194 Qgis::RenderUnit offsetUnit() const { return mOffsetUnit; }
1195
1202 void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
1203
1210 const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
1211
1212 // TODO QGIS 4.0 - setWidthUnit(), widthUnit(), setWidthUnitScale(), widthUnitScale()
1213 // only apply to simple line symbol layers and do not belong here.
1214
1220 void setWidthUnit( Qgis::RenderUnit unit ) { mWidthUnit = unit; }
1221
1226 Qgis::RenderUnit widthUnit() const { return mWidthUnit; }
1227
1228 void setWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWidthMapUnitScale = scale; }
1229 const QgsMapUnitScale &widthMapUnitScale() const { return mWidthMapUnitScale; }
1230
1241 RenderRingFilter ringFilter() const;
1242
1253 void setRingFilter( QgsLineSymbolLayer::RenderRingFilter filter );
1254
1255 protected:
1256 QgsLineSymbolLayer( bool locked = false );
1257
1258 double mWidth = 0;
1261 double mOffset = 0;
1264
1265 RenderRingFilter mRingFilter = AllRings;
1266
1267 private:
1268#ifdef SIP_RUN
1269 QgsLineSymbolLayer( const QgsLineSymbolLayer &other );
1270#endif
1271};
1272
1278class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
1279{
1280 public:
1281
1282 QgsFillSymbolLayer( const QgsFillSymbolLayer &other ) = delete;
1284
1290 virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) = 0;
1291
1292 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1293
1301 void setAngle( double angle ) { mAngle = angle; }
1302
1310 double angle() const { return mAngle; }
1311
1322 virtual QImage toTiledPatternImage( ) const;
1323
1324 protected:
1325 QgsFillSymbolLayer( bool locked = false );
1327 void _renderPolygon( QPainter *p, const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1328
1329 double mAngle = 0.0;
1330
1331 private:
1332#ifdef SIP_RUN
1333 QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
1334#endif
1335};
1336
1337class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
1338
1339#endif
ScaleMethod
Scale methods.
Definition qgis.h:588
@ ScaleDiameter
Calculate scale by the diameter.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
Definition qgis.h:800
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
Definition qgis.h:823
RenderUnit
Rendering size units.
Definition qgis.h:4734
@ Millimeters
Millimeters.
@ Unknown
Mixed or unknown units.
SymbolType
Symbol types.
Definition qgis.h:574
@ 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
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 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
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:231
#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