15 #ifndef QGSSYMBOLLAYER_H 16 #define QGSSYMBOLLAYER_H 18 #define DEG2RAD(x) ((x)*M_PI/180) 19 #define DEFAULT_SCALE_METHOD QgsSymbol::ScaleDiameter 21 #include "qgis_core.h" 27 #include <QDomDocument> 28 #include <QDomElement> 60 switch ( sipCpp->type() )
63 if ( sipCpp->layerType() ==
"EllipseMarker" )
64 sipType = sipType_QgsEllipseSymbolLayer;
65 else if ( sipCpp->layerType() ==
"FontMarker" )
66 sipType = sipType_QgsFontMarkerSymbolLayer;
67 else if ( sipCpp->layerType() ==
"SimpleMarker" )
68 sipType = sipType_QgsSimpleMarkerSymbolLayer;
69 else if ( sipCpp->layerType() ==
"FilledMarker" )
70 sipType = sipType_QgsFilledMarkerSymbolLayer;
71 else if ( sipCpp->layerType() ==
"SvgMarker" )
72 sipType = sipType_QgsSvgMarkerSymbolLayer;
73 else if ( sipCpp->layerType() ==
"RasterMarker" )
74 sipType = sipType_QgsRasterMarkerSymbolLayer;
75 else if ( sipCpp->layerType() ==
"VectorField" )
76 sipType = sipType_QgsVectorFieldSymbolLayer;
77 else if ( sipCpp->layerType() ==
"MaskMarker" )
78 sipType = sipType_QgsMaskMarkerSymbolLayer;
80 sipType = sipType_QgsMarkerSymbolLayer;
84 if ( sipCpp->layerType() ==
"MarkerLine" )
85 sipType = sipType_QgsMarkerLineSymbolLayer;
86 else if ( sipCpp->layerType() ==
"SimpleLine" )
87 sipType = sipType_QgsSimpleLineSymbolLayer;
88 else if ( sipCpp->layerType() ==
"ArrowLine" )
89 sipType = sipType_QgsArrowSymbolLayer;
91 sipType = sipType_QgsLineSymbolLayer;
95 if ( sipCpp->layerType() ==
"SimpleFill" )
96 sipType = sipType_QgsSimpleFillSymbolLayer;
97 else if ( sipCpp->layerType() ==
"LinePatternFill" )
98 sipType = sipType_QgsLinePatternFillSymbolLayer;
99 else if ( sipCpp->layerType() ==
"PointPatternFill" )
100 sipType = sipType_QgsPointPatternFillSymbolLayer;
101 else if ( sipCpp->layerType() ==
"SVGFill" )
102 sipType = sipType_QgsSVGFillSymbolLayer;
103 else if ( sipCpp->layerType() ==
"RasterFill" )
104 sipType = sipType_QgsRasterFillSymbolLayer;
105 else if ( sipCpp->layerType() ==
"CentroidFill" )
106 sipType = sipType_QgsCentroidFillSymbolLayer;
107 else if ( sipCpp->layerType() ==
"GradientFill" )
108 sipType = sipType_QgsGradientFillSymbolLayer;
109 else if ( sipCpp->layerType() ==
"ShapeburstFill" )
110 sipType = sipType_QgsShapeburstFillSymbolLayer;
111 else if ( sipCpp->layerType() ==
"RandomMarkerFill" )
112 sipType = sipType_QgsRandomMarkerFillSymbolLayer;
114 sipType = sipType_QgsFillSymbolLayer;
118 sipType = sipType_QgsGeometryGeneratorSymbolLayer;
223 virtual QColor
color()
const {
return mColor; }
228 virtual void setColor(
const QColor &color ) { mColor = color; }
254 virtual QString layerType()
const = 0;
329 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral(
"SymbolLayerV2 %1 not implemented yet" ).arg( layerType() ) ) ); }
331 virtual QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const { Q_UNUSED( mmScaleFactor ) Q_UNUSED( mapUnitScaleFactor );
return QString(); }
353 virtual bool isCompatibleWithSymbol(
QgsSymbol *symbol )
const;
395 void setRenderingPass(
int renderingPass );
403 int renderingPass()
const;
409 virtual QSet<QString> usedAttributes(
const QgsRenderContext &context )
const;
421 virtual bool writeDxf(
QgsDxfExport &e,
double mmMapUnitScaleFactor,
const QString &layerName,
QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) )
const;
439 virtual Qt::PenStyle dxfPenStyle()
const;
445 virtual Qt::BrushStyle dxfBrushStyle()
const;
499 virtual bool hasDataDefinedProperties()
const;
515 bool mEnabled =
true;
517 bool mLocked =
false;
519 int mRenderingPass = 0;
528 static const bool SELECTION_IS_OPAQUE =
true;
530 static const bool SELECT_FILL_BORDER =
false;
532 static const bool SELECT_FILL_STYLE =
false;
538 void restoreOldDataDefinedProperties(
const QgsStringMap &stringMap );
544 void copyDataDefinedProperties(
QgsSymbolLayer *destLayer )
const;
554 static void initPropertyDefinitions();
624 double angle()
const {
return mAngle; }
644 virtual void setSize(
double size ) { mSize = size; }
652 double size()
const {
return mSize; }
718 QPointF
offset()
const {
return mOffset; }
788 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
797 { Q_UNUSED( props ) element.appendChild( doc.createComment( QStringLiteral(
"QgsMarkerSymbolLayer %1 not implemented yet" ).arg(
layerType() ) ) ); }
839 void markerOffset(
QgsSymbolRenderContext &context,
double width,
double height,
double &offsetX,
double &offsetY )
const SIP_PYNAME( markerOffsetWithWidthAndHeight );
844 double &offsetX,
double &offsetY,
853 static QPointF _rotatedOffset( QPointF offset,
double angle );
858 double mLineAngle = 0;
930 virtual void renderPolygonStroke(
const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context );
945 virtual void setWidth(
double width ) { mWidth = width; }
956 virtual double width()
const {
return mWidth; }
979 double offset()
const {
return mOffset; }
1099 virtual void renderPolygon(
const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context ) = 0;
1109 void _renderPolygon( QPainter *p,
const QPolygonF &points,
const QList<QPolygonF> *rings,
QgsSymbolRenderContext &context );
1111 double mAngle = 0.0;
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
Class for parsing and evaluation of expressions (formerly called "search strings").
Gradient reference point 1 is centroid.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
void setLocked(bool locked)
Gradient reference point 1 x.
Calculate scale by the diameter.
Abstract base class for all rendered symbols.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the line's offset.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
Align to right side of symbol.
Render both exterior and interior rings.
void setAngle(double angle)
virtual QColor strokeColor() const
Gets stroke color.
Base class for visual effects which can be applied to QPicture drawings.
Whether markers should be clipped to polygon boundaries.
Container of fields for a vector layer.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
QPointF mOffset
Marker offset.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line's offset.
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
Align to horizontal center of symbol.
QMap< QString, QString > QgsStringMap
Shapeburst use whole shape.
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)
virtual double width() const
Returns the estimated width for the line symbol layer.
Name, eg shape name for simple markers.
void setWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line's width.
Gradient reference point 2 y.
virtual void setColor(const QColor &color)
The fill color.
SymbolType
Type of the symbol.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
virtual QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
Align to bottom of symbol.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
virtual void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line's width.
Gradient coordinate mode.
double size() const
Returns the symbol size.
Render the interior rings only.
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides...
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
QgsMapUnitScale mOffsetMapUnitScale
virtual QColor color() const
The fill color.
Filename, eg for svg files.
Align to left side of symbol.
virtual void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size)=0
Shapeburst fill from edge distance.
QgsSymbol::SymbolType type() const
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Character, eg for font marker symbol layers.
double offset() const
Returns the line's offset.
QMap< QString, QString > QgsStringMap
void setEnabled(bool enabled)
Sets whether symbol layer is enabled and should be drawn.
A store for object properties.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the symbol layer's property collection, used for data defined overrides...
QgsMapUnitScale mWidthMapUnitScale
RenderRingFilter
Options for filtering rings when the line symbol layer is being used to render a polygon's rings...
std::unique_ptr< QgsPaintEffect > mPaintEffect
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
HorizontalAnchorPoint
Symbol horizontal anchor points.
virtual void setStrokeColor(const QColor &color)
Set stroke color.
Gradient reference point 1 y.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
VerticalAnchorPoint
Symbol vertical anchor points.
QgsSymbol::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
Line angle, or angle of hash lines for hash line symbols.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
virtual QgsMapUnitScale mapUnitScale() const
Stroke style (eg solid, dashed)
Preserve aspect ratio between width and height.
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
virtual void setFillColor(const QColor &color)
Set fill color.
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
Struct for storing maximum and minimum scales for measurements in map units.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Distance between lines, or length of lines for hash line symbols.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's offset.
virtual void setSize(double size)
Sets the symbol size.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Align to vertical center of symbol.
QgsSymbolLayer & operator=(const QgsSymbolLayer &other)=delete
QgsSymbolLayer cannot be copied.
Secondary color (eg for gradient fills)
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
void setAngle(double angle)
Sets the rotation angle for the marker.
const QgsMapUnitScale & widthMapUnitScale() const
Length to average symbol angles over.
Render the exterior ring only.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the line's offset.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
Fill style (eg solid, dots)
virtual QColor fillColor() const
Gets fill color.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
Whether symbol layer is enabled.
Gradient reference point 2 is centroid.
QgsSymbol::SymbolType mType
Gradient reference point 2 x.
QgsPropertyCollection mDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the symbol layer's property collection, used for data defined overrides.
Property
Data definable properties.
RenderUnit
Rendering size units.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
void setOffset(double offset)
Sets the line's offset.
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
Horizontal distance between points.
virtual QString layerType() const =0
Returns a string that represents this layer type.
Vertical distance between points.