QGIS API Documentation  2.17.0-Master (8784312)
qgsellipsesymbollayerv2.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsellipsesymbollayerv2.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 "qgsmarkersymbollayerv2.h"
21 #include <QPainterPath>
22 
23 class QgsExpression;
24 
28 {
29  public:
32 
33  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
34  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
35 
36  void renderPoint( QPointF point, QgsSymbolV2RenderContext& context ) override;
37  QString layerType() const override;
38  void startRender( QgsSymbolV2RenderContext& context ) override;
39  void stopRender( QgsSymbolV2RenderContext& context ) override;
40  QgsEllipseSymbolLayerV2* clone() const override;
41  QgsStringMap properties() const override;
42 
43  void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
44  void writeSldMarker( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
45 
46  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
47 
48  void setSymbolName( const QString& name ) { mSymbolName = name; }
49  QString symbolName() const { return mSymbolName; }
50 
51  void setSymbolWidth( double w ) { mSymbolWidth = w; }
52  double symbolWidth() const { return mSymbolWidth; }
53 
54  void setSymbolHeight( double h ) { mSymbolHeight = h; }
55  double symbolHeight() const { return mSymbolHeight; }
56 
57  Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
58  void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }
59 
62  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
65  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
66 
67  void setOutlineWidth( double w ) { mOutlineWidth = w; }
68  double outlineWidth() const { return mOutlineWidth; }
69 
70  void setFillColor( const QColor& c ) override { setColor( c ); }
71  QColor fillColor() const override { return color(); }
72 
73  void setOutlineColor( const QColor& c ) override { mOutlineColor = c; }
74  QColor outlineColor() const override { return mOutlineColor; }
75 
76  void setSymbolWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSymbolWidthUnit = unit; }
77  QgsSymbolV2::OutputUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
78 
79  void setSymbolWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSymbolWidthMapUnitScale = scale; }
80  const QgsMapUnitScale& symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
81 
82  void setSymbolHeightUnit( QgsSymbolV2::OutputUnit unit ) { mSymbolHeightUnit = unit; }
83  QgsSymbolV2::OutputUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
84 
85  void setSymbolHeightMapUnitScale( const QgsMapUnitScale& scale ) { mSymbolHeightMapUnitScale = scale; }
86  const QgsMapUnitScale& symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
87 
88  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
89  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
90 
91  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
92  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
93 
94  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
95  QgsSymbolV2::OutputUnit outputUnit() const override;
96 
97  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
98  QgsMapUnitScale mapUnitScale() const override;
99 
100  QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context ) override;
101 
102  private:
103  QString mSymbolName;
104  double mSymbolWidth;
105  QgsSymbolV2::OutputUnit mSymbolWidthUnit;
106  QgsMapUnitScale mSymbolWidthMapUnitScale;
107  double mSymbolHeight;
108  QgsSymbolV2::OutputUnit mSymbolHeightUnit;
109  QgsMapUnitScale mSymbolHeightMapUnitScale;
110  QColor mOutlineColor;
111  Qt::PenStyle mOutlineStyle;
112  Qt::PenJoinStyle mPenJoinStyle;
113  double mOutlineWidth;
114  QgsSymbolV2::OutputUnit mOutlineWidthUnit;
115  QgsMapUnitScale mOutlineWidthMapUnitScale;
116 
117  QPainterPath mPainterPath;
118 
119  QPen mPen;
120  QBrush mBrush;
121 
129  void preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, double* scaledWidth = nullptr, double* scaledHeight = nullptr, const QgsFeature* f = nullptr );
130  QSizeF calculateSize( QgsSymbolV2RenderContext& context, double* scaledWidth = nullptr, double* scaledHeight = nullptr );
131  void calculateOffsetAndRotation( QgsSymbolV2RenderContext& context, double scaledWidth, double scaledHeight, bool& hasDataDefinedRotation, QPointF& offset, double& angle ) const;
132 };
133 
134 #endif // QGSELLIPSESYMBOLLAYERV2_H
135 
136 
virtual void renderPoint(QPointF point, QgsSymbolV2RenderContext &context)=0
Renders a marker at the specified point.
Class for parsing and evaluation of expressions (formerly called "search strings").
void setSymbolWidthUnit(QgsSymbolV2::OutputUnit unit)
QColor fillColor() const override
Get fill color.
QgsSymbolV2::OutputUnit outputUnit() const override
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
virtual QgsSymbolLayerV2 * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QRectF bounds(QPointF point, QgsSymbolV2RenderContext &context)
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
QColor outlineColor() const override
Get outline color.
A symbol layer for rendering objects with major and minor axis (e.g.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:492
void setMapUnitScale(const QgsMapUnitScale &scale) override
const QgsMapUnitScale & symbolWidthMapUnitScale() const
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QColor color() const
The fill color.
void setOutlineStyle(Qt::PenStyle outlineStyle)
void setSymbolName(const QString &name)
QgsSymbolV2::OutputUnit symbolHeightUnit() const
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
virtual QString layerType() const =0
Returns a string that represents this layer type.
void startRender(QgsSymbolV2RenderContext &context) override
const QgsMapUnitScale & outlineWidthMapUnitScale() const
Qt::PenJoinStyle penJoinStyle() const
Get outline join style.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
const QgsMapUnitScale & symbolHeightMapUnitScale() const
Struct for storing maximum and minimum scales for measurements in map units.
QgsMapUnitScale mapUnitScale() const override
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
void setOutlineColor(const QColor &c) override
Set outline color.
Qt::PenStyle outlineStyle() const
virtual void setColor(const QColor &color)
The fill color.
QgsSymbolV2::OutputUnit symbolWidthUnit() const
Abstract base class for marker symbol layers.
void setPenJoinStyle(Qt::PenJoinStyle style)
Set outline join style.
virtual void stopRender(QgsSymbolV2RenderContext &context)=0
void setFillColor(const QColor &c) override
Set fill color.
void setSymbolHeightUnit(QgsSymbolV2::OutputUnit unit)
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit outlineWidthUnit() const