16 #ifndef QGSFILLSYMBOLLAYERV2_H 17 #define QGSFILLSYMBOLLAYERV2_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; }
514 void setColor2(
const QColor &color2 ) { mColor2 = color2; }
523 QColor
color2()
const {
return mColor2; }
558 QPointF
offset()
const {
return mOffset; }
593 bool mUseWholeShape =
true;
594 double mMaxDistance = 5.0;
601 bool mIgnoreRings =
false;
607 std::unique_ptr< QgsColorRamp > mGradientRamp;
610 void applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QColor &color, QColor &color2,
int &blurRadius,
bool &useWholeShape,
611 double &maxDistance,
bool &ignoreRings );
614 void distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d );
616 void distanceTransform2d(
double *im,
int width,
int height,
QgsRenderContext &context );
621 void dtArrayToQImage(
double *array, QImage *im,
QgsColorRamp *ramp,
QgsRenderContext &context,
double layerAlpha = 1,
bool useWholeShape =
true,
int maxPixelDistance = 0 );
686 double mNextAngle = 0.0;
689 double mStrokeWidth = 0.0;
741 QString layerType() const override;
742 void renderPolygon( const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context ) override;
758 void setImageFilePath(
const QString &imagePath );
788 void setOpacity(
double opacity );
813 QPointF
offset()
const {
return mOffset; }
859 void setWidth(
const double width ) { mWidth = width; }
869 double width()
const {
return mWidth; }
914 QString mImageFilePath;
916 double mOpacity = 1.0;
927 void applyPattern( QBrush &brush,
const QString &imageFilePath,
double width,
double opacity,
975 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
987 void setSvgFilePath(
const QString &svgPath );
1169 double mPatternWidth = 20;
1174 QByteArray mSvgData;
1176 QString mSvgFilePath;
1182 QColor mSvgStrokeColor = QColor( 35, 35, 35 );
1183 double mSvgStrokeWidth = 0.2;
1188 void storeViewBox();
1189 void setDefaultSvgParams();
1192 void applyPattern( QBrush &brush,
const QString &svgFilePath,
double patternWidth,
QgsUnitTypes::RenderUnit patternWidthUnit,
const QColor &svgFillColor,
const QColor &svgStrokeColor,
1224 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1227 QString ogrFeatureStyleWidth(
double widthScaleFactor )
const;
1268 void setLineWidth(
double w );
1278 void setColor(
const QColor &
c )
override;
1279 QColor
color()
const override;
1420 double mDistance = 5.0;
1424 double mLineWidth = 0;
1428 double mLineAngle = 45.0;
1430 double mOffset = 0.0;
1439 void applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double lineAngle,
double distance );
1468 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1568 void setColor(
const QColor &
c )
override;
1569 QColor
color()
const override;
1573 double mDistanceX = 15;
1576 double mDistanceY = 15;
1579 double mDisplacementX = 0;
1582 double mDisplacementY = 0;
1593 void applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double distanceX,
double distanceY,
1594 double displacementX,
double displacementY );
1625 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1627 void setColor(
const QColor &color )
override;
1628 QColor
color()
const override;
1657 bool mPointOnSurface =
false;
1658 bool mPointOnAllParts =
true;
1661 int mBiggestPartIndex = -1;
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's stroke.
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
void setDistance(double d)
Sets the distance between lines in the fill pattern.
Qt::PenJoinStyle penJoinStyle() const
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Qt::BrushStyle mBrushStyle
const QgsMapUnitScale & displacementXMapUnitScale() const
QgsUnitTypes::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
Qt::PenStyle strokeStyle() const
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.
#define DEFAULT_SIMPLEFILL_JOINSTYLE
QgsUnitTypes::RenderUnit distanceXUnit() const
Returns the units for the horizontal distance between points in the pattern.
virtual QColor strokeColor() const
Gets stroke color.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the fill's offset.
QgsMapUnitScale mStrokeWidthMapUnitScale
virtual Qt::PenStyle dxfPenStyle() const
Gets pen style.
const QgsMapUnitScale & lineWidthMapUnitScale() const
Returns the map unit scale for the pattern's line width.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
Qt::BrushStyle brushStyle() const
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
Qt::PenStyle mStrokeStyle
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)
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
A symbol fill consisting of repeated parallel lines.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
double displacementX() const
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
Base class for polygon renderers generating texture images.
const QgsMapUnitScale & distanceMapUnitScale() const
void setDisplacementYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
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.
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.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the units for the distance between lines in the fill pattern.
std::unique_ptr< QgsMarkerSymbol > mMarker
QgsUnitTypes::RenderUnit displacementXUnit() const
Returns the units for the horizontal displacement between rows in the pattern.
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
const QgsMapUnitScale & offsetMapUnitScale() const
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the distance between lines in the fill pattern.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
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
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
const QgsMapUnitScale & strokeWidthMapUnitScale() const
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
double strokeWidth() const
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
double opacity() const
Returns the opacity for the raster image used in the fill.
GradientColorType mGradientColorType
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...
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.
virtual QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
QgsMapUnitScale mapUnitScale() const override
void setGradientType(GradientType gradientType)
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line pattern's offset.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
#define DEFAULT_SIMPLEFILL_STYLE
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the width of the fill's stroke.
bool referencePoint1IsCentroid() const
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features...
QgsMapUnitScale mDisplacementYMapUnitScale
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line pattern's offset.
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
QgsUnitTypes::RenderUnit displacementYUnit() const
Returns the units for the vertical displacement between rows in the pattern.
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context)=0
bool referencePoint2IsCentroid() const
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
void setLineAngle(double a)
Sets the angle for the parallel lines used to fill the symbol.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
Gets brush/fill color.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the image's width.
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
bool pointOnSurface() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
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.
const QgsMapUnitScale & offsetMapUnitScale() const
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
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.
virtual QgsMapUnitScale mapUnitScale() const
void setSvgStrokeWidth(double w)
Sets the stroke width used for rendering the SVG content.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
GradientType mGradientType
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the pattern's line offset.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width.
const QgsMapUnitScale & distanceXMapUnitScale() const
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QString imageFilePath() const
The path to the raster image used for the fill.
void setStrokeStyle(Qt::PenStyle strokeStyle)
double lineWidth() const
Returns the width of the line subsymbol used to render the parallel lines in the fill.
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
void setPenJoinStyle(Qt::PenJoinStyle style)
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
QColor fillColor() const override
Gets fill color.
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 void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
QgsUnitTypes::RenderUnit offsetUnit() const
const QgsMapUnitScale & displacementYMapUnitScale() const
void setSvgStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the stroke width.
void setStrokeColor(const QColor &strokeColor) override
Set stroke color.
void setOffset(QPointF offset)
Offset for gradient fill.
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops...
void setDistanceXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal distance between points in the pattern.
void setDisplacementY(double d)
GradientCoordinateMode mCoordinateMode
GradientSpread mGradientSpread
A class for filling symbols with a repeated SVG file.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
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 double dxfAngle(QgsSymbolRenderContext &context) const
Gets angle.
const QgsMapUnitScale & distanceMapUnitScale() const
Returns the map unit scale for the pattern's line distance.
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
void setGradientColorType(GradientColorType gradientColorType)
QPointF offset() const
Returns the offset for the fill.
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
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
const QgsMapUnitScale & distanceYMapUnitScale() const
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the fill's stroke.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
Qt::PenJoinStyle mPenJoinStyle
virtual double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const
Gets line width.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setDisplacementXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal displacement between rows in the pattern.
void setDistanceY(double d)
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
QPointF referencePoint1() const
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 ...
void setColor2(const QColor &color2)
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
void setDistanceX(double d)
double distance() const
Returns the distance between lines in the fill pattern.
QgsUnitTypes::RenderUnit lineWidthUnit() const
Returns the units for the line's width.
void setBrushStyle(Qt::BrushStyle style)
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient 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...
Resolves relative paths into absolute paths and vice versa.
void setLineWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's width.
double width() const
Returns the width used for scaling the image used in the fill.
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.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
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.
virtual QColor color() const
The fill color.
void setDisplacementX(double d)
QgsColorRamp * colorRamp()
Returns the color ramp used for the shapeburst fill.
void setGradientSpread(GradientSpread gradientSpread)
double displacementY() const
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.
virtual Qt::BrushStyle dxfBrushStyle() const
Gets brush/fill style.
QPointF offset() const
Returns the offset for the shapeburst fill.
RenderUnit
Rendering size units.
const QgsMapUnitScale & offsetMapUnitScale() const
QgsMapUnitScale mStrokeWidthMapUnitScale
void setPointOnSurface(bool pointOnSurface)
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QPointF referencePoint2() const
virtual void startRender(QgsSymbolRenderContext &context)=0
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
Gets color.
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsMapUnitScale mOffsetMapUnitScale