QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
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
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;
244 QString
ogrFeatureStyle(
double mmScaleFactor,
double mapUnitScaleFactor )
const override;
253 void setColor(
const QColor &color )
override;
254 QColor
color()
const override;
383 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
385 double mStrokeWidth = 0;
410 bool mUsingCache =
false;
412 static const int MAXIMUM_CACHE_WIDTH = 3000;
459 void setColor(
const QColor &
c )
override;
460 QColor
color()
const override;
470 std::unique_ptr< QgsFillSymbol > mFill;
475 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
476 #define DEFAULT_SVGMARKER_ANGLE 0
523 QString
path()
const {
return mPath; }
530 void setPath(
const QString &path );
543 double updateDefaultAspectRatio();
557 bool setPreservedAspectRatio(
bool par );
617 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
622 double mDefaultAspectRatio = 0.0;
624 double mFixedAspectRatio = 0.0;
641 #define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE
642 #define DEFAULT_RASTERMARKER_ANGLE 0
690 double calculateAspectRatio(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedAspectRatio )
const;
696 QString
path()
const {
return mPath; }
703 void setPath(
const QString &path );
730 double updateDefaultAspectRatio();
744 bool setPreservedAspectRatio(
bool par );
770 double mOpacity = 1.0;
772 double mDefaultAspectRatio = 0.0;
774 double mFixedAspectRatio = 0.0;
778 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight, QPointF &offset,
double &
angle )
const;
785 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
786 #define MM2POINT(x) ( (x) * 72 / 25.4 )
788 #define DEFAULT_FONTMARKER_FONT "Dingbats"
789 #define DEFAULT_FONTMARKER_CHR QChar('A')
790 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
791 #define DEFAULT_FONTMARKER_COLOR QColor( 35, 35, 35 )
792 #define DEFAULT_FONTMARKER_BORDERCOLOR QColor(Qt::white)
793 #define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin
794 #define DEFAULT_FONTMARKER_ANGLE 0
978 std::unique_ptr< QFontMetrics >mFontMetrics;
982 double mChrWidth = 0;
990 Qt::PenJoinStyle mPenJoinStyle;
995 bool mUseCachedPath =
false;
996 QPainterPath mCachedPath;
999 bool mNonZeroFontSize =
true;
1002 void calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledSize,
bool &hasDataDefinedRotation, QPointF &offset,
double &
angle )
const;
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
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.
#define DEFAULT_SIMPLEMARKER_ANGLE
QColor strokeColor() const override
Gets stroke color.
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)
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).
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.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
virtual void setColor(const QColor &color)
The fill color.
QImage mSelCache
Cached image of selected marker, if using cached version.
virtual QColor color() const
The fill color.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
@ SemiCircle
Semi circle (top half)
#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...
@ QuarterSquare
Quarter square (top left quarter)
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
@ RenderMillimeters
Millimeters.
#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
Set stroke color.
#define DEFAULT_SIMPLEMARKER_JOINSTYLE
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
QBrush mSelBrush
QBrush to use as fill of selected symbols.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
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.
void setShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Sets the rendered marker shape.
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
Set stroke color.
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
Gets stroke color.
QBrush mBrush
QBrush corresponding to marker's fill style.
#define DEFAULT_SVGMARKER_ANGLE
Shape mShape
Symbol shape.
Shape
Marker symbol shapes.
QColor fillColor() const override
Gets fill color.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
@ RightHalfTriangle
Right half of triangle.
QgsMapUnitScale mStrokeWidthMapUnitScale
@ DiagonalHalfSquare
Diagonal half square (bottom left half)
QColor fillColor() const override
Gets fill color.
void setStrokeWidth(double w)
QString path() const
Returns the marker SVG path.
@ ArrowHeadFilled
Right facing filled arrow head.
#define DEFAULT_FONTMARKER_SIZE
@ LeftHalfTriangle
Left half of triangle.
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
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
@ ThirdCircle
One third circle (top left third)
Struct for storing maximum and minimum scales for measurements in map units.
@ CrossFill
Solid filled cross.
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.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
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.
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...
QMap< QString, QString > QgsStringMap
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
Set fill color.
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...
@ QuarterCircle
Quarter circle (top left quarter)
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.
@ Cross2
Rotated cross (lines only), "x" shape.
#define DEFAULT_SVGMARKER_SIZE
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
@ Cross
Cross (lines only)
#define DEFAULT_SCALE_METHOD
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.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
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.
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.
@ HalfSquare
Half square (left half)
#define DEFAULT_FONTMARKER_COLOR
#define DEFAULT_SIMPLEMARKER_COLOR
@ EquilateralTriangle
Equilateral triangle.
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.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point.
@ ArrowHead
Right facing arrow head (unfilled, lines only)
QPen mPen
QPen corresponding to marker's stroke style.
void setFillColor(const QColor &color) override
Set fill color.
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.
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
#define DEFAULT_SIMPLEMARKER_SIZE