QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 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 };
222 // *INDENT-ON*
223
227 static const QgsPropertiesDefinition &propertyDefinitions();
228
230
231 QgsSymbolLayer &operator=( const QgsSymbolLayer &other ) = delete;
232
238 virtual Qgis::SymbolLayerFlags flags() const;
239
244 bool enabled() const { return mEnabled; }
245
252 void setEnabled( bool enabled ) { mEnabled = enabled; }
253
260 Qgis::SymbolLayerUserFlags userFlags() const;
261
268 void setUserFlags( Qgis::SymbolLayerUserFlags flags );
269
284 virtual QColor color() const;
285
297 virtual void setColor( const QColor &color );
298
309 virtual void setStrokeColor( const QColor &color );
310
322 virtual QColor strokeColor() const;
323
334 virtual void setFillColor( const QColor &color );
335
347 virtual QColor fillColor() const;
348
353 virtual QString layerType() const = 0;
354
367 virtual void startRender( QgsSymbolRenderContext &context ) = 0;
368
380 virtual void stopRender( QgsSymbolRenderContext &context ) = 0;
381
400 virtual void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
401
420 virtual void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context );
421
425 virtual QgsSymbolLayer *clone() const = 0 SIP_FACTORY;
426
428 virtual void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
429 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
430
431 virtual QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor ); return QString(); }
432
438 virtual QVariantMap properties() const = 0;
439
440 virtual void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) = 0;
441
445 virtual QgsSymbol *subSymbol();
446
448 virtual bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER );
449
450 Qgis::SymbolType type() const { return mType; }
451
453 virtual bool isCompatibleWithSymbol( QgsSymbol *symbol ) const;
454
463 virtual bool canCauseArtifactsBetweenAdjacentTiles() const;
464
472 void setLocked( bool locked ) { mLocked = locked; }
473
479 bool isLocked() const { return mLocked; }
480
488 virtual double estimateMaxBleed( const QgsRenderContext &context ) const { Q_UNUSED( context ) return 0; }
489
498 virtual void setOutputUnit( Qgis::RenderUnit unit ) { Q_UNUSED( unit ) }
499
509
515 virtual bool usesMapUnits() const;
516
517 virtual void setMapUnitScale( const QgsMapUnitScale &scale ) { Q_UNUSED( scale ) }
518 virtual QgsMapUnitScale mapUnitScale() const { return QgsMapUnitScale(); }
519
526 void setRenderingPass( int renderingPass );
527
534 int renderingPass() const;
535
540 virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const;
541
548 virtual void setDataDefinedProperty( Property key, const QgsProperty &property );
549
551 virtual bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const;
552
554 virtual double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
555
557 virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
558
560 virtual double dxfOffset( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const;
561
563 virtual QColor dxfColor( QgsSymbolRenderContext &context ) const;
564
566 virtual double dxfAngle( QgsSymbolRenderContext &context ) const;
567
569 virtual QVector<qreal> dxfCustomDashPattern( Qgis::RenderUnit &unit ) const;
570
572 virtual Qt::PenStyle dxfPenStyle() const;
573
575 virtual QColor dxfBrushColor( QgsSymbolRenderContext &context ) const;
576
578 virtual Qt::BrushStyle dxfBrushStyle() const;
579
585 QgsPaintEffect *paintEffect() const;
586
592 void setPaintEffect( QgsPaintEffect *effect SIP_TRANSFER );
593
599 virtual void prepareExpressions( const QgsSymbolRenderContext &context );
600
606 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
607
612 const QgsPropertyCollection &dataDefinedProperties() const { return mDataDefinedProperties; } SIP_SKIP
613
619 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
620
626 virtual bool hasDataDefinedProperties() const;
627
633 virtual QList<QgsSymbolLayerReference> masks() const;
634
642 virtual void prepareMasks( const QgsSymbolRenderContext &context );
643
649 void setId( const QString &id );
650
656 QString id() const;
657
673 bool installMasks( QgsRenderContext &context, bool recursive, const QRectF &rect = QRectF() );
674
675 protected:
676 QgsSymbolLayer( const QgsSymbolLayer &other ) SIP_SKIP;
677
683 QgsSymbolLayer( Qgis::SymbolType type, bool locked = false );
684
686
688 bool mEnabled = true;
689
692
693 bool mLocked = false;
694 QColor mColor;
695 int mRenderingPass = 0;
696 QString mId;
698
699 std::unique_ptr< QgsPaintEffect > mPaintEffect;
701
702 // clip path to be used during rendering
703 QPainterPath mClipPath;
704
705 // Configuration of selected symbology implementation
707 static const bool SELECTION_IS_OPAQUE = true;
709 static const bool SELECT_FILL_BORDER = false;
711 static const bool SELECT_FILL_STYLE = false;
712
716 void restoreOldDataDefinedProperties( const QVariantMap &stringMap );
717
722 void copyDataDefinedProperties( QgsSymbolLayer *destLayer ) const;
723
728 void copyPaintEffect( QgsSymbolLayer *destLayer ) const;
729
737 void removeMasks( QgsRenderContext &context, bool recursive );
738
745 bool shouldRenderUsingSelectionColor( const QgsSymbolRenderContext &context ) const;
746
747 private:
748 static void initPropertyDefinitions();
749
751 static QgsPropertiesDefinition sPropertyDefinitions;
752
753#ifdef SIP_RUN
754 QgsSymbolLayer( const QgsSymbolLayer &other );
755#endif
756
757};
758
760
766class CORE_EXPORT QgsMarkerSymbolLayer : public QgsSymbolLayer
767{
768 public:
769
777
785
787
788 void startRender( QgsSymbolRenderContext &context ) override;
789
790 void stopRender( QgsSymbolRenderContext &context ) override;
791
798 virtual void renderPoint( QPointF point, QgsSymbolRenderContext &context ) = 0;
799
800 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
801
808 void setAngle( double angle ) { mAngle = angle; }
809
814 double angle() const { return mAngle; }
815
824 void setLineAngle( double lineAngle ) { mLineAngle = lineAngle; }
825
833 virtual void setSize( double size ) { mSize = size; }
834
841 double size() const { return mSize; }
842
850 void setSizeUnit( Qgis::RenderUnit unit ) { mSizeUnit = unit; }
851
858 Qgis::RenderUnit sizeUnit() const { return mSizeUnit; }
859
867 void setSizeMapUnitScale( const QgsMapUnitScale &scale ) { mSizeMapUnitScale = scale; }
868
875 const QgsMapUnitScale &sizeMapUnitScale() const { return mSizeMapUnitScale; }
876
882 void setScaleMethod( Qgis::ScaleMethod scaleMethod ) { mScaleMethod = scaleMethod; }
883
888 Qgis::ScaleMethod scaleMethod() const { return mScaleMethod; }
889
898 void setOffset( QPointF offset ) { mOffset = offset; }
899
907 QPointF offset() const { return mOffset; }
908
916 void setOffsetUnit( Qgis::RenderUnit unit ) { mOffsetUnit = unit; }
917
924 Qgis::RenderUnit offsetUnit() const { return mOffsetUnit; }
925
933 void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
934
941 const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
942
950 void setHorizontalAnchorPoint( HorizontalAnchorPoint h ) { mHorizontalAnchorPoint = h; }
951
958 HorizontalAnchorPoint horizontalAnchorPoint() const { return mHorizontalAnchorPoint; }
959
967 void setVerticalAnchorPoint( VerticalAnchorPoint v ) { mVerticalAnchorPoint = v; }
968
975 VerticalAnchorPoint verticalAnchorPoint() const { return mVerticalAnchorPoint; }
976
977 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
978
985 virtual void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
986 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral( "QgsMarkerSymbolLayer %1 not implemented yet" ).arg( layerType() ) ) ); }
987
988 void setOutputUnit( Qgis::RenderUnit unit ) override;
989 Qgis::RenderUnit outputUnit() const override;
990 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
991 QgsMapUnitScale mapUnitScale() const override;
992 virtual double dxfSize( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
993 virtual double dxfAngle( QgsSymbolRenderContext &context ) const override;
994
1000 virtual QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) = 0;
1001
1002 protected:
1003
1005
1010 QgsMarkerSymbolLayer( bool locked = false );
1011
1019 void markerOffset( QgsSymbolRenderContext &context, double &offsetX, double &offsetY ) const;
1020
1031 void markerOffset( QgsSymbolRenderContext &context, double width, double height, double &offsetX, double &offsetY ) const SIP_PYNAME( markerOffsetWithWidthAndHeight );
1032
1034 void markerOffset( QgsSymbolRenderContext &context, double width, double height,
1035 Qgis::RenderUnit widthUnit, Qgis::RenderUnit heightUnit,
1036 double &offsetX, double &offsetY,
1037 const QgsMapUnitScale &widthMapUnitScale, const QgsMapUnitScale &heightMapUnitScale ) const SIP_PYNAME( markerOffset2 );
1038
1045 static QPointF _rotatedOffset( QPointF offset, double angle );
1046
1048 double mAngle = 0;
1050 double mLineAngle = 0;
1052 double mSize = 2.0;
1058 QPointF mOffset;
1066 HorizontalAnchorPoint mHorizontalAnchorPoint = HCenter;
1068 VerticalAnchorPoint mVerticalAnchorPoint = VCenter;
1069
1070 private:
1071 static QgsMarkerSymbolLayer::HorizontalAnchorPoint decodeHorizontalAnchorPoint( const QString &str );
1072 static QgsMarkerSymbolLayer::VerticalAnchorPoint decodeVerticalAnchorPoint( const QString &str );
1073
1074#ifdef SIP_RUN
1076#endif
1077};
1078
1085class CORE_EXPORT QgsLineSymbolLayer : public QgsSymbolLayer
1086{
1087 public:
1088
1096
1097 QgsLineSymbolLayer( const QgsLineSymbolLayer &other ) = delete;
1099
1100 void setOutputUnit( Qgis::RenderUnit unit ) override;
1101 Qgis::RenderUnit outputUnit() const override;
1102 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
1103 QgsMapUnitScale mapUnitScale() const override;
1104 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1105 double dxfWidth( const QgsDxfExport &e, QgsSymbolRenderContext &context ) const override;
1106
1111 virtual void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) = 0;
1112
1121 virtual void renderPolygonStroke( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1122
1136 virtual void setWidth( double width ) { mWidth = width; }
1137
1147 virtual double width() const { return mWidth; }
1148
1159 virtual double width( const QgsRenderContext &context ) const;
1160
1170 double offset() const { return mOffset; }
1171
1181 void setOffset( double offset ) { mOffset = offset; }
1182
1189 void setOffsetUnit( Qgis::RenderUnit unit ) { mOffsetUnit = unit; }
1190
1197 Qgis::RenderUnit offsetUnit() const { return mOffsetUnit; }
1198
1205 void setOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetMapUnitScale = scale; }
1206
1213 const QgsMapUnitScale &offsetMapUnitScale() const { return mOffsetMapUnitScale; }
1214
1215 // TODO QGIS 4.0 - setWidthUnit(), widthUnit(), setWidthUnitScale(), widthUnitScale()
1216 // only apply to simple line symbol layers and do not belong here.
1217
1223 void setWidthUnit( Qgis::RenderUnit unit ) { mWidthUnit = unit; }
1224
1229 Qgis::RenderUnit widthUnit() const { return mWidthUnit; }
1230
1231 void setWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWidthMapUnitScale = scale; }
1232 const QgsMapUnitScale &widthMapUnitScale() const { return mWidthMapUnitScale; }
1233
1244 RenderRingFilter ringFilter() const;
1245
1256 void setRingFilter( QgsLineSymbolLayer::RenderRingFilter filter );
1257
1258 protected:
1259 QgsLineSymbolLayer( bool locked = false );
1260
1261 double mWidth = 0;
1264 double mOffset = 0;
1267
1268 RenderRingFilter mRingFilter = AllRings;
1269
1270 private:
1271#ifdef SIP_RUN
1272 QgsLineSymbolLayer( const QgsLineSymbolLayer &other );
1273#endif
1274};
1275
1281class CORE_EXPORT QgsFillSymbolLayer : public QgsSymbolLayer
1282{
1283 public:
1284
1285 QgsFillSymbolLayer( const QgsFillSymbolLayer &other ) = delete;
1287
1293 virtual void renderPolygon( const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context ) = 0;
1294
1295 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
1296
1304 void setAngle( double angle ) { mAngle = angle; }
1305
1313 double angle() const { return mAngle; }
1314
1325 virtual QImage toTiledPatternImage( ) const;
1326
1327 protected:
1328 QgsFillSymbolLayer( bool locked = false );
1330 void _renderPolygon( QPainter *p, const QPolygonF &points, const QVector<QPolygonF> *rings, QgsSymbolRenderContext &context );
1331
1332 double mAngle = 0.0;
1333
1334 private:
1335#ifdef SIP_RUN
1336 QgsFillSymbolLayer( const QgsFillSymbolLayer &other );
1337#endif
1338};
1339
1340class QgsSymbolLayerWidget; // why does SIP fail, when this isn't here
1341
1342#endif
ScaleMethod
Scale methods.
Definition qgis.h:588
@ ScaleDiameter
Calculate scale by the diameter.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
Definition qgis.h:821
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
Definition qgis.h:844
RenderUnit
Rendering size units.
Definition qgis.h:4847
@ 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.
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.
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:39
#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