QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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_core.h"
22#include "qgis.h"
23#include "qgssymbollayer.h"
24
25class QgsLineSymbol;
26
32{
33 public:
35 {
36 Cartesian = 0,
38 Height
39 };
40
42 {
43 ClockwiseFromNorth = 0,
44 CounterclockwiseFromEast
45 };
46
48 {
49 Degrees = 0,
50 Radians
51 };
52
55
57 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() );
58 static QgsSymbolLayer *createFromSld( QDomElement &element );
59
60 QString layerType() const override { return QStringLiteral( "VectorField" ); }
61
62 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
63 QgsSymbol *subSymbol() override;
64
65 void setColor( const QColor &color ) override;
66 QColor color() const override;
67
68 void renderPoint( QPointF point, QgsSymbolRenderContext &context ) override;
69 void startRender( QgsSymbolRenderContext &context ) override;
70 void stopRender( QgsSymbolRenderContext &context ) override;
71
73 QVariantMap properties() const override;
74 bool usesMapUnits() const override;
75
76 void toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const override;
77
78 void drawPreviewIcon( QgsSymbolRenderContext &context, QSize size ) override;
79
80 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
81 bool hasDataDefinedProperties() const override;
82
83 //setters and getters
84 void setXAttribute( const QString &attribute ) { mXAttribute = attribute; }
85 QString xAttribute() const { return mXAttribute; }
86 void setYAttribute( const QString &attribute ) { mYAttribute = attribute; }
87 QString yAttribute() const { return mYAttribute; }
88 void setScale( double s ) { mScale = s; }
89 double scale() const { return mScale; }
90 void setVectorFieldType( VectorFieldType type ) { mVectorFieldType = type; }
91 VectorFieldType vectorFieldType() const { return mVectorFieldType; }
92 void setAngleOrientation( AngleOrientation orientation ) { mAngleOrientation = orientation; }
93 AngleOrientation angleOrientation() const { return mAngleOrientation; }
94 void setAngleUnits( AngleUnits units ) { mAngleUnits = units; }
95 AngleUnits angleUnits() const { return mAngleUnits; }
96
97 void setOutputUnit( Qgis::RenderUnit unit ) override;
98 Qgis::RenderUnit outputUnit() const override;
99
100 void setMapUnitScale( const QgsMapUnitScale &scale ) override;
101 QgsMapUnitScale mapUnitScale() const override;
102
108 void setDistanceUnit( Qgis::RenderUnit unit ) { mDistanceUnit = unit; }
109
114 Qgis::RenderUnit distanceUnit() const { return mDistanceUnit; }
115
116 void setDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mDistanceMapUnitScale = scale; }
117 const QgsMapUnitScale &distanceMapUnitScale() const { return mDistanceMapUnitScale; }
118
119 // TODO - implement properly
120 QRectF bounds( QPointF, QgsSymbolRenderContext & ) override { return QRectF(); }
121
122 private:
123#ifdef SIP_RUN
125#endif
126
127 QString mXAttribute;
128 QString mYAttribute;
130 QgsMapUnitScale mDistanceMapUnitScale;
131 double mScale = 1.0;
132 VectorFieldType mVectorFieldType = Cartesian;
133 AngleOrientation mAngleOrientation = ClockwiseFromNorth;
134 AngleUnits mAngleUnits = Degrees;
135
136 std::unique_ptr< QgsLineSymbol > mLineSymbol;
137
138 //Attribute indices are resolved in startRender method
139 int mXIndex = -1;
140 int mYIndex = -1;
141
142 //Converts length/angle to Cartesian x/y
143 void convertPolarToCartesian( double length, double angle, double &x, double &y ) const;
144};
145
146#endif // QGSVECTORFIELDSYMBOLLAYER_H
147
148
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ Millimeters
Millimeters.
A line symbol type, for rendering LineString and MultiLineString geometries.
Struct for storing maximum and minimum scales for measurements in map units.
Abstract base class for marker symbol layers.
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.
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.
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)
AngleOrientation angleOrientation() const
QRectF bounds(QPointF, QgsSymbolRenderContext &) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Qgis::RenderUnit distanceUnit() const
Returns the units for the distance.
VectorFieldType vectorFieldType() const
QString layerType() const override
Returns a string that represents this layer type.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76