QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
46 mDistanceMapUnitScale =
scale;
53 return mDistanceMapUnitScale;
61 if (
properties.contains( QStringLiteral(
"x_attribute" ) ) )
65 if (
properties.contains( QStringLiteral(
"y_attribute" ) ) )
69 if (
properties.contains( QStringLiteral(
"distance_unit" ) ) )
73 if (
properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
77 if (
properties.contains( QStringLiteral(
"scale" ) ) )
81 if (
properties.contains( QStringLiteral(
"vector_field_type" ) ) )
85 if (
properties.contains( QStringLiteral(
"angle_orientation" ) ) )
89 if (
properties.contains( QStringLiteral(
"angle_units" ) ) )
93 if (
properties.contains( QStringLiteral(
"size" ) ) )
97 if (
properties.contains( QStringLiteral(
"size_unit" ) ) )
101 if (
properties.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
105 if (
properties.contains( QStringLiteral(
"offset" ) ) )
109 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
113 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
144 line << QPointF( 0, 50 );
145 line << QPointF( 100, 50 );
146 mLineSymbol->renderPolyline( line,
nullptr, context.
renderContext() );
149 double xComponent = 0;
150 double yComponent = 0;
153 if ( f && mXIndex != -1 )
155 xVal = f->
attribute( mXIndex ).toDouble();
158 if ( f && mYIndex != -1 )
160 yVal = f->
attribute( mYIndex ).toDouble();
163 switch ( mVectorFieldType )
170 convertPolarToCartesian( xVal, yVal, xComponent, yComponent );
182 xComponent *= mScale;
183 yComponent *= mScale;
187 line << QPointF( point.x() + xComponent, point.y() - yComponent );
188 mLineSymbol->renderPolyline( line, f, context.
renderContext() );
232 properties[QStringLiteral(
"x_attribute" )] = mXAttribute;
233 properties[QStringLiteral(
"y_attribute" )] = mYAttribute;
236 properties[QStringLiteral(
"scale" )] = QString::number( mScale );
237 properties[QStringLiteral(
"vector_field_type" )] = QString::number( mVectorFieldType );
238 properties[QStringLiteral(
"angle_orientation" )] = QString::number( mAngleOrientation );
239 properties[QStringLiteral(
"angle_units" )] = QString::number( mAngleUnits );
251 element.appendChild( doc.createComment( QStringLiteral(
"VectorField not implemented yet..." ) ) );
252 mLineSymbol->toSld( doc, element, props );
272 if ( !mXAttribute.isEmpty() )
274 attributes.insert( mXAttribute );
276 if ( !mYAttribute.isEmpty() )
278 attributes.insert( mYAttribute );
282 attributes.unite( mLineSymbol->usedAttributes( context ) );
291 if ( mLineSymbol && mLineSymbol->hasDataDefinedProperties() )
296 void QgsVectorFieldSymbolLayer::convertPolarToCartesian(
double length,
double angle,
double &x,
double &y )
const
316 x = length * std::sin(
angle );
317 y = length * std::cos(
angle );
323 mLineSymbol->setColor(
color );
330 return mLineSymbol ? mLineSymbol->color() :
mColor;
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
void setVectorFieldType(VectorFieldType type)
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the distance.
double size() const
Returns the symbol size.
RenderUnit
Rendering size units.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
QgsMapUnitScale mapUnitScale() const override
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
bool isEmpty() const
Checks whether the container is empty.
const QgsFeature * feature() const
Returns the current feature being rendered.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
static QgsSymbolLayer * createFromSld(QDomElement &element)
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
void setXAttribute(const QString &attribute)
void setColor(const QColor &color) override
The fill color.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsVectorFieldSymbolLayer()
void setMapUnitScale(const QgsMapUnitScale &scale) override
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
QgsFields fields() const
Fields of the layer.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
@ CounterclockwiseFromEast
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsVectorFieldSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
Struct for storing maximum and minimum scales for measurements in map units.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
QMap< QString, QString > QgsStringMap
QPointF mOffset
Marker offset.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QgsMapUnitScale mapUnitScale() const override
QColor color() const override
The fill color.
void setAngleOrientation(AngleOrientation orientation)
@ RenderUnknownUnit
Mixed or unknown units.
SymbolType type() const
Returns the symbol's type.
virtual void setSize(double size)
Sets the symbol size.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QPainter * painter()
Returns the destination QPainter for the render operation.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void setYAttribute(const QString &attribute)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
void setAngleUnits(AngleUnits units)