QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
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 
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:65
A symbol layer for rendering objects with major and minor axis (e.g.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
const QgsMapUnitScale & symbolHeightMapUnitScale() const
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Shape
Marker symbol shapes.
@ Cross
Stroke-only cross.
@ HalfArc
Stroke-only half arc (since QGIS 3.20)
@ Arrow
Stroke-only arrow (since QGIS 3.20)
@ RightHalfTriangle
Right half of a triangle.
@ LeftHalfTriangle
Left half of a triangle.
QgsUnitTypes::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
QColor fillColor() const override
Returns the fill color for the symbol layer.
QgsEllipseSymbolLayer::Shape shape() const
Returns the shape for the rendered ellipse marker symbol.
void setFillColor(const QColor &c) override
Sets the fill color for the symbol layer.
void setShape(QgsEllipseSymbolLayer::Shape shape)
Sets the rendered ellipse marker shape.
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
Qt::PenStyle strokeStyle() const
Q_DECL_DEPRECATED QString symbolName() const
Returns the shape name for the rendered ellipse marker symbol.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
Qt::PenJoinStyle penJoinStyle() const
Gets stroke join style.
~QgsEllipseSymbolLayer() override
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
const QgsMapUnitScale & symbolWidthMapUnitScale() const
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Struct for storing maximum and minimum scales for measurements in map units.
Abstract base class for marker symbol layers.
virtual void setSize(double size)
Sets the symbol size.
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.
QgsMapUnitScale mapUnitScale() const override
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
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 usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
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_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define DEFAULT_ELLIPSE_JOINSTYLE