16 #ifndef QGSMARKERSYMBOLLAYER_H
17 #define QGSMARKERSYMBOLLAYER_H
19 #include "qgis_core.h"
23 #define DEFAULT_SIMPLEMARKER_NAME "circle"
24 #define DEFAULT_SIMPLEMARKER_COLOR QColor(255,0,0)
25 #define DEFAULT_SIMPLEMARKER_BORDERCOLOR QColor( 35, 35, 35 )
26 #define DEFAULT_SIMPLEMARKER_JOINSTYLE Qt::BevelJoin
27 #define DEFAULT_SIMPLEMARKER_SIZE DEFAULT_POINT_SIZE
28 #define DEFAULT_SIMPLEMARKER_ANGLE 0
80 static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes();
142 bool prepareMarkerShape( Shape shape );
147 bool prepareMarkerPath( Shape symbol );
155 bool shapeToPolygon( Shape shape, QPolygonF &polygon )
const;
173 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &
angle )
const;
247 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
248 QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const override;
258 void setColor(
const QColor &color )
override;
259 QColor
color()
const override;
388 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
390 double mStrokeWidth = 0;
415 bool mUsingCache =
false;
418 static const int MAXIMUM_CACHE_WIDTH = 3000;
424 double mCachedOpacity = 1.0;
468 void setColor(
const QColor &
c )
override;
469 QColor
color()
const override;
481 std::unique_ptr< QgsFillSymbol > mFill;
486 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
487 #define DEFAULT_SVGMARKER_ANGLE 0
513 static void resolvePaths( QVariantMap &properties,
const QgsPathResolver &pathResolver,
bool saving );
530 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
536 QString
path()
const {
return mPath; }
543 void setPath(
const QString &path );
556 double updateDefaultAspectRatio();
570 bool setPreservedAspectRatio(
bool par );
600 QMap<QString, QgsProperty>
parameters()
const {
return mParameters; }
606 void setParameters(
const QMap<QString, QgsProperty> ¶meters );
646 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
651 double mDefaultAspectRatio = 0.0;
653 double mFixedAspectRatio = 0.0;
656 bool mHasFillParam =
false;
666 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const;
673 #define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE
674 #define DEFAULT_RASTERMARKER_ANGLE 0
704 static void resolvePaths( QVariantMap &properties,
const QgsPathResolver &pathResolver,
bool saving );
723 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
729 QString
path()
const {
return mPath; }
736 void setPath(
const QString &path );
763 double updateDefaultAspectRatio();
777 bool setPreservedAspectRatio(
bool par );
803 double mOpacity = 1.0;
805 double mDefaultAspectRatio = 0.0;
807 double mFixedAspectRatio = 0.0;
811 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const;
818 #define POINT2MM(x) ( (x) * 25.4 / 72 )
819 #define MM2POINT(x) ( (x) * 72 / 25.4 )
821 #define DEFAULT_FONTMARKER_FONT "Dingbats"
822 #define DEFAULT_FONTMARKER_CHR QChar('A')
823 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
824 #define DEFAULT_FONTMARKER_COLOR QColor( 35, 35, 35 )
825 #define DEFAULT_FONTMARKER_BORDERCOLOR QColor(Qt::white)
826 #define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin
827 #define DEFAULT_FONTMARKER_ANGLE 0
870 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
1009 QString mFontFamily;
1012 std::unique_ptr< QFontMetrics >mFontMetrics;
1016 double mChrWidth = 0;
1020 QColor mStrokeColor;
1021 double mStrokeWidth;
1024 Qt::PenJoinStyle mPenJoinStyle;
1029 bool mUseCachedPath =
false;
1030 QPainterPath mCachedPath;
1033 bool mNonZeroFontSize =
true;
1036 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &
angle )
const;
Exports QGIS layers to the DXF format.
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
void setStrokeColor(const QColor &color) override
Set stroke color.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
double strokeWidth() const
Returns the marker's stroke width.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
QColor strokeColor() const override
Gets stroke color.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point.
void setCharacter(QString chr)
Sets the character(s) used when rendering points.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
void setStrokeWidth(double width)
Set's the marker's stroke width.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
QString character() const
Returns the character(s) used when rendering points.
Struct for storing maximum and minimum scales for measurements in map units.
Abstract base class for marker symbol layers.
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QgsMapUnitScale mapUnitScale() const override
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Writes the symbol layer definition as a SLD XML element.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Resolves relative paths into absolute paths and vice versa.
Raster marker symbol layer class.
void setOpacity(double opacity)
Set the marker opacity.
QString path() const
Returns the marker raster image path.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
double opacity() const
Returns the marker opacity.
Contains information about the context of a rendering operation.
Abstract base class for simple marker symbol layers.
Shape mShape
Symbol shape.
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath.
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
void setShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Sets the rendered marker shape.
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
Shape
Marker symbol shapes.
@ ArrowHead
Right facing arrow head (unfilled, lines only)
@ Octagon
Octagon (since QGIS 3.18)
@ ThirdCircle
One third circle (top left third)
@ CrossFill
Solid filled cross.
@ RightHalfTriangle
Right half of triangle.
@ SquareWithCorners
A square with diagonal corners (since QGIS 3.18)
@ LeftHalfTriangle
Left half of triangle.
@ QuarterSquare
Quarter square (top left quarter)
@ ArrowHeadFilled
Right facing filled arrow head.
@ Cross2
Rotated cross (lines only), "x" shape.
@ Cross
Cross (lines only)
@ EquilateralTriangle
Equilateral triangle.
@ HalfSquare
Half square (left half)
@ QuarterCircle
Quarter circle (top left quarter)
@ SemiCircle
Semi circle (top half)
@ DiagonalHalfSquare
Diagonal half square (bottom left half)
@ AsteriskFill
A filled asterisk shape (since QGIS 3.18)
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
QPen mSelPen
QPen to use as stroke of selected symbols.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
QColor mStrokeColor
Stroke color.
QImage mSelCache
Cached image of selected marker, if using cached version.
QImage mCache
Cached image of marker, if using cached version.
QBrush mSelBrush
QBrush to use as fill of selected symbols.
void setFillColor(const QColor &color) override
Set fill color.
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
QPen mPen
QPen corresponding to marker's stroke style.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker's stroke.
QColor fillColor() const override
Gets fill color.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the marker's stroke join style (e.g., miter, bevel, etc).
QColor strokeColor() const override
Returns the marker's stroke color.
QBrush mBrush
QBrush corresponding to marker's fill style.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
double strokeWidth() const
Returns the width of the marker's stroke.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
QColor fillColor() const override
Gets fill color.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QString path() const
Returns the marker SVG path.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
void setStrokeWidth(double w)
QMap< QString, QgsProperty > mParameters
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
void setStrokeColor(const QColor &c) override
Set stroke color.
QColor strokeColor() const override
Gets stroke color.
void setFillColor(const QColor &color) override
Set fill color.
double strokeWidth() const
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
QgsMapUnitScale mStrokeWidthMapUnitScale
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
virtual QColor color() const
The fill color.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual void prepareExpressions(const QgsSymbolRenderContext &context)
Prepares all data defined property expressions for evaluation.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
virtual void setColor(const QColor &color)
The fill color.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Abstract base class for all rendered symbols.
RenderUnit
Rendering size units.
@ RenderMillimeters
Millimeters.
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)
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
#define DEFAULT_SVGMARKER_ANGLE
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
#define DEFAULT_FONTMARKER_CHR
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
#define DEFAULT_SIMPLEMARKER_SIZE
#define DEFAULT_SIMPLEMARKER_ANGLE
#define DEFAULT_SVGMARKER_SIZE
#define DEFAULT_FONTMARKER_FONT
#define DEFAULT_FONTMARKER_ANGLE
#define DEFAULT_FONTMARKER_COLOR
#define DEFAULT_FONTMARKER_SIZE
#define DEFAULT_SIMPLEMARKER_COLOR
#define DEFAULT_SCALE_METHOD