28#include <QDomDocument>
34using namespace Qt::StringLiterals;
37 : mStrokeColor( QColor( 35, 35, 35 ) )
40 mPen.setColor( mStrokeColor );
41 mPen.setStyle( mStrokeStyle );
42 mPen.setJoinStyle( mPenJoinStyle );
45 mBrush.setStyle( Qt::SolidPattern );
67 if (
properties.contains( u
"size_map_unit_scale"_s ) )
71 if (
properties.contains( u
"symbol_width"_s ) )
75 if (
properties.contains( u
"symbol_width_unit"_s ) )
79 if (
properties.contains( u
"symbol_width_map_unit_scale"_s ) )
83 if (
properties.contains( u
"symbol_height"_s ) )
87 if (
properties.contains( u
"symbol_height_unit"_s ) )
91 if (
properties.contains( u
"symbol_height_map_unit_scale"_s ) )
99 if (
properties.contains( u
"outline_style"_s ) )
103 else if (
properties.contains( u
"line_style"_s ) )
115 if (
properties.contains( u
"outline_width"_s ) )
119 else if (
properties.contains( u
"line_width"_s ) )
123 if (
properties.contains( u
"outline_width_unit"_s ) )
127 else if (
properties.contains( u
"line_width_unit"_s ) )
131 if (
properties.contains( u
"outline_width_map_unit_scale"_s ) )
144 if (
properties.contains( u
"outline_color"_s ) )
148 else if (
properties.contains( u
"line_color"_s ) )
156 if (
properties.contains( u
"offset_unit"_s ) )
160 if (
properties.contains( u
"offset_map_unit_scale"_s ) )
164 if (
properties.contains( u
"horizontal_anchor_point"_s ) )
168 if (
properties.contains( u
"vertical_anchor_point"_s ) )
181 double scaledWidth = mSymbolWidth;
182 double scaledHeight = mSymbolHeight;
184 QColor brushColor =
mColor;
185 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
186 mBrush.setColor( brushColor );
188 QColor penColor = mStrokeColor;
189 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
190 mPen.setColor( penColor );
199 double width = exprVal.toDouble( &ok );
203 mPen.setWidthF( width );
204 mSelPen.setWidthF( width );
216 mSelPen.setStyle( mPen.style() );
227 mSelPen.setJoinStyle( mPen.joinStyle() );
246 brushColor.setAlphaF( brushColor.alphaF() * context.
opacity() );
247 mBrush.setColor( brushColor );
254 penColor.setAlphaF( penColor.alphaF() * context.
opacity() );
255 mPen.setColor( penColor );
269 preparePath(
shape, context, &scaledWidth, &scaledHeight, context.
feature() );
273 bool hasDataDefinedRotation =
false;
276 calculateOffsetAndRotation( context, scaledWidth, scaledHeight, hasDataDefinedRotation,
offset,
angle );
284 QTransform transform;
285 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
288 transform.rotate(
angle );
294 p->setPen( useSelectedColor ? mSelPen : mPen );
295 p->setBrush( useSelectedColor ? mSelBrush : mBrush );
299 p->setPen( useSelectedColor ? mSelPen : mPen );
300 p->setBrush( QBrush() );
302 p->drawPath( transform.map( mPainterPath ) );
306void QgsEllipseSymbolLayer::calculateOffsetAndRotation(
QgsSymbolRenderContext &context,
double scaledWidth,
double scaledHeight,
bool &hasDataDefinedRotation, QPointF &offset,
double &angle )
const
310 markerOffset( context, scaledWidth, scaledHeight, mSymbolWidthUnit, mSymbolHeightUnit, offsetX, offsetY, mSymbolWidthMapUnitScale, mSymbolHeightMapUnitScale );
311 offset = QPointF( offsetX, offsetY );
314 const bool ok =
true;
316 bool usingDataDefinedRotation =
false;
321 usingDataDefinedRotation = ok;
325 if ( hasDataDefinedRotation )
332 const QgsFeature *f = context.
feature();
335 const QgsGeometry g = f->
geometry();
350 return u
"EllipseMarker"_s;
363 preparePath( mShape, context );
365 mPen.setColor( mStrokeColor );
366 mPen.setStyle( mStrokeStyle );
367 mPen.setJoinStyle( mPenJoinStyle );
368 mPen.setCapStyle( mPenCapStyle );
370 mBrush.setColor(
mColor );
373 QColor selPenColor = selBrushColor ==
mColor ? selBrushColor : mStrokeColor;
376 selBrushColor.setAlphaF( context.
opacity() );
377 selPenColor.setAlphaF( context.
opacity() );
379 mSelBrush = QBrush( selBrushColor );
380 mSelPen = QPen( !
shapeIsFilled( mShape ) ? selBrushColor : selPenColor );
381 mSelPen.setStyle( mStrokeStyle );
424 toSld( doc, element, context );
429 QDomElement symbolizerElem = doc.createElement( u
"se:PointSymbolizer"_s );
431 if ( !props.value( u
"uom"_s, QString() ).toString().isEmpty() )
432 symbolizerElem.setAttribute( u
"uom"_s, props.value( u
"uom"_s, QString() ).toString() );
433 element.appendChild( symbolizerElem );
451 QDomElement graphicElem = doc.createElement( u
"se:Graphic"_s );
452 element.appendChild( graphicElem );
462 QString angleFunc = props.value( u
"angle"_s, QString() ).toString();
463 if ( angleFunc.isEmpty() )
465 if ( ddRotation && ddRotation.
isActive() )
470 angleFunc = QString::number(
mAngle );
472 else if ( ddRotation && ddRotation.
isActive() )
476 angleFunc = u
"%1 + %2"_s.arg( angleFunc, ddRotation.
asExpression() );
482 const double angle = angleFunc.toDouble( &ok );
486 angleFunc = u
"%1 + %2"_s.arg( angleFunc ).arg(
mAngle );
501 const double widthHeightFactor = mSymbolWidth / mSymbolHeight;
503 graphicElem.appendChild( factorElem );
511 QDomElement graphicElem = element.firstChildElement( u
"Graphic"_s );
512 if ( graphicElem.isNull() )
515 QString name = u
"circle"_s;
518 double widthHeightFactor = 1.0;
522 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
524 if ( it.key() ==
"widthHeightFactor"_L1 )
527 const double v = it.value().toDouble( &ok );
529 widthHeightFactor = v;
536 double scaleFactor = 1.0;
537 const QString uom = element.attribute( u
"uom"_s );
547 const double d = angleFunc.toDouble( &ok );
569 map[u
"symbol_width"_s] = QString::number( mSymbolWidth );
572 map[u
"symbol_height"_s] = QString::number( mSymbolHeight );
575 map[u
"angle"_s] = QString::number(
mAngle );
577 map[u
"outline_width"_s] = QString::number( mStrokeWidth );
587 map[u
"size"_s] = QString::number(
mSize );
591 map[u
"vertical_anchor_point"_s] = QString::number(
static_cast< int >(
mVerticalAnchorPoint ) );
595QSizeF QgsEllipseSymbolLayer::calculateSize(
QgsSymbolRenderContext &context,
double *scaledWidth,
double *scaledHeight )
606 width = mSymbolWidth;
610 *scaledWidth = width;
622 height = mSymbolHeight;
626 *scaledHeight = height;
629 return QSizeF( width, height );
634 mPainterPath = QPainterPath();
636 const QSizeF
size = calculateSize( context, scaledWidth, scaledHeight );
641 mPainterPath.addEllipse( QRectF( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height() ) );
645 mPainterPath.arcTo( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height(), 0, 180 );
646 mPainterPath.lineTo( 0, 0 );
650 mPainterPath.arcTo( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height(), 90, 120 );
651 mPainterPath.lineTo( 0, 0 );
655 mPainterPath.arcTo( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height(), 90, 90 );
656 mPainterPath.lineTo( 0, 0 );
660 mPainterPath.addRect( QRectF( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height() ) );
664 mPainterPath.moveTo( -
size.width() / 2.0, 0 );
665 mPainterPath.lineTo( 0,
size.height() / 2.0 );
666 mPainterPath.lineTo(
size.width() / 2.0, 0 );
667 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
668 mPainterPath.lineTo( -
size.width() / 2.0, 0 );
672 mPainterPath.moveTo( 0, -
size.height() / 2.0 );
673 mPainterPath.lineTo( 0,
size.height() / 2.0 );
674 mPainterPath.moveTo( -
size.width() / 2.0, 0 );
675 mPainterPath.lineTo(
size.width() / 2.0, 0 );
679 mPainterPath.moveTo( -
size.width() / 2.0,
size.height() / 2.0 );
680 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
681 mPainterPath.lineTo(
size.width() / 2.0,
size.height() / 2.0 );
685 mPainterPath.moveTo(
size.width() / 2.0, 0 );
686 mPainterPath.arcTo( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height(), 0, 180 );
690 mPainterPath.moveTo( 0, -
size.height() / 2.0 );
691 mPainterPath.lineTo( -
size.width() / 2.0,
size.height() / 2.0 );
692 mPainterPath.lineTo(
size.width() / 2.0,
size.height() / 2.0 );
693 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
697 mPainterPath.moveTo( 0,
size.height() / 2.0 );
698 mPainterPath.lineTo(
size.width() / 2.0,
size.height() / 2.0 );
699 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
700 mPainterPath.lineTo( 0,
size.height() / 2.0 );
704 mPainterPath.moveTo( -
size.width() / 2.0,
size.height() / 2.0 );
705 mPainterPath.lineTo( 0,
size.height() / 2.0 );
706 mPainterPath.lineTo( 0, -
size.height() / 2.0 );
707 mPainterPath.lineTo( -
size.width() / 2.0,
size.height() / 2.0 );
711 mPainterPath.moveTo( (
size.width() * -0.9511 ) / 2.0,
size.height() / ( 2 / -0.309 ) );
712 mPainterPath.lineTo( (
size.width() * -0.5878 ) / 2.0,
size.height() / ( 2 / 0.8090 ) );
713 mPainterPath.lineTo( (
size.width() * 0.5878 ) / 2.0,
size.height() / ( 2 / 0.8090 ) );
714 mPainterPath.lineTo( (
size.width() * 0.9511 ) / 2.0,
size.height() / ( 2 / -0.309 ) );
715 mPainterPath.lineTo( 0,
size.height() / -2.0 );
716 mPainterPath.lineTo( (
size.width() * -0.9511 ) / 2.0,
size.height() / ( 2 / -0.309 ) );
720 mPainterPath.moveTo( (
size.width() * 0.8660 ) / 2.0,
size.height() / 4.0 );
721 mPainterPath.lineTo( (
size.width() * 0.8660 ) / 2.0,
size.height() / -4.0 );
722 mPainterPath.lineTo( 0,
size.height() / -2.0 );
723 mPainterPath.lineTo( (
size.width() * 0.8660 ) / -2.0,
size.height() / -4.0 );
724 mPainterPath.lineTo( (
size.width() * 0.8660 ) / -2.0,
size.height() / 4.0 );
725 mPainterPath.lineTo( 0,
size.height() / 2.0 );
726 mPainterPath.lineTo( (
size.width() * 0.8660 ) / 2.0,
size.height() / 4.0 );
731 static constexpr double VERTEX_OFFSET_FROM_ORIGIN = 1.0 / ( 1 + M_SQRT2 );
732 mPainterPath.moveTo( (
size.width() * VERTEX_OFFSET_FROM_ORIGIN ) / -2.0,
size.height() / 2.0 );
733 mPainterPath.lineTo( (
size.width() * VERTEX_OFFSET_FROM_ORIGIN ) / 2.0,
size.height() / 2.0 );
734 mPainterPath.lineTo(
size.width() / 2.0, (
size.height() * VERTEX_OFFSET_FROM_ORIGIN ) / 2.0 );
735 mPainterPath.lineTo(
size.width() / 2.0, (
size.height() * VERTEX_OFFSET_FROM_ORIGIN ) / -2.0 );
736 mPainterPath.lineTo( (
size.width() * VERTEX_OFFSET_FROM_ORIGIN ) / 2.0,
size.height() / -2.0 );
737 mPainterPath.lineTo( (
size.width() * VERTEX_OFFSET_FROM_ORIGIN ) / -2.0,
size.height() / -2.0 );
738 mPainterPath.lineTo(
size.width() / -2.0, (
size.height() * VERTEX_OFFSET_FROM_ORIGIN ) / -2.0 );
739 mPainterPath.lineTo(
size.width() / -2.0, (
size.height() * VERTEX_OFFSET_FROM_ORIGIN ) / 2.0 );
740 mPainterPath.lineTo( (
size.width() * VERTEX_OFFSET_FROM_ORIGIN ) / -2.0,
size.height() / 2.0 );
746 const double inner_r = std::cos(
DEG2RAD( 72.0 ) ) / std::cos(
DEG2RAD( 36.0 ) );
747 mPainterPath.moveTo( (
size.width() * inner_r * std::sin(
DEG2RAD( 324.0 ) ) ) / 2.0, (
size.height() * inner_r * std::cos(
DEG2RAD( 324.0 ) ) ) / -2.0 );
748 mPainterPath.lineTo( (
size.width() * std::sin(
DEG2RAD( 288.0 ) ) ) / 2.0, (
size.height() * std::cos(
DEG2RAD( 288.0 ) ) ) / -2.0 );
749 mPainterPath.lineTo( (
size.width() * inner_r * std::sin(
DEG2RAD( 252.0 ) ) ) / 2.0, (
size.height() * inner_r * std::cos(
DEG2RAD( 252.0 ) ) ) / -2.0 );
750 mPainterPath.lineTo( (
size.width() * std::sin(
DEG2RAD( 216.0 ) ) ) / 2.0, (
size.height() * std::cos(
DEG2RAD( 216.0 ) ) ) / -2.0 );
751 mPainterPath.lineTo( 0, (
size.height() * inner_r ) / 2.0 );
752 mPainterPath.lineTo( (
size.width() * std::sin(
DEG2RAD( 144.0 ) ) ) / 2.0, (
size.height() * std::cos(
DEG2RAD( 144.0 ) ) ) / -2.0 );
753 mPainterPath.lineTo( (
size.width() * inner_r * std::sin(
DEG2RAD( 108.0 ) ) ) / 2.0, (
size.height() * inner_r * std::cos(
DEG2RAD( 108.0 ) ) ) / -2.0 );
754 mPainterPath.lineTo( (
size.width() * std::sin(
DEG2RAD( 72.0 ) ) ) / 2.0, (
size.height() * std::cos(
DEG2RAD( 72.0 ) ) ) / -2.0 );
755 mPainterPath.lineTo( (
size.width() * inner_r * std::sin(
DEG2RAD( 36.0 ) ) ) / 2.0, (
size.height() * inner_r * std::cos(
DEG2RAD( 36.0 ) ) ) / -2.0 );
756 mPainterPath.lineTo( 0,
size.height() / -2.0 );
757 mPainterPath.lineTo( (
size.width() * inner_r * std::sin(
DEG2RAD( 324.0 ) ) ) / 2.0, (
size.height() * inner_r * std::cos(
DEG2RAD( 324.0 ) ) ) / -2.0 );
793 if ( mSymbolWidth >= mSymbolHeight )
795 mSymbolHeight = mSymbolHeight *
size / mSymbolWidth;
800 mSymbolWidth = mSymbolWidth *
size / mSymbolHeight;
801 mSymbolHeight =
size;
821 mSymbolWidthUnit = unit;
822 mSymbolHeightUnit = unit;
823 mStrokeWidthUnit = unit;
829 if ( mSymbolWidthUnit != unit || mSymbolHeightUnit != unit || mStrokeWidthUnit != unit )
851 mSymbolWidthMapUnitScale = scale;
852 mSymbolHeightMapUnitScale = scale;
853 mStrokeWidthMapUnitScale = scale;
858 if (
QgsMarkerSymbolLayer::mapUnitScale() == mSymbolWidthMapUnitScale && mSymbolWidthMapUnitScale == mSymbolHeightMapUnitScale && mSymbolHeightMapUnitScale == mStrokeWidthMapUnitScale )
860 return mSymbolWidthMapUnitScale;
867 const QSizeF
size = calculateSize( context );
869 bool hasDataDefinedRotation =
false;
872 calculateOffsetAndRotation( context,
size.width(),
size.height(), hasDataDefinedRotation,
offset,
angle );
874 QTransform transform;
877 transform.translate( point.x() +
offset.x(), point.y() +
offset.y() );
880 transform.rotate(
angle );
882 double penWidth = mStrokeWidth;
891 const double strokeWidth = exprVal.toDouble( &ok );
909 else if ( mStrokeStyle == Qt::NoPen )
915 QRectF symbolBounds = transform.mapRect( QRectF( -
size.width() / 2.0, -
size.height() / 2.0,
size.width(),
size.height() ) );
918 symbolBounds.adjust( -penWidth / 2.0, -penWidth / 2.0, penWidth / 2.0, penWidth / 2.0 );
972 QColor oc = mStrokeColor;
991 QPointF off( offsetX, offsetY );
994 double rotation = 0.0;
1004 rotation = -rotation;
1009 t.translate( shift.x() + offsetX, shift.y() + offsetY );
1012 t.rotate( rotation );
1023 const QgsPoint pt( t.map( QPointF( 0, 0 ) ) );
1030 const double stepsize = 2 * M_PI / 40;
1031 for (
int i = 0; i < 39; ++i )
1033 const double angle = stepsize * i;
1034 const double x = halfWidth * std::cos(
angle );
1035 const double y = halfHeight * std::sin(
angle );
1036 line <<
QgsPoint( t.map( QPointF( x, y ) ) );
1039 line << line.at( 0 );
1041 if ( mBrush.style() != Qt::NoBrush )
1043 if ( mPen.style() != Qt::NoPen )
1053 <<
QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) )
1054 <<
QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) )
1055 <<
QgsPoint( t.map( QPointF( halfWidth, halfHeight ) ) )
1056 <<
QgsPoint( t.map( QPointF( -halfWidth, halfHeight ) ) );
1059 if ( mBrush.style() != Qt::NoBrush )
1061 if ( mPen.style() != Qt::NoPen )
1067 if ( mPen.style() != Qt::NoPen )
1079 p <<
QgsPoint( t.map( QPointF( -halfWidth, -halfHeight ) ) ) <<
QgsPoint( t.map( QPointF( halfWidth, -halfHeight ) ) ) <<
QgsPoint( t.map( QPointF( 0, halfHeight ) ) );
1081 if ( mBrush.style() != Qt::NoBrush )
1083 if ( mPen.style() != Qt::NoPen )
1110 const QString cleaned = name.toLower().trimmed();
1112 if ( cleaned ==
"circle"_L1 )
1114 else if ( cleaned ==
"square"_L1 || cleaned ==
"rectangle"_L1 )
1116 else if ( cleaned ==
"diamond"_L1 )
1118 else if ( cleaned ==
"cross"_L1 )
1120 else if ( cleaned ==
"arrow"_L1 )
1122 else if ( cleaned ==
"half_arc"_L1 )
1124 else if ( cleaned ==
"triangle"_L1 )
1126 else if ( cleaned ==
"right_half_triangle"_L1 )
1128 else if ( cleaned ==
"left_half_triangle"_L1 )
1130 else if ( cleaned ==
"semi_circle"_L1 )
1132 else if ( cleaned ==
"third_circle"_L1 )
1134 else if ( cleaned ==
"quarter_circle"_L1 )
1136 else if ( cleaned ==
"pentagon"_L1 )
1138 else if ( cleaned ==
"hexagon"_L1 )
1140 else if ( cleaned ==
"octagon"_L1 )
1142 else if ( cleaned ==
"star"_L1 )
1156 return u
"rectangle"_s;
1158 return u
"diamond"_s;
1164 return u
"half_arc"_s;
1166 return u
"triangle"_s;
1168 return u
"right_half_triangle"_s;
1170 return u
"left_half_triangle"_s;
1172 return u
"semi_circle"_s;
1174 return u
"third_circle"_s;
1176 return u
"quarter_circle"_s;
1178 return u
"pentagon"_s;
1180 return u
"hexagon"_s;
1182 return u
"octagon"_s;
1191 QList< Shape > shapes;
@ DynamicRotation
Rotation of symbol may be changed during rendering and symbol should not be cached.
@ CanCalculateMaskGeometryPerFeature
If present, indicates that mask geometry can safely be calculated per feature for the symbol layer....
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
VerticalAnchorPoint
Marker symbol vertical anchor points.
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
@ Unknown
Mixed or unknown units.
@ MetersInMapUnits
Meters value as Map units.
HorizontalAnchorPoint
Marker symbol horizontal anchor points.
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 QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
Exports QGIS layers to the DXF format.
void writeFilledCircle(const QString &layer, const QColor &color, const QgsPoint &pt, double radius)
Write filled circle (as hatch).
void writePolygon(const QgsRingSequence &polygon, const QString &layer, const QString &hatchPattern, const QColor &color)
Draw dxf filled polygon (HATCH).
void writePolyline(const QgsPointSequence &line, const QString &layer, const QString &lineStyleName, const QColor &color, double width=-1)
Draw dxf primitives (LWPOLYLINE).
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, etc).
bool writeDxf(QgsDxfExport &e, double mmMapUnitScaleFactor, const QString &layerName, QgsSymbolRenderContext &context, QPointF shift=QPointF(0.0, 0.0)) const override
write as DXF
void setStrokeWidth(double w)
void setSymbolHeightMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolWidthMapUnitScale(const QgsMapUnitScale &scale)
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QRectF bounds(QPointF point, QgsSymbolRenderContext &context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setSymbolWidth(double w)
void renderPoint(QPointF point, QgsSymbolRenderContext &context) override
Renders a marker at the specified point.
double strokeWidth() const
void setStrokeColor(const QColor &c) override
Sets the stroke color for the symbol layer.
void setStrokeStyle(Qt::PenStyle strokeStyle)
static QgsEllipseSymbolLayer::Shape decodeShape(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's stroke width.
void setSize(double size) override
Sets the symbol size.
QgsMapUnitScale mapUnitScale() const override
Shape
Marker symbol shapes.
@ ThirdCircle
Third Circle.
@ Cross
Stroke-only cross.
@ QuarterCircle
Quarter Circle.
@ HalfArc
Stroke-only half arc.
@ Arrow
Stroke-only arrow.
@ RightHalfTriangle
Right half of a triangle.
@ LeftHalfTriangle
Left half of a triangle.
QColor fillColor() const override
Returns the fill color for the symbol layer.
QgsEllipseSymbolLayer::Shape shape() const
Returns the shape for the rendered ellipse marker symbol.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
void setFillColor(const QColor &c) override
Sets the fill color for the symbol layer.
void setShape(QgsEllipseSymbolLayer::Shape shape)
Sets the rendered ellipse marker shape.
static QList< QgsEllipseSymbolLayer::Shape > availableShapes()
Returns a list of all available shape types.
Qt::PenStyle strokeStyle() const
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const override
Saves the symbol layer as SLD.
static QString encodeShape(QgsEllipseSymbolLayer::Shape shape)
Encodes a shape to its string representation.
double symbolWidth() const
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
void setSymbolHeightUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's height.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QString layerType() const override
Returns a string that represents this layer type.
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
void setPenJoinStyle(Qt::PenJoinStyle style)
Set stroke join style.
static bool shapeIsFilled(const QgsEllipseSymbolLayer::Shape &shape)
Returns true if a shape has a fill.
void setSymbolWidthUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's width.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
~QgsEllipseSymbolLayer() override
void setMapUnitScale(const QgsMapUnitScale &scale) override
double symbolHeight() const
void setSymbolHeight(double h)
Q_DECL_DEPRECATED void writeSldMarker(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Writes the symbol layer definition as a SLD XML element.
QgsEllipseSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
Struct for storing maximum and minimum scales for measurements in map units.
virtual void setSize(double size)
Sets the symbol size.
void setVerticalAnchorPoint(Qgis::VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
Qgis::RenderUnit mOffsetUnit
Offset units.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
double mLineAngle
Line rotation angle (see setLineAngle() for details).
void setOffsetUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's offset.
void setAngle(double angle)
Sets the rotation angle for the marker.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QPointF mOffset
Marker offset.
QgsMapUnitScale mapUnitScale() const override
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
double size() const
Returns the symbol size.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
Qgis::VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.
static QPointF _rotatedOffset(QPointF offset, double angle)
Adjusts a marker offset to account for rotation.
void setHorizontalAnchorPoint(Qgis::HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
Qgis::RenderUnit mSizeUnit
Marker size unit.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
void markerOffset(QgsSymbolRenderContext &context, double &offsetX, double &offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required...
Qgis::HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double mAngle
Marker rotation angle, in degrees clockwise from north.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Point geometry type, with support for z-dimension and m-values.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
A store for object properties.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
bool isActive() const
Returns whether the property is currently active.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QColor selectionColor() const
Returns the color to use when rendering selected features.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
QVariantMap extraProperties() const
Returns the open ended set of properties that can drive/inform the SLD encoding.
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static QString encodePenStyle(Qt::PenStyle style)
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static double rescaleUom(double size, Qgis::RenderUnit unit, const QVariantMap &props)
Rescales the given size based on the uomScale found in the props, if any is found,...
static Qt::PenCapStyle decodePenCapStyle(const QString &str)
static QString encodePenCapStyle(Qt::PenCapStyle style)
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
Extracts properties from an SLD marker definition.
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
static QString encodeColor(const QColor &color)
static Qgis::RenderUnit decodeSldUom(const QString &str, double *scaleFactor=nullptr)
Decodes a SLD unit of measure string to a render unit.
static Q_DECL_DEPRECATED void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
Creates an SLD geometry element.
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
Exports a marker to SLD.
static Qt::PenStyle decodePenStyle(const QString &str)
static Q_DECL_DEPRECATED void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
Creates SLD rotation element.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
static QgsStringMap getVendorOptionList(QDomElement &element)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
void copyCommonProperties(QgsSymbolLayer *destLayer) const
Copies all common base class properties from this layer to another symbol layer.
bool shouldRenderUsingSelectionColor(const QgsSymbolRenderContext &context) const
Returns true if the symbol layer should be rendered using the selection color from the render context...
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
@ StrokeStyle
Stroke style (eg solid, dashed).
@ Name
Name, eg shape name for simple markers.
@ StrokeColor
Stroke color.
@ CapStyle
Line cap style.
@ JoinStyle
Line join style.
@ StrokeWidth
Stroke width.
void restoreOldDataDefinedProperties(const QVariantMap &stringMap)
Restores older data defined properties from string map.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
virtual Qgis::SymbolLayerFlags flags() const
Returns flags which control the symbol layer's behavior.
QgsPropertyCollection mDataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
QgsSymbolLayer(const QgsSymbolLayer &other)
Encapsulates the context in which a symbol is being rendered.
const QgsFeature * feature() const
Returns the current feature being rendered.
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
qreal opacity() const
Returns the opacity for the symbol.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
QMap< QString, QString > QgsStringMap
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence
#define QgsDebugMsgLevel(str, level)