16 #ifndef QGSFILLSYMBOLLAYER_H 17 #define QGSFILLSYMBOLLAYER_H 19 #include "qgis_core.h" 23 #define DEFAULT_SIMPLEFILL_COLOR QColor(0,0,255) 24 #define DEFAULT_SIMPLEFILL_STYLE Qt::SolidPattern 25 #define DEFAULT_SIMPLEFILL_BORDERCOLOR QColor( 35, 35, 35 ) 26 #define DEFAULT_SIMPLEFILL_BORDERSTYLE Qt::SolidLine 27 #define DEFAULT_SIMPLEFILL_BORDERWIDTH DEFAULT_LINE_WIDTH 28 #define DEFAULT_SIMPLEFILL_JOINSTYLE Qt::BevelJoin 69 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
71 QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const override;
73 Qt::BrushStyle
brushStyle()
const {
return mBrushStyle; }
83 void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
91 void setOffset( QPointF offset ) { mOffset = offset; }
161 void applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen );
201 const QColor &color2 = Qt::white,
216 QString layerType() const override;
222 void renderPolygon( const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context ) override;
256 QColor
color2()
const {
return mColor2; }
257 void setColor2(
const QColor &color2 ) { mColor2 = color2; }
285 QPointF
offset()
const {
return mOffset; }
312 bool mReferencePoint1IsCentroid =
false;
314 bool mReferencePoint2IsCentroid =
false;
326 void applyGradient(
const QgsSymbolRenderContext &context, QBrush &brush,
const QColor &color,
const QColor &color2,
329 QPointF referencePoint1, QPointF referencePoint2,
double angle );
332 QPointF rotateReferencePoint( QPointF refPoint,
double angle );
351 int blurRadius = 0,
bool useWholeShape =
true,
double maxDistance = 5 );
373 QString layerType() const override;
379 void renderPolygon( const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context ) override;
393 void setBlurRadius(
int blurRadius ) { mBlurRadius = blurRadius; }
512 void setColor2(
const QColor &color2 ) { mColor2 = color2; }
521 QColor
color2()
const {
return mColor2; }
556 QPointF
offset()
const {
return mOffset; }
591 bool mUseWholeShape =
true;
592 double mMaxDistance = 5.0;
599 bool mIgnoreRings =
false;
605 std::unique_ptr< QgsColorRamp > mGradientRamp;
608 void applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QColor &color, QColor &color2,
int &blurRadius,
bool &useWholeShape,
609 double &maxDistance,
bool &ignoreRings );
612 void distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d );
614 void distanceTransform2d(
double *im,
int width,
int height );
616 double *distanceTransform( QImage *im );
619 void dtArrayToQImage(
double *array, QImage *im,
QgsColorRamp *ramp,
double layerAlpha = 1,
bool useWholeShape =
true,
int maxPixelDistance = 0 );
684 double mNextAngle = 0.0;
687 double mStrokeWidth = 0.0;
739 QString layerType() const override;
740 void renderPolygon( const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context ) override;
756 void setImageFilePath(
const QString &imagePath );
786 void setOpacity(
double opacity );
811 QPointF
offset()
const {
return mOffset; }
857 void setWidth(
const double width ) { mWidth = width; }
867 double width()
const {
return mWidth; }
912 QString mImageFilePath;
914 double mOpacity = 1.0;
925 void applyPattern( QBrush &brush,
const QString &imageFilePath,
double width,
double opacity,
973 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
985 void setSvgFilePath(
const QString &svgPath );
1167 double mPatternWidth = 20;
1172 QByteArray mSvgData;
1174 QString mSvgFilePath;
1180 QColor mSvgStrokeColor = QColor( 35, 35, 35 );
1181 double mSvgStrokeWidth = 0.2;
1186 void storeViewBox();
1187 void setDefaultSvgParams();
1190 void applyPattern( QBrush &brush,
const QString &svgFilePath,
double patternWidth,
QgsUnitTypes::RenderUnit patternWidthUnit,
const QColor &svgFillColor,
const QColor &svgStrokeColor,
1222 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1225 QString ogrFeatureStyleWidth(
double widthScaleFactor )
const;
1266 void setLineWidth(
double w );
1276 void setColor(
const QColor &
c )
override;
1277 QColor
color()
const override;
1418 double mDistance = 5.0;
1422 double mLineWidth = 0;
1426 double mLineAngle = 45.0;
1428 double mOffset = 0.0;
1437 void applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double lineAngle,
double distance );
1466 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1566 void setColor(
const QColor &
c )
override;
1567 QColor
color()
const override;
1571 double mDistanceX = 15;
1574 double mDistanceY = 15;
1577 double mDisplacementX = 0;
1580 double mDisplacementY = 0;
1591 void applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double distanceX,
double distanceY,
1592 double displacementX,
double displacementY );
1623 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1625 void setColor(
const QColor &color )
override;
1626 QColor
color()
const override;
1655 bool mPointOnSurface =
false;
1656 bool mPointOnAllParts =
true;
1659 int mBiggestPartIndex = -1;
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's stroke.
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
void setDistance(double d)
Sets the distance between lines in the fill pattern.
const QgsMapUnitScale & displacementYMapUnitScale() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Qt::BrushStyle mBrushStyle
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
void setPatternWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the width of the SVG images in the pattern.
QColor strokeColor() const override
Gets stroke color.
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
#define DEFAULT_SIMPLEFILL_JOINSTYLE
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the fill's offset.
QgsMapUnitScale mStrokeWidthMapUnitScale
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the units for the distance between lines in the fill pattern.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
Qt::PenStyle mStrokeStyle
const QgsMapUnitScale & lineWidthMapUnitScale() const
Returns the map unit scale for the pattern's line width.
void setSvgFillColor(const QColor &c)
Sets the fill color used for rendering the SVG content.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's width.
Abstract base class for all rendered symbols.
virtual void applyDataDefinedSettings(QgsSymbolRenderContext &context)
const QgsMapUnitScale & displacementXMapUnitScale() const
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
QString imageFilePath() const
The path to the raster image used for the fill.
QPointF offset() const
Returns the offset for the shapeburst fill.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
Qt::PenJoinStyle penJoinStyle() const
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line pattern's offset.
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops...
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
A symbol fill consisting of repeated parallel lines.
Base class for polygon renderers generating texture images.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the image's width.
void setDisplacementYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
Abstract base class for color ramps.
virtual QColor strokeColor() const
Gets stroke color.
std::unique_ptr< QgsMarkerSymbol > mMarker
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
const QgsMapUnitScale & strokeWidthMapUnitScale() const
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the distance between lines in the fill pattern.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
void setOffsetUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the fill's offset.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
#define DEFAULT_SIMPLEFILL_COLOR
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
GradientColorType mGradientColorType
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
QgsMapUnitScale mDistanceYMapUnitScale
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features...
QPointF referencePoint1() const
QMap< QString, QString > QgsStringMap
Tiling is based on complete map viewport.
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)
A marker symbol type, for rendering Point and MultiPoint geometries.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units fo the symbol's stroke width.
void setStrokeWidth(double strokeWidth)
void setPatternWidth(double width)
Sets the width to render the SVG content as within the fill (i.e.
A line symbol type, for rendering LineString and MultiLineString geometries.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
QgsMapUnitScale mapUnitScale() const override
void setGradientType(GradientType gradientType)
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the pattern's line offset.
void setMapUnitScale(const QgsMapUnitScale &scale) override
#define DEFAULT_SIMPLEFILL_STYLE
QgsMapUnitScale mDisplacementYMapUnitScale
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line pattern's offset.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
virtual void setColor(const QColor &color)
The fill color.
void setOffset(QPointF offset)
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context)=0
QPointF referencePoint2() const
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
virtual QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
void setLineAngle(double a)
Sets the angle for the parallel lines used to fill the symbol.
const QgsMapUnitScale & distanceMapUnitScale() const
double strokeWidth() const
std::unique_ptr< QgsLineSymbol > mStroke
Custom stroke.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
A class for filling symbols with a repeated raster image.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mDistanceXMapUnitScale
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
virtual void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
QgsUnitTypes::RenderUnit displacementYUnit() const
Returns the units for the vertical displacement between rows in the pattern.
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
void setFillColor(const QColor &color) override
Set fill color.
void setSvgStrokeWidth(double w)
Sets the stroke width used for rendering the SVG content.
GradientType mGradientType
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width.
double displacementX() const
virtual Qt::BrushStyle dxfBrushStyle() const
Gets brush/fill style.
const QgsMapUnitScale & offsetMapUnitScale() const
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setStrokeStyle(Qt::PenStyle strokeStyle)
virtual QColor color() const
The fill color.
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
bool referencePoint2IsCentroid() const
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
QgsUnitTypes::RenderUnit offsetUnit() const
void setPenJoinStyle(Qt::PenJoinStyle style)
QColor fillColor() const override
Gets fill color.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
QgsMapUnitScale mDisplacementXMapUnitScale
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line width.
Tiling is based on feature bounding box.
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
void setOffset(QPointF offset)
Sets the offset for the fill.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
double lineWidth() const
Returns the width of the line subsymbol used to render the parallel lines in the fill.
void setSvgStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the stroke width.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
Gets brush/fill color.
void setStrokeColor(const QColor &strokeColor) override
Set stroke color.
void setOffset(QPointF offset)
Offset for gradient fill.
void setDistanceXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal distance between points in the pattern.
void setDisplacementY(double d)
virtual Qt::PenStyle dxfPenStyle() const
Gets pen style.
Qt::BrushStyle brushStyle() const
GradientCoordinateMode mCoordinateMode
const QgsMapUnitScale & distanceMapUnitScale() const
Returns the map unit scale for the pattern's line distance.
GradientSpread mGradientSpread
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
A class for filling symbols with a repeated SVG file.
virtual QgsMapUnitScale mapUnitScale() const
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Contains information about the context of a rendering operation.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
void setGradientColorType(GradientColorType gradientColorType)
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
void setWidthUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the image's width.
Struct for storing maximum and minimum scales for measurements in map units.
virtual void stopRender(QgsSymbolRenderContext &context)=0
virtual double dxfAngle(QgsSymbolRenderContext &context) const
Gets angle.
QgsUnitTypes::RenderUnit distanceXUnit() const
Returns the units for the horizontal distance between points in the pattern.
QgsUnitTypes::RenderUnit displacementXUnit() const
Returns the units for the horizontal displacement between rows in the pattern.
const QgsMapUnitScale & distanceXMapUnitScale() const
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
Qt::PenStyle strokeStyle() const
const QgsMapUnitScale & offsetMapUnitScale() const
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the fill's stroke.
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
Qt::PenJoinStyle mPenJoinStyle
const QgsMapUnitScale & distanceYMapUnitScale() const
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
bool pointOnSurface() const
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
void setDisplacementXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal displacement between rows in the pattern.
void setDistanceY(double d)
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
bool referencePoint1IsCentroid() const
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features...
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon's boundary.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
double opacity() const
Returns the opacity for the raster image used in the fill.
QgsUnitTypes::RenderUnit lineWidthUnit() const
Returns the units for the line's width.
void setColor2(const QColor &color2)
void setDistanceX(double d)
void setBrushStyle(Qt::BrushStyle style)
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient fill.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the offset for the shapeburst fill.
void setOffset(double offset)
Sets the offset distance for lines within the fill, which is the distance to offset the parallel line...
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the width of the fill's stroke.
Resolves relative paths into absolute paths and vice versa.
void setLineWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's width.
void setSvgStrokeColor(const QColor &c)
Sets the stroke color used for rendering the SVG content.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Units for gradient fill offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line offset.
double distance() const
Returns the distance between lines in the fill pattern.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
void setColorType(ShapeburstColorType colorType)
Sets the color mode to use for the shapeburst fill.
void setDistanceYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical distance between points in the pattern.
double displacementY() const
void setDisplacementX(double d)
double width() const
Returns the width used for scaling the image used in the fill.
QgsColorRamp * colorRamp()
Returns the color ramp used for the shapeburst fill.
const QgsMapUnitScale & offsetMapUnitScale() const
void setGradientSpread(GradientSpread gradientSpread)
FillCoordinateMode
Fill coordinate modes, dictates fill tiling behavior.
QgsMapUnitScale mOffsetMapUnitScale
void setCoordinateMode(GradientCoordinateMode coordinateMode)
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line distance.
QgsUnitTypes::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
RenderUnit
Rendering size units.
QgsMapUnitScale mStrokeWidthMapUnitScale
void setPointOnSurface(bool pointOnSurface)
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
virtual void startRender(QgsSymbolRenderContext &context)=0
QPointF offset() const
Returns the offset for the fill.
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
QgsMapUnitScale mOffsetMapUnitScale