QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
28 #include <QDomDocument>
29 #include <QDomElement>
32 : mStrokeColor( QColor( 35, 35, 35 ) )
35 mPen.setColor( mStrokeColor );
36 mPen.setStyle( mStrokeStyle );
37 mPen.setJoinStyle( mPenJoinStyle );
40 mBrush.setStyle( Qt::SolidPattern );
50 if (
properties.contains( QStringLiteral(
"symbol_name" ) ) )
54 if (
properties.contains( QStringLiteral(
"size" ) ) )
58 if (
properties.contains( QStringLiteral(
"size_unit" ) ) )
62 if (
properties.contains( QStringLiteral(
"size_map_unit_scale" ) ) )
66 if (
properties.contains( QStringLiteral(
"symbol_width" ) ) )
70 if (
properties.contains( QStringLiteral(
"symbol_width_unit" ) ) )
74 if (
properties.contains( QStringLiteral(
"symbol_width_map_unit_scale" ) ) )
78 if (
properties.contains( QStringLiteral(
"symbol_height" ) ) )
82 if (
properties.contains( QStringLiteral(
"symbol_height_unit" ) ) )
86 if (
properties.contains( QStringLiteral(
"symbol_height_map_unit_scale" ) ) )
90 if (
properties.contains( QStringLiteral(
"angle" ) ) )
94 if (
properties.contains( QStringLiteral(
"outline_style" ) ) )
98 else if (
properties.contains( QStringLiteral(
"line_style" ) ) )
102 if (
properties.contains( QStringLiteral(
"joinstyle" ) ) )
106 if (
properties.contains( QStringLiteral(
"cap_style" ) ) )
110 if (
properties.contains( QStringLiteral(
"outline_width" ) ) )
114 else if (
properties.contains( QStringLiteral(
"line_width" ) ) )
118 if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
122 else if (
properties.contains( QStringLiteral(
"line_width_unit" ) ) )
126 if (
properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
130 if (
properties.contains( QStringLiteral(
"fill_color" ) ) )
135 else if (
properties.contains( QStringLiteral(
"color" ) ) )
139 if (
properties.contains( QStringLiteral(
"outline_color" ) ) )
143 else if (
properties.contains( QStringLiteral(
"line_color" ) ) )
147 if (
properties.contains( QStringLiteral(
"offset" ) ) )
151 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
155 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
159 if (
properties.contains( QStringLiteral(
"horizontal_anchor_point" ) ) )
163 if (
properties.contains( QStringLiteral(
"vertical_anchor_point" ) ) )
176 double scaledWidth = mSymbolWidth;
177 double scaledHeight = mSymbolHeight;
179 QColor brushColor =
mColor;
180 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
181 mBrush.setColor( brushColor );
183 QColor penColor = mStrokeColor;
184 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
185 mPen.setColor( penColor );
192 if ( !exprVal.isNull() )
194 double width = exprVal.toDouble( &ok );
198 mPen.setWidthF( width );
199 mSelPen.setWidthF( width );
208 if ( !exprVal.isNull() )
211 mSelPen.setStyle( mPen.style() );
219 if ( !exprVal.isNull() )
222 mSelPen.setJoinStyle( mPen.joinStyle() );
241 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
242 mBrush.setColor( brushColor );
249 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
250 mPen.setColor( penColor );
258 if ( !exprVal.isNull() )
262 preparePath(
shape, context, &scaledWidth, &scaledHeight, context.
feature() );
266 bool hasDataDefinedRotation =
false;
269 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, hasDataDefinedRotation,
offset,
angle );
277 QTransform transform;
278 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
281 transform.rotate(
angle );
286 p->setPen( context.
selected() ? mSelPen : mPen );
287 p->setBrush( context.
selected() ? mSelBrush : mBrush );
291 p->setPen( context.
selected() ? mSelPen : mPen );
292 p->setBrush( QBrush() );
294 p->drawPath( transform.map( mPainterPath ) );
301 bool &hasDataDefinedRotation,
303 double &
angle )
const
307 markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale );
308 offset = QPointF( offsetX, offsetY );
311 const bool ok =
true;
313 bool usingDataDefinedRotation =
false;
318 usingDataDefinedRotation = ok;
322 if ( hasDataDefinedRotation )
347 return QStringLiteral(
"EllipseMarker" );
355 preparePath( mShape, context );
357 mPen.setColor( mStrokeColor );
358 mPen.setStyle( mStrokeStyle );
359 mPen.setJoinStyle( mPenJoinStyle );
360 mPen.setCapStyle( mPenCapStyle );
362 mBrush.setColor(
mColor );
365 QColor selPenColor = selBrushColor ==
mColor ? selBrushColor : mStrokeColor;
368 selBrushColor.setAlphaF( context.
opacity() );
369 selPenColor.setAlphaF( context.
opacity() );
371 mSelBrush = QBrush( selBrushColor );
372 mSelPen = QPen( !
shapeIsFilled( mShape ) ? selBrushColor : selPenColor );
373 mSelPen.setStyle( mStrokeStyle );
414 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PointSymbolizer" ) );
415 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
416 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
417 element.appendChild( symbolizerElem );
428 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
429 element.appendChild( graphicElem );
438 QString angleFunc = props.
value( QStringLiteral(
"angle" ), QString() ).toString();
439 if ( angleFunc.isEmpty() )
441 if ( ddRotation && ddRotation.
isActive() )
446 angleFunc = QString::number(
mAngle );
448 else if ( ddRotation && ddRotation.
isActive() )
452 angleFunc = QStringLiteral(
"%1 + %2" ).arg( angleFunc, ddRotation.
asExpression() );
458 const double angle = angleFunc.toDouble( &ok );
462 angleFunc = QStringLiteral(
"%1 + %2" ).arg( angleFunc ).arg(
mAngle );
477 const double widthHeightFactor = mSymbolWidth / mSymbolHeight;
479 graphicElem.appendChild( factorElem );
486 QDomElement graphicElem = element.firstChildElement( QStringLiteral(
"Graphic" ) );
487 if ( graphicElem.isNull() )
490 QString name = QStringLiteral(
"circle" );
493 double widthHeightFactor = 1.0;
497 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
499 if ( it.key() == QLatin1String(
"widthHeightFactor" ) )
502 const double v = it.value().toDouble( &ok );
504 widthHeightFactor = v;
511 double scaleFactor = 1.0;
512 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
522 const double d = angleFunc.toDouble( &ok );
543 map[QStringLiteral(
"symbol_name" )] =
encodeShape( mShape );
544 map[QStringLiteral(
"symbol_width" )] = QString::number( mSymbolWidth );
547 map[QStringLiteral(
"symbol_height" )] = QString::number( mSymbolHeight );
550 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
552 map[QStringLiteral(
"outline_width" )] = QString::number( mStrokeWidth );
562 map[QStringLiteral(
"size" )] = QString::number(
mSize );
570 QSizeF QgsEllipseSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
double *scaledWidth,
double *scaledHeight )
581 width = mSymbolWidth;
585 *scaledWidth = width;
597 height = mSymbolHeight;
601 *scaledHeight = height;
604 return QSizeF( width, height );
609 mPainterPath = QPainterPath();
611 const QSizeF
size = calculateSize( context, scaledWidth, scaledHeight );
616 mPainterPath.addEllipse( QRectF( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height() ) );
620 mPainterPath.arcTo( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height(), 0, 180 );
621 mPainterPath.lineTo( 0, 0 );
625 mPainterPath.addRect( QRectF( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height() ) );
629 mPainterPath.moveTo( -
size.width() / 2.0, 0 );
630 mPainterPath.lineTo( 0,
size.height() / 2.0 );
631 mPainterPath.lineTo(
size.width() / 2.0, 0 );
632 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
633 mPainterPath.lineTo( -
size.width() / 2.0, 0 );
637 mPainterPath.moveTo( 0, -
size.height() / 2.0 );
638 mPainterPath.lineTo( 0,
size.height() / 2.0 );
639 mPainterPath.moveTo( -
size.width() / 2.0, 0 );
640 mPainterPath.lineTo(
size.width() / 2.0, 0 );
644 mPainterPath.moveTo( -
size.width() / 2.0,
size.height() / 2.0 );
645 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
646 mPainterPath.lineTo(
size.width() / 2.0,
size.height() / 2.0 );
650 mPainterPath.moveTo(
size.width() / 2.0, 0 );
651 mPainterPath.arcTo( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height(), 0, 180 );
655 mPainterPath.moveTo( 0, -
size.height() / 2.0 );
656 mPainterPath.lineTo( -
size.width() / 2.0,
size.height() / 2.0 );
657 mPainterPath.lineTo(
size.width() / 2.0,
size.height() / 2.0 );
658 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
662 mPainterPath.moveTo( 0,
size.height() / 2.0 );
663 mPainterPath.lineTo(
size.width() / 2.0,
size.height() / 2.0 );
664 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
665 mPainterPath.lineTo( 0,
size.height() / 2.0 );
669 mPainterPath.moveTo( -
size.width() / 2.0,
size.height() / 2.0 );
670 mPainterPath.lineTo( 0,
size.height() / 2.0 );
671 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
672 mPainterPath.lineTo( -
size.width() / 2.0,
size.height() / 2.0 );
701 if ( mSymbolWidth >= mSymbolHeight )
703 mSymbolHeight = mSymbolHeight *
size / mSymbolWidth;
708 mSymbolWidth = mSymbolWidth *
size / mSymbolHeight;
709 mSymbolHeight =
size;
729 mSymbolWidthUnit = unit;
730 mSymbolHeightUnit = unit;
731 mStrokeWidthUnit = unit;
737 if ( mSymbolWidthUnit != unit || mSymbolHeightUnit != unit || mStrokeWidthUnit != unit )
755 mSymbolWidthMapUnitScale = scale;
756 mSymbolHeightMapUnitScale = scale;
757 mStrokeWidthMapUnitScale = scale;
763 mSymbolWidthMapUnitScale == mSymbolHeightMapUnitScale &&
764 mSymbolHeightMapUnitScale == mStrokeWidthMapUnitScale )
766 return mSymbolWidthMapUnitScale;
773 const QSizeF
size = calculateSize( context );
775 bool hasDataDefinedRotation =
false;
778 calculateOffsetAndRotation( context,
size.width(),
size.height(), hasDataDefinedRotation,
offset,
angle );
780 QTransform transform;
783 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
786 transform.rotate(
angle );
788 double penWidth = mStrokeWidth;
794 if ( !exprVal.isNull() )
797 const double strokeWidth = exprVal.toDouble( &ok );
810 if ( !exprVal.isNull() && exprVal.toString() == QLatin1String(
"no" ) )
815 else if ( mStrokeStyle == Qt::NoPen )
821 QRectF symbolBounds = transform.mapRect( QRectF( -
size.width() / 2.0,
822 -
size.height() / 2.0,
827 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0,
828 penWidth / 2.0, penWidth / 2.0 );
882 QColor oc = mStrokeColor;
901 QPointF off( offsetX, offsetY );
904 double rotation = 0.0;
914 rotation = -rotation;
919 t.translate( shift.x() + offsetX, shift.y() + offsetY );
922 t.rotate( rotation );
933 const QgsPoint pt( t.map( QPointF( 0, 0 ) ) );
940 const double stepsize = 2 * M_PI / 40;
941 for (
int i = 0; i < 39; ++i )
943 const double angle = stepsize * i;
944 const double x = halfWidth * std::cos(
angle );
945 const double y = halfHeight * std::sin(
angle );
946 line <<
QgsPoint( t.map( QPointF( x, y ) ) );
949 line << line.at( 0 );
951 if ( mBrush.style() != Qt::NoBrush )
953 if ( mPen.style() != Qt::NoPen )
962 p <<
QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) )
963 <<
QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) )
964 <<
QgsPoint( t.map( QPointF( halfWidth, halfHeight ) ) )
965 <<
QgsPoint( t.map( QPointF( -halfWidth, halfHeight ) ) );
968 if ( mBrush.style() != Qt::NoBrush )
970 if ( mPen.style() != Qt::NoPen )
976 if ( mPen.style() != Qt::NoPen )
979 <<
QgsPoint( t.map( QPointF( -halfWidth, 0 ) ) )
980 <<
QgsPoint( t.map( QPointF( halfWidth, 0 ) ) ),
981 layerName, QStringLiteral(
"CONTINUOUS" ), oc,
strokeWidth );
983 <<
QgsPoint( t.map( QPointF( 0, halfHeight ) ) )
984 <<
QgsPoint( t.map( QPointF( 0, -halfHeight ) ) ),
985 layerName, QStringLiteral(
"CONTINUOUS" ), oc,
strokeWidth );
994 p <<
QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) )
995 <<
QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) )
996 <<
QgsPoint( t.map( QPointF( 0, halfHeight ) ) );
998 if ( mBrush.style() != Qt::NoBrush )
1000 if ( mPen.style() != Qt::NoPen )
1021 const QString cleaned = name.toLower().trimmed();
1023 if ( cleaned == QLatin1String(
"circle" ) )
1025 else if ( cleaned == QLatin1String(
"square" ) || cleaned == QLatin1String(
"rectangle" ) )
1027 else if ( cleaned == QLatin1String(
"diamond" ) )
1029 else if ( cleaned == QLatin1String(
"cross" ) )
1031 else if ( cleaned == QLatin1String(
"arrow" ) )
1033 else if ( cleaned == QLatin1String(
"half_arc" ) )
1035 else if ( cleaned == QLatin1String(
"triangle" ) )
1037 else if ( cleaned == QLatin1String(
"right_half_triangle" ) )
1039 else if ( cleaned == QLatin1String(
"left_half_triangle" ) )
1041 else if ( cleaned == QLatin1String(
"semi_circle" ) )
1054 return QStringLiteral(
"circle" );
1056 return QStringLiteral(
"rectangle" );
1058 return QStringLiteral(
"diamond" );
1060 return QStringLiteral(
"cross" );
1062 return QStringLiteral(
"arrow" );
1064 return QStringLiteral(
"half_arc" );
1066 return QStringLiteral(
"triangle" );
1068 return QStringLiteral(
"right_half_triangle" );
1070 return QStringLiteral(
"left_half_triangle" );
1072 return QStringLiteral(
"semi_circle" );
1079 QList< Shape > shapes;
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
@ Cross
Stroke-only cross.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
bool isActive() const
Returns whether the property is currently active.
Qt::PenStyle strokeStyle() const
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
double strokeWidth() const
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
static QString encodeColor(const QColor &color)
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
VerticalAnchorPoint
Symbol vertical anchor points.
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.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
A store for object properties.
RenderUnit
Rendering size units.
Exports QGIS layers to the DXF format.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsMapUnitScale mapUnitScale() const override
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
QgsMapUnitScale mapUnitScale() const override
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Point geometry type, with support for z-dimension and m-values.
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH)
#define QgsDebugMsgLevel(str, level)
const QgsFeature * feature() const
Returns the current feature being rendered.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
@ PropertyFillColor
Fill color.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setAngle(double angle)
Sets the rotation angle for the marker.
static bool shapeIsFilled(const QgsEllipseSymbolLayer::Shape &shape)
Returns true if a shape has a fill.
void setFillColor(const QColor &c) override
Sets the fill color for the symbol layer.
qreal opacity() const
Returns the opacity for the symbol.
static QString encodePenCapStyle(Qt::PenCapStyle style)
static QgsEllipseSymbolLayer::Shape decodeShape(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
void setMapUnitScale(const QgsMapUnitScale &scale) override
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
@ RenderMillimeters
Millimeters.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
@ PropertyCapStyle
Line cap style.
static QString encodePenStyle(Qt::PenStyle style)
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
static QString encodeShape(QgsEllipseSymbolLayer::Shape shape)
Encodes a shape to its string representation.
void setSymbolHeightUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's height.
@ PropertyStrokeColor
Stroke color.
A symbol layer for rendering objects with major and minor axis (e.g. ellipse, rectangle,...
static QColor decodeColor(const QString &str)
~QgsEllipseSymbolLayer() override
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
static void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static QList< QgsEllipseSymbolLayer::Shape > availableShapes()
Returns a list of all available shape types.
HorizontalAnchorPoint
Symbol horizontal anchor points.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
@ LeftHalfTriangle
Left half of a triangle.
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
void setShape(QgsEllipseSymbolLayer::Shape shape)
Sets the rendered ellipse marker shape.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
static QgsSymbolLayer * createFromSld(QDomElement &element)
void setStrokeWidth(double w)
void setSymbolWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's width.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
QgsEllipseSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
static double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QVariantMap &props)
Rescales the given size based on the uomScale found in the props, if any is found,...
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
void restoreOldDataDefinedProperties(const QVariantMap &stringMap)
Restores older data defined properties from string map.
Shape
Marker symbol shapes.
@ PropertyName
Name, eg shape name for simple markers.
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.
QgsEllipseSymbolLayer::Shape shape() const
Returns the shape for the rendered ellipse marker symbol.
@ HalfArc
Stroke-only half arc (since QGIS 3.20)
QgsPropertyCollection mDataDefinedProperties
@ PropertyStrokeWidth
Stroke width.
QVector< QgsPointSequence > QgsRingSequence
QColor fillColor() const override
Returns the fill color for the symbol layer.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
@ Arrow
Stroke-only arrow (since QGIS 3.20)
QString valueAsString(int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a string.
static QgsUnitTypes::RenderUnit decodeSldUom(const QString &str, double *scaleFactor=nullptr)
Decodes a SLD unit of measure string to a render unit.
void setSymbolHeight(double h)
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).
static Qt::PenCapStyle decodePenCapStyle(const QString &str)
QColor selectionColor() const
Returns the color to use when rendering selected features.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
QMap< QString, QString > QgsStringMap
QPointF mOffset
Marker offset.
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QVector< QgsPoint > QgsPointSequence
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection.
A geometry is the spatial representation of a feature.
Perform transforms between map coordinates and device coordinates.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch)
@ RightHalfTriangle
Right half of a triangle.
static QgsStringMap getVendorOptionList(QDomElement &element)
double mLineAngle
Line rotation angle (see setLineAngle() for details)
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
@ PropertyAngle
Symbol angle.
double symbolWidth() const
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderUnknownUnit
Mixed or unknown units.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
virtual void setSize(double size)
Sets the symbol size.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
double mAngle
Marker rotation angle, in degrees clockwise from north.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
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.
@ PropertyHeight
Symbol height.
void setStrokeStyle(Qt::PenStyle strokeStyle)
QPainter * painter()
Returns the destination QPainter for the render operation.
static Qt::PenStyle decodePenStyle(const QString &str)
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
void setSize(double size) override
Sets the symbol size.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsWkbTypes::GeometryType type
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 copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
@ RenderMapUnits
Map units.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QString layerType() const override
Returns a string that represents this layer type.
double symbolHeight() const
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color.
void setSymbolWidth(double w)
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE)
@ PropertyJoinStyle
Line join style.
@ PropertyWidth
Symbol width.