15#ifndef QGSSYMBOLLAYER_H
16#define QGSSYMBOLLAYER_H
18#define DEG2RAD( x ) ( ( x ) * M_PI / 180 )
19#define DEFAULT_SCALE_METHOD Qgis::ScaleMethod::ScaleDiameter
28#include <QDomDocument>
32#include <QPainterPath>
64 switch ( sipCpp->type() )
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;
86 sipType = sipType_QgsMarkerSymbolLayer;
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;
109 sipType = sipType_QgsLineSymbolLayer;
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;
132 sipType = sipType_QgsFillSymbolLayer;
136 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
287 virtual QColor color()
const;
300 virtual void setColor(
const QColor &color );
312 virtual void setStrokeColor(
const QColor &color );
325 virtual QColor strokeColor()
const;
337 virtual void setFillColor(
const QColor &color );
350 virtual QColor fillColor()
const;
435 Q_DECL_DEPRECATED
virtual void toSld( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const SIP_DEPRECATED;
446 virtual QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const
448 Q_UNUSED( mmScaleFactor )
449 Q_UNUSED( mapUnitScaleFactor );
473 virtual bool isCompatibleWithSymbol(
QgsSymbol *symbol )
const;
488 virtual bool rendersIdenticallyTo(
const QgsSymbolLayer *other )
const;
498 virtual bool canCauseArtifactsBetweenAdjacentTiles()
const;
554 virtual bool usesMapUnits()
const;
565 void setRenderingPass(
int renderingPass );
573 int renderingPass()
const;
579 virtual QSet<QString> usedAttributes(
const QgsRenderContext &context )
const;
587 virtual void setDataDefinedProperty( Property key,
const QgsProperty &property );
590 virtual bool writeDxf(
QgsDxfExport &e,
double mmMapUnitScaleFactor,
const QString &layerName,
QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) )
const;
635 virtual QVector<qreal> dxfCustomDashPattern(
Qgis::RenderUnit &unit )
const;
638 virtual Qt::PenStyle dxfPenStyle()
const;
644 virtual Qt::BrushStyle dxfBrushStyle()
const;
692 virtual bool hasDataDefinedProperties()
const;
699 virtual QList<QgsSymbolLayerReference> masks()
const;
711 QString selectiveMaskingSourceSetId()
const;
723 void setSelectiveMaskingSourceSetId(
const QString &
id );
739 void setId(
const QString &
id );
854 static void initPropertyDefinitions();
1068 bool toSld( QDomDocument &doc, QDomElement &element,
QgsSldExportContext &context )
const override;
1077 Q_DECL_DEPRECATED
virtual void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const SIP_DEPRECATED;
1086 virtual bool writeSldMarker( QDomDocument &doc, QDomElement &element,
QgsSldExportContext &context )
const;
1363 RenderRingFilter ringFilter()
const;
1443 virtual QImage toTiledPatternImage()
const;
1448 void _renderPolygon( QPainter *p,
const QPolygonF &points,
const QVector<QPolygonF> *rings,
QgsSymbolRenderContext &context );
ScaleMethod
Scale methods.
@ ScaleDiameter
Calculate scale by the diameter.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
VerticalAnchorPoint
Marker symbol vertical anchor points.
@ Center
Align to vertical center of symbol.
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
@ Unknown
Mixed or unknown units.
HorizontalAnchorPoint
Marker symbol horizontal anchor points.
@ Center
Align to horizontal center of symbol.
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...
Container of fields for a vector layer.
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.
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 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.
std::unique_ptr< QgsScopedQPainterState > mStateBeforeInstallingMaskClipPaths
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the symbol layer's property collection, used for data defined overrides.
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
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.
QMap< QString, QString > QgsStringMap
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.