QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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 Qgis::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
36class QgsFillSymbol;
37class QgsPathResolver;
38
48{
49 public:
51 static QList< Qgis::MarkerShape > availableShapes();
52
59
69 );
70
72
77 Qgis::MarkerShape shape() const { return mShape; }
78
85
94 static Qgis::MarkerShape decodeShape( const QString &name, bool *ok = nullptr );
95
102 static QString encodeShape( Qgis::MarkerShape shape );
103
104 void startRender( QgsSymbolRenderContext &context ) override;
105 void stopRender( QgsSymbolRenderContext &context ) override;
106 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
107 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
108
109 protected:
113 bool prepareMarkerShape( Qgis::MarkerShape shape );
114
118 bool prepareMarkerPath( Qgis::MarkerShape symbol );
119
126 bool shapeToPolygon( Qgis::MarkerShape shape, QPolygonF &polygon ) const;
127
134 double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
135
144 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
145
147 QPolygonF mPolygon;
148
150 QPainterPath mPath;
151
154
155 private:
164 virtual void draw( QgsSymbolRenderContext &context, Qgis::MarkerShape shape, const QPolygonF &polygon, const QPainterPath &path ) = 0 SIP_FORCE;
165};
166
173{
174 public:
190 const QColor &color = DEFAULT_SIMPLEMARKER_COLOR,
193 );
194
196
197 // static methods
198
204 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
205
211 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
212
213 // reimplemented from base classes
214
215 QString layerType() const override;
216 Qgis::SymbolLayerFlags flags() const override;
217 void startRender( QgsSymbolRenderContext &context ) override;
218 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
219 QVariantMap properties() const override;
221 Q_DECL_DEPRECATED void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
222 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
223
224 Q_DECL_DEPRECATED void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
225 bool writeSldMarker( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
226 QString ogrFeatureStyle( double mmScaleFactor, double mapUnitScaleFactor ) const override;
227 bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
228 void setOutputUnit( Qgis::RenderUnit unit ) override;
229 Qgis::RenderUnit outputUnit() const override;
230 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
231 QgsMapUnitScale mapUnitScale() const override;
232 bool usesMapUnits() const override;
233 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
234 QColor fillColor() const override { return mColor; }
235 void setFillColor( const QColor &color ) override { mColor = color; }
236 void setColor( const QColor &color ) override;
237 QColor color() const override;
238
239 // new methods
240
247 QColor strokeColor() const override { return mStrokeColor; }
248
256 void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
257
264 Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
265
274
282 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
283
292 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
293
302 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
303
312 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
313
320 double strokeWidth() const { return mStrokeWidth; }
321
329 void setStrokeWidth( double w ) { mStrokeWidth = w; }
330
339
347
356
364
365 protected:
372 void drawMarker( QPainter *p, QgsSymbolRenderContext &context );
373
378 bool prepareCache( QgsSymbolRenderContext &context );
379
383 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
385 double mStrokeWidth = 0;
391 Qt::PenJoinStyle mPenJoinStyle;
393 Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
395 QPen mPen;
397 QBrush mBrush;
398
400 QImage mCache;
404 QBrush mSelBrush;
406 QImage mSelCache;
407
412 bool mUsingCache = false;
413
415 static const int MAXIMUM_CACHE_WIDTH = 3000;
416
417 private:
418 // cppcheck-suppress unusedPrivateFunction
419 void draw( QgsSymbolRenderContext &context, Qgis::MarkerShape shape, const QPolygonF &polygon, const QPainterPath &path ) override SIP_FORCE;
420
421 double mCachedOpacity = 1.0;
422};
423
431{
432 public:
442 );
443
445
451 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
452
453 QString layerType() const override;
454 void startRender( QgsSymbolRenderContext &context ) override;
455 void stopRender( QgsSymbolRenderContext &context ) override;
456 void startFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
457 void stopFeatureRender( const QgsFeature &feature, QgsRenderContext &context ) override;
458 QVariantMap properties() const override;
460 QgsSymbol *subSymbol() override;
461 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
462 double estimateMaxBleed( const QgsRenderContext &context ) const override;
463 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
464 bool hasDataDefinedProperties() const override;
465 void setColor( const QColor &c ) override;
466 QColor color() const override;
467 bool usesMapUnits() const override;
468 void setOutputUnit( Qgis::RenderUnit unit ) override;
469
470 private:
471#ifdef SIP_RUN
473#endif
474
475 // cppcheck-suppress unusedPrivateFunction
476 void draw( QgsSymbolRenderContext &context, Qgis::MarkerShape shape, const QPolygonF &polygon, const QPainterPath &path ) override SIP_FORCE;
477
479 std::unique_ptr< QgsFillSymbol > mFill;
480};
481
483
484#define DEFAULT_SVGMARKER_SIZE ( 2 * Qgis::DEFAULT_POINT_SIZE )
485#define DEFAULT_SVGMARKER_ANGLE 0
486
493{
494 public:
498
500
501 // static stuff
502
504 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
505 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
506
511 static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
512
513 // implemented from base classes
514
515 QString layerType() const override;
516 Qgis::SymbolLayerFlags flags() const override;
517 void startRender( QgsSymbolRenderContext &context ) override;
518 void stopRender( QgsSymbolRenderContext &context ) override;
519 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
520 QVariantMap properties() const override;
521 bool usesMapUnits() const override;
522 QgsSvgMarkerSymbolLayer *clone() const override SIP_FACTORY;
523 Q_DECL_DEPRECATED void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
524 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
525 Q_DECL_DEPRECATED void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
526 bool writeSldMarker( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
527
532 QString path() const { return mPath; }
533
539 void setPath( const QString &path );
540
545 double defaultAspectRatio() const { return mDefaultAspectRatio; }
546
552 double updateDefaultAspectRatio();
553
558 bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
559
566 bool setPreservedAspectRatio( bool par );
567
574 double fixedAspectRatio() const { return mFixedAspectRatio; }
575
583 void setFixedAspectRatio( double ratio ) { mFixedAspectRatio = ratio; }
584
585 QColor fillColor() const override { return color(); }
586 void setFillColor( const QColor &color ) override { setColor( color ); }
587
588 QColor strokeColor() const override { return mStrokeColor; }
589 void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
590
591 double strokeWidth() const { return mStrokeWidth; }
592 void setStrokeWidth( double w ) { mStrokeWidth = w; }
593
598 QMap<QString, QgsProperty> parameters() const { return mParameters; }
599
604 void setParameters( const QMap<QString, QgsProperty> &parameters );
605
612
618
621
622 void setOutputUnit( Qgis::RenderUnit unit ) override;
623 Qgis::RenderUnit outputUnit() const override;
624
625 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
626 QgsMapUnitScale mapUnitScale() const override;
627
628 bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
629
630 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
631
632 void prepareExpressions( const QgsSymbolRenderContext &context ) override;
633
634 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
635
636 protected:
643 double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
644
645 QString mPath;
646
650 double mFixedAspectRatio = 0.0;
651 //param(fill), param(stroke), param(stroke-width) are going
652 //to be replaced in memory
653 bool mHasFillParam = false;
656 QMap<QString, QgsProperty> mParameters;
657
660
661 private:
662 double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
663 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
664};
665
666
668
669#define DEFAULT_RASTERMARKER_SIZE ( 2 * Qgis::DEFAULT_POINT_SIZE )
670#define DEFAULT_RASTERMARKER_ANGLE 0
671
679{
680 public:
683
685
686 // static stuff
687
692 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
693
701 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
702
707 static void resolvePaths( QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving );
708
709 // implemented from base classes
710
711 QString layerType() const override;
712 Qgis::SymbolLayerFlags flags() const override;
713 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
714 QVariantMap properties() const override;
716 bool usesMapUnits() const override;
717 QColor color() const override;
718 Q_DECL_DEPRECATED void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
719 bool writeSldMarker( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
720
727 double calculateAspectRatio( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio ) const;
728
733 QString path() const { return mPath; }
734
740 void setPath( const QString &path );
741
747 double opacity() const { return mOpacity; }
748
754 void setOpacity( double opacity ) { mOpacity = opacity; }
755
760 double defaultAspectRatio() const { return mDefaultAspectRatio; }
761
767 double updateDefaultAspectRatio();
768
773 bool preservedAspectRatio() const { return mFixedAspectRatio <= 0.0; }
774
781 bool setPreservedAspectRatio( bool par );
782
789 double fixedAspectRatio() const { return mFixedAspectRatio; }
790
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:
811 void setCommonProperties( const QVariantMap &properties );
812
819
825 virtual QImage fetchImage( QgsRenderContext &context, const QString &path, QSize size, bool preserveAspectRatio, double opacity ) const SIP_SKIP;
826
827 QString mPath;
829 double mOpacity = 1.0;
833 double mFixedAspectRatio = 0.0;
834
835 private:
836 double calculateSize( QgsSymbolRenderContext &context, bool &hasDataDefinedSize ) const;
837 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, QPointF &offset, double &angle ) const;
838};
839
840
842
843#define POINT2MM( x ) ( ( x ) * 25.4 / 72 ) // point is 1/72 of inch
844#define MM2POINT( x ) ( ( x ) * 72 / 25.4 )
845
846#define DEFAULT_FONTMARKER_FONT "Dingbats"
847#define DEFAULT_FONTMARKER_CHR QChar( 'A' )
848#define DEFAULT_FONTMARKER_SIZE POINT2MM( 12 )
849#define DEFAULT_FONTMARKER_COLOR QColor( 35, 35, 35 )
850#define DEFAULT_FONTMARKER_BORDERCOLOR QColor( Qt::white )
851#define DEFAULT_FONTMARKER_JOINSTYLE Qt::MiterJoin
852#define DEFAULT_FONTMARKER_ANGLE 0
853
860{
861 public:
864 const QString &fontFamily = DEFAULT_FONTMARKER_FONT,
865 QString chr = DEFAULT_FONTMARKER_CHR,
866 double pointSize = DEFAULT_FONTMARKER_SIZE,
867 const QColor &color = DEFAULT_FONTMARKER_COLOR,
869 );
870
872
873 // static stuff
874
878 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
879
883 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
884
891 static void resolveFonts( const QVariantMap &properties, const QgsReadWriteContext &context );
892
893 // implemented from base classes
894
895 QString layerType() const override;
896 Qgis::SymbolLayerFlags flags() const override;
897
898 void startRender( QgsSymbolRenderContext &context ) override;
899
900 void stopRender( QgsSymbolRenderContext &context ) override;
901
902 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
903
904 QVariantMap properties() const override;
905
907 Q_DECL_DEPRECATED void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
908 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
909 Q_DECL_DEPRECATED void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
910 bool writeSldMarker( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
911 bool usesMapUnits() const override;
912 void setOutputUnit( Qgis::RenderUnit unit ) override;
913
914 // new methods
915
921 QString fontFamily() const { return mFontFamily; }
922
928 void setFontFamily( const QString &family ) { mFontFamily = family; }
929
936 QString fontStyle() const { return mFontStyle; }
937
944 void setFontStyle( const QString &style ) { mFontStyle = style; }
945
951 QString character() const { return mString; }
952
958 void setCharacter( QString chr ) { mString = chr; }
959
960 QColor strokeColor() const override { return mStrokeColor; }
961 void setStrokeColor( const QColor &color ) override { mStrokeColor = color; }
962
971 double strokeWidth() const { return mStrokeWidth; }
972
981 void setStrokeWidth( double width ) { mStrokeWidth = width; }
982
991 Qgis::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
992
1000 void setStrokeWidthUnit( Qgis::RenderUnit unit ) { mStrokeWidthUnit = unit; }
1001
1010 const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
1011
1020 void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
1021
1028 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
1029
1036 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
1037
1038 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
1039
1040 private:
1041 QString mFontFamily;
1042 QString mFontStyle;
1043 QFont mFont;
1044 std::unique_ptr< QFontMetrics > mFontMetrics;
1045
1046 QString mString;
1047
1048 double mChrWidth = 0;
1049 QPointF mChrOffset;
1051 double mFontSizeScale = 1.0;
1052 double mOrigSize;
1053
1054 QColor mStrokeColor;
1055 double mStrokeWidth;
1056 Qgis::RenderUnit mStrokeWidthUnit;
1057 QgsMapUnitScale mStrokeWidthMapUnitScale;
1058 Qt::PenJoinStyle mPenJoinStyle;
1059
1060 QPen mPen;
1061 QBrush mBrush;
1062
1063 bool mUseCachedPath = false;
1064 QPainterPath mCachedPath;
1065
1066 // If font has a zero (or nearly zero) size, we skip rendering altogether..
1067 bool mNonZeroFontSize = true;
1068
1069 QString characterToRender( QgsSymbolRenderContext &context, QPointF &charOffset, double &charWidth );
1070 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
1071 double calculateSize( QgsSymbolRenderContext &context );
1072};
1073
1074
1086{
1087 public:
1091 QgsAnimatedMarkerSymbolLayer( const QString &path = QString(), double size = DEFAULT_RASTERMARKER_SIZE, double angle = DEFAULT_RASTERMARKER_ANGLE );
1092
1094
1095 // static stuff
1096
1100 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember
1101
1102 // implemented from base classes
1103
1104 QString layerType() const override;
1105 QVariantMap properties() const override;
1107
1113 void setFrameRate( double rate ) { mFrameRateFps = rate; }
1114
1120 double frameRate() const { return mFrameRateFps; }
1121
1122 void startRender( QgsSymbolRenderContext &context ) override;
1123
1124 protected:
1125 QImage fetchImage( QgsRenderContext &context, const QString &path, QSize size, bool preserveAspectRatio, double opacity ) const override SIP_SKIP;
1126
1127 private:
1128 double mFrameRateFps = 10;
1129 bool mStaticPath = false;
1130 mutable QSet< QString > mPreparedPaths;
1131};
1132
1133// clazy:excludeall=qstring-allocations
1134
1135#endif
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
ScaleMethod
Scale methods.
Definition qgis.h:650
MarkerShape
Marker shapes.
Definition qgis.h:3194
@ Circle
Circle.
Definition qgis.h:3203
RenderUnit
Rendering size units.
Definition qgis.h:5340
@ Millimeters
Millimeters.
Definition qgis.h:5341
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsAnimatedMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
~QgsAnimatedMarkerSymbolLayer() override
QgsAnimatedMarkerSymbolLayer(const QString &path=QString(), double size=DEFAULT_RASTERMARKER_SIZE, double angle=DEFAULT_RASTERMARKER_ANGLE)
Constructor for animated marker symbol layer using the specified source image path.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates an animated marker symbol layer from a string map of properties.
QString layerType() const override
Returns a string that represents this layer type.
void setFrameRate(double rate)
Sets the marker frame rate in frame per second.
double frameRate() const
Returns the marker frame rate in frame per second.
Exports QGIS layers to the DXF format.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QColor color() const override
Returns the "representative" color of the symbol layer.
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called before the layer will be rendered for a particular feature.
~QgsFilledMarkerSymbolLayer() override
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setColor(const QColor &c) override
Sets the "representative" color for the symbol layer.
QString layerType() const override
Returns a string that represents this layer type.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsFilledMarkerSymbolLayer.
QgsFilledMarkerSymbolLayer(Qgis::MarkerShape shape=Qgis::MarkerShape::Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsFilledMarkerSymbolLayer.
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the stroke width unit.
~QgsFontMarkerSymbolLayer() override
void setStrokeColor(const QColor &color) override
Sets the stroke color for the symbol layer.
QgsFontMarkerSymbolLayer(const QString &fontFamily=DEFAULT_FONTMARKER_FONT, QString chr=DEFAULT_FONTMARKER_CHR, double pointSize=DEFAULT_FONTMARKER_SIZE, const QColor &color=DEFAULT_FONTMARKER_COLOR, double angle=DEFAULT_FONTMARKER_ANGLE)
Constructs a font marker symbol layer.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
Qgis::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
double strokeWidth() const
Returns the marker's stroke width.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
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.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void setStrokeWidth(double width)
Set's the marker's stroke width.
static void resolveFonts(const QVariantMap &properties, const QgsReadWriteContext &context)
Resolves fonts from a properties map, raising warnings in the specified context if the required fonts...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsFontMarkerSymbolLayer from an SLD XML element.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QString layerType() const override
Returns a string that represents this layer type.
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
QString character() const
Returns the character(s) used when rendering points.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsFontMarkerSymbolLayer from a property map (see properties()).
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
Struct for storing maximum and minimum scales for measurements in map units.
QgsMarkerSymbolLayer(const QgsMarkerSymbolLayer &other)
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
Qgis::RenderUnit outputUnit() const override
Returns 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
double size() const
Returns the symbol size.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets 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.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Resolves relative paths into absolute paths and vice versa.
Raster marker symbol layer class.
double mFixedAspectRatio
The marker fixed aspect ratio.
QColor color() const override
Returns the "representative" color of the symbol layer.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsRasterMarkerSymbolLayer from an SLD XML element.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setOpacity(double opacity)
Set the marker opacity.
QString path() const
Returns the marker raster image path.
double calculateAspectRatio(QgsSymbolRenderContext &context, double scaledSize, bool &hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
QgsRasterMarkerSymbolLayer(const QString &path=QString(), double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs raster marker symbol layer with picture from given absolute path to a raster image file.
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
QgsRasterMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
static void resolvePaths(QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
~QgsRasterMarkerSymbolLayer() override
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a raster marker symbol layer from a string map of properties.
double mOpacity
The marker default opacity.
double mDefaultAspectRatio
The marker default aspect ratio.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QString layerType() const override
Returns a string that represents this layer type.
double opacity() const
Returns the marker opacity.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
Qgis::MarkerShape mShape
Symbol shape.
QPainterPath mPath
Painter path representing shape. If mPolygon is empty then the shape is stored in mPath.
static QList< Qgis::MarkerShape > availableShapes()
Returns a list of all available shape types.
~QgsSimpleMarkerSymbolLayerBase() override
static bool shapeIsFilled(Qgis::MarkerShape shape)
Returns true if a symbol shape has a fill.
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.
QgsSimpleMarkerSymbolLayerBase(Qgis::MarkerShape shape=Qgis::MarkerShape::Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructor for QgsSimpleMarkerSymbolLayerBase.
void setShape(Qgis::MarkerShape shape)
Sets the rendered marker shape.
QPen mSelPen
QPen to use as stroke of selected symbols.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
QImage mSelCache
Cached image of selected marker, if using cached version.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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
Sets the fill color for the symbol layer.
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.
Qgis::RenderUnit mStrokeWidthUnit
Stroke width units.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsSimpleMarkerSymbolLayer.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void setMapUnitScale(const QgsMapUnitScale &scale) override
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setStrokeWidthUnit(Qgis::RenderUnit u)
Sets the unit for the width of the marker's stroke.
QColor color() const override
Returns the "representative" color of the symbol layer.
QgsMapUnitScale mapUnitScale() const override
Qt::PenStyle mStrokeStyle
Stroke style.
QgsSimpleMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSimpleMarkerSymbolLayer from an SLD XML element.
~QgsSimpleMarkerSymbolLayer() override
Qt::PenCapStyle mPenCapStyle
Stroke pen cap style.
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
QString layerType() const override
Returns a string that represents this layer type.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
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).
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker's stroke.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QColor fillColor() const override
Returns the fill color for the symbol layer.
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).
bool mUsingCache
true if using cached images of markers for drawing.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
Qgis::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
static const int MAXIMUM_CACHE_WIDTH
Maximum width/height of cache image.
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
QgsMapUnitScale mStrokeWidthMapUnitScale
Stroke width map unit scale.
QgsSimpleMarkerSymbolLayer(Qgis::MarkerShape shape=Qgis::MarkerShape::Circle, double size=DEFAULT_SIMPLEMARKER_SIZE, double angle=DEFAULT_SIMPLEMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD, const QColor &color=DEFAULT_SIMPLEMARKER_COLOR, const QColor &strokeColor=DEFAULT_SIMPLEMARKER_BORDERCOLOR, Qt::PenJoinStyle penJoinStyle=DEFAULT_SIMPLEMARKER_JOINSTYLE)
Constructor for QgsSimpleMarkerSymbolLayer.
double strokeWidth() const
Returns the width of the marker's stroke.
Qt::PenJoinStyle mPenJoinStyle
Stroke pen join style.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QColor fillColor() const override
Returns the fill color for the symbol layer.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol.
double mDefaultAspectRatio
The marker default aspect ratio.
QString layerType() const override
Returns a string that represents this layer type.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QString path() const
Returns the marker SVG path.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
QMap< QString, QgsProperty > mParameters
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
static QgsSymbolLayer * createFromSld(QDomElement &element)
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the stroke width.
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
Sets the stroke color for the symbol layer.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.
QgsSvgMarkerSymbolLayer(const QString &path, double size=DEFAULT_SVGMARKER_SIZE, double angle=DEFAULT_SVGMARKER_ANGLE, Qgis::ScaleMethod scaleMethod=DEFAULT_SCALE_METHOD)
Constructs SVG marker symbol layer with picture from given absolute path to a SVG file.
Qgis::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
~QgsSvgMarkerSymbolLayer() override
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
static void resolvePaths(QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
QgsMapUnitScale mStrokeWidthMapUnitScale
double mFixedAspectRatio
The marker fixed aspect ratio.
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.
void copyCommonProperties(QgsSymbolLayer *destLayer) const
Copies all common base class properties from this layer to another symbol layer.
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)
Sets the "representative" color for the symbol layer.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
QgsSymbolLayer(const QgsSymbolLayer &other)
Encapsulates the context in which a symbol is being rendered.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:227
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_DEPRECATED
Definition qgis_sip.h:113
#define SIP_FORCE
Definition qgis_sip.h:138
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
#define DEFAULT_RASTERMARKER_ANGLE
#define DEFAULT_RASTERMARKER_SIZE
#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