QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
36 class QgsFillSymbol;
37 class QgsPathResolver;
38 
47 {
48 
49  public:
50 
52  enum Shape
53  {
60  Star,
66  Line,
83  };
84 
86  static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes();
87 
93  static bool shapeIsFilled( QgsSimpleMarkerSymbolLayerBase::Shape shape );
94 
103  double size = DEFAULT_SIMPLEMARKER_SIZE,
105  Qgis::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
106 
108 
113  QgsSimpleMarkerSymbolLayerBase::Shape shape() const { return mShape; }
114 
120  void setShape( QgsSimpleMarkerSymbolLayerBase::Shape shape ) { mShape = shape; }
121 
130  static QgsSimpleMarkerSymbolLayerBase::Shape decodeShape( const QString &name, bool *ok = nullptr );
131 
138  static QString encodeShape( QgsSimpleMarkerSymbolLayerBase::Shape shape );
139 
140  void startRender( QgsSymbolRenderContext &context ) override;
141  void stopRender( QgsSymbolRenderContext &context ) override;
142  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
143  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
144 
145  protected:
146 
150  bool prepareMarkerShape( Shape shape );
151 
155  bool prepareMarkerPath( Shape symbol );
156 
163  bool shapeToPolygon( Shape shape, QPolygonF &polygon ) const;
164 
171  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
172 
181  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
182 
184  QPolygonF mPolygon;
185 
187  QPainterPath mPath;
188 
191 
192  private:
193 
202  virtual void draw( QgsSymbolRenderContext &context, QgsSimpleMarkerSymbolLayerBase::Shape shape, const QPolygonF &polygon, const QPainterPath &path ) = 0 SIP_FORCE;
203 };
204 
211 {
212  public:
213 
225  double size = DEFAULT_SIMPLEMARKER_SIZE,
228  const QColor &color = DEFAULT_SIMPLEMARKER_COLOR,
229  const QColor &strokeColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR,
230  Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEMARKER_JOINSTYLE );
231 
233 
234  // static methods
235 
241  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
242 
248  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
249 
250  // reimplemented from base classes
251 
252  QString layerType() const override;
253  void startRender( QgsSymbolRenderContext &context ) override;
254  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
255  QVariantMap properties() const override;
256  QgsSimpleMarkerSymbolLayer *clone() const override SIP_FACTORY;
257  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
258  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
259  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
260  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
261  QgsUnitTypes::RenderUnit outputUnit() const override;
262  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
263  QgsMapUnitScale mapUnitScale() const override;
264  bool usesMapUnits() const override;
265  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
266  QColor fillColor() const override { return mColor; }
267  void setFillColor( const QColor &color ) override { mColor = color; }
268  void setColor( const QColor &color ) override;
269  QColor color() const override;
270 
271  // new methods
272 
279  QColor strokeColor() const override { return mStrokeColor; }
280 
288  void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
289 
297  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
298 
307  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
308 
317  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
318 
328  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
329 
338  Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
339 
348  void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
349 
356  double strokeWidth() const { return mStrokeWidth; }
357 
365  void setStrokeWidth( double w ) { mStrokeWidth = w; }
366 
374  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit u ) { mStrokeWidthUnit = u; }
375 
382  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
383 
391  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
392 
399  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
400 
401  protected:
402 
409  void drawMarker( QPainter *p, QgsSymbolRenderContext &context );
410 
415  bool prepareCache( QgsSymbolRenderContext &context );
416 
418  QColor mStrokeColor;
420  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
422  double mStrokeWidth = 0;
428  Qt::PenJoinStyle mPenJoinStyle;
430  Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
432  QPen mPen;
434  QBrush mBrush;
435 
437  QImage mCache;
439  QPen mSelPen;
441  QBrush mSelBrush;
443  QImage mSelCache;
444 
449  bool mUsingCache = false;
450 
452  static const int MAXIMUM_CACHE_WIDTH = 3000;
453 
454  private:
455  // cppcheck-suppress unusedPrivateFunction
456  void draw( QgsSymbolRenderContext &context, QgsSimpleMarkerSymbolLayerBase::Shape shape, const QPolygonF &polygon, const QPainterPath &path ) override SIP_FORCE;
457 
458  double mCachedOpacity = 1.0;
459 
460 };
461 
470 {
471  public:
472 
481  double size = DEFAULT_SIMPLEMARKER_SIZE,
483  Qgis::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
484 
486 
492  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
493 
494  QString layerType() const override;
495  void startRender( QgsSymbolRenderContext &context ) override;
496  void stopRender( QgsSymbolRenderContext &context ) override;
497  QVariantMap properties() const override;
498  QgsFilledMarkerSymbolLayer *clone() const override SIP_FACTORY;
499  QgsSymbol *subSymbol() override;
500  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
501  double estimateMaxBleed( const QgsRenderContext &context ) const override;
502  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
503  bool hasDataDefinedProperties() const override;
504  void setColor( const QColor &c ) override;
505  QColor color() const override;
506  bool usesMapUnits() const override;
507 
508  private:
509 #ifdef SIP_RUN
511 #endif
512 
513  // cppcheck-suppress unusedPrivateFunction
514  void draw( QgsSymbolRenderContext &context, QgsSimpleMarkerSymbolLayerBase::Shape shape, const QPolygonF &polygon, const QPainterPath &path ) override SIP_FORCE;
515 
517  std::unique_ptr< QgsFillSymbol > mFill;
518 };
519 
521 
522 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
523 #define DEFAULT_SVGMARKER_ANGLE 0
524 
530 {
531  public:
533  QgsSvgMarkerSymbolLayer( const QString &path,
534  double size = DEFAULT_SVGMARKER_SIZE,
536  Qgis::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
537 
539 
540  // static stuff
541 
543  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
544  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
545 
551  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
552 
553  // implemented from base classes
554 
555  QString layerType() const override;
556 
557  void startRender( QgsSymbolRenderContext &context ) override;
558 
559  void stopRender( QgsSymbolRenderContext &context ) override;
560 
561  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
562 
563  QVariantMap properties() const override;
564  bool usesMapUnits() const override;
565 
566  QgsSvgMarkerSymbolLayer *clone() const override SIP_FACTORY;
567 
568  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
569 
574  QString path() const { return mPath; }
575 
581  void setPath( const QString &path );
582 
587  double defaultAspectRatio() const { return mDefaultAspectRatio; }
588 
594  double updateDefaultAspectRatio();
595 
600  bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
601 
608  bool setPreservedAspectRatio( bool par );
609 
615  double fixedAspectRatio() const { return mFixedAspectRatio; }
616 
623  void setFixedAspectRatio( double ratio ) { mFixedAspectRatio = ratio; }
624 
625  QColor fillColor() const override { return color(); }
626  void setFillColor( const QColor &color ) override { setColor( color ); }
627 
628  QColor strokeColor() const override { return mStrokeColor; }
629  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
630 
631  double strokeWidth() const { return mStrokeWidth; }
632  void setStrokeWidth( double w ) { mStrokeWidth = w; }
633 
638  QMap<QString, QgsProperty> parameters() const { return mParameters; }
639 
644  void setParameters( const QMap<QString, QgsProperty> &parameters );
645 
651  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
652 
657  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
658 
659  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
660  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
661 
662  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
663  QgsUnitTypes::RenderUnit outputUnit() const override;
664 
665  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
666  QgsMapUnitScale mapUnitScale() const override;
667 
668  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
669 
670  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
671 
672  void prepareExpressions( const QgsSymbolRenderContext &context ) override;
673 
674  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
675 
676  protected:
677 
684  double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
685 
686  QString mPath;
687 
689  double mDefaultAspectRatio = 0.0;
691  double mFixedAspectRatio = 0.0;
692  //param(fill), param(stroke), param(stroke-width) are going
693  //to be replaced in memory
694  bool mHasFillParam = false;
695  QColor mStrokeColor;
696  double mStrokeWidth;
697  QMap<QString, QgsProperty> mParameters;
698 
701 
702  private:
703  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
704  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
705 
706 };
707 
708 
710 
711 #define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE
712 #define DEFAULT_RASTERMARKER_ANGLE 0
713 
721 {
722  public:
724  QgsRasterMarkerSymbolLayer( const QString &path = QString(),
725  double size = DEFAULT_SVGMARKER_SIZE,
727  Qgis::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
728 
730 
731  // static stuff
732 
737  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
738 
744  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
745 
746  // implemented from base classes
747 
748  QString layerType() const override;
749 
750  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
751 
752  QVariantMap properties() const override;
753 
754  QgsRasterMarkerSymbolLayer *clone() const override SIP_FACTORY;
755  bool usesMapUnits() const override;
756 
763  double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
764 
769  QString path() const { return mPath; }
770 
776  void setPath( const QString &path );
777 
783  double opacity() const { return mOpacity; }
784 
790  void setOpacity( double opacity ) { mOpacity = opacity; }
791 
796  double defaultAspectRatio() const { return mDefaultAspectRatio; }
797 
803  double updateDefaultAspectRatio();
804 
809  bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
810 
817  bool setPreservedAspectRatio( bool par );
818 
824  double fixedAspectRatio() const { return mFixedAspectRatio; }
825 
832  void setFixedAspectRatio( double ratio ) { mFixedAspectRatio = ratio; }
833 
834  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
835  QgsMapUnitScale mapUnitScale() const override;
836 
837  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
838 
839  protected:
840 
841  QString mPath;
843  double mOpacity = 1.0;
845  double mDefaultAspectRatio = 0.0;
847  double mFixedAspectRatio = 0.0;
848 
849  private:
850  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
851  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
852 
853 };
854 
855 
857 
858 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
859 #define MM2POINT(x) ( (x) * 72 / 25.4 )
860 
861 #define DEFAULT_FONTMARKER_FONT "Dingbats"
862 #define DEFAULT_FONTMARKER_CHR QChar('A')
863 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
864 #define DEFAULT_FONTMARKER_COLOR QColor( 35, 35, 35 )
865 #define DEFAULT_FONTMARKER_BORDERCOLOR QColor(Qt::white)
866 #define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin
867 #define DEFAULT_FONTMARKER_ANGLE 0
868 
874 {
875  public:
876 
878  QgsFontMarkerSymbolLayer( const QString &fontFamily = DEFAULT_FONTMARKER_FONT,
879  QString chr = DEFAULT_FONTMARKER_CHR,
880  double pointSize = DEFAULT_FONTMARKER_SIZE,
881  const QColor &color = DEFAULT_FONTMARKER_COLOR,
882  double angle = DEFAULT_FONTMARKER_ANGLE );
883 
885 
886  // static stuff
887 
891  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
892 
896  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
897 
904  static void resolveFonts( const QVariantMap &properties, const QgsReadWriteContext &context );
905 
906  // implemented from base classes
907 
908  QString layerType() const override;
909 
910  void startRender( QgsSymbolRenderContext &context ) override;
911 
912  void stopRender( QgsSymbolRenderContext &context ) override;
913 
914  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
915 
916  QVariantMap properties() const override;
917 
918  QgsFontMarkerSymbolLayer *clone() const override SIP_FACTORY;
919 
920  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
921  bool usesMapUnits() const override;
922 
923  // new methods
924 
930  QString fontFamily() const { return mFontFamily; }
931 
937  void setFontFamily( const QString &family ) { mFontFamily = family; }
938 
945  QString fontStyle() const { return mFontStyle; }
946 
953  void setFontStyle( const QString &style ) { mFontStyle = style; }
954 
960  QString character() const { return mString; }
961 
967  void setCharacter( QString chr ) { mString = chr; }
968 
969  QColor strokeColor() const override { return mStrokeColor; }
970  void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
971 
981  double strokeWidth() const { return mStrokeWidth; }
982 
992  void setStrokeWidth( double width ) { mStrokeWidth = width; }
993 
1003  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
1004 
1013  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
1014 
1024  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
1025 
1035  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
1036 
1044  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1045 
1053  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1054 
1055  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
1056 
1057  private:
1058 
1059  QString mFontFamily;
1060  QString mFontStyle;
1061  QFont mFont;
1062  std::unique_ptr< QFontMetrics >mFontMetrics;
1063 
1064  QString mString;
1065 
1066  double mChrWidth = 0;
1067  QPointF mChrOffset;
1069  double mFontSizeScale = 1.0;
1070  double mOrigSize;
1071 
1072  QColor mStrokeColor;
1073  double mStrokeWidth;
1074  QgsUnitTypes::RenderUnit mStrokeWidthUnit;
1075  QgsMapUnitScale mStrokeWidthMapUnitScale;
1076  Qt::PenJoinStyle mPenJoinStyle;
1077 
1078  QPen mPen;
1079  QBrush mBrush;
1080 
1081  bool mUseCachedPath = false;
1082  QPainterPath mCachedPath;
1083 
1084  // If font has a zero (or nearly zero) size, we skip rendering altogether..
1085  bool mNonZeroFontSize = true;
1086 
1087  QString characterToRender( QgsSymbolRenderContext &context, QPointF &charOffset, double &charWidth );
1088  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
1089  double calculateSize( QgsSymbolRenderContext &context );
1090 };
1091 
1092 // clazy:excludeall=qstring-allocations
1093 
1094 #endif
1095 
1096 
ScaleMethod
Scale methods.
Definition: qgis.h:182
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:64
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:30
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
~QgsFilledMarkerSymbolLayer() override
~QgsFontMarkerSymbolLayer() override
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.
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.
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.
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.
~QgsRasterMarkerSymbolLayer() override
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.
The class is used as a container of context for various read/write operations on other objects.
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.
~QgsSimpleMarkerSymbolLayerBase() override
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)
@ QuarterArc
A line-only one quarter arc (since QGIS 3.20)
@ 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)
@ ThirdArc
A line-only one third arc (since QGIS 3.20)
@ 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)
@ HalfArc
A line-only half arc (since QGIS 3.20)
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.
~QgsSimpleMarkerSymbolLayer() override
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
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.
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)
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, 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)
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.
~QgsSvgMarkerSymbolLayer() override
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 void prepareExpressions(const QgsSymbolRenderContext &context)
Prepares all data defined property expressions for evaluation.
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
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
Helper functions for various unit types.
Definition: qgsunittypes.h:39
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
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