QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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.h"
21#include "qgis_core.h"
23
24#include <QPainterPath>
25
26class QgsExpression;
27
33{
34 public:
35
56
58 static QList< QgsEllipseSymbolLayer::Shape > availableShapes();
59
65 static bool shapeIsFilled( const QgsEllipseSymbolLayer::Shape &shape );
66
69
71 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
72 static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
73
74 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
75 QString layerType() const override;
76 Qgis::SymbolLayerFlags flags() const override;
77 void startRender( QgsSymbolRenderContext &context ) override;
78 void stopRender( QgsSymbolRenderContext &context ) override;
79 QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
80 QVariantMap properties() const override;
81 Q_DECL_DEPRECATED void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props = QVariantMap() ) const override SIP_DEPRECATED;
82 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
83 Q_DECL_DEPRECATED void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
84 bool writeSldMarker( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
85
86 bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
87
94 Q_DECL_DEPRECATED void setSymbolName( const QString &name ) SIP_DEPRECATED { mShape = decodeShape( name ); }
95
102 Q_DECL_DEPRECATED QString symbolName() const SIP_DEPRECATED { return encodeShape( mShape ); }
103
109 QgsEllipseSymbolLayer::Shape shape() const { return mShape; }
110
118
128 static QgsEllipseSymbolLayer::Shape decodeShape( const QString &name, bool *ok = nullptr );
129
137 static QString encodeShape( QgsEllipseSymbolLayer::Shape shape );
138
139 void setSize( double size ) override;
140
141 void setSymbolWidth( double w );
142 double symbolWidth() const { return mSymbolWidth; }
143
144 void setSymbolHeight( double h );
145 double symbolHeight() const { return mSymbolHeight; }
146
147 Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
148 void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
149
153 Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
154
158 void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
159
168 Qt::PenCapStyle penCapStyle() const { return mPenCapStyle; }
169
178 void setPenCapStyle( Qt::PenCapStyle style ) { mPenCapStyle = style; }
179
180 void setStrokeWidth( double w ) { mStrokeWidth = w; }
181 double strokeWidth() const { return mStrokeWidth; }
182
183 void setFillColor( const QColor &c ) override { setColor( c ); }
184 QColor fillColor() const override { return color(); }
185
186 void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
187 QColor strokeColor() const override { return mStrokeColor; }
188
195 void setSymbolWidthUnit( Qgis::RenderUnit unit ) { mSymbolWidthUnit = unit; }
196
202 Qgis::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
203
204 void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
205 const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
206
213 void setSymbolHeightUnit( Qgis::RenderUnit unit ) { mSymbolHeightUnit = unit; }
214
220 Qgis::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
221
222 void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
223 const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
224
230 void setStrokeWidthUnit( Qgis::RenderUnit unit ) { mStrokeWidthUnit = unit; }
231
236 Qgis::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
237
238 void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
239 const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
240
241 void setOutputUnit( Qgis::RenderUnit unit ) override;
242 Qgis::RenderUnit outputUnit() const override;
243 bool usesMapUnits() const override;
244
245 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
246 QgsMapUnitScale mapUnitScale() const override;
247
248 QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
249
250 private:
251 Shape mShape = Circle;
252 double mSymbolWidth = 4;
254 QgsMapUnitScale mSymbolWidthMapUnitScale;
255 double mSymbolHeight = 3;
257 QgsMapUnitScale mSymbolHeightMapUnitScale;
258 QColor mStrokeColor;
259 Qt::PenStyle mStrokeStyle = Qt::SolidLine;
260 Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
261 Qt::PenCapStyle mPenCapStyle = Qt::SquareCap;
262 double mStrokeWidth = 0;
264 QgsMapUnitScale mStrokeWidthMapUnitScale;
265
266 QPainterPath mPainterPath;
267
268 QPen mPen;
269 QBrush mBrush;
271 QPen mSelPen;
273 QBrush mSelBrush;
274
283 void preparePath( const QgsEllipseSymbolLayer::Shape &shape, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
284 QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
285 void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
286};
287
288// clazy:excludeall=qstring-allocations
289
290#endif // QGSELLIPSESYMBOLLAYER_H
291
292
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
RenderUnit
Rendering size units.
Definition qgis.h:5183
@ Millimeters
Millimeters.
Definition qgis.h:5184
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).
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
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
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Qgis::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
void setStrokeStyle(Qt::PenStyle strokeStyle)
static QgsEllipseSymbolLayer::Shape decodeShape(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
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
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
const QgsMapUnitScale & symbolWidthMapUnitScale() const
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const override
Saves the symbol layer as SLD.
Q_DECL_DEPRECATED QString symbolName() const
Returns the shape name for the rendered ellipse marker symbol.
Q_DECL_DEPRECATED void setSymbolName(const QString &name)
Sets the rendered ellipse marker shape using a symbol name.
static QString encodeShape(QgsEllipseSymbolLayer::Shape shape)
Encodes a shape to its string representation.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolHeightUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's height.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QString layerType() const override
Returns a string that represents this layer type.
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.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
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).
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
QgsEllipseSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Handles 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.
virtual void setSize(double size)
Sets the symbol size.
QgsMarkerSymbolLayer(const QgsMarkerSymbolLayer &other)
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
Holds SLD export options and other information related to SLD export of a QGIS layer style.
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.
QgsSymbolLayer(const QgsSymbolLayer &other)
Encapsulates the context in which a symbol is being rendered.
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:114
#define SIP_FACTORY
Definition qgis_sip.h:84
#define DEFAULT_ELLIPSE_JOINSTYLE