QGIS API Documentation  2.17.0-Master (00653d2)
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 
44  void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
45  void writeSldMarker( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
46 
47  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
48 
49  void setSymbolName( const QString& name ) { mSymbolName = name; }
50  QString symbolName() const { return mSymbolName; }
51 
52  void setSymbolWidth( double w ) { mSymbolWidth = w; }
53  double symbolWidth() const { return mSymbolWidth; }
54 
55  void setSymbolHeight( double h ) { mSymbolHeight = h; }
56  double symbolHeight() const { return mSymbolHeight; }
57 
58  Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
59  void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }
60 
63  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
66  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
67 
68  void setOutlineWidth( double w ) { mOutlineWidth = w; }
69  double outlineWidth() const { return mOutlineWidth; }
70 
71  void setFillColor( const QColor& c ) override { setColor( c ); }
72  QColor fillColor() const override { return color(); }
73 
74  void setOutlineColor( const QColor& c ) override { mOutlineColor = c; }
75  QColor outlineColor() const override { return mOutlineColor; }
76 
77  void setSymbolWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSymbolWidthUnit = unit; }
78  QgsSymbolV2::OutputUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
79 
80  void setSymbolWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSymbolWidthMapUnitScale = scale; }
81  const QgsMapUnitScale& symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
82 
83  void setSymbolHeightUnit( QgsSymbolV2::OutputUnit unit ) { mSymbolHeightUnit = unit; }
84  QgsSymbolV2::OutputUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
85 
86  void setSymbolHeightMapUnitScale( const QgsMapUnitScale& scale ) { mSymbolHeightMapUnitScale = scale; }
87  const QgsMapUnitScale& symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
88 
89  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
90  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
91 
92  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
93  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
94 
95  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
96  QgsSymbolV2::OutputUnit outputUnit() const override;
97 
98  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
99  QgsMapUnitScale mapUnitScale() const override;
100 
101  QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context ) override;
102 
103  private:
104  QString mSymbolName;
105  double mSymbolWidth;
106  QgsSymbolV2::OutputUnit mSymbolWidthUnit;
107  QgsMapUnitScale mSymbolWidthMapUnitScale;
108  double mSymbolHeight;
109  QgsSymbolV2::OutputUnit mSymbolHeightUnit;
110  QgsMapUnitScale mSymbolHeightMapUnitScale;
111  QColor mOutlineColor;
112  Qt::PenStyle mOutlineStyle;
113  Qt::PenJoinStyle mPenJoinStyle;
114  double mOutlineWidth;
115  QgsSymbolV2::OutputUnit mOutlineWidthUnit;
116  QgsMapUnitScale mOutlineWidthMapUnitScale;
117 
118  QPainterPath mPainterPath;
119 
120  QPen mPen;
121  QBrush mBrush;
122 
130  void preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, double* scaledWidth = nullptr, double* scaledHeight = nullptr, const QgsFeature* f = nullptr );
131  QSizeF calculateSize( QgsSymbolV2RenderContext& context, double* scaledWidth = nullptr, double* scaledHeight = nullptr );
132  void calculateOffsetAndRotation( QgsSymbolV2RenderContext& context, double scaledWidth, double scaledHeight, bool& hasDataDefinedRotation, QPointF& offset, double& angle ) const;
133 };
134 
135 #endif // QGSELLIPSESYMBOLLAYERV2_H
136 
137 
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...
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
const QgsMapUnitScale & symbolHeightMapUnitScale() const
virtual bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const
write as DXF
const QgsMapUnitScale & symbolWidthMapUnitScale() const
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
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolV2::OutputUnit symbolWidthUnit() const
QgsSymbolV2::OutputUnit outlineWidthUnit() const
virtual QgsStringMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Qt::PenStyle outlineStyle() const
void setOutlineStyle(Qt::PenStyle outlineStyle)
void setSymbolName(const QString &name)
virtual QColor color() const
The fill color.
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
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
QgsSymbolV2::OutputUnit symbolHeightUnit() const
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
Struct for storing maximum and minimum scales for measurements in map units.
QgsMapUnitScale mapUnitScale() const override
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenJoinStyle penJoinStyle() const
Get outline join style.
void setOutlineColor(const QColor &c) override
Set outline color.
const QgsMapUnitScale & outlineWidthMapUnitScale() const
virtual void setColor(const QColor &color)
The fill color.
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)