QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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
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
150 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
151
155 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
156
165 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
166
175 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
176
177 void setStrokeWidth( double w ) { mStrokeWidth = w; }
178 double strokeWidth() const { return mStrokeWidth; }
179
180 void setFillColor( const QColor &c ) override { setColor( c ); }
181 QColor fillColor() const override { return color(); }
182
183 void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
184 QColor strokeColor() const override { return mStrokeColor; }
185
192 void setSymbolWidthUnit( Qgis::RenderUnit unit ) { mSymbolWidthUnit = unit; }
193
199 Qgis::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
200
201 void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
202 const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
203
210 void setSymbolHeightUnit( Qgis::RenderUnit unit ) { mSymbolHeightUnit = unit; }
211
217 Qgis::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
218
219 void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
220 const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
221
227 void setStrokeWidthUnit( Qgis::RenderUnit unit ) { mStrokeWidthUnit = unit; }
228
233 Qgis::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
234
235 void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
236 const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
237
238 void setOutputUnit( Qgis::RenderUnit unit ) override;
239 Qgis::RenderUnit outputUnit() const override;
240 bool usesMapUnits() const override;
241
242 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
243 QgsMapUnitScale mapUnitScale() const override;
244
245 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
246
247 private:
248 Shape mShape = Circle;
249 double mSymbolWidth = 4;
251 QgsMapUnitScale mSymbolWidthMapUnitScale;
252 double mSymbolHeight = 3;
254 QgsMapUnitScale mSymbolHeightMapUnitScale;
255 QColor mStrokeColor;
256 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
257 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
258 Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
259 double mStrokeWidth = 0;
261 QgsMapUnitScale mStrokeWidthMapUnitScale;
262
263 QPainterPath mPainterPath;
264
265 QPen mPen;
266 QBrush mBrush;
268 QPen mSelPen;
270 QBrush mSelBrush;
271
280 void preparePath( const QgsEllipseSymbolLayer::Shape &shape, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
281 QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
282 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
283};
284
285// clazy:excludeall=qstring-allocations
286
287#endif // QGSELLIPSESYMBOLLAYER_H
288
289
RenderUnit
Rendering size units.
Definition qgis.h:4193
@ Millimeters
Millimeters.
Exports QGIS layers to the DXF format.
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)
Qgis::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Qgis::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)
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's stroke width.
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.
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
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)
void setSymbolHeightUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's height.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
void setSymbolWidthUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's width.
Qgis::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
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).
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...
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mapUnitScale() const override
void setOutputUnit(Qgis::RenderUnit unit) override
Sets 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.
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