27 , mVectorFieldType( Cartesian )
28 , mAngleOrientation( ClockwiseFromNorth )
29 , mAngleUnits( Degrees )
30 , mLineSymbol( nullptr )
60 mDistanceMapUnitScale =
scale;
67 return mDistanceMapUnitScale;
75 if ( properties.
contains(
"x_attribute" ) )
79 if ( properties.
contains(
"y_attribute" ) )
83 if ( properties.
contains(
"distance_unit" ) )
87 if ( properties.
contains(
"distance_map_unit_scale" ) )
91 if ( properties.
contains(
"scale" ) )
93 symbolLayer->
setScale( properties[
"scale"].toDouble() );
95 if ( properties.
contains(
"vector_field_type" ) )
97 symbolLayer->
setVectorFieldType( static_cast< VectorFieldType >( properties[
"vector_field_type"].toInt() ) );
99 if ( properties.
contains(
"angle_orientation" ) )
101 symbolLayer->
setAngleOrientation( static_cast< AngleOrientation >( properties[
"angle_orientation"].toInt() ) );
103 if ( properties.
contains(
"angle_units" ) )
105 symbolLayer->
setAngleUnits( static_cast< AngleUnits >( properties[
"angle_units"].toInt() ) );
107 if ( properties.
contains(
"size" ) )
109 symbolLayer->
setSize( properties[
"size"].toDouble() );
111 if ( properties.
contains(
"size_unit" ) )
115 if ( properties.
contains(
"size_map_unit_scale" ) )
119 if ( properties.
contains(
"offset" ) )
123 if ( properties.
contains(
"offset_unit" ) )
127 if ( properties.
contains(
"offset_map_unit_scale" ) )
160 line << QPointF( 100, 50 );
164 double xComponent = 0;
165 double yComponent = 0;
168 if ( f && mXIndex != -1 )
173 if ( f && mYIndex != -1 )
178 switch ( mVectorFieldType )
185 convertPolarToCartesian( xVal, yVal, xComponent, yComponent );
197 xComponent *= mScale;
198 yComponent *= mScale;
202 line <<
QPointF( point.x() + xComponent, point.y() - yComponent );
247 properties[
"x_attribute"] = mXAttribute;
248 properties[
"y_attribute"] = mYAttribute;
253 properties[
"angle_orientation"] =
QString::number( mAngleOrientation );
267 mLineSymbol->
toSld( doc, element, props );
289 attributes.
insert( mXAttribute );
293 attributes.
insert( mYAttribute );
302 void QgsVectorFieldSymbolLayer::convertPolarToCartesian(
double length,
double angle,
double& x,
double& y )
const 322 x = length * sin(
angle );
323 y = length * cos(
angle );
336 return mLineSymbol ? mLineSymbol->
color() :
mColor;
QgsVectorFieldSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
Renders a marker at the specified point.
QgsMapUnitScale mapUnitScale() const override
void setXAttribute(const QString &attribute)
QgsSymbolV2::OutputUnit outputUnit() const override
const QgsFields * fields() const
Fields of the layer.
OutputUnit
The unit of the output.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
void setYAttribute(const QString &attribute)
bool contains(const Key &key) const
virtual QgsLineSymbolV2 * clone() const override
QgsVectorFieldSymbolLayer()
QDomNode appendChild(const QDomNode &newChild)
void setAngleUnits(AngleUnits units)
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
double size() const
Returns the symbol size.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
Container of fields for a vector layer.
static QPointF decodePoint(const QString &str)
const QgsFeature * feature() const
Current feature being rendered - may be null.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
const_iterator insert(const T &value)
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr)
Draw icon of the symbol that occupyies area given by size using the painter.
void setMapUnitScale(const QgsMapUnitScale &scale) override
~QgsVectorFieldSymbolLayer()
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units for the symbol's offset.
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the SLD element following the SLD v1.1 specs.
static QgsSymbolV2::OutputUnit decodeOutputUnit(const QString &str)
A symbol layer class for displaying displacement arrows based on point layer attributes.
void setColor(const QColor &color)
Mixed units in symbol layers.
QString number(int n, int base)
void startRender(QgsRenderContext &context, const QgsFields *fields=nullptr)
static QString encodePoint(QPointF point)
static double convertToPainterUnits(const QgsRenderContext &c, double size, QgsSymbolV2::OutputUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale())
Converts a size from the specied units to painter units.
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void setSizeUnit(QgsSymbolV2::OutputUnit unit)
Sets the units for the symbol's size.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
void stopRender(QgsSymbolV2RenderContext &context) override
virtual QColor color() const override
The fill color.
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
void setColor(const QColor &color) override
The fill color.
void startRender(QgsSymbolV2RenderContext &context) override
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
bool setSubSymbol(QgsSymbolV2 *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
Contains information about the context of a rendering operation.
void stopRender(QgsRenderContext &context)
QSet< T > & unite(const QSet< T > &other)
QgsSymbolV2::OutputUnit outputUnit() const override
Struct for storing maximum and minimum scales for measurements in map units.
QgsMapUnitScale mapUnitScale() const override
QSet< QString > usedAttributes() const override
Returns the set of attributes referenced by the layer.
void drawPreviewIcon(QgsSymbolV2RenderContext &context, QSize size) override
QgsRenderContext & renderContext()
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
void setAngleOrientation(AngleOrientation orientation)
QgsSymbolV2::OutputUnit mOffsetUnit
Offset units.
double toDouble(bool *ok) const
QgsSymbolV2::OutputUnit mSizeUnit
Marker size unit.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QSet< QString > usedAttributes() const
Return a list of attributes required to render this feature.
void setSize(double size)
Sets the symbol size.
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
virtual bool setSubSymbol(QgsSymbolV2 *symbol)
set layer's subsymbol. takes ownership of the passed symbol
void setVectorFieldType(VectorFieldType type)
QPointF mOffset
Marker offset.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override