QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
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
52 static QList< Qgis::MarkerShape > availableShapes();
147 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &
angle )
const;
223 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
224 QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const override;
234 void setColor(
const QColor &color )
override;
235 QColor
color()
const override;
386 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
388 double mStrokeWidth = 0;
396 Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
415 bool mUsingCache =
false;
418 static const int MAXIMUM_CACHE_WIDTH = 3000;
424 double mCachedOpacity = 1.0;
470 void setColor(
const QColor &
c )
override;
471 QColor
color()
const override;
484 std::unique_ptr< QgsFillSymbol > mFill;
489 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
490 #define DEFAULT_SVGMARKER_ANGLE 0
518 static void resolvePaths( QVariantMap &properties,
const QgsPathResolver &pathResolver,
bool saving );
535 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
541 QString
path()
const {
return mPath; }
548 void setPath(
const QString &path );
561 double updateDefaultAspectRatio();
575 bool setPreservedAspectRatio(
bool par );
605 QMap<QString, QgsProperty>
parameters()
const {
return mParameters; }
611 void setParameters(
const QMap<QString, QgsProperty> ¶meters );
651 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
656 double mDefaultAspectRatio = 0.0;
658 double mFixedAspectRatio = 0.0;
661 bool mHasFillParam =
false;
671 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const;
678 #define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE
679 #define DEFAULT_RASTERMARKER_ANGLE 0
711 static void resolvePaths( QVariantMap &properties,
const QgsPathResolver &pathResolver,
bool saving );
721 QColor
color()
const override;
729 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
735 QString
path()
const {
return mPath; }
742 void setPath(
const QString &path );
769 double updateDefaultAspectRatio();
783 bool setPreservedAspectRatio(
bool par );
812 void setCommonProperties(
const QVariantMap &properties );
826 virtual QImage fetchImage(
QgsRenderContext &context,
const QString &path, QSize size,
bool preserveAspectRatio,
double opacity )
const SIP_SKIP;
830 double mOpacity = 1.0;
832 double mDefaultAspectRatio = 0.0;
834 double mFixedAspectRatio = 0.0;
838 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const;
845 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
846 #define MM2POINT(x) ( (x) * 72 / 25.4 )
848 #define DEFAULT_FONTMARKER_FONT "Dingbats"
849 #define DEFAULT_FONTMARKER_CHR QChar('A')
850 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
851 #define DEFAULT_FONTMARKER_COLOR QColor( 35, 35, 35 )
852 #define DEFAULT_FONTMARKER_BORDERCOLOR QColor(Qt::white)
853 #define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin
854 #define DEFAULT_FONTMARKER_ANGLE 0
891 static void resolveFonts(
const QVariantMap &properties,
const QgsReadWriteContext &context );
907 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
1047 QString mFontFamily;
1050 std::unique_ptr< QFontMetrics >mFontMetrics;
1054 double mChrWidth = 0;
1057 double mFontSizeScale = 1.0;
1060 QColor mStrokeColor;
1061 double mStrokeWidth;
1064 Qt::PenJoinStyle mPenJoinStyle;
1069 bool mUseCachedPath =
false;
1070 QPainterPath mCachedPath;
1073 bool mNonZeroFontSize =
true;
1076 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &
angle )
const;
1137 double mFrameRateFps = 10;
1138 bool mStaticPath =
false;
1139 mutable QSet< QString > mPreparedPaths;
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol....
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
#define DEFAULT_SIMPLEMARKER_ANGLE
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
double opacity() const
Returns the marker opacity.
RenderUnit
Rendering size units.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
Exports QGIS layers to the DXF format.
void setStrokeWidth(double width)
Set's the marker's stroke width.
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
The class is used as a container of context for various read/write operations on other objects.
QgsMapUnitScale mapUnitScale() const override
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker's stroke.
QString character() const
Returns the character(s) used when rendering points.
virtual void prepareExpressions(const QgsSymbolRenderContext &context)
Prepares all data defined property expressions for evaluation.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
Qgis::MarkerShape mShape
Symbol shape.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
QImage mSelCache
Cached image of selected marker, if using cached version.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
#define DEFAULT_FONTMARKER_ANGLE
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Contains information about the context of a rendering operation.
#define DEFAULT_RASTERMARKER_SIZE
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
@ RenderMillimeters
Millimeters.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
#define DEFAULT_FONTMARKER_FONT
Abstract base class for marker symbol layers.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setCharacter(QString chr)
Sets the character(s) used when rendering points.
void setOpacity(double opacity)
Set the marker opacity.
void setStrokeColor(const QColor &color) override
Sets the stroke color for the symbol layer.
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
Abstract base class for all rendered symbols.
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
Animated marker symbol layer class.
QgsRasterMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
QBrush mSelBrush
QBrush to use as fill of selected symbols.
QMap< QString, QgsProperty > mParameters
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
ScaleMethod
Scale methods.
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 strokeWidth() const
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
double frameRate() const
Returns the marker frame rate in frame per second.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
Abstract base class for simple marker symbol layers. Handles creation of the symbol shapes but leaves...
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
QBrush mBrush
QBrush corresponding to marker's fill style.
#define DEFAULT_SVGMARKER_ANGLE
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Writes the symbol layer definition as a SLD XML element.
QColor fillColor() const override
Returns the fill color for the symbol layer.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
QgsMapUnitScale mStrokeWidthMapUnitScale
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
QString layerType() const override
Returns a string that represents this layer type.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
QColor fillColor() const override
Returns the fill color for the symbol layer.
void setStrokeWidth(double w)
QString path() const
Returns the marker SVG path.
#define DEFAULT_FONTMARKER_SIZE
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
#define DEFAULT_FONTMARKER_CHR
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
double strokeWidth() const
Returns the width of the marker's stroke.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
Raster marker symbol layer class.
QColor mStrokeColor
Stroke color.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
Struct for storing maximum and minimum scales for measurements in map units.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
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.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QColor strokeColor() const override
Returns the marker's stroke color.
Qgis::MarkerShape shape() const
Returns the shape for the rendered marker symbol.
QPen mSelPen
QPen to use as stroke of selected symbols.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
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
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath.
#define DEFAULT_SVGMARKER_SIZE
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
#define DEFAULT_SCALE_METHOD
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
QImage mCache
Cached image of marker, if using cached version.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a raster marker symbol layer from a string map of properties.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the marker's stroke join style (e.g., miter, bevel, etc).
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
MarkerShape
Marker shapes.
#define DEFAULT_FONTMARKER_COLOR
#define DEFAULT_SIMPLEMARKER_COLOR
virtual QImage fetchImage(QgsRenderContext &context, const QString &path, QSize size, bool preserveAspectRatio, double opacity) const
Fetches the image to render.
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 stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
Resolves relative paths into absolute paths and vice versa. Used for writing.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point.
void setShape(Qgis::MarkerShape shape)
Sets the rendered marker shape.
QPen mPen
QPen corresponding to marker's stroke style.
void setFrameRate(double rate)
Sets the marker frame rate in frame per second.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.
double strokeWidth() const
Returns the marker's stroke width.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
#define DEFAULT_RASTERMARKER_ANGLE
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
#define DEFAULT_SIMPLEMARKER_SIZE