QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
31 {
32  public:
34 
35  static QgsSymbolLayer *create( const QgsStringMap &properties = QgsStringMap() ) SIP_FACTORY;
36  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
37 
38  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
39  QString layerType() const override;
40  void startRender( QgsSymbolRenderContext &context ) override;
41  void stopRender( QgsSymbolRenderContext &context ) override;
42  QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
43  QgsStringMap properties() const override;
44 
45  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const override;
46  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const override;
47 
48  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
49 
50  void setSymbolName( const QString &name ) { mSymbolName = name; }
51  QString symbolName() const { return mSymbolName; }
52 
53  void setSize( double size ) override;
54 
55  void setSymbolWidth( double w );
56  double symbolWidth() const { return mSymbolWidth; }
57 
58  void setSymbolHeight( double h );
59  double symbolHeight() const { return mSymbolHeight; }
60 
61  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
62  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
63 
67  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
68 
72  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
73 
74  void setStrokeWidth( double w ) { mStrokeWidth = w; }
75  double strokeWidth() const { return mStrokeWidth; }
76 
77  void setFillColor( const QColor &c ) override { setColor( c ); }
78  QColor fillColor() const override { return color(); }
79 
80  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
81  QColor strokeColor() const override { return mStrokeColor; }
82 
89  void setSymbolWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolWidthUnit = unit; }
90 
96  QgsUnitTypes::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
97 
98  void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
99  const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
100 
107  void setSymbolHeightUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolHeightUnit = unit; }
108 
114  QgsUnitTypes::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
115 
116  void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
117  const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
118 
124  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
125 
130  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
131 
132  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
133  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
134 
135  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
136  QgsUnitTypes::RenderUnit outputUnit() const override;
137 
138  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
139  QgsMapUnitScale mapUnitScale() const override;
140 
141  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
142 
143  private:
144  QString mSymbolName;
145  double mSymbolWidth = 4;
147  QgsMapUnitScale mSymbolWidthMapUnitScale;
148  double mSymbolHeight = 3;
150  QgsMapUnitScale mSymbolHeightMapUnitScale;
151  QColor mStrokeColor;
152  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
153  Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
154  double mStrokeWidth = 0;
156  QgsMapUnitScale mStrokeWidthMapUnitScale;
157 
158  QPainterPath mPainterPath;
159 
160  QPen mPen;
161  QBrush mBrush;
162 
171  void preparePath( const QString &symbolName, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
172  QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
173  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
174 };
175 
176 // clazy:excludeall=qstring-allocations
177 
178 #endif // QGSELLIPSESYMBOLLAYER_H
179 
180 
QgsEllipseSymbolLayer::setStrokeWidthUnit
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
Definition: qgsellipsesymbollayer.h:124
QgsEllipseSymbolLayer::symbolWidthMapUnitScale
const QgsMapUnitScale & symbolWidthMapUnitScale() const
Definition: qgsellipsesymbollayer.h:99
QgsEllipseSymbolLayer::strokeStyle
Qt::PenStyle strokeStyle() const
Definition: qgsellipsesymbollayer.h:61
QgsEllipseSymbolLayer::strokeWidth
double strokeWidth() const
Definition: qgsellipsesymbollayer.h:75
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:166
QgsDxfExport
Definition: qgsdxfexport.h:62
QgsMarkerSymbolLayer::mapUnitScale
QgsMapUnitScale mapUnitScale() const override
Definition: qgssymbollayer.cpp:627
QgsEllipseSymbolLayer::strokeColor
QColor strokeColor() const override
Gets stroke color.
Definition: qgsellipsesymbollayer.h:81
QgsEllipseSymbolLayer::setSymbolName
void setSymbolName(const QString &name)
Definition: qgsellipsesymbollayer.h:50
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
The fill color.
Definition: qgssymbollayer.h:231
QgsSymbolLayer::color
virtual QColor color() const
The fill color.
Definition: qgssymbollayer.h:226
QgsEllipseSymbolLayer::setFillColor
void setFillColor(const QColor &c) override
Set fill color.
Definition: qgsellipsesymbollayer.h:77
qgsmarkersymbollayer.h
QgsMarkerSymbolLayer::startRender
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Definition: qgssymbollayer.cpp:443
qgis.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsMarkerSymbolLayer
Abstract base class for marker symbol layers.
Definition: qgssymbollayer.h:575
QgsEllipseSymbolLayer::symbolName
QString symbolName() const
Definition: qgsellipsesymbollayer.h:51
QgsMarkerSymbolLayer::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
Definition: qgssymbollayer.cpp:621
QgsEllipseSymbolLayer::setStrokeColor
void setStrokeColor(const QColor &c) override
Set stroke color.
Definition: qgsellipsesymbollayer.h:80
QgsEllipseSymbolLayer::setSymbolHeightUnit
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
Definition: qgsellipsesymbollayer.h:107
QgsEllipseSymbolLayer
Definition: qgsellipsesymbollayer.h:30
QgsSymbolLayer::properties
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsEllipseSymbolLayer::strokeWidthMapUnitScale
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Definition: qgsellipsesymbollayer.h:133
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsEllipseSymbolLayer::symbolHeightUnit
QgsUnitTypes::RenderUnit symbolHeightUnit() const
Returns the units for the symbol's height.
Definition: qgsellipsesymbollayer.h:114
QgsEllipseSymbolLayer::setSymbolWidthMapUnitScale
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:98
QgsEllipseSymbolLayer::setPenJoinStyle
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
Definition: qgsellipsesymbollayer.h:72
QgsSymbolRenderContext
Definition: qgssymbol.h:681
QgsMarkerSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:606
QgsSymbolLayer::writeDxf
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
Definition: qgssymbollayer.cpp:127
QgsSymbolLayer::clone
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolLayer
Definition: qgssymbollayer.h:52
QgsEllipseSymbolLayer::setStrokeWidth
void setStrokeWidth(double w)
Definition: qgsellipsesymbollayer.h:74
QgsEllipseSymbolLayer::setSymbolWidthUnit
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
Definition: qgsellipsesymbollayer.h:89
QgsMarkerSymbolLayer::toSld
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Definition: qgssymbollayer.cpp:787
QgsMarkerSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:612
QgsEllipseSymbolLayer::strokeWidthUnit
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
Definition: qgsellipsesymbollayer.h:130
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:37
QgsEllipseSymbolLayer::fillColor
QColor fillColor() const override
Gets fill color.
Definition: qgsellipsesymbollayer.h:78
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:714
c
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
Definition: porting_processing.dox:1
QgsEllipseSymbolLayer::symbolHeightMapUnitScale
const QgsMapUnitScale & symbolHeightMapUnitScale() const
Definition: qgsellipsesymbollayer.h:117
QgsMarkerSymbolLayer::renderPoint
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QgsEllipseSymbolLayer::symbolWidth
double symbolWidth() const
Definition: qgsellipsesymbollayer.h:56
QgsMarkerSymbolLayer::writeSldMarker
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
Definition: qgssymbollayer.h:799
QgsMarkerSymbolLayer::bounds
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QgsMarkerSymbolLayer::setSize
virtual void setSize(double size)
Sets the symbol size.
Definition: qgssymbollayer.h:647
QgsSymbolLayer::layerType
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsEllipseSymbolLayer::penJoinStyle
Qt::PenJoinStyle penJoinStyle() const
Gets stroke join style.
Definition: qgsellipsesymbollayer.h:67
QgsFeature
Definition: qgsfeature.h:55
QgsEllipseSymbolLayer::symbolWidthUnit
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
Definition: qgsellipsesymbollayer.h:96
QgsEllipseSymbolLayer::setStrokeStyle
void setStrokeStyle(Qt::PenStyle strokeStyle)
Definition: qgsellipsesymbollayer.h:62
QgsExpression
Definition: qgsexpression.h:113
QgsEllipseSymbolLayer::setStrokeWidthMapUnitScale
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:132
MathUtils::angle
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
QgsMarkerSymbolLayer::stopRender
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Definition: qgssymbollayer.cpp:448
QgsEllipseSymbolLayer::setSymbolHeightMapUnitScale
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:116
DEFAULT_ELLIPSE_JOINSTYLE
#define DEFAULT_ELLIPSE_JOINSTYLE
Definition: qgsellipsesymbollayer.h:18
QgsEllipseSymbolLayer::symbolHeight
double symbolHeight() const
Definition: qgsellipsesymbollayer.h:59