QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
36  static QgsSymbolLayer *create( const QgsStringMap &properties = QgsStringMap() ) SIP_FACTORY;
37  static QgsSymbolLayer *createFromSld( QDomElement &element ) SIP_FACTORY;
38 
39  void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
40  QString layerType() const override;
41  void startRender( QgsSymbolRenderContext &context ) override;
42  void stopRender( QgsSymbolRenderContext &context ) override;
43  QgsEllipseSymbolLayer *clone() const override SIP_FACTORY;
44  QgsStringMap properties() const override;
45 
46  void toSld( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const override;
47  void writeSldMarker( QDomDocument &doc, QDomElement &element, const QgsStringMap &props ) const override;
48 
49  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
50 
51  void setSymbolName( const QString &name ) { mSymbolName = name; }
52  QString symbolName() const { return mSymbolName; }
53 
54  void setSize( double size ) override;
55 
56  void setSymbolWidth( double w );
57  double symbolWidth() const { return mSymbolWidth; }
58 
59  void setSymbolHeight( double h );
60  double symbolHeight() const { return mSymbolHeight; }
61 
62  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
63  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
64 
69  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
70 
75  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
76 
77  void setStrokeWidth( double w ) { mStrokeWidth = w; }
78  double strokeWidth() const { return mStrokeWidth; }
79 
80  void setFillColor( const QColor &c ) override { setColor( c ); }
81  QColor fillColor() const override { return color(); }
82 
83  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
84  QColor strokeColor() const override { return mStrokeColor; }
85 
92  void setSymbolWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolWidthUnit = unit; }
93 
99  QgsUnitTypes::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
100 
101  void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
102  const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
103 
110  void setSymbolHeightUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolHeightUnit = unit; }
111 
117  QgsUnitTypes::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
118 
119  void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
120  const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
121 
127  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
128 
133  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
134 
135  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
136  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
137 
138  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
139  QgsUnitTypes::RenderUnit outputUnit() const override;
140 
141  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
142  QgsMapUnitScale mapUnitScale() const override;
143 
144  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
145 
146  private:
147  QString mSymbolName;
148  double mSymbolWidth = 4;
150  QgsMapUnitScale mSymbolWidthMapUnitScale;
151  double mSymbolHeight = 3;
153  QgsMapUnitScale mSymbolHeightMapUnitScale;
154  QColor mStrokeColor;
155  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
156  Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
157  double mStrokeWidth = 0;
159  QgsMapUnitScale mStrokeWidthMapUnitScale;
160 
161  QPainterPath mPainterPath;
162 
163  QPen mPen;
164  QBrush mBrush;
166  QPen mSelPen;
168  QBrush mSelBrush;
169 
178  void preparePath( const QString &symbolName, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
179  QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
180  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
181 };
182 
183 // clazy:excludeall=qstring-allocations
184 
185 #endif // QGSELLIPSESYMBOLLAYER_H
186 
187 
QgsEllipseSymbolLayer::setStrokeWidthUnit
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
Definition: qgsellipsesymbollayer.h:127
QgsEllipseSymbolLayer::symbolWidthMapUnitScale
const QgsMapUnitScale & symbolWidthMapUnitScale() const
Definition: qgsellipsesymbollayer.h:102
QgsEllipseSymbolLayer::strokeStyle
Qt::PenStyle strokeStyle() const
Definition: qgsellipsesymbollayer.h:62
QgsEllipseSymbolLayer::strokeWidth
double strokeWidth() const
Definition: qgsellipsesymbollayer.h:78
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsDxfExport
Definition: qgsdxfexport.h:63
QgsMarkerSymbolLayer::mapUnitScale
QgsMapUnitScale mapUnitScale() const override
Definition: qgssymbollayer.cpp:631
QgsEllipseSymbolLayer::strokeColor
QColor strokeColor() const override
Gets stroke color.
Definition: qgsellipsesymbollayer.h:84
QgsEllipseSymbolLayer::setSymbolName
void setSymbolName(const QString &name)
Definition: qgsellipsesymbollayer.h:51
QgsSymbolLayer::setColor
virtual void setColor(const QColor &color)
The fill color.
Definition: qgssymbollayer.h:232
QgsSymbolLayer::color
virtual QColor color() const
The fill color.
Definition: qgssymbollayer.h:227
QgsEllipseSymbolLayer::setFillColor
void setFillColor(const QColor &c) override
Set fill color.
Definition: qgsellipsesymbollayer.h:80
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:447
qgis.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsMarkerSymbolLayer
Abstract base class for marker symbol layers.
Definition: qgssymbollayer.h:582
QgsEllipseSymbolLayer::symbolName
QString symbolName() const
Definition: qgsellipsesymbollayer.h:52
QgsMarkerSymbolLayer::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
Definition: qgssymbollayer.cpp:625
QgsEllipseSymbolLayer::setStrokeColor
void setStrokeColor(const QColor &c) override
Set stroke color.
Definition: qgsellipsesymbollayer.h:83
QgsEllipseSymbolLayer::setSymbolHeightUnit
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
Definition: qgsellipsesymbollayer.h:110
QgsEllipseSymbolLayer
A symbol layer for rendering objects with major and minor axis (e.g.
Definition: qgsellipsesymbollayer.h:32
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:136
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:117
QgsEllipseSymbolLayer::setSymbolWidthMapUnitScale
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:101
QgsEllipseSymbolLayer::setPenJoinStyle
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
Definition: qgsellipsesymbollayer.h:75
QgsSymbolRenderContext
Definition: qgssymbol.h:695
QgsMarkerSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:610
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:128
QgsSymbolLayer::clone
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolLayer
Definition: qgssymbollayer.h:53
QgsEllipseSymbolLayer::setStrokeWidth
void setStrokeWidth(double w)
Definition: qgsellipsesymbollayer.h:77
QgsEllipseSymbolLayer::setSymbolWidthUnit
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
Definition: qgsellipsesymbollayer.h:92
QgsMarkerSymbolLayer::toSld
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Definition: qgssymbollayer.cpp:791
QgsMarkerSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:616
QgsEllipseSymbolLayer::strokeWidthUnit
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol's stroke width.
Definition: qgsellipsesymbollayer.h:133
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:38
QgsEllipseSymbolLayer::fillColor
QColor fillColor() const override
Gets fill color.
Definition: qgsellipsesymbollayer.h:81
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
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:120
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:57
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:805
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:653
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:69
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsEllipseSymbolLayer::symbolWidthUnit
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol's width.
Definition: qgsellipsesymbollayer.h:99
QgsEllipseSymbolLayer::setStrokeStyle
void setStrokeStyle(Qt::PenStyle strokeStyle)
Definition: qgsellipsesymbollayer.h:63
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:105
QgsEllipseSymbolLayer::setStrokeWidthMapUnitScale
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:135
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:452
QgsEllipseSymbolLayer::setSymbolHeightMapUnitScale
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsellipsesymbollayer.h:119
DEFAULT_ELLIPSE_JOINSTYLE
#define DEFAULT_ELLIPSE_JOINSTYLE
Definition: qgsellipsesymbollayer.h:18
QgsEllipseSymbolLayer::symbolHeight
double symbolHeight() const
Definition: qgsellipsesymbollayer.h:60