15#ifndef QGSSYMBOLLAYER_H
16#define QGSSYMBOLLAYER_H
18#define DEG2RAD(x) ((x)*M_PI/180)
19#define DEFAULT_SCALE_METHOD Qgis::ScaleMethod::ScaleDiameter
31#include <QDomDocument>
33#include <QPainterPath>
61 switch ( sipCpp->type() )
64 if ( sipCpp->layerType() ==
"EllipseMarker" )
65 sipType = sipType_QgsEllipseSymbolLayer;
66 else if ( sipCpp->layerType() ==
"FontMarker" )
67 sipType = sipType_QgsFontMarkerSymbolLayer;
68 else if ( sipCpp->layerType() ==
"SimpleMarker" )
69 sipType = sipType_QgsSimpleMarkerSymbolLayer;
70 else if ( sipCpp->layerType() ==
"FilledMarker" )
71 sipType = sipType_QgsFilledMarkerSymbolLayer;
72 else if ( sipCpp->layerType() ==
"SvgMarker" )
73 sipType = sipType_QgsSvgMarkerSymbolLayer;
74 else if ( sipCpp->layerType() ==
"RasterMarker" )
75 sipType = sipType_QgsRasterMarkerSymbolLayer;
76 else if ( sipCpp->layerType() ==
"AnimatedMarker" )
77 sipType = sipType_QgsAnimatedMarkerSymbolLayer;
78 else if ( sipCpp->layerType() ==
"VectorField" )
79 sipType = sipType_QgsVectorFieldSymbolLayer;
80 else if ( sipCpp->layerType() ==
"MaskMarker" )
81 sipType = sipType_QgsMaskMarkerSymbolLayer;
83 sipType = sipType_QgsMarkerSymbolLayer;
87 if ( sipCpp->layerType() ==
"MarkerLine" )
88 sipType = sipType_QgsMarkerLineSymbolLayer;
89 else if ( sipCpp->layerType() ==
"SimpleLine" )
90 sipType = sipType_QgsSimpleLineSymbolLayer;
91 else if ( sipCpp->layerType() ==
"HashLine" )
92 sipType = sipType_QgsHashedLineSymbolLayer;
93 else if ( sipCpp->layerType() ==
"ArrowLine" )
94 sipType = sipType_QgsArrowSymbolLayer;
95 else if ( sipCpp->layerType() ==
"InterpolatedLine" )
96 sipType = sipType_QgsInterpolatedLineSymbolLayer;
97 else if ( sipCpp->layerType() ==
"RasterLine" )
98 sipType = sipType_QgsRasterLineSymbolLayer;
99 else if ( sipCpp->layerType() ==
"Lineburst" )
100 sipType = sipType_QgsLineburstSymbolLayer;
101 else if ( sipCpp->layerType() ==
"LinearReferencing" )
102 sipType = sipType_QgsLinearReferencingSymbolLayer;
103 else if ( sipCpp->layerType() ==
"FilledLine" )
104 sipType = sipType_QgsFilledLineSymbolLayer;
106 sipType = sipType_QgsLineSymbolLayer;
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;
129 sipType = sipType_QgsFillSymbolLayer;
133 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
282 virtual QColor color()
const;
295 virtual void setColor(
const QColor &color );
307 virtual void setStrokeColor(
const QColor &color );
320 virtual QColor strokeColor()
const;
332 virtual void setFillColor(
const QColor &color );
345 virtual QColor fillColor()
const;
426 virtual void toSld( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const
427 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral(
"SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
429 virtual QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor );
return QString(); }
451 virtual bool isCompatibleWithSymbol(
QgsSymbol *symbol )
const;
461 virtual bool canCauseArtifactsBetweenAdjacentTiles()
const;
513 virtual bool usesMapUnits()
const;
524 void setRenderingPass(
int renderingPass );
532 int renderingPass()
const;
538 virtual QSet<QString> usedAttributes(
const QgsRenderContext &context )
const;
546 virtual void setDataDefinedProperty( Property key,
const QgsProperty &property );
549 virtual bool writeDxf(
QgsDxfExport &e,
double mmMapUnitScaleFactor,
const QString &layerName,
QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) )
const;
567 virtual QVector<qreal> dxfCustomDashPattern(
Qgis::RenderUnit &unit )
const;
570 virtual Qt::PenStyle dxfPenStyle()
const;
576 virtual Qt::BrushStyle dxfBrushStyle()
const;
624 virtual bool hasDataDefinedProperties()
const;
631 virtual QList<QgsSymbolLayerReference> masks()
const;
647 void setId(
const QString &
id );
671 bool installMasks(
QgsRenderContext &context,
bool recursive,
const QRectF &rect = QRectF() );
686 bool mEnabled =
true;
691 bool mLocked =
false;
693 int mRenderingPass = 0;
705 static const bool SELECTION_IS_OPAQUE =
true;
707 static const bool SELECT_FILL_BORDER =
false;
709 static const bool SELECT_FILL_STYLE =
false;
714 void restoreOldDataDefinedProperties(
const QVariantMap &stringMap );
720 void copyDataDefinedProperties(
QgsSymbolLayer *destLayer )
const;
746 static void initPropertyDefinitions();
812 double angle()
const {
return mAngle; }
831 virtual void setSize(
double size ) { mSize = size; }
839 double size()
const {
return mSize; }
905 QPointF
offset()
const {
return mOffset; }
975 void toSld( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
983 virtual void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const
984 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral(
"QgsMarkerSymbolLayer %1 not implemented yet" ).arg( layerType() ) ) ); }
1029 void markerOffset(
QgsSymbolRenderContext &context,
double width,
double height,
double &offsetX,
double &offsetY )
const SIP_PYNAME( markerOffsetWithWidthAndHeight );
1034 double &offsetX,
double &offsetY,
1043 static QPointF _rotatedOffset( QPointF offset,
double angle );
1048 double mLineAngle = 0;
1119 virtual void renderPolygonStroke(
const QPolygonF &points,
const QVector<QPolygonF> *rings,
QgsSymbolRenderContext &context );
1134 virtual void setWidth(
double width ) { mWidth = width; }
1145 virtual double width()
const {
return mWidth; }
1242 RenderRingFilter ringFilter()
const;
1323 virtual QImage toTiledPatternImage( )
const;
1328 void _renderPolygon( QPainter *p,
const QPolygonF &points,
const QVector<QPolygonF> *rings,
QgsSymbolRenderContext &context );
1330 double mAngle = 0.0;
ScaleMethod
Scale methods.
@ ScaleDiameter
Calculate scale by the diameter.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
QFlags< SymbolLayerUserFlag > SymbolLayerUserFlags
Symbol layer user flags.
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
@ Unknown
Mixed or unknown units.
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...
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 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.
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
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.
#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.
QMap< QString, QString > QgsStringMap