QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
qgsmarkersymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmarkersymbollayer.h
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSMARKERSYMBOLLAYER_H
17 #define QGSMARKERSYMBOLLAYER_H
18 
19 #include "qgis_core.h"
20 #include "qgis_sip.h"
21 #include "qgssymbollayer.h"
22 
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
29 
30 #include <QPen>
31 #include <QBrush>
32 #include <QPicture>
33 #include <QPolygonF>
34 #include <QFont>
35 
44 {
45 
46  public:
47 
49  enum Shape
50  {
57  Star,
63  Line,
77  };
78 
80  static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes();
81 
87  static bool shapeIsFilled( QgsSimpleMarkerSymbolLayerBase::Shape shape );
88 
97  double size = DEFAULT_SIMPLEMARKER_SIZE,
100 
105  QgsSimpleMarkerSymbolLayerBase::Shape shape() const { return mShape; }
106 
112  void setShape( QgsSimpleMarkerSymbolLayerBase::Shape shape ) { mShape = shape; }
113 
122  static QgsSimpleMarkerSymbolLayerBase::Shape decodeShape( const QString &name, bool *ok = nullptr );
123 
130  static QString encodeShape( QgsSimpleMarkerSymbolLayerBase::Shape shape );
131 
132  void startRender( QgsSymbolRenderContext &context ) override;
133  void stopRender( QgsSymbolRenderContext &context ) override;
134  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
135  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
136 
137  protected:
138 
142  bool prepareMarkerShape( Shape shape );
143 
147  bool prepareMarkerPath( Shape symbol );
148 
155  bool shapeToPolygon( Shape shape, QPolygonF &polygon ) const;
156 
163  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
164 
173  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
174 
176  QPolygonF mPolygon;
177 
179  QPainterPath mPath;
180 
183 
184  private:
185 
194  virtual void draw( QgsSymbolRenderContext &context, QgsSimpleMarkerSymbolLayerBase::Shape shape, const QPolygonF &polygon, const QPainterPath &path ) = 0 SIP_FORCE;
195 };
196 
203 {
204  public:
205 
217  double size = DEFAULT_SIMPLEMARKER_SIZE,
220  const QColor &color = DEFAULT_SIMPLEMARKER_COLOR,
221  const QColor &strokeColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR,
222  Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEMARKER_JOINSTYLE );
223 
224  // static methods
225 
231  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
232 
238  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
239 
240  // reimplemented from base classes
241 
242  QString layerType() const override;
243  void startRender( QgsSymbolRenderContext &context ) override;
244  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
245  QVariantMap properties() const override;
246  QgsSimpleMarkerSymbolLayer *clone() const override SIP_FACTORY;
247  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
248  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
249  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
250  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
251  QgsUnitTypes::RenderUnit outputUnit() const override;
252  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
253  QgsMapUnitScale mapUnitScale() const override;
254  bool usesMapUnits() const override;
255  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
256  QColor fillColor() const override { return mColor; }
257  void setFillColor( const QColor &color ) override { mColor = color; }
258  void setColor( const QColor &color ) override;
259  QColor color() const override;
260 
261  // new methods
262 
269  QColor strokeColor() const override { return mStrokeColor; }
270 
278  void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
279 
287  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
288 
297  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
298 
306  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
307 
316  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
317 
324  double strokeWidth() const { return mStrokeWidth; }
325 
333  void setStrokeWidth( double w ) { mStrokeWidth = w; }
334 
342  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit u ) { mStrokeWidthUnit = u; }
343 
350  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
351 
359  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
360 
367  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
368 
369  protected:
370 
377  void drawMarker( QPainter *p, QgsSymbolRenderContext &context );
378 
383  bool prepareCache( QgsSymbolRenderContext &context );
384 
386  QColor mStrokeColor;
388  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
390  double mStrokeWidth = 0;
396  Qt::PenJoinStyle mPenJoinStyle;
398  QPen mPen;
400  QBrush mBrush;
401 
403  QImage mCache;
405  QPen mSelPen;
407  QBrush mSelBrush;
409  QImage mSelCache;
410 
415  bool mUsingCache = false;
416 
418  static const int MAXIMUM_CACHE_WIDTH = 3000;
419 
420  private:
421  // cppcheck-suppress unusedPrivateFunction
422  void draw( QgsSymbolRenderContext &context, QgsSimpleMarkerSymbolLayerBase::Shape shape, const QPolygonF &polygon, const QPainterPath &path ) override SIP_FORCE;
423 
424  double mCachedOpacity = 1.0;
425 
426 };
427 
436 {
437  public:
438 
447  double size = DEFAULT_SIMPLEMARKER_SIZE,
450 
456  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
457 
458  QString layerType() const override;
459  void startRender( QgsSymbolRenderContext &context ) override;
460  void stopRender( QgsSymbolRenderContext &context ) override;
461  QVariantMap properties() const override;
462  QgsFilledMarkerSymbolLayer *clone() const override SIP_FACTORY;
463  QgsSymbol *subSymbol() override;
464  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
465  double estimateMaxBleed( const QgsRenderContext &context ) const override;
466  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
467  bool hasDataDefinedProperties() const override;
468  void setColor( const QColor &c ) override;
469  QColor color() const override;
470  bool usesMapUnits() const override;
471 
472  private:
473 #ifdef SIP_RUN
475 #endif
476 
477  // cppcheck-suppress unusedPrivateFunction
478  void draw( QgsSymbolRenderContext &context, QgsSimpleMarkerSymbolLayerBase::Shape shape, const QPolygonF &polygon, const QPainterPath &path ) override SIP_FORCE;
479 
481  std::unique_ptr< QgsFillSymbol > mFill;
482 };
483 
485 
486 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
487 #define DEFAULT_SVGMARKER_ANGLE 0
488 
494 {
495  public:
497  QgsSvgMarkerSymbolLayer( const QString &path,
498  double size = DEFAULT_SVGMARKER_SIZE,
501 
502  // static stuff
503 
505  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
506  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
507 
513  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
514 
515  // implemented from base classes
516 
517  QString layerType() const override;
518 
519  void startRender( QgsSymbolRenderContext &context ) override;
520 
521  void stopRender( QgsSymbolRenderContext &context ) override;
522 
523  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
524 
525  QVariantMap properties() const override;
526  bool usesMapUnits() const override;
527 
528  QgsSvgMarkerSymbolLayer *clone() const override SIP_FACTORY;
529 
530  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
531 
536  QString path() const { return mPath; }
537 
543  void setPath( const QString &path );
544 
549  double defaultAspectRatio() const { return mDefaultAspectRatio; }
550 
556  double updateDefaultAspectRatio();
557 
562  bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
563 
570  bool setPreservedAspectRatio( bool par );
571 
577  double fixedAspectRatio() const { return mFixedAspectRatio; }
578 
585  void setFixedAspectRatio( double ratio ) { mFixedAspectRatio = ratio; }
586 
587  QColor fillColor() const override { return color(); }
588  void setFillColor( const QColor &color ) override { setColor( color ); }
589 
590  QColor strokeColor() const override { return mStrokeColor; }
591  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
592 
593  double strokeWidth() const { return mStrokeWidth; }
594  void setStrokeWidth( double w ) { mStrokeWidth = w; }
595 
600  QMap<QString, QgsProperty> parameters() const { return mParameters; }
601 
606  void setParameters( const QMap<QString, QgsProperty> &parameters );
607 
613  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
614 
619  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
620 
621  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
622  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
623 
624  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
625  QgsUnitTypes::RenderUnit outputUnit() const override;
626 
627  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
628  QgsMapUnitScale mapUnitScale() const override;
629 
630  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
631 
632  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
633 
634  void prepareExpressions( const QgsSymbolRenderContext &context ) override;
635 
636  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
637 
638  protected:
639 
646  double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
647 
648  QString mPath;
649 
651  double mDefaultAspectRatio = 0.0;
653  double mFixedAspectRatio = 0.0;
654  //param(fill), param(stroke), param(stroke-width) are going
655  //to be replaced in memory
656  bool mHasFillParam = false;
657  QColor mStrokeColor;
658  double mStrokeWidth;
659  QMap<QString, QgsProperty> mParameters;
660 
663 
664  private:
665  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
666  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
667 
668 };
669 
670 
672 
673 #define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE
674 #define DEFAULT_RASTERMARKER_ANGLE 0
675 
683 {
684  public:
686  QgsRasterMarkerSymbolLayer( const QString &path = QString(),
687  double size = DEFAULT_SVGMARKER_SIZE,
690 
691  // static stuff
692 
697  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
698 
704  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
705 
706  // implemented from base classes
707 
708  QString layerType() const override;
709 
710  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
711 
712  QVariantMap properties() const override;
713 
714  QgsRasterMarkerSymbolLayer *clone() const override SIP_FACTORY;
715  bool usesMapUnits() const override;
716 
723  double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
724 
729  QString path() const { return mPath; }
730 
736  void setPath( const QString &path );
737 
743  double opacity() const { return mOpacity; }
744 
750  void setOpacity( double opacity ) { mOpacity = opacity; }
751 
756  double defaultAspectRatio() const { return mDefaultAspectRatio; }
757 
763  double updateDefaultAspectRatio();
764 
769  bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
770 
777  bool setPreservedAspectRatio( bool par );
778 
784  double fixedAspectRatio() const { return mFixedAspectRatio; }
785 
792  void setFixedAspectRatio( double ratio ) { mFixedAspectRatio = ratio; }
793 
794  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
795  QgsMapUnitScale mapUnitScale() const override;
796 
797  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
798 
799  protected:
800 
801  QString mPath;
803  double mOpacity = 1.0;
805  double mDefaultAspectRatio = 0.0;
807  double mFixedAspectRatio = 0.0;
808 
809  private:
810  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
811  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
812 
813 };
814 
815 
817 
818 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
819 #define MM2POINT(x) ( (x) * 72 / 25.4 )
820 
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
828 
834 {
835  public:
836 
838  QgsFontMarkerSymbolLayer( const QString &fontFamily = DEFAULT_FONTMARKER_FONT,
839  QString chr = DEFAULT_FONTMARKER_CHR,
840  double pointSize = DEFAULT_FONTMARKER_SIZE,
841  const QColor &color = DEFAULT_FONTMARKER_COLOR,
842  double angle = DEFAULT_FONTMARKER_ANGLE );
843 
844  // static stuff
845 
849  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
850 
854  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
855 
856  // implemented from base classes
857 
858  QString layerType() const override;
859 
860  void startRender( QgsSymbolRenderContext &context ) override;
861 
862  void stopRender( QgsSymbolRenderContext &context ) override;
863 
864  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
865 
866  QVariantMap properties() const override;
867 
868  QgsFontMarkerSymbolLayer *clone() const override SIP_FACTORY;
869 
870  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
871  bool usesMapUnits() const override;
872 
873  // new methods
874 
880  QString fontFamily() const { return mFontFamily; }
881 
887  void setFontFamily( const QString &family ) { mFontFamily = family; }
888 
895  QString fontStyle() const { return mFontStyle; }
896 
903  void setFontStyle( const QString &style ) { mFontStyle = style; }
904 
910  QString character() const { return mString; }
911 
917  void setCharacter( QString chr ) { mString = chr; }
918 
919  QColor strokeColor() const override { return mStrokeColor; }
920  void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
921 
931  double strokeWidth() const { return mStrokeWidth; }
932 
942  void setStrokeWidth( double width ) { mStrokeWidth = width; }
943 
953  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
954 
963  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
964 
974  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
975 
985  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
986 
994  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
995 
1003  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1004 
1005  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
1006 
1007  private:
1008 
1009  QString mFontFamily;
1010  QString mFontStyle;
1011  QFont mFont;
1012  std::unique_ptr< QFontMetrics >mFontMetrics;
1013 
1014  QString mString;
1015 
1016  double mChrWidth = 0;
1017  QPointF mChrOffset;
1018  double mOrigSize;
1019 
1020  QColor mStrokeColor;
1021  double mStrokeWidth;
1022  QgsUnitTypes::RenderUnit mStrokeWidthUnit;
1023  QgsMapUnitScale mStrokeWidthMapUnitScale;
1024  Qt::PenJoinStyle mPenJoinStyle;
1025 
1026  QPen mPen;
1027  QBrush mBrush;
1028 
1029  bool mUseCachedPath = false;
1030  QPainterPath mCachedPath;
1031 
1032  // If font has a zero (or nearly zero) size, we skip rendering altogether..
1033  bool mNonZeroFontSize = true;
1034 
1035  QString characterToRender( QgsSymbolRenderContext &context, QPointF &charOffset, double &charWidth );
1036  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
1037  double calculateSize( QgsSymbolRenderContext &context );
1038 };
1039 
1040 // clazy:excludeall=qstring-allocations
1041 
1042 #endif
1043 
1044 
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:64
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.
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.
@ ArrowHead
Right facing arrow head (unfilled, lines only)
@ Octagon
Octagon (since QGIS 3.18)
@ ThirdCircle
One third circle (top left third)
@ 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.
@ 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.
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.
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.
Definition: qgssymbol.h:65
ScaleMethod
Scale method.
Definition: qgssymbol.h:98
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
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)
Definition: MathUtils.cpp:786
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 SIP_FORCE
Definition: qgis_sip.h:131
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
#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