QGIS API Documentation 3.99.0-Master (e9821da5c6b)
Loading...
Searching...
No Matches
qgsvectorfieldsymbollayer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorfieldsymbollayer.h
3 -------------------------
4 begin : Octorer 25, 2011
5 copyright : (C) 2011 by Marco Hugentobler
6 email : marco dot hugentobler at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSVECTORFIELDSYMBOLLAYER_H
19#define QGSVECTORFIELDSYMBOLLAYER_H
20
21#include "qgis.h"
22#include "qgis_core.h"
23#include "qgssymbollayer.h"
24
25#include <QString>
26
27using namespace Qt::StringLiterals;
28
29class QgsLineSymbol;
30
36{
37 public:
44
50
52 {
55 };
56
59
61 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() );
62 static QgsSymbolLayer *createFromSld( QDomElement &element );
63
64 QString layerType() const override { return u"VectorField"_s; }
65
66 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
67 QgsSymbol *subSymbol() override;
68
69 void setColor( const QColor &color ) override;
70 QColor color() const override;
71
72 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
73 void startRender( QgsSymbolRenderContext &context ) override;
74 void stopRender( QgsSymbolRenderContext &context ) override;
75
77 QVariantMap properties() const override;
78 bool usesMapUnits() const override;
79 Q_DECL_DEPRECATED void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override SIP_DEPRECATED;
80 bool toSld( QDomDocument &doc, QDomElement &element, QgsSldExportContext &context ) const override;
81
82 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
83
84 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
85 bool hasDataDefinedProperties() const override;
86
87 //setters and getters
88 void setXAttribute( const QString &attribute ) { mXAttribute = attribute; }
89 QString xAttribute() const { return mXAttribute; }
90 void setYAttribute( const QString &attribute ) { mYAttribute = attribute; }
91 QString yAttribute() const { return mYAttribute; }
92 void setScale( double s ) { mScale = s; }
93 double scale() const { return mScale; }
94 void setVectorFieldType( VectorFieldType type ) { mVectorFieldType = type; }
95 VectorFieldType vectorFieldType() const { return mVectorFieldType; }
96 void setAngleOrientation( AngleOrientation orientation ) { mAngleOrientation = orientation; }
97 AngleOrientation angleOrientation() const { return mAngleOrientation; }
98 void setAngleUnits( AngleUnits units ) { mAngleUnits = units; }
99 AngleUnits angleUnits() const { return mAngleUnits; }
100
101 void setOutputUnit( Qgis::RenderUnit unit ) override;
102 Qgis::RenderUnit outputUnit() const override;
103
104 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
105 QgsMapUnitScale mapUnitScale() const override;
106
112 void setDistanceUnit( Qgis::RenderUnit unit ) { mDistanceUnit = unit; }
113
118 Qgis::RenderUnit distanceUnit() const { return mDistanceUnit; }
119
120 void setDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceMapUnitScale = scale; }
121 const QgsMapUnitScale &distanceMapUnitScale() const { return mDistanceMapUnitScale; }
122
123 // TODO - implement properly
124 QRectF bounds( QPointF, QgsSymbolRenderContext & ) override { return QRectF(); }
125
126 private:
127#ifdef SIP_RUN
129#endif
130
131 QString mXAttribute;
132 QString mYAttribute;
134 QgsMapUnitScale mDistanceMapUnitScale;
135 double mScale = 1.0;
136 VectorFieldType mVectorFieldType = Cartesian;
137 AngleOrientation mAngleOrientation = ClockwiseFromNorth;
138 AngleUnits mAngleUnits = Degrees;
139
140 std::unique_ptr< QgsLineSymbol > mLineSymbol;
141
142 //Attribute indices are resolved in startRender method
143 int mXIndex = -1;
144 int mYIndex = -1;
145
146 //Converts length/angle to Cartesian x/y
147 void convertPolarToCartesian( double length, double angle, double &x, double &y ) const;
148};
149
150#endif // QGSVECTORFIELDSYMBOLLAYER_H
151
152
RenderUnit
Rendering size units.
Definition qgis.h:5279
@ Millimeters
Millimeters.
Definition qgis.h:5280
A line symbol type, for rendering LineString and MultiLineString geometries.
Struct for storing maximum and minimum scales for measurements in map units.
QgsMarkerSymbolLayer(const QgsMarkerSymbolLayer &other)
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QgsMapUnitScale mapUnitScale() const override
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Contains information about the context of a rendering operation.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Qgis::SymbolType type() const
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
QgsSymbolLayer(const QgsSymbolLayer &other)
Encapsulates the context in which a symbol is being rendered.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
A symbol layer class for displaying displacement arrows based on point layer attributes.
const QgsMapUnitScale & distanceMapUnitScale() const
void setYAttribute(const QString &attribute)
void setAngleUnits(AngleUnits units)
void setVectorFieldType(VectorFieldType type)
void setDistanceUnit(Qgis::RenderUnit unit)
Sets the units for the distance.
~QgsVectorFieldSymbolLayer() override
void setAngleOrientation(AngleOrientation orientation)
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
AngleOrientation angleOrientation() const
QRectF bounds(QPointF, QgsSymbolRenderContext &) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
void setXAttribute(const QString &attribute)
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Qgis::RenderUnit distanceUnit() const
Returns the units for the distance.
static QgsSymbolLayer * createFromSld(QDomElement &element)
VectorFieldType vectorFieldType() const
QString layerType() const override
Returns a string that represents this layer type.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84