QGIS API Documentation  3.23.0-Master (b5237dafc3)
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  static QList< Qgis::MarkerShape > availableShapes();
53 
59  static bool shapeIsFilled( Qgis::MarkerShape shape );
60 
69  double size = DEFAULT_SIMPLEMARKER_SIZE,
72 
74 
79  Qgis::MarkerShape shape() const { return mShape; }
80 
86  void setShape( Qgis::MarkerShape shape ) { mShape = shape; }
87 
96  static Qgis::MarkerShape decodeShape( const QString &name, bool *ok = nullptr );
97 
104  static QString encodeShape( Qgis::MarkerShape shape );
105 
106  void startRender( QgsSymbolRenderContext &context ) override;
107  void stopRender( QgsSymbolRenderContext &context ) override;
108  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
109  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
110 
111  protected:
112 
116  bool prepareMarkerShape( Qgis::MarkerShape shape );
117 
121  bool prepareMarkerPath( Qgis::MarkerShape symbol );
122 
129  bool shapeToPolygon( Qgis::MarkerShape shape, QPolygonF &polygon ) const;
130 
137  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
138 
147  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
148 
150  QPolygonF mPolygon;
151 
153  QPainterPath mPath;
154 
157 
158  private:
159 
168  virtual void draw( QgsSymbolRenderContext &context, Qgis::MarkerShape shape, const QPolygonF &polygon, const QPainterPath &path ) = 0 SIP_FORCE;
169 };
170 
177 {
178  public:
179 
191  double size = DEFAULT_SIMPLEMARKER_SIZE,
194  const QColor &color = DEFAULT_SIMPLEMARKER_COLOR,
195  const QColor &strokeColor = DEFAULT_SIMPLEMARKER_BORDERCOLOR,
196  Qt::PenJoinStyle penJoinStyle = DEFAULT_SIMPLEMARKER_JOINSTYLE );
197 
199 
200  // static methods
201 
207  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
208 
214  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
215 
216  // reimplemented from base classes
217 
218  QString layerType() const override;
219  void startRender( QgsSymbolRenderContext &context ) override;
220  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
221  QVariantMap properties() const override;
222  QgsSimpleMarkerSymbolLayer *clone() const override SIP_FACTORY;
223  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
224  QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
225  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
226  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
227  QgsUnitTypes::RenderUnit outputUnit() const override;
228  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
229  QgsMapUnitScale mapUnitScale() const override;
230  bool usesMapUnits() const override;
231  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
232  QColor fillColor() const override { return mColor; }
233  void setFillColor( const QColor &color ) override { mColor = color; }
234  void setColor( const QColor &color ) override;
235  QColor color() const override;
236 
237  // new methods
238 
245  QColor strokeColor() const override { return mStrokeColor; }
246 
254  void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
255 
263  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
264 
273  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
274 
283  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
284 
294  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
295 
304  Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
305 
314  void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
315 
322  double strokeWidth() const { return mStrokeWidth; }
323 
331  void setStrokeWidth( double w ) { mStrokeWidth = w; }
332 
340  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit u ) { mStrokeWidthUnit = u; }
341 
348  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
349 
357  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
358 
365  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
366 
367  protected:
368 
375  void drawMarker( QPainter *p, QgsSymbolRenderContext &context );
376 
381  bool prepareCache( QgsSymbolRenderContext &context );
382 
384  QColor mStrokeColor;
386  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
388  double mStrokeWidth = 0;
394  Qt::PenJoinStyle mPenJoinStyle;
396  Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
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, Qgis::MarkerShape 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,
449  Qgis::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
450 
452 
458  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
459 
460  QString layerType() const override;
461  void startRender( QgsSymbolRenderContext &context ) override;
462  void stopRender( QgsSymbolRenderContext &context ) override;
463  QVariantMap properties() const override;
464  QgsFilledMarkerSymbolLayer *clone() const override SIP_FACTORY;
465  QgsSymbol *subSymbol() override;
466  bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
467  double estimateMaxBleed( const QgsRenderContext &context ) const override;
468  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
469  bool hasDataDefinedProperties() const override;
470  void setColor( const QColor &c ) override;
471  QColor color() const override;
472  bool usesMapUnits() const override;
473 
474  private:
475 #ifdef SIP_RUN
477 #endif
478 
479  // cppcheck-suppress unusedPrivateFunction
480  void draw( QgsSymbolRenderContext &context, Qgis::MarkerShape shape, const QPolygonF &polygon, const QPainterPath &path ) override SIP_FORCE;
481 
483  std::unique_ptr< QgsFillSymbol > mFill;
484 };
485 
487 
488 #define DEFAULT_SVGMARKER_SIZE 2*DEFAULT_POINT_SIZE
489 #define DEFAULT_SVGMARKER_ANGLE 0
490 
496 {
497  public:
499  QgsSvgMarkerSymbolLayer( const QString &path,
500  double size = DEFAULT_SVGMARKER_SIZE,
502  Qgis::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
503 
505 
506  // static stuff
507 
509  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
510  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
511 
517  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
518 
519  // implemented from base classes
520 
521  QString layerType() const override;
522 
523  void startRender( QgsSymbolRenderContext &context ) override;
524 
525  void stopRender( QgsSymbolRenderContext &context ) override;
526 
527  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
528 
529  QVariantMap properties() const override;
530  bool usesMapUnits() const override;
531 
532  QgsSvgMarkerSymbolLayer *clone() const override SIP_FACTORY;
533 
534  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
535 
540  QString path() const { return mPath; }
541 
547  void setPath( const QString &path );
548 
553  double defaultAspectRatio() const { return mDefaultAspectRatio; }
554 
560  double updateDefaultAspectRatio();
561 
566  bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
567 
574  bool setPreservedAspectRatio( bool par );
575 
581  double fixedAspectRatio() const { return mFixedAspectRatio; }
582 
589  void setFixedAspectRatio( double ratio ) { mFixedAspectRatio = ratio; }
590 
591  QColor fillColor() const override { return color(); }
592  void setFillColor( const QColor &color ) override { setColor( color ); }
593 
594  QColor strokeColor() const override { return mStrokeColor; }
595  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
596 
597  double strokeWidth() const { return mStrokeWidth; }
598  void setStrokeWidth( double w ) { mStrokeWidth = w; }
599 
604  QMap<QString, QgsProperty> parameters() const { return mParameters; }
605 
610  void setParameters( const QMap<QString, QgsProperty> &parameters );
611 
617  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
618 
623  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
624 
625  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
626  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
627 
628  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
629  QgsUnitTypes::RenderUnit outputUnit() const override;
630 
631  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
632  QgsMapUnitScale mapUnitScale() const override;
633 
634  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
635 
636  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
637 
638  void prepareExpressions( const QgsSymbolRenderContext &context ) override;
639 
640  QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
641 
642  protected:
643 
650  double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
651 
652  QString mPath;
653 
655  double mDefaultAspectRatio = 0.0;
657  double mFixedAspectRatio = 0.0;
658  //param(fill), param(stroke), param(stroke-width) are going
659  //to be replaced in memory
660  bool mHasFillParam = false;
661  QColor mStrokeColor;
662  double mStrokeWidth;
663  QMap<QString, QgsProperty> mParameters;
664 
667 
668  private:
669  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
670  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
671 
672 };
673 
674 
676 
677 #define DEFAULT_RASTERMARKER_SIZE 2*DEFAULT_POINT_SIZE
678 #define DEFAULT_RASTERMARKER_ANGLE 0
679 
687 {
688  public:
690  QgsRasterMarkerSymbolLayer( const QString &path = QString(),
691  double size = DEFAULT_SVGMARKER_SIZE,
693  Qgis::ScaleMethod scaleMethod = DEFAULT_SCALE_METHOD );
694 
696 
697  // static stuff
698 
703  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
704 
710  static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
711 
712  // implemented from base classes
713 
714  QString layerType() const override;
715 
716  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
717 
718  QVariantMap properties() const override;
719 
720  QgsRasterMarkerSymbolLayer *clone() const override SIP_FACTORY;
721  bool usesMapUnits() const override;
722 
729  double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
730 
735  QString path() const { return mPath; }
736 
742  void setPath( const QString &path );
743 
749  double opacity() const { return mOpacity; }
750 
756  void setOpacity( double opacity ) { mOpacity = opacity; }
757 
762  double defaultAspectRatio() const { return mDefaultAspectRatio; }
763 
769  double updateDefaultAspectRatio();
770 
775  bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
776 
783  bool setPreservedAspectRatio( bool par );
784 
790  double fixedAspectRatio() const { return mFixedAspectRatio; }
791 
798  void setFixedAspectRatio( double ratio ) { mFixedAspectRatio = ratio; }
799 
800  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
801  QgsMapUnitScale mapUnitScale() const override;
802 
803  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
804 
805  protected:
806 
807  QString mPath;
809  double mOpacity = 1.0;
811  double mDefaultAspectRatio = 0.0;
813  double mFixedAspectRatio = 0.0;
814 
815  private:
816  double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
817  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
818 
819 };
820 
821 
823 
824 #define POINT2MM(x) ( (x) * 25.4 / 72 ) // point is 1/72 of inch
825 #define MM2POINT(x) ( (x) * 72 / 25.4 )
826 
827 #define DEFAULT_FONTMARKER_FONT "Dingbats"
828 #define DEFAULT_FONTMARKER_CHR QChar('A')
829 #define DEFAULT_FONTMARKER_SIZE POINT2MM(12)
830 #define DEFAULT_FONTMARKER_COLOR QColor( 35, 35, 35 )
831 #define DEFAULT_FONTMARKER_BORDERCOLOR QColor(Qt::white)
832 #define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin
833 #define DEFAULT_FONTMARKER_ANGLE 0
834 
840 {
841  public:
842 
844  QgsFontMarkerSymbolLayer( const QString &fontFamily = DEFAULT_FONTMARKER_FONT,
845  QString chr = DEFAULT_FONTMARKER_CHR,
846  double pointSize = DEFAULT_FONTMARKER_SIZE,
847  const QColor &color = DEFAULT_FONTMARKER_COLOR,
848  double angle = DEFAULT_FONTMARKER_ANGLE );
849 
851 
852  // static stuff
853 
857  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
858 
862  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
863 
870  static void resolveFonts( const QVariantMap &properties, const QgsReadWriteContext &context );
871 
872  // implemented from base classes
873 
874  QString layerType() const override;
875 
876  void startRender( QgsSymbolRenderContext &context ) override;
877 
878  void stopRender( QgsSymbolRenderContext &context ) override;
879 
880  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
881 
882  QVariantMap properties() const override;
883 
884  QgsFontMarkerSymbolLayer *clone() const override SIP_FACTORY;
885 
886  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
887  bool usesMapUnits() const override;
888 
889  // new methods
890 
896  QString fontFamily() const { return mFontFamily; }
897 
903  void setFontFamily( const QString &family ) { mFontFamily = family; }
904 
911  QString fontStyle() const { return mFontStyle; }
912 
919  void setFontStyle( const QString &style ) { mFontStyle = style; }
920 
926  QString character() const { return mString; }
927 
933  void setCharacter( QString chr ) { mString = chr; }
934 
935  QColor strokeColor() const override { return mStrokeColor; }
936  void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
937 
947  double strokeWidth() const { return mStrokeWidth; }
948 
958  void setStrokeWidth( double width ) { mStrokeWidth = width; }
959 
969  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
970 
979  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
980 
990  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
991 
1001  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
1002 
1010  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1011 
1019  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1020 
1021  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
1022 
1023  private:
1024 
1025  QString mFontFamily;
1026  QString mFontStyle;
1027  QFont mFont;
1028  std::unique_ptr< QFontMetrics >mFontMetrics;
1029 
1030  QString mString;
1031 
1032  double mChrWidth = 0;
1033  QPointF mChrOffset;
1035  double mFontSizeScale = 1.0;
1036  double mOrigSize;
1037 
1038  QColor mStrokeColor;
1039  double mStrokeWidth;
1040  QgsUnitTypes::RenderUnit mStrokeWidthUnit;
1041  QgsMapUnitScale mStrokeWidthMapUnitScale;
1042  Qt::PenJoinStyle mPenJoinStyle;
1043 
1044  QPen mPen;
1045  QBrush mBrush;
1046 
1047  bool mUseCachedPath = false;
1048  QPainterPath mCachedPath;
1049 
1050  // If font has a zero (or nearly zero) size, we skip rendering altogether..
1051  bool mNonZeroFontSize = true;
1052 
1053  QString characterToRender( QgsSymbolRenderContext &context, QPointF &charOffset, double &charWidth );
1054  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
1055  double calculateSize( QgsSymbolRenderContext &context );
1056 };
1057 
1058 // clazy:excludeall=qstring-allocations
1059 
1060 #endif
1061 
1062 
ScaleMethod
Scale methods.
Definition: qgis.h:197
MarkerShape
Marker shapes.
Definition: qgis.h:1022
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:65
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.
Qgis::MarkerShape mShape
Symbol shape.
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath.
~QgsSimpleMarkerSymbolLayerBase() override
QPolygonF mPolygon
Polygon of points in shape. If polygon is empty then shape is using mPath.
Qgis::MarkerShape shape() const
Returns the shape for the rendered marker symbol.
void setShape(Qgis::MarkerShape shape)
Sets the rendered marker shape.
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