QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
15 #ifndef QGSSYMBOLLAYER_H
16 #define QGSSYMBOLLAYER_H
18 #define DEG2RAD(x) ((x)*M_PI/180)
19 #define DEFAULT_SCALE_METHOD Qgis::ScaleMethod::ScaleDiameter
21 #include "qgis_core.h"
31 #include <QDomDocument>
32 #include <QDomElement>
33 #include <QPainterPath>
63 switch ( sipCpp->type() )
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;
85 sipType = sipType_QgsMarkerSymbolLayer;
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;
104 sipType = sipType_QgsLineSymbolLayer;
108 if ( sipCpp->layerType() ==
"SimpleFill" )
109 sipType = sipType_QgsSimpleFillSymbolLayer;
110 else if ( sipCpp->layerType() ==
"LinePatternFill" )
111 sipType = sipType_QgsLinePatternFillSymbolLayer;
112 else if ( sipCpp->layerType() ==
"PointPatternFill" )
113 sipType = sipType_QgsPointPatternFillSymbolLayer;
114 else if ( sipCpp->layerType() ==
"SVGFill" )
115 sipType = sipType_QgsSVGFillSymbolLayer;
116 else if ( sipCpp->layerType() ==
"RasterFill" )
117 sipType = sipType_QgsRasterFillSymbolLayer;
118 else if ( sipCpp->layerType() ==
"CentroidFill" )
119 sipType = sipType_QgsCentroidFillSymbolLayer;
120 else if ( sipCpp->layerType() ==
"GradientFill" )
121 sipType = sipType_QgsGradientFillSymbolLayer;
122 else if ( sipCpp->layerType() ==
"ShapeburstFill" )
123 sipType = sipType_QgsShapeburstFillSymbolLayer;
124 else if ( sipCpp->layerType() ==
"RandomMarkerFill" )
125 sipType = sipType_QgsRandomMarkerFillSymbolLayer;
127 sipType = sipType_QgsFillSymbolLayer;
131 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
235 virtual Qgis::SymbolLayerFlags flags()
const;
267 virtual QColor color()
const;
280 virtual void setColor(
const QColor &color );
293 virtual void setStrokeColor(
const QColor &color );
307 virtual QColor strokeColor()
const;
320 virtual void setFillColor(
const QColor &color );
334 virtual QColor fillColor()
const;
340 virtual QString layerType()
const = 0;
415 virtual void toSld( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const
416 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral(
"SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
418 virtual QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor );
return QString(); }
425 virtual QVariantMap properties()
const = 0;
440 virtual bool isCompatibleWithSymbol(
QgsSymbol *symbol )
const;
450 virtual bool canCauseArtifactsBetweenAdjacentTiles()
const;
502 virtual bool usesMapUnits()
const;
513 void setRenderingPass(
int renderingPass );
521 int renderingPass()
const;
527 virtual QSet<QString> usedAttributes(
const QgsRenderContext &context )
const;
536 virtual void setDataDefinedProperty( Property key,
const QgsProperty &property );
539 virtual bool writeDxf(
QgsDxfExport &e,
double mmMapUnitScaleFactor,
const QString &layerName,
QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) )
const;
557 virtual Qt::PenStyle dxfPenStyle()
const;
563 virtual Qt::BrushStyle dxfBrushStyle()
const;
617 virtual bool hasDataDefinedProperties()
const;
624 virtual QList<QgsSymbolLayerReference> masks()
const;
645 bool mEnabled =
true;
647 bool mLocked =
false;
649 int mRenderingPass = 0;
661 static const bool SELECTION_IS_OPAQUE =
true;
663 static const bool SELECT_FILL_BORDER =
false;
665 static const bool SELECT_FILL_STYLE =
false;
671 void restoreOldDataDefinedProperties(
const QVariantMap &stringMap );
677 void copyDataDefinedProperties(
QgsSymbolLayer *destLayer )
const;
687 static void initPropertyDefinitions();
757 double angle()
const {
return mAngle; }
777 virtual void setSize(
double size ) { mSize = size; }
785 double size()
const {
return mSize; }
851 QPointF
offset()
const {
return mOffset; }
921 void toSld( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
929 virtual void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const
930 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral(
"QgsMarkerSymbolLayer %1 not implemented yet" ).arg(
layerType() ) ) ); }
972 void markerOffset(
QgsSymbolRenderContext &context,
double width,
double height,
double &offsetX,
double &offsetY )
const SIP_PYNAME( markerOffsetWithWidthAndHeight );
977 double &offsetX,
double &offsetY,
986 static QPointF _rotatedOffset( QPointF offset,
double angle );
991 double mLineAngle = 0;
1063 virtual void renderPolygonStroke(
const QPolygonF &points,
const QVector<QPolygonF> *rings,
QgsSymbolRenderContext &context );
1078 virtual void setWidth(
double width ) { mWidth = width; }
1089 virtual double width()
const {
return mWidth; }
1186 RenderRingFilter ringFilter()
const;
1237 virtual void renderPolygon(
const QPolygonF &points,
const QVector<QPolygonF> *rings,
QgsSymbolRenderContext &context ) = 0;
1247 void _renderPolygon( QPainter *p,
const QPolygonF &points,
const QVector<QPolygonF> *rings,
QgsSymbolRenderContext &context );
1249 double mAngle = 0.0;
@ PropertyDashPatternOffset
Dash pattern offset,.
@ PropertyArrowHeadType
Arrow head type.
void setEnabled(bool enabled)
Sets whether symbol layer is enabled and should be drawn.
virtual QgsMapUnitScale mapUnitScale() const
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
@ Right
Align to right side of symbol.
@ PropertyHorizontalAnchor
Horizontal anchor point.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
void setWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line's width.
@ PropertyBlurRadius
Shapeburst blur radius.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
VerticalAnchorPoint
Symbol vertical anchor points.
@ PropertyArrowHeadThickness
Arrow head thickness.
RenderRingFilter
Options for filtering rings when the line symbol layer is being used to render a polygon's rings.
@ PropertyLineDistance
Distance between lines, or length of lines for hash line symbols.
@ PropertyShapeburstUseWholeShape
Shapeburst use whole shape.
double size() const
Returns the symbol size.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
A store for object properties.
@ PropertyClipPoints
Whether markers should be clipped to polygon boundaries.
@ PropertyGradientReference2IsCentroid
Gradient reference point 2 is centroid.
RenderUnit
Rendering size units.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Exports QGIS layers to the DXF format.
const QgsMapUnitScale & widthMapUnitScale() const
@ PropertyAverageAngleLength
Length to average symbol angles over.
virtual double width() const
Returns the estimated width for the line symbol layer.
@ PropertyArrowStartWidth
Arrow tail start width.
@ PropertyFontFamily
Font family.
@ PropertyFillStyle
Fill style (eg solid, dots)
@ PropertyGradientReference2Y
Gradient reference point 2 y.
@ PropertyFillColor
Fill color.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
QgsMapUnitScale mWidthMapUnitScale
Type used to refer to a specific symbol layer in a symbol of a layer.
void setAngle(double angle)
Sets the rotation angle for the marker.
Container of fields for a vector layer.
std::unique_ptr< QgsPaintEffect > mPaintEffect
@ PropertyLineEndColorValue
End line color for interpolated line renderer (since QGIS 3.22)
@ PropertyGradientReference1IsCentroid
Gradient reference point 1 is centroid.
bool isLocked() const
Returns true if the symbol layer colors are locked and the layer will ignore any symbol-level color c...
@ PropertyDisplacementX
Horizontal displacement.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line's offset.
Contains information about the context of a rendering operation.
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
@ RenderMillimeters
Millimeters.
Abstract base class for marker symbol layers.
virtual void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size)=0
@ PropertyInterval
Line marker interval.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
@ PropertyCapStyle
Line cap style.
Abstract base class for all rendered symbols.
@ PropertyStrokeColor
Stroke color.
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
QMap< QString, QString > QgsStringMap
@ ScaleDiameter
Calculate scale by the diameter.
void setOffset(double offset)
Sets the line's offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the line's offset.
ScaleMethod
Scale methods.
@ PropertyFontStyle
Font style.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
@ PropertyArrowHeadLength
Arrow head length.
@ PropertyGradientSpread
Gradient spread mode.
HorizontalAnchorPoint
Symbol horizontal anchor points.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Writes the symbol layer definition as a SLD XML element.
@ PropertyLineStartWidthValue
Start line width for interpolated line renderer (since QGIS 3.22)
@ PropertyOffset
Symbol offset.
@ PropertyCharacter
Character, eg for font marker symbol layers.
@ PropertyMarkerClipping
Marker clipping mode (since QGIS 3.24)
@ PropertyGradientType
Gradient fill type.
@ PropertyArrowWidth
Arrow tail width.
@ Top
Align to top of symbol.
@ PropertyRandomSeed
Random number seed.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Saves the symbol layer as SLD.
@ HCenter
Align to horizontal center of symbol.
@ PropertyVerticalAnchor
Vertical anchor point.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's offset.
@ PropertyGradientReference1Y
Gradient reference point 1 y.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the symbol layer's property collection, used for data defined overrides.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
virtual void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
@ PropertyRandomOffsetX
Random offset X (since QGIS 3.24)
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
@ PropertyLineClipping
Line clipping mode (since QGIS 3.24)
@ Bottom
Align to bottom of symbol.
@ PropertyDensityArea
Density area.
@ PropertyTrimEnd
Trim distance from end of line (since QGIS 3.20)
@ Left
Align to left side of symbol.
@ PropertyName
Name, eg shape name for simple markers.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
Struct for storing maximum and minimum scales for measurements in map units.
@ PropertyPointCount
Point count.
QgsPropertyCollection mDataDefinedProperties
@ PropertyStrokeWidth
Stroke width.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
@ PropertyShapeburstIgnoreRings
Shapeburst ignore rings.
@ VCenter
Align to vertical center of symbol.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
@ InteriorRingsOnly
Render the interior rings only.
@ PropertyLayerEnabled
Whether symbol layer is enabled.
@ PropertyOffsetY
Vertical offset.
@ PropertyOffsetAlongLine
Offset along line.
virtual QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
QPointF mOffset
Marker offset.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
@ PropertyGradientReference2X
Gradient reference point 2 x.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the line's offset.
@ PropertyCoordinateMode
Gradient coordinate mode.
Qgis::SymbolType type() const
@ PropertyDistanceY
Vertical distance between points.
QgsMapUnitScale mOffsetMapUnitScale
@ PropertyDistanceX
Horizontal distance between points.
QgsSymbolLayer & operator=(const QgsSymbolLayer &other)=delete
QgsSymbolLayer cannot be copied.
@ PropertyFile
Filename, eg for svg files.
@ PropertyCustomDash
Custom dash pattern.
Base class for visual effects which can be applied to QPicture drawings.
@ PropertyAngle
Symbol angle.
void setLocked(bool locked)
Sets whether the layer's colors are locked.
@ PropertyArrowType
Arrow type.
@ RenderUnknownUnit
Mixed or unknown units.
@ AllRings
Render both exterior and interior rings.
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
@ PropertyShapeburstMaxDistance
Shapeburst fill from edge distance.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
Property
Data definable properties.
@ PropertyRandomOffsetY
Random offset Y (since QGIS 3.24)
virtual void setSize(double size)
Sets the symbol size.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
virtual QString layerType() const =0
Returns a string that represents this layer type.
@ PropertyGradientReference1X
Gradient reference point 1 x.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
@ PropertyOpacity
Opacity.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
double offset() const
Returns the line's offset.
@ PropertyTrimStart
Trim distance from start of line (since QGIS 3.20)
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
@ PropertyHeight
Symbol height.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line's width.
@ ExteriorRingOnly
Render the exterior ring only.
@ PropertyOffsetX
Horizontal offset.
Class for parsing and evaluation of expressions (formerly called "search strings")....
@ PropertyLineEndWidthValue
End line width for interpolated line renderer (since QGIS 3.22)
@ PropertyLineStartColorValue
Start line color for interpolated line renderer (since QGIS 3.22)
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
@ PropertyDisplacementY
Vertical displacement.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void setAngle(double angle)
@ PropertyPlacement
Line marker placement.
@ PropertyPreserveAspectRatio
Preserve aspect ratio between width and height.
@ PropertyLineAngle
Line angle, or angle of hash lines for hash line symbols.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
@ PropertySecondaryColor
Secondary color (eg for gradient fills)
@ PropertyJoinStyle
Line join style.
@ PropertyWidth
Symbol width.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.