QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsellipsesymbollayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsellipsesymbollayer.h
3  ---------------------
4  begin : June 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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 #ifndef QGSELLIPSESYMBOLLAYER_H
16 #define QGSELLIPSESYMBOLLAYER_H
17 
18 #define DEFAULT_ELLIPSE_JOINSTYLE Qt::MiterJoin
19 
20 #include "qgis_core.h"
21 #include "qgis.h"
22 #include "qgsmarkersymbollayer.h"
23 #include <QPainterPath>
24 
25 class QgsExpression;
26 
32 {
33  public:
34 
36  enum Shape
37  {
48  };
49 
51  static QList< QgsEllipseSymbolLayer::Shape > availableShapes();
52 
58  static bool shapeIsFilled( const QgsEllipseSymbolLayer::Shape &shape );
59 
61  ~QgsEllipseSymbolLayer() override;
62 
64  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
65  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
66 
67  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
68  QString layerType() const override;
69  void startRender( QgsSymbolRenderContext &context ) override;
70  void stopRender( QgsSymbolRenderContext &context ) override;
71  QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
72  QVariantMap properties() const override;
73 
74  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
75  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
76 
77  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
78 
85  Q_DECL_DEPRECATED void setSymbolName( const QString &name ) SIP_DEPRECATED { mShape = decodeShape( name ); }
86 
93  Q_DECL_DEPRECATED QString symbolName() const SIP_DEPRECATED { return encodeShape( mShape ); }
94 
100  QgsEllipseSymbolLayer::Shape shape() const { return mShape; }
101 
108  void setShape( QgsEllipseSymbolLayer::Shape shape ) { mShape = shape; }
109 
119  static QgsEllipseSymbolLayer::Shape decodeShape( const QString &name, bool *ok = nullptr );
120 
128  static QString encodeShape( QgsEllipseSymbolLayer::Shape shape );
129 
130  void setSize( double size ) override;
131 
132  void setSymbolWidth( double w );
133  double symbolWidth() const { return mSymbolWidth; }
134 
135  void setSymbolHeight( double h );
136  double symbolHeight() const { return mSymbolHeight; }
137 
138  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
139  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
140 
145  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
146 
151  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
152 
161  Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
162 
171  void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
172 
173  void setStrokeWidth( double w ) { mStrokeWidth = w; }
174  double strokeWidth() const { return mStrokeWidth; }
175 
176  void setFillColor( const QColor &c ) override { setColor( c ); }
177  QColor fillColor() const override { return color(); }
178 
179  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
180  QColor strokeColor() const override { return mStrokeColor; }
181 
188  void setSymbolWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolWidthUnit = unit; }
189 
195  QgsUnitTypes::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
196 
197  void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
198  const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
199 
206  void setSymbolHeightUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolHeightUnit = unit; }
207 
213  QgsUnitTypes::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
214 
215  void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
216  const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
217 
223  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
224 
229  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
230 
231  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
232  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
233 
234  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
235  QgsUnitTypes::RenderUnit outputUnit() const override;
236  bool usesMapUnits() const override;
237 
238  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
239  QgsMapUnitScale mapUnitScale() const override;
240 
241  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
242 
243  private:
244  Shape mShape = Circle;
245  double mSymbolWidth = 4;
247  QgsMapUnitScale mSymbolWidthMapUnitScale;
248  double mSymbolHeight = 3;
250  QgsMapUnitScale mSymbolHeightMapUnitScale;
251  QColor mStrokeColor;
252  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
253  Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
254  Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
255  double mStrokeWidth = 0;
257  QgsMapUnitScale mStrokeWidthMapUnitScale;
258 
259  QPainterPath mPainterPath;
260 
261  QPen mPen;
262  QBrush mBrush;
264  QPen mSelPen;
266  QBrush mSelBrush;
267 
276  void preparePath( const QgsEllipseSymbolLayer::Shape &shape, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
277  QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
278  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
279 };
280 
281 // clazy:excludeall=qstring-allocations
282 
283 #endif // QGSELLIPSESYMBOLLAYER_H
284 
285 
QgsEllipseSymbolLayer::setStrokeWidthUnit
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
Definition: qgsellipsesymbollayer.h:223
QgsEllipseSymbolLayer::Cross
@ Cross
Stroke-only cross.
Definition: qgsellipsesymbollayer.h:41
QgsEllipseSymbolLayer::symbolWidthMapUnitScale
const QgsMapUnitScale & symbolWidthMapUnitScale() const
Definition: qgsellipsesymbollayer.h:198
QgsEllipseSymbolLayer::strokeStyle
Qt::PenStyle strokeStyle() const
Definition: qgsellipsesymbollayer.h:138
QgsEllipseSymbolLayer::strokeWidth
double strokeWidth() const
Definition: qgsellipsesymbollayer.h:174
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
Definition: qgssymbollayer.cpp:252
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsDxfExport
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:64
QgsMarkerSymbolLayer::mapUnitScale
QgsMapUnitScale mapUnitScale() const override
Definition: qgssymbollayer.cpp:712
QgsEllipseSymbolLayer::symbolName
Q_DECL_DEPRECATED QString symbolName() const
Returns the shape name for the rendered ellipse marker symbol.
Definition: qgsellipsesymbollayer.h:93
QgsEllipseSymbolLayer::strokeColor
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
Definition: qgsellipsesymbollayer.h:180
QgsEllipseSymbolLayer::SemiCircle
@ SemiCircle
Semi circle.
Definition: qgsellipsesymbollayer.h:47
QgsEllipseSymbolLayer::setFillColor
void setFillColor(const QColor &c) override
Sets the fill color for the symbol layer.
Definition: qgsellipsesymbollayer.h:176
qgsmarkersymbollayer.h
qgis.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsMarkerSymbolLayer
Abstract base class for marker symbol layers.
Definition: qgssymbollayer.h:705
QgsMarkerSymbolLayer::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
Definition: qgssymbollayer.cpp:706
QgsEllipseSymbolLayer::setStrokeColor
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
Definition: qgsellipsesymbollayer.h:179
QgsEllipseSymbolLayer::setSymbolHeightUnit
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
Definition: qgsellipsesymbollayer.h:206
QgsEllipseSymbolLayer
A symbol layer for rendering objects with major and minor axis (e.g. ellipse, rectangle,...
Definition: qgsellipsesymbollayer.h:31
QgsSymbolLayer::usesMapUnits
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
Definition: qgssymbollayer.cpp:313
QgsEllipseSymbolLayer::strokeWidthMapUnitScale
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Definition: qgsellipsesymbollayer.h:232
QgsEllipseSymbolLayer::Rectangle
@ Rectangle
Rectangle.
Definition: qgsellipsesymbollayer.h:39
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsEllipseSymbolLayer::symbolHeightUnit
QgsUnitTypes::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
Definition: qgsellipsesymbollayer.h:213
QgsEllipseSymbolLayer::setSymbolWidthMapUnitScale
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:197
QgsEllipseSymbolLayer::setPenJoinStyle
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
Definition: qgsellipsesymbollayer.h:151
QgsSymbolRenderContext
Definition: qgssymbolrendercontext.h:35
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsMarkerSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:691
QgsEllipseSymbolLayer::LeftHalfTriangle
@ LeftHalfTriangle
Left half of a triangle.
Definition: qgsellipsesymbollayer.h:46
QgsSymbolLayer
Definition: qgssymbollayer.h:54
QgsEllipseSymbolLayer::setPenCapStyle
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
Definition: qgsellipsesymbollayer.h:171
QgsEllipseSymbolLayer::setShape
void setShape(QgsEllipseSymbolLayer::Shape shape)
Sets the rendered ellipse marker shape.
Definition: qgsellipsesymbollayer.h:108
QgsEllipseSymbolLayer::setStrokeWidth
void setStrokeWidth(double w)
Definition: qgsellipsesymbollayer.h:173
QgsEllipseSymbolLayer::setSymbolWidthUnit
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
Definition: qgsellipsesymbollayer.h:188
QgsMarkerSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:697
QgsEllipseSymbolLayer::strokeWidthUnit
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
Definition: qgsellipsesymbollayer.h:229
QgsEllipseSymbolLayer::Shape
Shape
Marker symbol shapes.
Definition: qgsellipsesymbollayer.h:36
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsEllipseSymbolLayer::shape
QgsEllipseSymbolLayer::Shape shape() const
Returns the shape for the rendered ellipse marker symbol.
Definition: qgsellipsesymbollayer.h:100
QgsEllipseSymbolLayer::HalfArc
@ HalfArc
Stroke-only half arc (since QGIS 3.20)
Definition: qgsellipsesymbollayer.h:43
QgsEllipseSymbolLayer::fillColor
QColor fillColor() const override
Returns the fill color for the symbol layer.
Definition: qgsellipsesymbollayer.h:177
QgsEllipseSymbolLayer::Arrow
@ Arrow
Stroke-only arrow (since QGIS 3.20)
Definition: qgsellipsesymbollayer.h:42
QgsEllipseSymbolLayer::Diamond
@ Diamond
Diamond.
Definition: qgsellipsesymbollayer.h:40
c
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
Definition: porting_processing.dox:1
QgsEllipseSymbolLayer::RightHalfTriangle
@ RightHalfTriangle
Right half of a triangle.
Definition: qgsellipsesymbollayer.h:45
QgsEllipseSymbolLayer::symbolHeightMapUnitScale
const QgsMapUnitScale & symbolHeightMapUnitScale() const
Definition: qgsellipsesymbollayer.h:216
QgsEllipseSymbolLayer::symbolWidth
double symbolWidth() const
Definition: qgsellipsesymbollayer.h:133
QgsEllipseSymbolLayer::penCapStyle
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
Definition: qgsellipsesymbollayer.h:161
QgsMarkerSymbolLayer::bounds
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QgsMarkerSymbolLayer::setSize
virtual void setSize(double size)
Sets the symbol size.
Definition: qgssymbollayer.h:777
QgsSymbolLayer::color
virtual QColor color() const
Returns the "representative" color of the symbol layer.
Definition: qgssymbollayer.cpp:247
QgsEllipseSymbolLayer::penJoinStyle
Qt::PenJoinStyle penJoinStyle() const
Gets stroke join style.
Definition: qgsellipsesymbollayer.h:145
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsEllipseSymbolLayer::symbolWidthUnit
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
Definition: qgsellipsesymbollayer.h:195
QgsEllipseSymbolLayer::setStrokeStyle
void setStrokeStyle(Qt::PenStyle strokeStyle)
Definition: qgsellipsesymbollayer.h:139
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings")....
Definition: qgsexpression.h:102
QgsEllipseSymbolLayer::setStrokeWidthMapUnitScale
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:231
QgsEllipseSymbolLayer::Triangle
@ Triangle
Triangle.
Definition: qgsellipsesymbollayer.h:44
MathUtils::angle
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
QgsEllipseSymbolLayer::setSymbolHeightMapUnitScale
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:215
DEFAULT_ELLIPSE_JOINSTYLE
#define DEFAULT_ELLIPSE_JOINSTYLE
Definition: qgsellipsesymbollayer.h:18
QgsEllipseSymbolLayer::Circle
@ Circle
Circle.
Definition: qgsellipsesymbollayer.h:38
QgsEllipseSymbolLayer::symbolHeight
double symbolHeight() const
Definition: qgsellipsesymbollayer.h:136