QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 Qgis::SymbolLayerFlags flags() const override;
76 void startRender( QgsSymbolRenderContext &context ) override;
77 void stopRender( QgsSymbolRenderContext &context ) override;
78 QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
79 QVariantMap properties() const override;
80
81 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
82 void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
83
84 bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
85
92 Q_DECL_DEPRECATED void setSymbolName( const QString &name ) SIP_DEPRECATED { mShape = decodeShape( name ); }
93
100 Q_DECL_DEPRECATED QString symbolName() const SIP_DEPRECATED { return encodeShape( mShape ); }
101
107 QgsEllipseSymbolLayer::Shape shape() const { return mShape; }
108
115 void setShape( QgsEllipseSymbolLayer::Shape shape ) { mShape = shape; }
116
126 static QgsEllipseSymbolLayer::Shape decodeShape( const QString &name, bool *ok = nullptr );
127
135 static QString encodeShape( QgsEllipseSymbolLayer::Shape shape );
136
137 void setSize( double size ) override;
138
139 void setSymbolWidth( double w );
140 double symbolWidth() const { return mSymbolWidth; }
141
142 void setSymbolHeight( double h );
143 double symbolHeight() const { return mSymbolHeight; }
144
145 Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
146 void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
147
151 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
152
156 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
157
166 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
167
176 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
177
178 void setStrokeWidth( double w ) { mStrokeWidth = w; }
179 double strokeWidth() const { return mStrokeWidth; }
180
181 void setFillColor( const QColor &c ) override { setColor( c ); }
182 QColor fillColor() const override { return color(); }
183
184 void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
185 QColor strokeColor() const override { return mStrokeColor; }
186
193 void setSymbolWidthUnit( Qgis::RenderUnit unit ) { mSymbolWidthUnit = unit; }
194
200 Qgis::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
201
202 void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
203 const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
204
211 void setSymbolHeightUnit( Qgis::RenderUnit unit ) { mSymbolHeightUnit = unit; }
212
218 Qgis::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
219
220 void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
221 const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
222
228 void setStrokeWidthUnit( Qgis::RenderUnit unit ) { mStrokeWidthUnit = unit; }
229
234 Qgis::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
235
236 void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
237 const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
238
239 void setOutputUnit( Qgis::RenderUnit unit ) override;
240 Qgis::RenderUnit outputUnit() const override;
241 bool usesMapUnits() const override;
242
243 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
244 QgsMapUnitScale mapUnitScale() const override;
245
246 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
247
248 private:
249 Shape mShape = Circle;
250 double mSymbolWidth = 4;
252 QgsMapUnitScale mSymbolWidthMapUnitScale;
253 double mSymbolHeight = 3;
255 QgsMapUnitScale mSymbolHeightMapUnitScale;
256 QColor mStrokeColor;
257 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
258 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
259 Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
260 double mStrokeWidth = 0;
262 QgsMapUnitScale mStrokeWidthMapUnitScale;
263
264 QPainterPath mPainterPath;
265
266 QPen mPen;
267 QBrush mBrush;
269 QPen mSelPen;
271 QBrush mSelBrush;
272
281 void preparePath( const QgsEllipseSymbolLayer::Shape &shape, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
282 QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
283 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
284};
285
286// clazy:excludeall=qstring-allocations
287
288#endif // QGSELLIPSESYMBOLLAYER_H
289
290
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
RenderUnit
Rendering size units.
Definition qgis.h:4847
@ 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.
@ Cross
Stroke-only cross.
@ HalfArc
Stroke-only half arc.
@ Arrow
Stroke-only arrow.
@ RightHalfTriangle
Right half of a triangle.
@ 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:58
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