QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 
Class for parsing and evaluation of expressions (formerly called "search strings").
QgsMapUnitScale mapUnitScale() const override
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setFillColor(const QColor &c) override
Set fill color.
void startRender(QgsSymbolRenderContext &context) override
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol&#39;s width.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QColor strokeColor() const override
Gets stroke color.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:587
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
const QgsMapUnitScale & symbolHeightMapUnitScale() const
virtual void setColor(const QColor &color)
The fill color.
QgsUnitTypes::RenderUnit symbolHeightUnit() const
Returns the units for the symbol&#39;s height.
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
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
Qt::PenJoinStyle penJoinStyle() const
Gets stroke join style.
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
Qt::PenStyle strokeStyle() const
A symbol layer for rendering objects with major and minor axis (e.g.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
void setSymbolName(const QString &name)
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol&#39;s stroke width.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QColor color() const
The fill color.
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
#define SIP_FACTORY
Definition: qgis_sip.h:69
#define DEFAULT_ELLIPSE_JOINSTYLE
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol&#39;s height.
Abstract base class for marker symbol layers.
void setStrokeStyle(Qt::PenStyle strokeStyle)
void setStrokeColor(const QColor &c) override
Set stroke color.
Struct for storing maximum and minimum scales for measurements in map units.
void setMapUnitScale(const QgsMapUnitScale &scale) override
const QgsMapUnitScale & symbolWidthMapUnitScale() const
virtual void setSize(double size)
Sets the symbol size.
QColor fillColor() const override
Gets fill color.
void stopRender(QgsSymbolRenderContext &context) override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit symbolWidthUnit() const
Returns the units for the symbol&#39;s width.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the symbol&#39;s stroke width.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:111
virtual QString layerType() const =0
Returns a string that represents this layer type.