QGIS API Documentation  2.15.0-Master (972fc9f)
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 
27 {
28  public:
31 
32  static QgsSymbolLayerV2* create( const QgsStringMap& properties = QgsStringMap() );
33  static QgsSymbolLayerV2* createFromSld( QDomElement &element );
34 
35  void renderPoint( QPointF point, QgsSymbolV2RenderContext& context ) override;
36  QString layerType() const override;
37  void startRender( QgsSymbolV2RenderContext& context ) override;
38  void stopRender( QgsSymbolV2RenderContext& context ) override;
39  QgsEllipseSymbolLayerV2* clone() const override;
40  QgsStringMap properties() const override;
41 
42  void toSld( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
43  void writeSldMarker( QDomDocument& doc, QDomElement &element, const QgsStringMap& props ) const override;
44 
45  bool writeDxf( QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolV2RenderContext &context, QPointF shift = QPointF( 0.0, 0.0 ) ) const override;
46 
47  void setSymbolName( const QString& name ) { mSymbolName = name; }
48  QString symbolName() const { return mSymbolName; }
49 
50  void setSymbolWidth( double w ) { mSymbolWidth = w; }
51  double symbolWidth() const { return mSymbolWidth; }
52 
53  void setSymbolHeight( double h ) { mSymbolHeight = h; }
54  double symbolHeight() const { return mSymbolHeight; }
55 
56  Qt::PenStyle outlineStyle() const { return mOutlineStyle; }
57  void setOutlineStyle( Qt::PenStyle outlineStyle ) { mOutlineStyle = outlineStyle; }
58 
61  Qt::PenJoinStyle penJoinStyle() const { return mPenJoinStyle; }
64  void setPenJoinStyle( Qt::PenJoinStyle style ) { mPenJoinStyle = style; }
65 
66  void setOutlineWidth( double w ) { mOutlineWidth = w; }
67  double outlineWidth() const { return mOutlineWidth; }
68 
69  void setFillColor( const QColor& c ) override { setColor( c ); }
70  QColor fillColor() const override { return color(); }
71 
72  void setOutlineColor( const QColor& c ) override { mOutlineColor = c; }
73  QColor outlineColor() const override { return mOutlineColor; }
74 
75  void setSymbolWidthUnit( QgsSymbolV2::OutputUnit unit ) { mSymbolWidthUnit = unit; }
76  QgsSymbolV2::OutputUnit symbolWidthUnit() const { return mSymbolWidthUnit; }
77 
78  void setSymbolWidthMapUnitScale( const QgsMapUnitScale& scale ) { mSymbolWidthMapUnitScale = scale; }
79  const QgsMapUnitScale& symbolWidthMapUnitScale() const { return mSymbolWidthMapUnitScale; }
80 
81  void setSymbolHeightUnit( QgsSymbolV2::OutputUnit unit ) { mSymbolHeightUnit = unit; }
82  QgsSymbolV2::OutputUnit symbolHeightUnit() const { return mSymbolHeightUnit; }
83 
84  void setSymbolHeightMapUnitScale( const QgsMapUnitScale& scale ) { mSymbolHeightMapUnitScale = scale; }
85  const QgsMapUnitScale& symbolHeightMapUnitScale() const { return mSymbolHeightMapUnitScale; }
86 
87  void setOutlineWidthUnit( QgsSymbolV2::OutputUnit unit ) { mOutlineWidthUnit = unit; }
88  QgsSymbolV2::OutputUnit outlineWidthUnit() const { return mOutlineWidthUnit; }
89 
90  void setOutlineWidthMapUnitScale( const QgsMapUnitScale& scale ) { mOutlineWidthMapUnitScale = scale; }
91  const QgsMapUnitScale& outlineWidthMapUnitScale() const { return mOutlineWidthMapUnitScale; }
92 
93  void setOutputUnit( QgsSymbolV2::OutputUnit unit ) override;
94  QgsSymbolV2::OutputUnit outputUnit() const override;
95 
96  void setMapUnitScale( const QgsMapUnitScale& scale ) override;
97  QgsMapUnitScale mapUnitScale() const override;
98 
99  QRectF bounds( QPointF point, QgsSymbolV2RenderContext& context ) override;
100 
101  private:
102  QString mSymbolName;
103  double mSymbolWidth;
104  QgsSymbolV2::OutputUnit mSymbolWidthUnit;
105  QgsMapUnitScale mSymbolWidthMapUnitScale;
106  double mSymbolHeight;
107  QgsSymbolV2::OutputUnit mSymbolHeightUnit;
108  QgsMapUnitScale mSymbolHeightMapUnitScale;
109  QColor mOutlineColor;
110  Qt::PenStyle mOutlineStyle;
111  Qt::PenJoinStyle mPenJoinStyle;
112  double mOutlineWidth;
113  QgsSymbolV2::OutputUnit mOutlineWidthUnit;
114  QgsMapUnitScale mOutlineWidthMapUnitScale;
115 
116  QPainterPath mPainterPath;
117 
118  QPen mPen;
119  QBrush mBrush;
120 
128  void preparePath( const QString& symbolName, QgsSymbolV2RenderContext& context, double* scaledWidth = nullptr, double* scaledHeight = nullptr, const QgsFeature* f = nullptr );
129  QSizeF calculateSize( QgsSymbolV2RenderContext& context, double* scaledWidth = nullptr, double* scaledHeight = nullptr );
130  void calculateOffsetAndRotation( QgsSymbolV2RenderContext& context, double scaledWidth, double scaledHeight, bool& hasDataDefinedRotation, QPointF& offset, double& angle ) const;
131 };
132 
133 #endif // QGSELLIPSESYMBOLLAYERV2_H
134 
135 
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:62
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:491
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