QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
36 mLineSymbol->setOutputUnit( unit );
51 mDistanceMapUnitScale =
scale;
58 return mDistanceMapUnitScale;
66 if (
properties.contains( QStringLiteral(
"x_attribute" ) ) )
70 if (
properties.contains( QStringLiteral(
"y_attribute" ) ) )
74 if (
properties.contains( QStringLiteral(
"distance_unit" ) ) )
78 if (
properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
82 if (
properties.contains( QStringLiteral(
"scale" ) ) )
86 if (
properties.contains( QStringLiteral(
"vector_field_type" ) ) )
90 if (
properties.contains( QStringLiteral(
"angle_orientation" ) ) )
94 if (
properties.contains( QStringLiteral(
"angle_units" ) ) )
98 if (
properties.contains( QStringLiteral(
"size" ) ) )
102 if (
properties.contains( QStringLiteral(
"size_unit" ) ) )
106 if (
properties.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
110 if (
properties.contains( QStringLiteral(
"offset" ) ) )
114 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
118 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
137 return mLineSymbol.get();
156 line << QPointF( 0, 50 );
157 line << QPointF( 100, 50 );
158 mLineSymbol->renderPolyline( line,
nullptr, context.
renderContext() );
165 double xComponent = 0;
166 double yComponent = 0;
171 xVal = f.
attribute( mXIndex ).toDouble();
176 yVal = f.
attribute( mYIndex ).toDouble();
186 switch ( mVectorFieldType )
190 destPoint = QPointF( point.x() + mScale * ctx.
convertToPainterUnits( xVal, mDistanceUnit, mDistanceMapUnitScale ),
197 convertPolarToCartesian( xVal, yVal, xComponent, yComponent );
198 destPoint = QPointF( point.x() + mScale * ctx.
convertToPainterUnits( xComponent, mDistanceUnit, mDistanceMapUnitScale ),
199 point.y() - mScale * ctx.
convertToPainterUnits( yComponent, mDistanceUnit, mDistanceMapUnitScale ) );
205 destPoint = QPointF( point.x(), point.y() - ( mScale * ctx.
convertToPainterUnits( yVal, mDistanceUnit, mDistanceMapUnitScale ) ) );
212 const double radians = mapRotation * M_PI / 180.0;
213 destPoint = QPointF( cos( radians ) * ( destPoint.x() - point.x() ) - sin( radians ) * ( destPoint.y() - point.y() ) + point.x(),
214 sin( radians ) * ( destPoint.x() - point.x() ) + cos( radians ) * ( destPoint.y() - point.y() ) + point.y() );
219 mLineSymbol->renderPolyline( line, &f, context.
renderContext() );
264 properties[QStringLiteral(
"x_attribute" )] = mXAttribute;
265 properties[QStringLiteral(
"y_attribute" )] = mYAttribute;
268 properties[QStringLiteral(
"scale" )] = QString::number( mScale );
269 properties[QStringLiteral(
"vector_field_type" )] = QString::number( mVectorFieldType );
270 properties[QStringLiteral(
"angle_orientation" )] = QString::number( mAngleOrientation );
271 properties[QStringLiteral(
"angle_units" )] = QString::number( mAngleUnits );
290 element.appendChild( doc.createComment( QStringLiteral(
"VectorField not implemented yet..." ) ) );
291 mLineSymbol->toSld( doc, element, props );
311 if ( !mXAttribute.isEmpty() )
313 attributes.insert( mXAttribute );
315 if ( !mYAttribute.isEmpty() )
317 attributes.insert( mYAttribute );
321 attributes.unite( mLineSymbol->usedAttributes( context ) );
330 if ( mLineSymbol && mLineSymbol->hasDataDefinedProperties() )
335 void QgsVectorFieldSymbolLayer::convertPolarToCartesian(
double length,
double angle,
double &x,
double &y )
const
355 x = length * std::sin(
angle );
356 y = length * std::cos(
angle );
362 mLineSymbol->setColor(
color );
369 return mLineSymbol ? mLineSymbol->color() :
mColor;
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
void setVectorFieldType(VectorFieldType type)
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the distance.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
double size() const
Returns the symbol size.
RenderUnit
Rendering size units.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
A symbol layer class for displaying displacement arrows based on point layer attributes.
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
Container of fields for a vector layer.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
Contains information about the context of a rendering operation.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Abstract base class for all rendered symbols.
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
Sets the "representative" color for the symbol layer.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
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.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsFields fields() const
Fields of the layer.
Qgis::SymbolType type() const
Returns the symbol's type.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
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.
A line symbol type, for rendering LineString and MultiLineString geometries.
@ CounterclockwiseFromEast
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
QVariant attribute(const QString &name) const
Lookup attribute value by 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...
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
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 QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
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.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
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.
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
~QgsVectorFieldSymbolLayer() override
QColor color() const override
Returns the "representative" color of the symbol layer.
Perform transforms between map coordinates and device coordinates.
void setAngleOrientation(AngleOrientation orientation)
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderUnknownUnit
Mixed or unknown units.
virtual void setSize(double size)
Sets the symbol size.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
@ RenderingSubSymbol
Set whenever a sub-symbol of a parent symbol is currently being rendered. Can be used during symbol a...
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)
@ RenderMapUnits
Map units.
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)
void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.