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 76 static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes();
138 bool prepareMarkerShape(
Shape shape );
143 bool prepareMarkerPath(
Shape symbol );
151 bool shapeToPolygon(
Shape shape, QPolygonF &polygon )
const;
169 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &
angle )
const;
243 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
244 QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const override;
254 void setColor(
const QColor &color )
override;
255 QColor
color()
const override;
384 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
386 double mStrokeWidth = 0;
411 bool mUsingCache =
false;
414 static const int MAXIMUM_CACHE_WIDTH = 3000;
420 double mCachedOpacity = 1.0;
464 void setColor(
const QColor &
c )
override;
465 QColor
color()
const override;
477 std::unique_ptr< QgsFillSymbol > mFill;
482 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE 483 #define DEFAULT_SVGMARKER_ANGLE 0 509 static void resolvePaths( QVariantMap &properties,
const QgsPathResolver &pathResolver,
bool saving );
526 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
532 QString
path()
const {
return mPath; }
539 void setPath(
const QString &path );
552 double updateDefaultAspectRatio();
566 bool setPreservedAspectRatio(
bool par );
596 QMap<QString, QgsProperty>
parameters()
const {
return mParameters; }
602 void setParameters(
const QMap<QString, QgsProperty> ¶meters );
642 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
647 double mDefaultAspectRatio = 0.0;
649 double mFixedAspectRatio = 0.0;
652 bool mHasFillParam =
false;
662 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const;
669 #define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE 670 #define DEFAULT_RASTERMARKER_ANGLE 0 700 static void resolvePaths( QVariantMap &properties,
const QgsPathResolver &pathResolver,
bool saving );
719 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
725 QString
path()
const {
return mPath; }
732 void setPath(
const QString &path );
759 double updateDefaultAspectRatio();
773 bool setPreservedAspectRatio(
bool par );
799 double mOpacity = 1.0;
801 double mDefaultAspectRatio = 0.0;
803 double mFixedAspectRatio = 0.0;
807 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const;
814 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch 815 #define MM2POINT(x) ( (x) * 72 / 25.4 ) 817 #define DEFAULT_FONTMARKER_FONT "Dingbats" 818 #define DEFAULT_FONTMARKER_CHR QChar('A') 819 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12) 820 #define DEFAULT_FONTMARKER_COLOR QColor( 35, 35, 35 ) 821 #define DEFAULT_FONTMARKER_BORDERCOLOR QColor(Qt::white) 822 #define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin 823 #define DEFAULT_FONTMARKER_ANGLE 0 866 void writeSldMarker( QDomDocument &doc, QDomElement &element,
const QVariantMap &props )
const override;
1005 QString mFontFamily;
1008 std::unique_ptr< QFontMetrics >mFontMetrics;
1012 double mChrWidth = 0;
1016 QColor mStrokeColor;
1017 double mStrokeWidth;
1020 Qt::PenJoinStyle mPenJoinStyle;
1025 bool mUseCachedPath =
false;
1026 QPainterPath mCachedPath;
1029 bool mNonZeroFontSize =
true;
1032 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &
angle )
const;
#define DEFAULT_SIMPLEMARKER_SIZE
QgsMapUnitScale mapUnitScale() const override
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Writes the symbol layer definition as a SLD XML element.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the marker's stroke join style (e.g., miter, bevel, etc).
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
QColor mStrokeColor
Stroke color.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Abstract base class for all rendered symbols.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point...
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke...
Abstract base class for simple marker symbol layers.
Right facing filled arrow head.
virtual void prepareExpressions(const QgsSymbolRenderContext &context)
Prepares all data defined property expressions for evaluation.
Right facing arrow head (unfilled, lines only)
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
void setStrokeColor(const QColor &c) override
Set stroke color.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
#define DEFAULT_FONTMARKER_COLOR
QBrush mSelBrush
QBrush to use as fill of selected symbols.
void setStrokeWidth(double width)
Set's the marker's stroke width.
QColor strokeColor() const override
Returns the marker's stroke color.
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
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 renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
QString path() const
Returns the marker SVG path.
#define DEFAULT_FONTMARKER_SIZE
QColor strokeColor() const override
Gets stroke color.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
double strokeWidth() const
Returns the width of the marker's stroke.
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath...
Diagonal half square (bottom left half)
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.
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 strokeWidthUnit() const
Returns the stroke width unit.
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
One third circle (top left third)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
QMap< QString, QgsProperty > mParameters
Quarter circle (top left quarter)
Raster marker symbol layer class.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
void setStrokeColor(const QColor &color) override
Set stroke color.
double opacity() const
Returns the marker opacity.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
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.
#define DEFAULT_SCALE_METHOD
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
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...
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker's stroke.
QBrush mBrush
QBrush corresponding to marker's fill style.
QgsMapUnitScale mStrokeWidthMapUnitScale
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QColor color() const
The fill color.
void setFillColor(const QColor &color) override
Set fill color.
QColor fillColor() const override
Gets fill color.
double strokeWidth() const
#define DEFAULT_FONTMARKER_ANGLE
void setStrokeWidth(double w)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
void setOpacity(double opacity)
Set the marker opacity.
QPen mSelPen
QPen to use as stroke of selected symbols.
QString path() const
Returns the marker raster image path.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
QString character() const
Returns the character(s) used when rendering points.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
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.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
#define DEFAULT_SIMPLEMARKER_BORDERCOLOR
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.
Abstract base class for marker symbol layers.
void setShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Sets the rendered marker shape.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0...
QImage mCache
Cached image of marker, if using cached version.
Struct for storing maximum and minimum scales for measurements in map units.
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
#define DEFAULT_SIMPLEMARKER_ANGLE
#define DEFAULT_SIMPLEMARKER_COLOR
Shape
Marker symbol shapes.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
double strokeWidth() const
Returns the marker's stroke width.
QColor fillColor() const override
Gets fill color.
QImage mSelCache
Cached image of selected marker, if using cached version.
#define DEFAULT_FONTMARKER_CHR
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
void setCharacter(QString chr)
Sets the character(s) used when rendering points.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void setFillColor(const QColor &color) override
Set fill color.
QColor strokeColor() const override
Gets stroke color.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Shape mShape
Symbol shape.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
Resolves relative paths into absolute paths and vice versa.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
#define DEFAULT_SVGMARKER_SIZE
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
#define DEFAULT_SVGMARKER_ANGLE
Rotated cross (lines only), "x" shape.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
#define DEFAULT_FONTMARKER_FONT
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
Quarter square (top left quarter)
RenderUnit
Rendering size units.
virtual QString layerType() const =0
Returns a string that represents this layer type.