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,
const double angle );
332 QPointF rotateReferencePoint( QPointF refPoint,
double angle );
351 int blurRadius = 0,
bool useWholeShape =
true,
double maxDistance = 5 );
361 QString layerType() const override;
367 void renderPolygon( const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context ) override;
381 void setBlurRadius(
int blurRadius ) { mBlurRadius = blurRadius; }
500 void setColor2(
const QColor &color2 ) { mColor2 = color2; }
509 QColor
color2()
const {
return mColor2; }
544 QPointF
offset()
const {
return mOffset; }
589 bool mIgnoreRings =
false;
598 void applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QColor &color, QColor &color2,
int &blurRadius,
bool &useWholeShape,
599 double &maxDistance,
bool &ignoreRings );
602 void distanceTransform1d(
double *
f,
int n,
int *v,
double *z,
double *d );
604 void distanceTransform2d(
double *im,
int width,
int height );
606 double *distanceTransform( QImage *im );
609 void dtArrayToQImage(
double *array, QImage *im,
QgsColorRamp *ramp,
double layerAlpha = 1,
bool useWholeShape =
true,
int maxPixelDistance = 0 );
658 double mNextAngle = 0.0;
661 double mStrokeWidth = 0.0;
704 QString layerType() const override;
705 void renderPolygon( const QPolygonF &points, QList<QPolygonF> *rings,
QgsSymbolRenderContext &context ) override;
721 void setImageFilePath(
const QString &imagePath );
751 void setOpacity(
const double opacity );
776 QPointF
offset()
const {
return mOffset; }
822 void setWidth(
const double width ) { mWidth = width; }
832 double width()
const {
return mWidth; }
875 double mOpacity = 1.0;
890 void applyPattern( QBrush &brush,
const QString &imageFilePath,
const double width,
const double opacity,
927 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
930 void setSvgFilePath(
const QString &svgPath );
994 QImage *mSvgPattern =
nullptr;
1007 void storeViewBox();
1008 void setDefaultSvgParams();
1011 void applyPattern( QBrush &brush,
const QString &svgFilePath,
double patternWidth,
QgsUnitTypes::RenderUnit patternWidthUnit,
const QColor &svgFillColor,
const QColor &svgStrokeColor,
1038 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1042 QString ogrFeatureStyleWidth(
double widthScaleFactor )
const;
1063 void setLineWidth(
double w );
1065 void setColor(
const QColor &c )
override;
1066 QColor
color()
const override;
1133 double mDistance = 5.0;
1137 double mLineWidth = 0;
1142 double mLineAngle = 45.0;
1144 double mOffset = 0.0;
1156 void applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double lineAngle,
double distance );
1185 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1284 void setColor(
const QColor &c )
override;
1285 QColor
color()
const override;
1289 double mDistanceX = 15;
1292 double mDistanceY = 15;
1295 double mDisplacementX = 0;
1298 double mDisplacementY = 0;
1309 void applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double distanceX,
double distanceY,
1310 double displacementX,
double displacementY );
1341 void toSld( QDomDocument &doc, QDomElement &element,
const QgsStringMap &props )
const override;
1343 void setColor(
const QColor &color )
override;
1344 QColor
color()
const override;
1372 bool mPointOnSurface =
false;
1373 bool mPointOnAllParts =
true;
1376 int mBiggestPartIndex = -1;
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
#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
void setPatternWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the SVG images in the pattern.
QColor strokeColor() const override
Get 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)
QgsMapUnitScale mLineWidthMapUnitScale
Qt::PenStyle mStrokeStyle
const QgsMapUnitScale & lineWidthMapUnitScale() const
void setSvgFillColor(const QColor &c)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
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.
Base class for polygon renderers generating texture images.
QgsMapUnitScale mPatternWidthMapUnitScale
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
set 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.
Abstract base class for color ramps.
virtual QColor strokeColor() const
Get stroke color.
std::unique_ptr< QgsMarkerSymbol > mMarker
QgsUnitTypes::RenderUnit mSvgStrokeWidthUnit
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
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units 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
get 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
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
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)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
void setStrokeWidth(double strokeWidth)
void setPatternWidth(double width)
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
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
void setMapUnitScale(const QgsMapUnitScale &scale) override
#define DEFAULT_SIMPLEFILL_STYLE
QgsMapUnitScale mDisplacementYMapUnitScale
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line pattern's offset.
virtual void setColor(const QColor &color)
The fill color.
void setOffset(QPointF offset)
virtual void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context)=0
QPointF referencePoint2() const
QString mImageFilePath
Path to the image file.
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
QgsMapUnitScale mDistanceMapUnitScale
virtual QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol layer.
void setLineAngle(double a)
const QgsMapUnitScale & distanceMapUnitScale() const
double strokeWidth() const
std::unique_ptr< QgsLineSymbol > mStroke
Custom stroke.
virtual bool setSubSymbol(QgsSymbol *symbol)
set layer's subsymbol. takes ownership of the passed symbol
A class for filling symbols with a repeated raster image.
QByteArray mSvgData
SVG data.
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)
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
get 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
QgsMapUnitScale mOffsetMapUnitScale
QgsMapUnitScale mOffsetMapUnitScale
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
Get fill color.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
QColor svgStrokeColor() const
QgsMapUnitScale mDisplacementXMapUnitScale
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mOffsetMapUnitScale
void setOffset(QPointF offset)
Sets the offset for the fill.
ShapeburstColorType mColorType
QString mSvgFilePath
Path to the svg file (or empty if constructed directly from data)
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setSvgStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
virtual QColor dxfBrushColor(QgsSymbolRenderContext &context) const
get 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
get pen style
Qt::BrushStyle brushStyle() const
GradientCoordinateMode mCoordinateMode
const QgsMapUnitScale & distanceMapUnitScale() const
GradientSpread mGradientSpread
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
QgsMapUnitScale mWidthMapUnitScale
A class for svg fill patterns.
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
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
get angle
QgsMapUnitScale mDistanceMapUnitScale
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
virtual QColor dxfColor(QgsSymbolRenderContext &context) const
get 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
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
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)
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 units for the line's width.
void setSvgStrokeColor(const QColor &c)
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Units for gradient fill offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
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)
QgsUnitTypes::RenderUnit mPatternWidthUnit
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)
QgsUnitTypes::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
QgsMapUnitScale mSvgStrokeWidthMapUnitScale
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.
QRectF mSvgViewBox
SVG view box (to keep the aspect ratio.
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.
double mPatternWidth
Width of the pattern (in output units)
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
QgsMapUnitScale mOffsetMapUnitScale