QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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:
35 
37  static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
38  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
39 
40  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
41  QString layerType() const override;
42  void startRender( QgsSymbolRenderContext &context ) override;
43  void stopRender( QgsSymbolRenderContext &context ) override;
44  QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
45  QVariantMap properties() const override;
46 
47  void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
48  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
49 
50  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
51 
52  void setSymbolName( const QString &name ) { mSymbolName = name; }
53  QString symbolName() const { return mSymbolName; }
54 
55  void setSize( double size ) override;
56 
57  void setSymbolWidth( double w );
58  double symbolWidth() const { return mSymbolWidth; }
59 
60  void setSymbolHeight( double h );
61  double symbolHeight() const { return mSymbolHeight; }
62 
63  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
64  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
65 
70  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
71 
76  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
77 
78  void setStrokeWidth( double w ) { mStrokeWidth = w; }
79  double strokeWidth() const { return mStrokeWidth; }
80 
81  void setFillColor( const QColor &c ) override { setColor( c ); }
82  QColor fillColor() const override { return color(); }
83 
84  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
85  QColor strokeColor() const override { return mStrokeColor; }
86 
93  void setSymbolWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolWidthUnit = unit; }
94 
100  QgsUnitTypes::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
101 
102  void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
103  const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
104 
111  void setSymbolHeightUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolHeightUnit = unit; }
112 
118  QgsUnitTypes::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
119 
120  void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
121  const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
122 
128  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
129 
134  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
135 
136  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
137  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
138 
139  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
140  QgsUnitTypes::RenderUnit outputUnit() const override;
141  bool usesMapUnits() const override;
142 
143  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
144  QgsMapUnitScale mapUnitScale() const override;
145 
146  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
147 
148  private:
149  QString mSymbolName;
150  double mSymbolWidth = 4;
152  QgsMapUnitScale mSymbolWidthMapUnitScale;
153  double mSymbolHeight = 3;
155  QgsMapUnitScale mSymbolHeightMapUnitScale;
156  QColor mStrokeColor;
157  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
158  Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
159  double mStrokeWidth = 0;
161  QgsMapUnitScale mStrokeWidthMapUnitScale;
162 
163  QPainterPath mPainterPath;
164 
165  QPen mPen;
166  QBrush mBrush;
168  QPen mSelPen;
170  QBrush mSelBrush;
171 
180  void preparePath( const QString &symbolName, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
181  QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
182  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
183 };
184 
185 // clazy:excludeall=qstring-allocations
186 
187 #endif // QGSELLIPSESYMBOLLAYER_H
188 
189 
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:64
A symbol layer for rendering objects with major and minor axis (e.g.
const QgsMapUnitScale & symbolHeightMapUnitScale() const
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolName(const QString &name)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
void setStrokeColor(const QColor &c) override
Set stroke color.
void setStrokeStyle(Qt::PenStyle strokeStyle)
QgsUnitTypes::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
QColor fillColor() const override
Gets fill color.
void setFillColor(const QColor &c) override
Set fill color.
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
Qt::PenStyle strokeStyle() const
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QColor strokeColor() const override
Gets stroke color.
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.
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 id, geometry and a list of field/values...
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.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QgsMapUnitScale mapUnitScale() const override
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const
Writes the symbol layer definition as a SLD XML element.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual QColor color() const
The fill color.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual bool usesMapUnits() const
Returns true if the symbol layer has any components which use map unit based sizes.
virtual void setColor(const QColor &color)
The fill color.
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
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_FACTORY
Definition: qgis_sip.h:76
#define DEFAULT_ELLIPSE_JOINSTYLE