QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsvectorfieldsymbollayer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorfieldsymbollayer.cpp
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 
19 #include "qgsvectorlayer.h"
20 #include "qgsunittypes.h"
21 #include "qgssymbollayerutils.h"
22 #include "qgslinesymbol.h"
23 
25 {
26  setSubSymbol( new QgsLineSymbol() );
27 }
28 
30 
32 {
34  mDistanceUnit = unit;
35  if ( mLineSymbol )
36  mLineSymbol->setOutputUnit( unit );
37 }
38 
40 {
41  if ( QgsMarkerSymbolLayer::outputUnit() == mDistanceUnit )
42  {
43  return mDistanceUnit;
44  }
46 }
47 
49 {
51  mDistanceMapUnitScale = scale;
52 }
53 
55 {
56  if ( QgsMarkerSymbolLayer::mapUnitScale() == mDistanceMapUnitScale )
57  {
58  return mDistanceMapUnitScale;
59  }
60  return QgsMapUnitScale();
61 }
62 
63 QgsSymbolLayer *QgsVectorFieldSymbolLayer::create( const QVariantMap &properties )
64 {
66  if ( properties.contains( QStringLiteral( "x_attribute" ) ) )
67  {
68  symbolLayer->setXAttribute( properties[QStringLiteral( "x_attribute" )].toString() );
69  }
70  if ( properties.contains( QStringLiteral( "y_attribute" ) ) )
71  {
72  symbolLayer->setYAttribute( properties[QStringLiteral( "y_attribute" )].toString() );
73  }
74  if ( properties.contains( QStringLiteral( "distance_unit" ) ) )
75  {
76  symbolLayer->setDistanceUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "distance_unit" )].toString() ) );
77  }
78  if ( properties.contains( QStringLiteral( "distance_map_unit_scale" ) ) )
79  {
80  symbolLayer->setDistanceMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "distance_map_unit_scale" )].toString() ) );
81  }
82  if ( properties.contains( QStringLiteral( "scale" ) ) )
83  {
84  symbolLayer->setScale( properties[QStringLiteral( "scale" )].toDouble() );
85  }
86  if ( properties.contains( QStringLiteral( "vector_field_type" ) ) )
87  {
88  symbolLayer->setVectorFieldType( static_cast< VectorFieldType >( properties[QStringLiteral( "vector_field_type" )].toInt() ) );
89  }
90  if ( properties.contains( QStringLiteral( "angle_orientation" ) ) )
91  {
92  symbolLayer->setAngleOrientation( static_cast< AngleOrientation >( properties[QStringLiteral( "angle_orientation" )].toInt() ) );
93  }
94  if ( properties.contains( QStringLiteral( "angle_units" ) ) )
95  {
96  symbolLayer->setAngleUnits( static_cast< AngleUnits >( properties[QStringLiteral( "angle_units" )].toInt() ) );
97  }
98  if ( properties.contains( QStringLiteral( "size" ) ) )
99  {
100  symbolLayer->setSize( properties[QStringLiteral( "size" )].toDouble() );
101  }
102  if ( properties.contains( QStringLiteral( "size_unit" ) ) )
103  {
104  symbolLayer->setSizeUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "size_unit" )].toString() ) );
105  }
106  if ( properties.contains( QStringLiteral( "size_map_unit_scale" ) ) )
107  {
108  symbolLayer->setSizeMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "size_map_unit_scale" )].toString() ) );
109  }
110  if ( properties.contains( QStringLiteral( "offset" ) ) )
111  {
112  symbolLayer->setOffset( QgsSymbolLayerUtils::decodePoint( properties[QStringLiteral( "offset" )].toString() ) );
113  }
114  if ( properties.contains( QStringLiteral( "offset_unit" ) ) )
115  {
116  symbolLayer->setOffsetUnit( QgsUnitTypes::decodeRenderUnit( properties[QStringLiteral( "offset_unit" )].toString() ) );
117  }
118  if ( properties.contains( QStringLiteral( "offset_map_unit_scale" ) ) )
119  {
120  symbolLayer->setOffsetMapUnitScale( QgsSymbolLayerUtils::decodeMapUnitScale( properties[QStringLiteral( "offset_map_unit_scale" )].toString() ) );
121  }
122  return symbolLayer;
123 }
124 
126 {
127  if ( symbol->type() == Qgis::SymbolType::Line )
128  {
129  mLineSymbol.reset( static_cast<QgsLineSymbol *>( symbol ) );
130  return true;
131  }
132  return false;
133 }
134 
136 {
137  return mLineSymbol.get();
138 }
139 
141 {
142  if ( !mLineSymbol )
143  {
144  return;
145  }
146 
147  const QgsRenderContext &ctx = context.renderContext();
148 
149  const bool prevIsSubsymbol = context.renderContext().flags() & Qgis::RenderContextFlag::RenderingSubSymbol;
151 
152  if ( !context.feature() )
153  {
154  //preview
155  QPolygonF line;
156  line << QPointF( 0, 50 );
157  line << QPointF( 100, 50 );
158  mLineSymbol->renderPolyline( line, nullptr, context.renderContext() );
160  return;
161  }
162 
163  const QgsFeature f( *context.feature() );
164 
165  double xComponent = 0;
166  double yComponent = 0;
167 
168  double xVal = 0;
169  if ( mXIndex != -1 )
170  {
171  xVal = f.attribute( mXIndex ).toDouble();
172  }
173  double yVal = 0;
174  if ( mYIndex != -1 )
175  {
176  yVal = f.attribute( mYIndex ).toDouble();
177  }
178 
179  const QgsMapToPixel &m2p = ctx.mapToPixel();
180  const double mapRotation = m2p.mapRotation();
181 
182  QPolygonF line;
183  line << point;
184 
185  QPointF destPoint;
186  switch ( mVectorFieldType )
187  {
188  case Cartesian:
189  {
190  destPoint = QPointF( point.x() + mScale * ctx.convertToPainterUnits( xVal, mDistanceUnit, mDistanceMapUnitScale ),
191  point.y() - mScale * ctx.convertToPainterUnits( yVal, mDistanceUnit, mDistanceMapUnitScale ) );
192  break;
193  }
194 
195  case Polar:
196  {
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 ) );
200  break;
201  }
202 
203  case Height:
204  {
205  destPoint = QPointF( point.x(), point.y() - ( mScale * ctx.convertToPainterUnits( yVal, mDistanceUnit, mDistanceMapUnitScale ) ) );
206  break;
207  }
208  }
209 
210  if ( !qgsDoubleNear( mapRotation, 0.0 ) && mVectorFieldType != Height )
211  {
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() );
215  }
216 
217  line << destPoint;
218 
219  mLineSymbol->renderPolyline( line, &f, context.renderContext() );
221 }
222 
224 {
225  if ( mLineSymbol )
226  {
227  mLineSymbol->startRender( context.renderContext(), context.fields() );
228  }
229 
230  const QgsFields fields = context.fields();
231  if ( !fields.isEmpty() )
232  {
233  mXIndex = fields.lookupField( mXAttribute );
234  mYIndex = fields.lookupField( mYAttribute );
235  }
236  else
237  {
238  mXIndex = -1;
239  mYIndex = -1;
240  }
241 }
242 
244 {
245  if ( mLineSymbol )
246  {
247  mLineSymbol->stopRender( context.renderContext() );
248  }
249 }
250 
252 {
254  if ( mLineSymbol )
255  {
256  clonedLayer->setSubSymbol( mLineSymbol->clone() );
257  }
258  return static_cast< QgsVectorFieldSymbolLayer * >( clonedLayer );
259 }
260 
262 {
263  QVariantMap properties;
264  properties[QStringLiteral( "x_attribute" )] = mXAttribute;
265  properties[QStringLiteral( "y_attribute" )] = mYAttribute;
266  properties[QStringLiteral( "distance_unit" )] = QgsUnitTypes::encodeUnit( mDistanceUnit );
267  properties[QStringLiteral( "distance_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mDistanceMapUnitScale );
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 );
272  properties[QStringLiteral( "size" )] = QString::number( mSize );
273  properties[QStringLiteral( "size_unit" )] = QgsUnitTypes::encodeUnit( mSizeUnit );
274  properties[QStringLiteral( "size_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mSizeMapUnitScale );
275  properties[QStringLiteral( "offset" )] = QgsSymbolLayerUtils::encodePoint( mOffset );
276  properties[QStringLiteral( "offset_unit" )] = QgsUnitTypes::encodeUnit( mOffsetUnit );
277  properties[QStringLiteral( "offset_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale( mOffsetMapUnitScale );
278  return properties;
279 }
280 
282 {
283  return mDistanceUnit == QgsUnitTypes::RenderMapUnits || mDistanceUnit == QgsUnitTypes::RenderMetersInMapUnits
286 }
287 
288 void QgsVectorFieldSymbolLayer::toSld( QDomDocument &doc, QDomElement &element, const QVariantMap &props ) const
289 {
290  element.appendChild( doc.createComment( QStringLiteral( "VectorField not implemented yet..." ) ) );
291  mLineSymbol->toSld( doc, element, props );
292 }
293 
295 {
296  Q_UNUSED( element )
297  return nullptr;
298 }
299 
301 {
302  if ( mLineSymbol )
303  {
304  mLineSymbol->drawPreviewIcon( context.renderContext().painter(), size );
305  }
306 }
307 
308 QSet<QString> QgsVectorFieldSymbolLayer::usedAttributes( const QgsRenderContext &context ) const
309 {
310  QSet<QString> attributes = QgsMarkerSymbolLayer::usedAttributes( context );
311  if ( !mXAttribute.isEmpty() )
312  {
313  attributes.insert( mXAttribute );
314  }
315  if ( !mYAttribute.isEmpty() )
316  {
317  attributes.insert( mYAttribute );
318  }
319  if ( mLineSymbol )
320  {
321  attributes.unite( mLineSymbol->usedAttributes( context ) );
322  }
323  return attributes;
324 }
325 
327 {
329  return true;
330  if ( mLineSymbol && mLineSymbol->hasDataDefinedProperties() )
331  return true;
332  return false;
333 }
334 
335 void QgsVectorFieldSymbolLayer::convertPolarToCartesian( double length, double angle, double &x, double &y ) const
336 {
337  //convert angle to degree and to north orientation
338  if ( mAngleOrientation == CounterclockwiseFromEast )
339  {
340  if ( angle <= 90 )
341  {
342  angle = 90 - angle;
343  }
344  else
345  {
346  angle = 360 - angle + 90;
347  }
348  }
349 
350  if ( mAngleUnits == Degrees )
351  {
352  angle = angle * M_PI / 180.0;
353  }
354 
355  x = length * std::sin( angle );
356  y = length * std::cos( angle );
357 }
358 
359 void QgsVectorFieldSymbolLayer::setColor( const QColor &color )
360 {
361  if ( mLineSymbol )
362  mLineSymbol->setColor( color );
363 
364  mColor = color;
365 }
366 
368 {
369  return mLineSymbol ? mLineSymbol->color() : mColor;
370 }
371 
372 
QgsVectorFieldSymbolLayer::AngleOrientation
AngleOrientation
Definition: qgsvectorfieldsymbollayer.h:41
QgsMarkerSymbolLayer::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
Definition: qgssymbollayer.h:794
QgsVectorFieldSymbolLayer::setVectorFieldType
void setVectorFieldType(VectorFieldType type)
Definition: qgsvectorfieldsymbollayer.h:90
QgsVectorFieldSymbolLayer::usesMapUnits
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
Definition: qgsvectorfieldsymbollayer.cpp:281
QgsVectorFieldSymbolLayer::setDistanceUnit
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the distance.
Definition: qgsvectorfieldsymbollayer.h:108
QgsSymbolLayer::mColor
QColor mColor
Definition: qgssymbollayer.h:648
QgsRenderContext::mapToPixel
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Definition: qgsrendercontext.h:258
QgsMarkerSymbolLayer::size
double size() const
Returns the symbol size.
Definition: qgssymbollayer.h:785
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsMarkerSymbolLayer::mSizeMapUnitScale
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Definition: qgssymbollayer.h:997
Qgis::SymbolType::Line
@ Line
Line symbol.
QgsVectorFieldSymbolLayer
A symbol layer class for displaying displacement arrows based on point layer attributes.
Definition: qgsvectorfieldsymbollayer.h:31
QgsMarkerSymbolLayer::mapUnitScale
QgsMapUnitScale mapUnitScale() const override
Definition: qgssymbollayer.cpp:712
QgsSymbolLayerUtils::encodeMapUnitScale
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Definition: qgssymbollayerutils.cpp:666
QgsFields::isEmpty
bool isEmpty() const
Checks whether the container is empty.
Definition: qgsfields.cpp:128
QgsSymbolRenderContext::feature
const QgsFeature * feature() const
Returns the current feature being rendered.
Definition: qgssymbolrendercontext.h:143
QgsVectorFieldSymbolLayer::startRender
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Definition: qgsvectorfieldsymbollayer.cpp:223
QgsVectorFieldSymbolLayer::drawPreviewIcon
void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size) override
Definition: qgsvectorfieldsymbollayer.cpp:300
qgssymbollayerutils.h
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsSymbolLayer::hasDataDefinedProperties
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Definition: qgssymbollayer.cpp:287
QgsRenderContext::flags
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
Definition: qgsrendercontext.cpp:224
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsVectorFieldSymbolLayer::createFromSld
static QgsSymbolLayer * createFromSld(QDomElement &element)
Definition: qgsvectorfieldsymbollayer.cpp:294
qgsunittypes.h
QgsVectorFieldSymbolLayer::Height
@ Height
Definition: qgsvectorfieldsymbollayer.h:38
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:92
QgsMarkerSymbolLayer::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
Definition: qgssymbollayer.cpp:706
QgsMarkerSymbolLayer::mSizeUnit
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
Definition: qgssymbollayer.h:995
QgsVectorFieldSymbolLayer::hasDataDefinedProperties
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Definition: qgsvectorfieldsymbollayer.cpp:326
QgsVectorFieldSymbolLayer::setXAttribute
void setXAttribute(const QString &attribute)
Definition: qgsvectorfieldsymbollayer.h:84
QgsVectorFieldSymbolLayer::setColor
void setColor(const QColor &color) override
Sets the "representative" color for the symbol layer.
Definition: qgsvectorfieldsymbollayer.cpp:359
QgsVectorFieldSymbolLayer::setSubSymbol
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
Definition: qgsvectorfieldsymbollayer.cpp:125
QgsMarkerSymbolLayer::mOffsetUnit
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
Definition: qgssymbollayer.h:1001
QgsMarkerSymbolLayer::mSize
double mSize
Marker size.
Definition: qgssymbollayer.h:993
QgsUnitTypes::decodeRenderUnit
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
Definition: qgsunittypes.cpp:2948
QgsSymbolRenderContext
Definition: qgssymbolrendercontext.h:35
QgsVectorFieldSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgsvectorfieldsymbollayer.cpp:31
QgsMarkerSymbolLayer::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:691
QgsVectorFieldSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgsvectorfieldsymbollayer.cpp:39
QgsVectorFieldSymbolLayer::QgsVectorFieldSymbolLayer
QgsVectorFieldSymbolLayer()
Definition: qgsvectorfieldsymbollayer.cpp:24
QgsSymbolLayer
Definition: qgssymbollayer.h:54
QgsVectorFieldSymbolLayer::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
Definition: qgsvectorfieldsymbollayer.cpp:48
QgsUnitTypes::encodeUnit
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
Definition: qgsunittypes.cpp:122
QgsSymbolLayer::setSubSymbol
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Definition: qgssymbollayer.cpp:159
QgsVectorFieldSymbolLayer::Polar
@ Polar
Definition: qgsvectorfieldsymbollayer.h:37
QgsSymbolRenderContext::fields
QgsFields fields() const
Fields of the layer.
Definition: qgssymbolrendercontext.h:168
QgsSymbol::type
Qgis::SymbolType type() const
Returns the symbol's type.
Definition: qgssymbol.h:152
qgsDoubleNear
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:2265
QgsRenderContext::setFlag
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
Definition: qgsrendercontext.cpp:216
QgsMapToPixel::mapRotation
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
Definition: qgsmaptopixel.h:269
QgsSymbolLayerUtils::decodePoint
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
Definition: qgssymbollayerutils.cpp:543
QgsMarkerSymbolLayer::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Definition: qgssymbollayer.cpp:697
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
QgsVectorFieldSymbolLayer::CounterclockwiseFromEast
@ CounterclockwiseFromEast
Definition: qgsvectorfieldsymbollayer.h:44
QgsVectorFieldSymbolLayer::properties
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Definition: qgsvectorfieldsymbollayer.cpp:261
QgsVectorFieldSymbolLayer::renderPoint
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
Definition: qgsvectorfieldsymbollayer.cpp:140
QgsFeature::attribute
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Definition: qgsfeature.cpp:327
QgsVectorFieldSymbolLayer::clone
QgsVectorFieldSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Definition: qgsvectorfieldsymbollayer.cpp:251
QgsMarkerSymbolLayer::setOffset
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
Definition: qgssymbollayer.h:842
QgsVectorFieldSymbolLayer::subSymbol
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Definition: qgsvectorfieldsymbollayer.cpp:135
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsVectorFieldSymbolLayer::setDistanceMapUnitScale
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgsvectorfieldsymbollayer.h:116
QgsMarkerSymbolLayer::setOffsetUnit
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
Definition: qgssymbollayer.h:860
QgsVectorFieldSymbolLayer::create
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
Definition: qgsvectorfieldsymbollayer.cpp:63
QgsSymbolLayerUtils::encodePoint
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
Definition: qgssymbollayerutils.cpp:538
qgsvectorfieldsymbollayer.h
QgsSymbolLayer::usedAttributes
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Definition: qgssymbollayer.cpp:328
qgsvectorlayer.h
QgsRenderContext::convertToPainterUnits
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).
Definition: qgsrendercontext.cpp:367
QgsVectorFieldSymbolLayer::setScale
void setScale(double s)
Definition: qgsvectorfieldsymbollayer.h:88
QgsVectorFieldSymbolLayer::usedAttributes
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
Definition: qgsvectorfieldsymbollayer.cpp:308
QgsMarkerSymbolLayer::setOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
Definition: qgssymbollayer.h:877
QgsMarkerSymbolLayer::mOffset
QPointF mOffset
Marker offset.
Definition: qgssymbollayer.h:999
QgsVectorFieldSymbolLayer::stopRender
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Definition: qgsvectorfieldsymbollayer.cpp:243
QgsVectorFieldSymbolLayer::mapUnitScale
QgsMapUnitScale mapUnitScale() const override
Definition: qgsvectorfieldsymbollayer.cpp:54
QgsVectorFieldSymbolLayer::~QgsVectorFieldSymbolLayer
~QgsVectorFieldSymbolLayer() override
QgsVectorFieldSymbolLayer::Degrees
@ Degrees
Definition: qgsvectorfieldsymbollayer.h:49
QgsVectorFieldSymbolLayer::color
QColor color() const override
Returns the "representative" color of the symbol layer.
Definition: qgsvectorfieldsymbollayer.cpp:367
QgsMapToPixel
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:38
QgsVectorFieldSymbolLayer::VectorFieldType
VectorFieldType
Definition: qgsvectorfieldsymbollayer.h:34
QgsVectorFieldSymbolLayer::setAngleOrientation
void setAngleOrientation(AngleOrientation orientation)
Definition: qgsvectorfieldsymbollayer.h:92
QgsUnitTypes::RenderMetersInMapUnits
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:176
QgsVectorFieldSymbolLayer::AngleUnits
AngleUnits
Definition: qgsvectorfieldsymbollayer.h:47
QgsUnitTypes::RenderUnknownUnit
@ RenderUnknownUnit
Mixed or unknown units.
Definition: qgsunittypes.h:175
QgsVectorFieldSymbolLayer::Cartesian
@ Cartesian
Definition: qgsvectorfieldsymbollayer.h:36
QgsMarkerSymbolLayer::setSize
virtual void setSize(double size)
Sets the symbol size.
Definition: qgssymbollayer.h:777
QgsMarkerSymbolLayer::setSizeMapUnitScale
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
Definition: qgssymbollayer.h:811
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsSymbolRenderContext::renderContext
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Definition: qgssymbolrendercontext.h:62
QgsVectorFieldSymbolLayer::scale
double scale() const
Definition: qgsvectorfieldsymbollayer.h:89
Qgis::RenderContextFlag::RenderingSubSymbol
@ RenderingSubSymbol
Set whenever a sub-symbol of a parent symbol is currently being rendered. Can be used during symbol a...
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:112
QgsFields::lookupField
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Definition: qgsfields.cpp:349
QgsMarkerSymbolLayer::mOffsetMapUnitScale
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
Definition: qgssymbollayer.h:1003
MathUtils::angle
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)
Definition: MathUtils.cpp:786
QgsVectorFieldSymbolLayer::setYAttribute
void setYAttribute(const QString &attribute)
Definition: qgsvectorfieldsymbollayer.h:86
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
QgsSymbolLayerUtils::decodeMapUnitScale
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
Definition: qgssymbollayerutils.cpp:676
QgsMarkerSymbolLayer::angle
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
Definition: qgssymbollayer.h:757
QgsVectorFieldSymbolLayer::setAngleUnits
void setAngleUnits(AngleUnits units)
Definition: qgsvectorfieldsymbollayer.h:94
qgslinesymbol.h
QgsVectorFieldSymbolLayer::toSld
void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
Definition: qgsvectorfieldsymbollayer.cpp:288