QGIS API Documentation 3.27.0-Master (95e00c50d2)
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"
23#include <QPainterPath>
24
25class QgsExpression;
26
32{
33 public:
34
36 enum Shape
37 {
54 };
55
57 static QList< QgsEllipseSymbolLayer::Shape > availableShapes();
58
64 static bool shapeIsFilled( const QgsEllipseSymbolLayer::Shape &shape );
65
68
70 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
71 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
72
73 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
74 QString layerType() const override;
75 void startRender( QgsSymbolRenderContext &context ) override;
76 void stopRender( QgsSymbolRenderContext &context ) override;
77 QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
78 QVariantMap properties() const override;
79
80 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
81 void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
82
83 bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
84
91 Q_DECL_DEPRECATED void setSymbolName( const QString &name ) SIP_DEPRECATED { mShape = decodeShape( name ); }
92
99 Q_DECL_DEPRECATED QString symbolName() const SIP_DEPRECATED { return encodeShape( mShape ); }
100
106 QgsEllipseSymbolLayer::Shape shape() const { return mShape; }
107
114 void setShape( QgsEllipseSymbolLayer::Shape shape ) { mShape = shape; }
115
125 static QgsEllipseSymbolLayer::Shape decodeShape( const QString &name, bool *ok = nullptr );
126
134 static QString encodeShape( QgsEllipseSymbolLayer::Shape shape );
135
136 void setSize( double size ) override;
137
138 void setSymbolWidth( double w );
139 double symbolWidth() const { return mSymbolWidth; }
140
141 void setSymbolHeight( double h );
142 double symbolHeight() const { return mSymbolHeight; }
143
144 Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
145 void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
146
151 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
152
157 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
158
167 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
168
177 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
178
179 void setStrokeWidth( double w ) { mStrokeWidth = w; }
180 double strokeWidth() const { return mStrokeWidth; }
181
182 void setFillColor( const QColor &c ) override { setColor( c ); }
183 QColor fillColor() const override { return color(); }
184
185 void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
186 QColor strokeColor() const override { return mStrokeColor; }
187
194 void setSymbolWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolWidthUnit = unit; }
195
201 QgsUnitTypes::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
202
203 void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
204 const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
205
212 void setSymbolHeightUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolHeightUnit = unit; }
213
219 QgsUnitTypes::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
220
221 void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
222 const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
223
229 void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
230
235 QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
236
237 void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
238 const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
239
240 void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
241 QgsUnitTypes::RenderUnit outputUnit() const override;
242 bool usesMapUnits() const override;
243
244 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
245 QgsMapUnitScale mapUnitScale() const override;
246
247 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
248
249 private:
250 Shape mShape = Circle;
251 double mSymbolWidth = 4;
253 QgsMapUnitScale mSymbolWidthMapUnitScale;
254 double mSymbolHeight = 3;
256 QgsMapUnitScale mSymbolHeightMapUnitScale;
257 QColor mStrokeColor;
258 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
259 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
260 Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
261 double mStrokeWidth = 0;
263 QgsMapUnitScale mStrokeWidthMapUnitScale;
264
265 QPainterPath mPainterPath;
266
267 QPen mPen;
268 QBrush mBrush;
270 QPen mSelPen;
272 QBrush mSelBrush;
273
282 void preparePath( const QgsEllipseSymbolLayer::Shape &shape, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
283 QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
284 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
285};
286
287// clazy:excludeall=qstring-allocations
288
289#endif // QGSELLIPSESYMBOLLAYER_H
290
291
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).
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.
@ ThirdCircle
Third Circle (since QGIS 3.28)
@ Pentagon
Pentagon (since QGIS 3.28)
@ Hexagon
Hexagon (since QGIS 3.28)
@ Cross
Stroke-only cross.
@ QuarterCircle
Quarter Circle (since QGIS 3.28)
@ HalfArc
Stroke-only half arc (since QGIS 3.20)
@ Arrow
Stroke-only arrow (since QGIS 3.20)
@ RightHalfTriangle
Right half of a triangle.
@ Star
Star (since QGIS 3.28)
@ Octagon
Octagon (since QGIS 3.28)
@ 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.
const QgsMapUnitScale & symbolHeightMapUnitScale() const
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
Qt::PenStyle strokeStyle() const
const QgsMapUnitScale & symbolWidthMapUnitScale() 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.
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