QGIS API Documentation  3.0.2-Girona (307d082)
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 QGSELLIPSESYMBOLLAYERV2_H
16 #define QGSELLIPSESYMBOLLAYERV2_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 setSymbolWidth( double w ) { mSymbolWidth = w; }
54  double symbolWidth() const { return mSymbolWidth; }
55 
56  void setSymbolHeight( double h ) { mSymbolHeight = h; }
57  double symbolHeight() const { return mSymbolHeight; }
58 
59  Qt::PenStyle strokeStyle() const { return mStrokeStyle; }
60  void setStrokeStyle( Qt::PenStyle strokeStyle ) { mStrokeStyle = strokeStyle; }
61 
65  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
66 
70  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
71 
72  void setStrokeWidth( double w ) { mStrokeWidth = w; }
73  double strokeWidth() const { return mStrokeWidth; }
74 
75  void setFillColor( const QColor &c ) override { setColor( c ); }
76  QColor fillColor() const override { return color(); }
77 
78  void setStrokeColor( const QColor &c ) override { mStrokeColor = c; }
79  QColor strokeColor() const override { return mStrokeColor; }
80 
87  void setSymbolWidthUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolWidthUnit = unit; }
88 
94  QgsUnitTypes::RenderUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
95 
96  void setSymbolWidthMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolWidthMapUnitScale = scale; }
97  const QgsMapUnitScale &symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
98 
105  void setSymbolHeightUnit( QgsUnitTypes::RenderUnit unit ) { mSymbolHeightUnit = unit; }
106 
112  QgsUnitTypes::RenderUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
113 
114  void setSymbolHeightMapUnitScale( const QgsMapUnitScale &scale ) { mSymbolHeightMapUnitScale = scale; }
115  const QgsMapUnitScale &symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
116 
122  void setStrokeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mStrokeWidthUnit = unit; }
123 
128  QgsUnitTypes::RenderUnit strokeWidthUnit() const { return mStrokeWidthUnit; }
129 
130  void setStrokeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mStrokeWidthMapUnitScale = scale; }
131  const QgsMapUnitScale &strokeWidthMapUnitScale() const { return mStrokeWidthMapUnitScale; }
132 
133  void setOutputUnit( QgsUnitTypes::RenderUnit unit ) override;
134  QgsUnitTypes::RenderUnit outputUnit() const override;
135 
136  void setMapUnitScale( const QgsMapUnitScale &scale ) override;
137  QgsMapUnitScale mapUnitScale() const override;
138 
139  QRectF bounds( QPointF point, QgsSymbolRenderContext &context ) override;
140 
141  private:
142  QString mSymbolName;
143  double mSymbolWidth = 4;
145  QgsMapUnitScale mSymbolWidthMapUnitScale;
146  double mSymbolHeight = 3;
148  QgsMapUnitScale mSymbolHeightMapUnitScale;
149  QColor mStrokeColor;
150  Qt::PenStyle mStrokeStyle = Qt::SolidLine;
151  Qt::PenJoinStyle mPenJoinStyle = DEFAULT_ELLIPSE_JOINSTYLE;
152  double mStrokeWidth = 0;
154  QgsMapUnitScale mStrokeWidthMapUnitScale;
155 
156  QPainterPath mPainterPath;
157 
158  QPen mPen;
159  QBrush mBrush;
160 
169  void preparePath( const QString &symbolName, QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr, const QgsFeature *f = nullptr );
170  QSizeF calculateSize( QgsSymbolRenderContext &context, double *scaledWidth = nullptr, double *scaledHeight = nullptr );
171  void calculateOffsetAndRotation( QgsSymbolRenderContext &context, double scaledWidth, double scaledHeight, bool &hasDataDefinedRotation, QPointF &offset, double &angle ) const;
172 };
173 
174 // clazy:excludeall=qstring-allocations
175 
176 #endif // QGSELLIPSESYMBOLLAYERV2_H
177 
178 
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:62
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QColor strokeColor() const override
Get stroke color.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:479
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.
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
Get 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.
virtual void stopRender(QgsSymbolRenderContext &context)=0
void setMapUnitScale(const QgsMapUnitScale &scale) override
const QgsMapUnitScale & symbolWidthMapUnitScale() const
QColor fillColor() const override
Get fill color.
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:100
virtual QString layerType() const =0
Returns a string that represents this layer type.