44#include <QPagedPaintDevice>
46#include <QSvgRenderer>
47#include <QDomDocument>
54 Qt::PenJoinStyle penJoinStyle )
55 : mBrushStyle( style )
56 , mStrokeColor( strokeColor )
57 , mStrokeStyle( strokeStyle )
58 , mStrokeWidth( strokeWidth )
59 , mPenJoinStyle( penJoinStyle )
103void QgsSimpleFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen )
128 penColor.setAlphaF( context.
opacity() * penColor.alphaF() );
129 pen.setColor( penColor );
137 double width = exprVal.toDouble( &ok );
141 pen.setWidthF( width );
142 selPen.setWidthF( width );
179 if ( props.contains( QStringLiteral(
"color" ) ) )
181 if ( props.contains( QStringLiteral(
"style" ) ) )
183 if ( props.contains( QStringLiteral(
"color_border" ) ) )
188 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
192 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
197 if ( props.contains( QStringLiteral(
"style_border" ) ) )
202 else if ( props.contains( QStringLiteral(
"outline_style" ) ) )
206 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
210 if ( props.contains( QStringLiteral(
"width_border" ) ) )
213 strokeWidth = props[QStringLiteral(
"width_border" )].toDouble();
215 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
217 strokeWidth = props[QStringLiteral(
"outline_width" )].toDouble();
219 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
221 strokeWidth = props[QStringLiteral(
"line_width" )].toDouble();
223 if ( props.contains( QStringLiteral(
"offset" ) ) )
225 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
230 if ( props.contains( QStringLiteral(
"border_width_unit" ) ) )
234 else if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
238 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
242 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
245 if ( props.contains( QStringLiteral(
"border_width_map_unit_scale" ) ) )
247 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
250 sl->restoreOldDataDefinedProperties( props );
258 return QStringLiteral(
"SimpleFill" );
275 selColor.setAlphaF( context.
opacity() );
334 if (
mBrush.style() == Qt::SolidPattern ||
mBrush.style() == Qt::NoBrush || !
dynamic_cast<QPagedPaintDevice *
>( p->device() ) )
346 p->setPen( Qt::NoPen );
350 p->setBrush( Qt::NoBrush );
367 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
394 toSld( doc, element, context );
403 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
404 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
405 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
406 element.appendChild( symbolizerElem );
412 bool exportOk {
false };
416 if ( ! image.isNull() )
419 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
420 symbolizerElem.appendChild( fillElem );
421 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
422 fillElem.appendChild( graphicFillElem );
423 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
424 graphicFillElem.appendChild( graphicElem );
427 QString pngPath { info.completeSuffix().isEmpty() ? context.
exportFilePath() : context.
exportFilePath().chopped( info.completeSuffix().length() ).append( QStringLiteral(
"png" ) ) };
429 image.save( pngPath );
444 const double alpha { props.value( QStringLiteral(
"alpha" ), QVariant() ).toDouble( &ok ) };
450 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
451 symbolizerElem.appendChild( fillElem );
458 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
459 symbolizerElem.appendChild( strokeElem );
463 const double alpha { props.value( QStringLiteral(
"alpha" ), QVariant() ).toDouble( &ok ) };
484 symbolStyle.append(
';' );
493 Qt::BrushStyle fillStyle;
497 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
500 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
506 double scaleFactor = 1.0;
507 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
514 sl->setOutputUnit( sldUnitSize );
523 return penBleed + offsetBleed;
581 QPixmap pixmap( QSize( 32, 32 ) );
582 pixmap.fill( Qt::transparent );
584 painter.begin( &pixmap );
585 painter.setRenderHint( QPainter::Antialiasing );
593 std::unique_ptr< QgsSimpleFillSymbolLayer > layerClone(
clone() );
594 layerClone->setStrokeStyle( Qt::PenStyle::NoPen );
595 layerClone->drawPreviewIcon( symbolContext, pixmap.size() );
597 return pixmap.toImage();
605 : mGradientColorType( colorType )
606 , mGradientType( gradientType )
607 , mCoordinateMode( coordinateMode )
608 , mGradientSpread( spread )
609 , mReferencePoint1( QPointF( 0.5, 0 ) )
610 , mReferencePoint2( QPointF( 0.5, 1 ) )
631 bool refPoint1IsCentroid =
false;
633 bool refPoint2IsCentroid =
false;
638 if ( props.contains( QStringLiteral(
"type" ) ) )
640 if ( props.contains( QStringLiteral(
"coordinate_mode" ) ) )
642 if ( props.contains( QStringLiteral(
"spread" ) ) )
644 if ( props.contains( QStringLiteral(
"color_type" ) ) )
646 if ( props.contains( QStringLiteral(
"gradient_color" ) ) )
651 else if ( props.contains( QStringLiteral(
"color" ) ) )
655 if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
660 if ( props.contains( QStringLiteral(
"reference_point1" ) ) )
662 if ( props.contains( QStringLiteral(
"reference_point1_iscentroid" ) ) )
663 refPoint1IsCentroid = props[QStringLiteral(
"reference_point1_iscentroid" )].toInt();
664 if ( props.contains( QStringLiteral(
"reference_point2" ) ) )
666 if ( props.contains( QStringLiteral(
"reference_point2_iscentroid" ) ) )
667 refPoint2IsCentroid = props[QStringLiteral(
"reference_point2_iscentroid" )].toInt();
668 if ( props.contains( QStringLiteral(
"angle" ) ) )
669 angle = props[QStringLiteral(
"angle" )].toDouble();
671 if ( props.contains( QStringLiteral(
"offset" ) ) )
688 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
690 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
693 sl->setReferencePoint1IsCentroid( refPoint1IsCentroid );
695 sl->setReferencePoint2IsCentroid( refPoint2IsCentroid );
696 sl->setAngle(
angle );
698 sl->setColorRamp( gradientRamp );
700 sl->restoreOldDataDefinedProperties( props );
717 return QStringLiteral(
"GradientFill" );
720void QgsGradientFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context,
const QPolygonF &points )
765 if ( currentType == QObject::tr(
"linear" ) )
769 else if ( currentType == QObject::tr(
"radial" ) )
773 else if ( currentType == QObject::tr(
"conical" ) )
787 if ( currentCoordMode == QObject::tr(
"feature" ) )
791 else if ( currentCoordMode == QObject::tr(
"viewport" ) )
805 if ( currentSpread == QObject::tr(
"pad" ) )
809 else if ( currentSpread == QObject::tr(
"repeat" ) )
813 else if ( currentSpread == QObject::tr(
"reflect" ) )
860 if ( refPoint1IsCentroid || refPoint2IsCentroid )
865 QRectF bbox = points.boundingRect();
866 double centroidX = ( centroid.x() - bbox.left() ) / bbox.width();
867 double centroidY = ( centroid.y() - bbox.top() ) / bbox.height();
869 if ( refPoint1IsCentroid )
871 refPoint1X = centroidX;
872 refPoint1Y = centroidY;
874 if ( refPoint2IsCentroid )
876 refPoint2X = centroidX;
877 refPoint2Y = centroidY;
883 spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ),
angle );
886QPointF QgsGradientFillSymbolLayer::rotateReferencePoint( QPointF refPoint,
double angle )
891 QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
893 refLine.setAngle( refLine.angle() +
angle );
895 QPointF rotatedReferencePoint = refLine.p2();
897 if ( rotatedReferencePoint.x() > 1 )
898 rotatedReferencePoint.setX( 1 );
899 if ( rotatedReferencePoint.x() < 0 )
900 rotatedReferencePoint.setX( 0 );
901 if ( rotatedReferencePoint.y() > 1 )
902 rotatedReferencePoint.setY( 1 );
903 if ( rotatedReferencePoint.y() < 0 )
904 rotatedReferencePoint.setY( 0 );
906 return rotatedReferencePoint;
913 QPointF referencePoint1, QPointF referencePoint2,
const double angle )
918 QColor fillColor2 =
color2;
919 fillColor2.setAlphaF( context.
opacity() * fillColor2.alphaF() );
930 gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
933 gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
936 gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
942 gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
945 gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
951 gradient.setSpread( QGradient::PadSpread );
954 gradient.setSpread( QGradient::ReflectSpread );
957 gradient.setSpread( QGradient::RepeatSpread );
973 gradient.setColorAt( 1.0, fillColor2 );
977 brush = QBrush( gradient );
984 selColor.setAlphaF( context.
opacity() );
1001 applyDataDefinedSymbology( context, points );
1005 p->setPen( Qt::NoPen );
1038 map[QStringLiteral(
"color_type" )] = QString::number(
static_cast< int >(
mGradientColorType ) );
1039 map[QStringLiteral(
"type" )] = QString::number(
static_cast<int>(
mGradientType ) );
1040 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
static_cast< int >(
mCoordinateMode ) );
1041 map[QStringLiteral(
"spread" )] = QString::number(
static_cast< int >(
mGradientSpread ) );
1046 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
1072 return sl.release();
1114 int blurRadius,
bool useWholeShape,
double maxDistance )
1115 : mBlurRadius( blurRadius )
1116 , mUseWholeShape( useWholeShape )
1117 , mMaxDistance( maxDistance )
1118 , mColorType( colorType )
1137 if ( props.contains( QStringLiteral(
"color_type" ) ) )
1141 if ( props.contains( QStringLiteral(
"shapeburst_color" ) ) )
1146 else if ( props.contains( QStringLiteral(
"color" ) ) )
1151 if ( props.contains( QStringLiteral(
"shapeburst_color2" ) ) )
1156 else if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
1160 if ( props.contains( QStringLiteral(
"blur_radius" ) ) )
1162 blurRadius = props[QStringLiteral(
"blur_radius" )].toInt();
1164 if ( props.contains( QStringLiteral(
"use_whole_shape" ) ) )
1166 useWholeShape = props[QStringLiteral(
"use_whole_shape" )].toInt();
1168 if ( props.contains( QStringLiteral(
"max_distance" ) ) )
1170 maxDistance = props[QStringLiteral(
"max_distance" )].toDouble();
1172 if ( props.contains( QStringLiteral(
"offset" ) ) )
1191 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1195 if ( props.contains( QStringLiteral(
"distance_unit" ) ) )
1199 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1203 if ( props.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
1207 if ( props.contains( QStringLiteral(
"ignore_rings" ) ) )
1209 sl->setIgnoreRings( props[QStringLiteral(
"ignore_rings" )].toInt() );
1213 sl->setColorRamp( gradientRamp );
1216 sl->restoreOldDataDefinedProperties( props );
1218 return sl.release();
1223 return QStringLiteral(
"ShapeburstFill" );
1233 if ( mGradientRamp.get() == ramp )
1236 mGradientRamp.reset( ramp );
1239void QgsShapeburstFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QColor &color, QColor &color2,
int &blurRadius,
bool &useWholeShape,
1240 double &maxDistance,
bool &ignoreRings )
1297 selColor.setAlphaF( context.
opacity() );
1298 mSelBrush = QBrush( selColor );
1315 if ( useSelectedColor )
1318 p->setBrush( mSelBrush );
1319 QPointF
offset = mOffset;
1354 int outputPixelMaxDist = 0;
1362 std::unique_ptr< QgsGradientColorRamp > twoColorGradientRamp;
1365 twoColorGradientRamp = std::make_unique< QgsGradientColorRamp >( color1,
color2 );
1369 p->setPen( QPen( Qt::NoPen ) );
1374 int pointsWidth =
static_cast< int >( std::round( points.boundingRect().width() ) );
1375 int pointsHeight =
static_cast< int >( std::round( points.boundingRect().height() ) );
1376 int imWidth = pointsWidth + ( sideBuffer * 2 );
1377 int imHeight = pointsHeight + ( sideBuffer * 2 );
1383 auto fillImage = std::make_unique< QImage >( imWidth,
1384 imHeight, QImage::Format_ARGB32_Premultiplied );
1385 if ( fillImage->isNull() )
1395 auto alphaImage = std::make_unique< QImage >( fillImage->width(), fillImage->height(), QImage::Format_ARGB32_Premultiplied );
1396 if ( alphaImage->isNull() )
1408 fillImage->fill( Qt::black );
1414 alphaImage->fill( Qt::transparent );
1420 QPainter imgPainter;
1421 imgPainter.begin( alphaImage.get() );
1422 imgPainter.setRenderHint( QPainter::Antialiasing,
true );
1423 imgPainter.setBrush( QBrush( Qt::white ) );
1424 imgPainter.setPen( QPen( Qt::black ) );
1425 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1434 imgPainter.begin( fillImage.get() );
1437 imgPainter.drawImage( 0, 0, *alphaImage );
1444 imgPainter.setBrush( QBrush( Qt::white ) );
1445 imgPainter.setPen( QPen( Qt::black ) );
1446 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1455 double *dtArray = distanceTransform( fillImage.get(), context.
renderContext() );
1475 imgPainter.begin( fillImage.get() );
1476 imgPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
1477 imgPainter.drawImage( 0, 0, *alphaImage );
1485 QPointF
offset = mOffset;
1502 p->drawImage( points.boundingRect().left() - sideBuffer, points.boundingRect().top() - sideBuffer, *fillImage );
1513void QgsShapeburstFillSymbolLayer::distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d )
1519 for (
int q = 1; q <= n - 1; q++ )
1521 double s = ( ( f[q] +
static_cast< double >( q ) * q ) - ( f[v[k]] + (
static_cast< double >( v[k] ) * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1525 s = ( ( f[q] +
static_cast< double >( q ) * q ) - ( f[v[k]] + (
static_cast< double >( v[k] ) * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1534 for (
int q = 0; q <= n - 1; q++ )
1536 while ( z[k + 1] < q )
1538 d[q] =
static_cast< double >( q - v[k] ) * ( q - v[k] ) + f[v[k]];
1543void QgsShapeburstFillSymbolLayer::distanceTransform2d(
double *im,
int width,
int height,
QgsRenderContext &context )
1545 int maxDimension = std::max( width, height );
1546 double *f =
new double[ maxDimension ];
1547 int *v =
new int[ maxDimension ];
1548 double *z =
new double[ maxDimension + 1 ];
1549 double *d =
new double[ maxDimension ];
1552 for (
int x = 0; x < width; x++ )
1557 for (
int y = 0; y < height; y++ )
1559 f[y] = im[ x +
static_cast< std::size_t
>( y ) * width ];
1561 distanceTransform1d( f, height, v, z, d );
1562 for (
int y = 0; y < height; y++ )
1564 im[ x +
static_cast< std::size_t
>( y ) * width ] = d[y];
1569 for (
int y = 0; y < height; y++ )
1574 for (
int x = 0; x < width; x++ )
1576 f[x] = im[ x +
static_cast< std::size_t
>( y ) * width ];
1578 distanceTransform1d( f, width, v, z, d );
1579 for (
int x = 0; x < width; x++ )
1581 im[ x +
static_cast< std::size_t
>( y ) * width ] = d[x];
1592double *QgsShapeburstFillSymbolLayer::distanceTransform( QImage *im,
QgsRenderContext &context )
1594 int width = im->width();
1595 int height = im->height();
1597 double *dtArray =
new double[
static_cast< std::size_t
>( width ) * height];
1601 std::size_t idx = 0;
1602 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1607 const QRgb *scanLine =
reinterpret_cast< const QRgb *
>( im->constScanLine( heightIndex ) );
1608 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1610 tmpRgb = scanLine[widthIndex];
1611 if ( qRed( tmpRgb ) == 0 )
1619 dtArray[ idx ] =
INF;
1626 distanceTransform2d( dtArray, width, height, context );
1631void QgsShapeburstFillSymbolLayer::dtArrayToQImage(
double *array, QImage *im,
QgsColorRamp *ramp,
QgsRenderContext &context,
bool useWholeShape,
int maxPixelDistance )
1633 int width = im->width();
1634 int height = im->height();
1637 double maxDistanceValue;
1642 double dtMaxValue = array[0];
1643 for ( std::size_t i = 1; i < static_cast< std::size_t >( width ) * height; ++i )
1645 if ( array[i] > dtMaxValue )
1647 dtMaxValue = array[i];
1652 maxDistanceValue = std::sqrt( dtMaxValue );
1657 maxDistanceValue = maxPixelDistance;
1661 std::size_t idx = 0;
1662 double squaredVal = 0;
1665 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1670 QRgb *scanLine =
reinterpret_cast< QRgb *
>( im->scanLine( heightIndex ) );
1671 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1674 squaredVal = array[idx];
1677 if ( maxDistanceValue > 0 )
1679 pixVal = squaredVal > 0 ? std::min( ( std::sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1688 scanLine[widthIndex] = qPremultiply( ramp->
color( pixVal ).rgba() );
1699 map[QStringLiteral(
"color_type" )] = QString::number(
static_cast< int >( mColorType ) );
1700 map[QStringLiteral(
"blur_radius" )] = QString::number( mBlurRadius );
1701 map[QStringLiteral(
"use_whole_shape" )] = QString::number( mUseWholeShape );
1702 map[QStringLiteral(
"max_distance" )] = QString::number( mMaxDistance );
1705 map[QStringLiteral(
"ignore_rings" )] = QString::number( mIgnoreRings );
1709 if ( mGradientRamp )
1711 map.insert( mGradientRamp->properties() );
1719 auto sl = std::make_unique< QgsShapeburstFillSymbolLayer >(
mColor, mColor2, mColorType, mBlurRadius, mUseWholeShape, mMaxDistance );
1720 if ( mGradientRamp )
1722 sl->setColorRamp( mGradientRamp->clone() );
1724 sl->setDistanceUnit( mDistanceUnit );
1725 sl->setDistanceMapUnitScale( mDistanceMapUnitScale );
1726 sl->setIgnoreRings( mIgnoreRings );
1727 sl->setOffset( mOffset );
1728 sl->setOffsetUnit( mOffsetUnit );
1729 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
1732 return sl.release();
1737 double offsetBleed = context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
1748 mDistanceUnit = unit;
1754 if ( mDistanceUnit == mOffsetUnit )
1756 return mDistanceUnit;
1769 mDistanceMapUnitScale = scale;
1770 mOffsetMapUnitScale = scale;
1775 if ( mDistanceMapUnitScale == mOffsetMapUnitScale )
1777 return mDistanceMapUnitScale;
1802 p->setPen( QPen( Qt::NoPen ) );
1804 QTransform bkTransform =
mBrush.transform();
1808 QTransform t =
mBrush.transform();
1809 t.translate( leftCorner.x(), leftCorner.y() );
1810 mBrush.setTransform( t );
1814 QTransform t =
mBrush.transform();
1815 t.translate( 0, 0 );
1816 mBrush.setTransform( t );
1820 if ( useSelectedColor )
1823 p->setBrush( QBrush( selColor ) );
1829 QTransform t =
mBrush.transform();
1831 mBrush.setTransform( t );
1836 mBrush.setTransform( bkTransform );
1872 return Qt::SolidLine;
1876 return Qt::SolidLine;
1880 return mStroke->dxfPenStyle();
1916 , mPatternWidth( width )
1920 mColor = QColor( 255, 255, 255 );
1926 , mPatternWidth( width )
1927 , mSvgData( svgData )
1932 mColor = QColor( 255, 255, 255 );
1933 setDefaultSvgParams();
1941 mPatternWidthUnit = unit;
1942 mSvgStrokeWidthUnit = unit;
1945 mStroke->setOutputUnit( unit );
1951 if ( mPatternWidthUnit != unit || mSvgStrokeWidthUnit != unit ||
mStrokeWidthUnit != unit )
1961 mPatternWidthMapUnitScale = scale;
1962 mSvgStrokeWidthMapUnitScale = scale;
1968 mPatternWidthMapUnitScale == mSvgStrokeWidthMapUnitScale &&
1971 return mPatternWidthMapUnitScale;
1981 mSvgFilePath = svgPath;
1982 setDefaultSvgParams();
1992 if (
properties.contains( QStringLiteral(
"width" ) ) )
1994 width =
properties[QStringLiteral(
"width" )].toDouble();
1996 if (
properties.contains( QStringLiteral(
"svgFile" ) ) )
2000 if (
properties.contains( QStringLiteral(
"angle" ) ) )
2005 std::unique_ptr< QgsSVGFillSymbolLayer > symbolLayer;
2008 symbolLayer = std::make_unique< QgsSVGFillSymbolLayer >(
svgFilePath, width,
angle );
2012 if (
properties.contains( QStringLiteral(
"data" ) ) )
2014 data = QByteArray::fromHex(
properties[QStringLiteral(
"data" )].toString().toLocal8Bit() );
2016 symbolLayer = std::make_unique< QgsSVGFillSymbolLayer >( data, width,
angle );
2020 if (
properties.contains( QStringLiteral(
"svgFillColor" ) ) )
2025 else if (
properties.contains( QStringLiteral(
"color" ) ) )
2029 if (
properties.contains( QStringLiteral(
"svgOutlineColor" ) ) )
2034 else if (
properties.contains( QStringLiteral(
"outline_color" ) ) )
2038 else if (
properties.contains( QStringLiteral(
"line_color" ) ) )
2042 if (
properties.contains( QStringLiteral(
"svgOutlineWidth" ) ) )
2045 symbolLayer->setSvgStrokeWidth(
properties[QStringLiteral(
"svgOutlineWidth" )].toDouble() );
2047 else if (
properties.contains( QStringLiteral(
"outline_width" ) ) )
2049 symbolLayer->setSvgStrokeWidth(
properties[QStringLiteral(
"outline_width" )].toDouble() );
2051 else if (
properties.contains( QStringLiteral(
"line_width" ) ) )
2053 symbolLayer->setSvgStrokeWidth(
properties[QStringLiteral(
"line_width" )].toDouble() );
2057 if (
properties.contains( QStringLiteral(
"pattern_width_unit" ) ) )
2061 if (
properties.contains( QStringLiteral(
"pattern_width_map_unit_scale" ) ) )
2065 if (
properties.contains( QStringLiteral(
"svg_outline_width_unit" ) ) )
2069 if (
properties.contains( QStringLiteral(
"svg_outline_width_map_unit_scale" ) ) )
2073 if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2077 if (
properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2082 if (
properties.contains( QStringLiteral(
"parameters" ) ) )
2088 symbolLayer->restoreOldDataDefinedProperties(
properties );
2090 return symbolLayer.release();
2095 QVariantMap::iterator it =
properties.find( QStringLiteral(
"svgFile" ) );
2107 return QStringLiteral(
"SVGFill" );
2110void QgsSVGFillSymbolLayer::applyPattern( QBrush &brush,
const QString &svgFilePath,
double patternWidth,
Qgis::RenderUnit patternWidthUnit,
2111 const QColor &svgFillColor,
const QColor &svgStrokeColor,
double svgStrokeWidth,
2115 if ( mSvgViewBox.isNull() )
2122 if (
static_cast< int >( size ) < 1.0 || 10000.0 < size )
2124 brush.setTextureImage( QImage() );
2128 bool fitsInCache =
true;
2136 double hwRatio = 1.0;
2137 if ( patternPict.width() > 0 )
2139 hwRatio =
static_cast< double >( patternPict.height() ) /
static_cast< double >( patternPict.width() );
2141 patternImage = QImage(
static_cast< int >( size ),
static_cast< int >( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
2142 patternImage.fill( 0 );
2144 QPainter p( &patternImage );
2145 p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
2148 QTransform brushTransform;
2151 QImage transparentImage = patternImage.copy();
2153 brush.setTextureImage( transparentImage );
2157 brush.setTextureImage( patternImage );
2159 brush.setTransform( brushTransform );
2167 applyPattern(
mBrush, mSvgFilePath, mPatternWidth, mPatternWidthUnit,
mColor, mSvgStrokeColor, mSvgStrokeWidth, mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale, evaluatedParameters );
2191 mStroke->renderPolyline( points, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2194 for (
auto ringIt = rings->constBegin(); ringIt != rings->constEnd(); ++ringIt )
2196 mStroke->renderPolyline( *ringIt, context.
feature(), context.
renderContext(), -1, useSelectedColor );
2205 if ( !mSvgFilePath.isEmpty() )
2207 map.insert( QStringLiteral(
"svgFile" ), mSvgFilePath );
2211 map.insert( QStringLiteral(
"data" ), QString( mSvgData.toHex() ) );
2214 map.insert( QStringLiteral(
"width" ), QString::number( mPatternWidth ) );
2215 map.insert( QStringLiteral(
"angle" ), QString::number(
mAngle ) );
2220 map.insert( QStringLiteral(
"outline_width" ), QString::number( mSvgStrokeWidth ) );
2237 std::unique_ptr< QgsSVGFillSymbolLayer > clonedLayer;
2238 if ( !mSvgFilePath.isEmpty() )
2240 clonedLayer = std::make_unique< QgsSVGFillSymbolLayer >( mSvgFilePath, mPatternWidth,
mAngle );
2241 clonedLayer->setSvgFillColor(
mColor );
2242 clonedLayer->setSvgStrokeColor( mSvgStrokeColor );
2243 clonedLayer->setSvgStrokeWidth( mSvgStrokeWidth );
2247 clonedLayer = std::make_unique< QgsSVGFillSymbolLayer >( mSvgData, mPatternWidth,
mAngle );
2250 clonedLayer->setPatternWidthUnit( mPatternWidthUnit );
2251 clonedLayer->setPatternWidthMapUnitScale( mPatternWidthMapUnitScale );
2252 clonedLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnit );
2253 clonedLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthMapUnitScale );
2257 clonedLayer->setParameters( mParameters );
2261 clonedLayer->setSubSymbol( mStroke->clone() );
2265 return clonedLayer.release();
2272 toSld( doc, element, context );
2278 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2279 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
2280 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
2281 element.appendChild( symbolizerElem );
2285 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2286 symbolizerElem.appendChild( fillElem );
2288 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2289 fillElem.appendChild( graphicFillElem );
2291 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2292 graphicFillElem.appendChild( graphicElem );
2294 if ( !mSvgFilePath.isEmpty() )
2306 context.
pushWarning( QObject::tr(
"Exporting embedded SVG content to SLD is not supported" ) );
2312 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2315 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
2328 mStroke->toSld( doc, element, context );
2341 return mStroke.get();
2348 mStroke.reset(
nullptr );
2361 mStroke.reset( lineSymbol );
2371 if ( mStroke && mStroke->symbolLayer( 0 ) )
2373 double subLayerBleed = mStroke->symbolLayer( 0 )->estimateMaxBleed( context );
2374 return subLayerBleed;
2384 return QColor( Qt::black );
2386 return mStroke->color();
2393 attr.unite( mStroke->usedAttributes( context ) );
2401 if ( mStroke && mStroke->hasDataDefinedProperties() )
2408 QString path, mimeType;
2410 Qt::PenStyle penStyle;
2411 double size, strokeWidth;
2413 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2414 if ( fillElem.isNull() )
2417 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2418 if ( graphicFillElem.isNull() )
2421 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2422 if ( graphicElem.isNull() )
2428 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2433 double scaleFactor = 1.0;
2434 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
2436 size = size * scaleFactor;
2437 strokeWidth = strokeWidth * scaleFactor;
2444 double d = angleFunc.toDouble( &ok );
2449 auto sl = std::make_unique< QgsSVGFillSymbolLayer >( path, size,
angle );
2450 sl->setOutputUnit( sldUnitSize );
2453 sl->setSvgStrokeWidth( strokeWidth );
2456 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2457 if ( !strokeElem.isNull() )
2463 layers.append( l.release() );
2468 return sl.release();
2486 double width = mPatternWidth;
2492 QString svgFile = mSvgFilePath;
2511 double strokeWidth = mSvgStrokeWidth;
2520 mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale, evaluatedParameters );
2524void QgsSVGFillSymbolLayer::storeViewBox()
2526 if ( !mSvgData.isEmpty() )
2528 QSvgRenderer r( mSvgData );
2531 mSvgViewBox = r.viewBoxF();
2536 mSvgViewBox = QRectF();
2539void QgsSVGFillSymbolLayer::setDefaultSvgParams()
2541 if ( mSvgFilePath.isEmpty() )
2546 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2547 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2548 QColor defaultFillColor, defaultStrokeColor;
2549 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2551 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2552 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2553 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2554 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2556 double newFillOpacity = hasFillOpacityParam ?
mColor.alphaF() : 1.0;
2557 double newStrokeOpacity = hasStrokeOpacityParam ? mSvgStrokeColor.alphaF() : 1.0;
2559 if ( hasDefaultFillColor )
2561 mColor = defaultFillColor;
2562 mColor.setAlphaF( newFillOpacity );
2564 if ( hasDefaultFillOpacity )
2566 mColor.setAlphaF( defaultFillOpacity );
2568 if ( hasDefaultStrokeColor )
2570 mSvgStrokeColor = defaultStrokeColor;
2571 mSvgStrokeColor.setAlphaF( newStrokeOpacity );
2573 if ( hasDefaultStrokeOpacity )
2575 mSvgStrokeColor.setAlphaF( defaultStrokeOpacity );
2577 if ( hasDefaultStrokeWidth )
2579 mSvgStrokeWidth = defaultStrokeWidth;
2592 mFillLineSymbol = std::make_unique<QgsLineSymbol>( );
2600 mFillLineSymbol->setWidth( w );
2606 mFillLineSymbol->setColor(
c );
2612 return mFillLineSymbol ? mFillLineSymbol->color() :
mColor;
2624 mFillLineSymbol.reset( qgis::down_cast<QgsLineSymbol *>( symbol ) );
2633 return mFillLineSymbol.get();
2639 if ( mFillLineSymbol )
2640 attr.unite( mFillLineSymbol->usedAttributes( context ) );
2648 if ( mFillLineSymbol && mFillLineSymbol->hasDataDefinedProperties() )
2670 double lineAngleRad { qDegreesToRadians( mLineAngle ) };
2672 const int quadrant {
static_cast<int>( lineAngleRad / M_PI_2 ) };
2673 Q_ASSERT( quadrant >= 0 && quadrant <= 3 );
2683 lineAngleRad -= M_PI / 2;
2688 lineAngleRad -= M_PI;
2693 lineAngleRad -= M_PI + M_PI_2;
2701 QSize size {
static_cast<int>( distancePx ),
static_cast<int>( distancePx ) };
2703 if (
static_cast<int>( mLineAngle ) % 90 != 0 )
2705 size = QSize(
static_cast<int>( distancePx / std::sin( lineAngleRad ) ),
static_cast<int>( distancePx / std::cos( lineAngleRad ) ) );
2708 QPixmap pixmap( size );
2709 pixmap.fill( Qt::transparent );
2711 painter.begin( &pixmap );
2712 painter.setRenderHint( QPainter::Antialiasing );
2720 std::unique_ptr< QgsLinePatternFillSymbolLayer > layerClone(
clone() );
2721 layerClone->setOffset( 0 );
2722 layerClone->drawPreviewIcon( symbolContext, pixmap.size() );
2724 return pixmap.toImage();
2735 mDistanceUnit = unit;
2736 mLineWidthUnit = unit;
2739 if ( mFillLineSymbol )
2740 mFillLineSymbol->setOutputUnit( unit );
2763 mDistanceMapUnitScale = scale;
2764 mLineWidthMapUnitScale = scale;
2765 mOffsetMapUnitScale = scale;
2771 mDistanceMapUnitScale == mLineWidthMapUnitScale &&
2772 mLineWidthMapUnitScale == mOffsetMapUnitScale )
2774 return mDistanceMapUnitScale;
2781 auto patternLayer = std::make_unique< QgsLinePatternFillSymbolLayer >();
2787 QColor
color( Qt::black );
2790 if (
properties.contains( QStringLiteral(
"lineangle" ) ) )
2795 else if (
properties.contains( QStringLiteral(
"angle" ) ) )
2799 patternLayer->setLineAngle(
lineAngle );
2801 if (
properties.contains( QStringLiteral(
"distance" ) ) )
2805 patternLayer->setDistance(
distance );
2807 if (
properties.contains( QStringLiteral(
"linewidth" ) ) )
2812 else if (
properties.contains( QStringLiteral(
"outline_width" ) ) )
2816 else if (
properties.contains( QStringLiteral(
"line_width" ) ) )
2820 patternLayer->setLineWidth(
lineWidth );
2822 if (
properties.contains( QStringLiteral(
"color" ) ) )
2826 else if (
properties.contains( QStringLiteral(
"outline_color" ) ) )
2830 else if (
properties.contains( QStringLiteral(
"line_color" ) ) )
2834 patternLayer->setColor(
color );
2836 if (
properties.contains( QStringLiteral(
"offset" ) ) )
2840 patternLayer->setOffset(
offset );
2843 if (
properties.contains( QStringLiteral(
"distance_unit" ) ) )
2847 if (
properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
2851 if (
properties.contains( QStringLiteral(
"line_width_unit" ) ) )
2855 else if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2859 if (
properties.contains( QStringLiteral(
"line_width_map_unit_scale" ) ) )
2863 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
2867 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2871 if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2875 if (
properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2879 if (
properties.contains( QStringLiteral(
"coordinate_reference" ) ) )
2883 if (
properties.contains( QStringLiteral(
"clip_mode" ) ) )
2888 patternLayer->restoreOldDataDefinedProperties(
properties );
2890 return patternLayer.release();
2895 return QStringLiteral(
"LinePatternFill" );
2898bool QgsLinePatternFillSymbolLayer::applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double lineAngle,
double distance )
2900 mBrush.setTextureImage( QImage() );
2902 if ( !mFillLineSymbol )
2907 std::unique_ptr< QgsLineSymbol > fillLineSymbol( mFillLineSymbol->clone() );
2908 if ( !fillLineSymbol )
2924 outputPixelOffset = std::fmod( outputPixelOffset, outputPixelDist );
2925 if ( outputPixelOffset > outputPixelDist / 2.0 )
2926 outputPixelOffset -= outputPixelDist;
2930 double outputPixelBleed = 0;
2931 double outputPixelInterval = 0;
2932 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2936 outputPixelBleed = std::max( outputPixelBleed, outputPixelLayerBleed );
2939 if ( markerLineLayer )
2948 outputPixelInterval = std::max( outputPixelInterval, outputPixelLayerInterval );
2952 if ( outputPixelInterval > 0 )
2956 double intervalScale = std::round( outputPixelInterval ) / outputPixelInterval;
2957 outputPixelInterval = std::round( outputPixelInterval );
2959 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2964 if ( markerLineLayer )
2978 height = outputPixelDist;
2979 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2983 width = outputPixelDist;
2984 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2988 height = outputPixelDist / std::cos(
lineAngle * M_PI / 180 );
2989 width = outputPixelDist / std::sin(
lineAngle * M_PI / 180 );
2992 lineAngle = 180 * std::atan2(
static_cast< double >( height ),
static_cast< double >( width ) ) / M_PI;
2998 height = std::abs( height );
2999 width = std::abs( width );
3001 outputPixelDist = std::abs( height * std::cos(
lineAngle * M_PI / 180 ) );
3005 int offsetHeight =
static_cast< int >( std::round( outputPixelOffset / std::cos(
lineAngle * M_PI / 180 ) ) );
3006 outputPixelOffset = offsetHeight * std::cos(
lineAngle * M_PI / 180 );
3015 int bufferMulti =
static_cast< int >( std::max( std::ceil( outputPixelBleed / width ), std::ceil( outputPixelBleed / width ) ) );
3019 bufferMulti = std::max( bufferMulti, 1 );
3021 int xBuffer = width * bufferMulti;
3022 int yBuffer = height * bufferMulti;
3023 int innerWidth = width;
3024 int innerHeight = height;
3025 width += 2 * xBuffer;
3026 height += 2 * yBuffer;
3029 if ( width > 2000 || height > 2000 || width == 0 || height == 0 )
3034 QImage patternImage( width, height, QImage::Format_ARGB32 );
3035 patternImage.fill( 0 );
3037 QPointF p1, p2, p3, p4, p5, p6;
3040 p1 = QPointF( 0, yBuffer );
3041 p2 = QPointF( width, yBuffer );
3042 p3 = QPointF( 0, yBuffer + innerHeight );
3043 p4 = QPointF( width, yBuffer + innerHeight );
3047 p1 = QPointF( xBuffer, height );
3048 p2 = QPointF( xBuffer, 0 );
3049 p3 = QPointF( xBuffer + innerWidth, height );
3050 p4 = QPointF( xBuffer + innerWidth, 0 );
3054 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
3055 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
3056 p1 = QPointF( 0, height );
3057 p2 = QPointF( width, 0 );
3058 p3 = QPointF( -dx, height - dy );
3059 p4 = QPointF( width - dx, -dy );
3060 p5 = QPointF( dx, height + dy );
3061 p6 = QPointF( width + dx, dy );
3065 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
3066 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
3067 p1 = QPointF( width, 0 );
3068 p2 = QPointF( 0, height );
3069 p3 = QPointF( width - dx, -dy );
3070 p4 = QPointF( -dx, height - dy );
3071 p5 = QPointF( width + dx, dy );
3072 p6 = QPointF( dx, height + dy );
3076 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
3077 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
3078 p1 = QPointF( 0, 0 );
3079 p2 = QPointF( width, height );
3080 p5 = QPointF( dx, -dy );
3081 p6 = QPointF( width + dx, height - dy );
3082 p3 = QPointF( -dx, dy );
3083 p4 = QPointF( width - dx, height + dy );
3087 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
3088 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
3089 p1 = QPointF( width, height );
3090 p2 = QPointF( 0, 0 );
3091 p5 = QPointF( width + dx, height - dy );
3092 p6 = QPointF( dx, -dy );
3093 p3 = QPointF( width - dx, height + dy );
3094 p4 = QPointF( -dx, dy );
3101 p3 = QPointF( tempPt.x(), tempPt.y() );
3103 p4 = QPointF( tempPt.x(), tempPt.y() );
3105 p5 = QPointF( tempPt.x(), tempPt.y() );
3107 p6 = QPointF( tempPt.x(), tempPt.y() );
3111 p1 = QPointF( tempPt.x(), tempPt.y() );
3113 p2 = QPointF( tempPt.x(), tempPt.y() );
3116 QPainter p( &patternImage );
3120 p.setRenderHint( QPainter::Antialiasing,
false );
3121 QPen pen( QColor( Qt::black ) );
3122 pen.setWidthF( 0.1 );
3123 pen.setCapStyle( Qt::FlatCap );
3128 QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 );
3129 p.drawPolygon( polygon );
3131 polygon = QPolygon() << QPoint( xBuffer, yBuffer ) << QPoint( width - xBuffer - 1, yBuffer ) << QPoint( width - xBuffer - 1, height - yBuffer - 1 ) << QPoint( xBuffer, height - yBuffer - 1 ) << QPoint( xBuffer, yBuffer );
3132 p.drawPolygon( polygon );
3138 p.setRenderHint( QPainter::Antialiasing,
true );
3152 fillLineSymbol->startRender( lineRenderContext, context.
fields() );
3154 QVector<QPolygonF> polygons;
3155 polygons.append( QPolygonF() << p1 << p2 );
3156 polygons.append( QPolygonF() << p3 << p4 );
3159 polygons.append( QPolygonF() << p5 << p6 );
3163 for (
const QPolygonF &polygon : std::as_const( polygons ) )
3165 fillLineSymbol->renderPolyline( polygon, context.
feature(), lineRenderContext, -1, useSelectedColor );
3168 fillLineSymbol->stopRender( lineRenderContext );
3172 patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
3177 QImage transparentImage = patternImage.copy();
3179 brush.setTextureImage( transparentImage );
3183 brush.setTextureImage( patternImage );
3186 QTransform brushTransform;
3187 brush.setTransform( brushTransform );
3197 || ( mFillLineSymbol && mFillLineSymbol->hasDataDefinedProperties() )
3201 if ( !mRenderUsingLines )
3205 mRenderUsingLines = !applyPattern( context,
mBrush, mLineAngle, mDistance );
3208 if ( mRenderUsingLines && mFillLineSymbol )
3212 mFillLineSymbolRenderStarted =
true;
3218 if ( mFillLineSymbolRenderStarted )
3221 mFillLineSymbolRenderStarted =
false;
3228 if ( !useSelectedColor && !mRenderUsingLines )
3235 if ( !mFillLineSymbolRenderStarted && mFillLineSymbol )
3239 mFillLineSymbolRenderStarted =
true;
3269 outputPixelOffset = std::fmod( outputPixelOffset, outputPixelDistance );
3270 if ( outputPixelOffset > outputPixelDistance / 2.0 )
3271 outputPixelOffset -= outputPixelDistance;
3273 p->setPen( QPen( Qt::NoPen ) );
3295 std::unique_ptr< QgsPolygon > shapePolygon;
3296 std::unique_ptr< QgsGeometryEngine > shapeEngine;
3304 shapePolygon = std::make_unique< QgsPolygon >();
3306 shapePolygon->setExteriorRing( fromPolygon.release() );
3309 for (
const QPolygonF &ring : *rings )
3312 shapePolygon->addInteriorRing( fromRing.release() );
3316 shapeEngine->prepareGeometry();
3323 path.addPolygon( points );
3326 for (
const QPolygonF &ring : *rings )
3328 path.addPolygon( ring );
3331 p->setClipPath( path, Qt::IntersectClip );
3337 const QRectF boundingRect = points.boundingRect();
3339 QTransform invertedRotateTransform;
3345 QTransform transform;
3346 if ( applyBrushTransform )
3349 transform.translate( -boundingRect.center().x(),
3350 -boundingRect.center().y() );
3352 transform.translate( boundingRect.center().x(),
3353 boundingRect.center().y() );
3361 const QRectF transformedBounds = transform.map( points ).boundingRect();
3365 left = transformedBounds.left() - buffer * 2;
3366 top = transformedBounds.top() - buffer * 2;
3367 right = transformedBounds.right() + buffer * 2;
3368 bottom = transformedBounds.bottom() + buffer * 2;
3369 invertedRotateTransform = transform.inverted();
3371 if ( !applyBrushTransform )
3373 top -= transformedBounds.top() - ( outputPixelDistance * std::floor( transformedBounds.top() / outputPixelDistance ) );
3378 const bool needsExpressionContext = mFillLineSymbol->hasDataDefinedProperties();
3383 int currentLine = 0;
3384 for (
double currentY = top; currentY <= bottom; currentY += outputPixelDistance )
3389 if ( needsExpressionContext )
3393 double y1 = currentY;
3395 double y2 = currentY;
3396 invertedRotateTransform.map( left, currentY - outputPixelOffset, &x1, &y1 );
3397 invertedRotateTransform.map( right, currentY - outputPixelOffset, &x2, &y2 );
3402 std::unique_ptr< QgsAbstractGeometry > intersection( shapeEngine->intersection( &ls ) );
3403 for (
auto it = intersection->const_parts_begin(); it != intersection->const_parts_end(); ++it )
3405 if (
const QgsLineString *ls = qgsgeometry_cast< const QgsLineString * >( *it ) )
3413 mFillLineSymbol->renderPolyline( QPolygonF() << QPointF( x1, y1 ) << QPointF( x2, y2 ), context.
feature(), context.
renderContext(), -1, useSelectedColor );
3425 map.insert( QStringLiteral(
"angle" ), QString::number( mLineAngle ) );
3426 map.insert( QStringLiteral(
"distance" ), QString::number( mDistance ) );
3427 map.insert( QStringLiteral(
"line_width" ), QString::number( mLineWidth ) );
3429 map.insert( QStringLiteral(
"offset" ), QString::number( mOffset ) );
3445 if ( mFillLineSymbol )
3458 toSld( doc, element, context );
3464 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
3465 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
3466 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
3467 element.appendChild( symbolizerElem );
3472 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
3473 symbolizerElem.appendChild( fillElem );
3475 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
3476 fillElem.appendChild( graphicFillElem );
3478 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3479 graphicFillElem.appendChild( graphicElem );
3482 bool exportOk {
false };
3486 if ( ! image.isNull() )
3489 QString pngPath { info.completeSuffix().isEmpty() ? context.
exportFilePath() : context.
exportFilePath().chopped( info.completeSuffix().length() ).append( QStringLiteral(
"png" ) ) };
3491 image.save( pngPath );
3500 QColor lineColor = mFillLineSymbol ? mFillLineSymbol->color() : QColor();
3501 double lineWidth = mFillLineSymbol ? mFillLineSymbol->width() : 0.0;
3509 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3512 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg( mLineAngle );
3516 angleFunc = QString::number(
angle + mLineAngle );
3521 QPointF lineOffset( std::sin( mLineAngle ) * mOffset, std::cos( mLineAngle ) * mOffset );
3530 QString featureStyle;
3531 featureStyle.append(
"Brush(" );
3532 featureStyle.append( QStringLiteral(
"fc:%1" ).arg(
mColor.name() ) );
3533 featureStyle.append( QStringLiteral(
",bc:%1" ).arg( QLatin1String(
"#00000000" ) ) );
3534 featureStyle.append(
",id:\"ogr-brush-2\"" );
3535 featureStyle.append( QStringLiteral(
",a:%1" ).arg( mLineAngle ) );
3536 featureStyle.append( QStringLiteral(
",s:%1" ).arg( mLineWidth * widthScaleFactor ) );
3537 featureStyle.append(
",dx:0mm" );
3538 featureStyle.append( QStringLiteral(
",dy:%1mm" ).arg( mDistance * widthScaleFactor ) );
3539 featureStyle.append(
')' );
3540 return featureStyle;
3546 && ( !mFillLineSymbol || !mFillLineSymbol->hasDataDefinedProperties() ) )
3571 Qt::PenStyle lineStyle;
3573 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
3574 if ( fillElem.isNull() )
3577 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
3578 if ( graphicFillElem.isNull() )
3581 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
3582 if ( graphicElem.isNull() )
3588 if ( name != QLatin1String(
"horline" ) )
3596 double d = angleFunc.toDouble( &ok );
3605 offset = std::sqrt( std::pow( vectOffset.x(), 2 ) + std::pow( vectOffset.y(), 2 ) );
3608 double scaleFactor = 1.0;
3609 const QString uom = element.attribute( QStringLiteral(
"uom" ) );
3611 size = size * scaleFactor;
3614 auto sl = std::make_unique< QgsLinePatternFillSymbolLayer >();
3615 sl->setOutputUnit( sldUnitSize );
3616 sl->setColor( lineColor );
3618 sl->setLineAngle(
angle );
3620 sl->setDistance( size );
3623 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
3624 if ( !strokeElem.isNull() )
3630 layers.append( l.release() );
3635 return sl.release();
3735 auto layer = std::make_unique< QgsPointPatternFillSymbolLayer >();
3736 if (
properties.contains( QStringLiteral(
"distance_x" ) ) )
3738 layer->setDistanceX(
properties[QStringLiteral(
"distance_x" )].toDouble() );
3740 if (
properties.contains( QStringLiteral(
"distance_y" ) ) )
3742 layer->setDistanceY(
properties[QStringLiteral(
"distance_y" )].toDouble() );
3744 if (
properties.contains( QStringLiteral(
"displacement_x" ) ) )
3746 layer->setDisplacementX(
properties[QStringLiteral(
"displacement_x" )].toDouble() );
3748 if (
properties.contains( QStringLiteral(
"displacement_y" ) ) )
3750 layer->setDisplacementY(
properties[QStringLiteral(
"displacement_y" )].toDouble() );
3752 if (
properties.contains( QStringLiteral(
"offset_x" ) ) )
3754 layer->setOffsetX(
properties[QStringLiteral(
"offset_x" )].toDouble() );
3756 if (
properties.contains( QStringLiteral(
"offset_y" ) ) )
3758 layer->setOffsetY(
properties[QStringLiteral(
"offset_y" )].toDouble() );
3761 if (
properties.contains( QStringLiteral(
"distance_x_unit" ) ) )
3765 if (
properties.contains( QStringLiteral(
"distance_x_map_unit_scale" ) ) )
3769 if (
properties.contains( QStringLiteral(
"distance_y_unit" ) ) )
3773 if (
properties.contains( QStringLiteral(
"distance_y_map_unit_scale" ) ) )
3777 if (
properties.contains( QStringLiteral(
"displacement_x_unit" ) ) )
3781 if (
properties.contains( QStringLiteral(
"displacement_x_map_unit_scale" ) ) )
3785 if (
properties.contains( QStringLiteral(
"displacement_y_unit" ) ) )
3789 if (
properties.contains( QStringLiteral(
"displacement_y_map_unit_scale" ) ) )
3793 if (
properties.contains( QStringLiteral(
"offset_x_unit" ) ) )
3797 if (
properties.contains( QStringLiteral(
"offset_x_map_unit_scale" ) ) )
3801 if (
properties.contains( QStringLiteral(
"offset_y_unit" ) ) )
3805 if (
properties.contains( QStringLiteral(
"offset_y_map_unit_scale" ) ) )
3810 if (
properties.contains( QStringLiteral(
"random_deviation_x" ) ) )
3812 layer->setMaximumRandomDeviationX(
properties[QStringLiteral(
"random_deviation_x" )].toDouble() );
3814 if (
properties.contains( QStringLiteral(
"random_deviation_y" ) ) )
3816 layer->setMaximumRandomDeviationY(
properties[QStringLiteral(
"random_deviation_y" )].toDouble() );
3818 if (
properties.contains( QStringLiteral(
"random_deviation_x_unit" ) ) )
3822 if (
properties.contains( QStringLiteral(
"random_deviation_x_map_unit_scale" ) ) )
3826 if (
properties.contains( QStringLiteral(
"random_deviation_y_unit" ) ) )
3830 if (
properties.contains( QStringLiteral(
"random_deviation_y_map_unit_scale" ) ) )
3834 unsigned long seed = 0;
3835 if (
properties.contains( QStringLiteral(
"seed" ) ) )
3841 std::random_device rd;
3842 std::mt19937 mt(
seed == 0 ? rd() :
seed );
3843 std::uniform_int_distribution<> uniformDist( 1, 999999999 );
3844 seed = uniformDist( mt );
3846 layer->setSeed(
seed );
3848 if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
3852 if (
properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3856 if (
properties.contains( QStringLiteral(
"clip_mode" ) ) )
3860 if (
properties.contains( QStringLiteral(
"coordinate_reference" ) ) )
3865 if (
properties.contains( QStringLiteral(
"angle" ) ) )
3867 layer->setAngle(
properties[QStringLiteral(
"angle" )].toDouble() );
3872 return layer.release();
3877 return QStringLiteral(
"PointPatternFill" );
3880bool QgsPointPatternFillSymbolLayer::applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double distanceX,
double distanceY,
3881 double displacementX,
double displacementY,
double offsetX,
double offsetY )
3888 double widthOffset = std::fmod(
3891 double heightOffset = std::fmod(
3895 if ( width > 2000 || height > 2000 )
3897 brush.setTextureImage( QImage() );
3901 QImage patternImage( width, height, QImage::Format_ARGB32 );
3902 patternImage.fill( 0 );
3903 if ( patternImage.isNull() )
3905 brush.setTextureImage( QImage() );
3910 QPainter p( &patternImage );
3929 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3931 for (
double currentY = -height; currentY <= height * 2.0; currentY += height )
3933 mMarkerSymbol->renderPoint( QPointF( currentX + widthOffset, currentY + heightOffset ), context.
feature(), pointRenderContext );
3944 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3946 for (
double currentY = -height / 2.0; currentY <= height * 2.0; currentY += height )
3948 mMarkerSymbol->renderPoint( QPointF( currentX + widthOffset + displacementPixelX, currentY + heightOffset ), context.
feature(), pointRenderContext );
3952 for (
double currentX = -width / 2.0; currentX <= width * 2.0; currentX += width )
3954 for (
double currentY = -height; currentY <= height * 2.0; currentY += height / 2.0 )
3956 mMarkerSymbol->renderPoint( QPointF( currentX + widthOffset + ( std::fmod( currentY, height ) != 0 ? displacementPixelX : 0 ), currentY + heightOffset - displacementPixelY ), context.feature(), pointRenderContext );
3965 QImage transparentImage = patternImage.copy();
3967 brush.setTextureImage( transparentImage );
3971 brush.setTextureImage( patternImage );
3973 QTransform brushTransform;
3974 brush.setTransform( brushTransform );
3994 if ( !mRenderUsingMarkers )
4039 if ( !useSelectedColor && !mRenderUsingMarkers )
4089 const double widthOffset = std::fmod(
4101 const double heightOffset = std::fmod(
4127 p->setPen( QPen( Qt::NoPen ) );
4149 std::unique_ptr< QgsPolygon > shapePolygon;
4150 std::unique_ptr< QgsGeometryEngine > shapeEngine;
4157 shapePolygon = std::make_unique< QgsPolygon >();
4159 shapePolygon->setExteriorRing( fromPolygon.release() );
4162 for (
const QPolygonF &ring : *rings )
4165 shapePolygon->addInteriorRing( fromRing.release() );
4169 shapeEngine->prepareGeometry();
4176 path.addPolygon( points );
4179 for (
const QPolygonF &ring : *rings )
4181 path.addPolygon( ring );
4184 p->setClipPath( path, Qt::IntersectClip );
4190 const QRectF boundingRect = points.boundingRect();
4192 QTransform invertedRotateTransform;
4200 QTransform transform;
4201 if ( applyBrushTransform )
4204 transform.translate( -boundingRect.center().x(),
4205 -boundingRect.center().y() );
4206 transform.rotate( -
angle );
4207 transform.translate( boundingRect.center().x(),
4208 boundingRect.center().y() );
4213 transform.rotate( -
angle );
4216 const QRectF transformedBounds = transform.map( points ).boundingRect();
4217 left = transformedBounds.left() - 2 * width;
4218 top = transformedBounds.top() - 2 * height;
4219 right = transformedBounds.right() + 2 * width;
4220 bottom = transformedBounds.bottom() + 2 * height;
4221 invertedRotateTransform = transform.inverted();
4223 if ( !applyBrushTransform )
4225 left -= transformedBounds.left() - ( width * std::floor( transformedBounds.left() / width ) );
4226 top -= transformedBounds.top() - ( height * std::floor( transformedBounds.top() / height ) );
4231 left = boundingRect.left() - 2 * width;
4232 top = boundingRect.top() - 2 * height;
4233 right = boundingRect.right() + 2 * width;
4234 bottom = boundingRect.bottom() + 2 * height;
4236 if ( !applyBrushTransform )
4238 left -= boundingRect.left() - ( width * std::floor( boundingRect.left() / width ) );
4239 top -= boundingRect.top() - ( height * std::floor( boundingRect.top() / height ) );
4268 std::random_device rd;
4269 std::mt19937 mt(
seed == 0 ? rd() :
seed );
4270 std::uniform_real_distribution<> uniformDist( 0, 1 );
4276 const bool needsExpressionContext =
mMarkerSymbol->hasDataDefinedProperties();
4284 bool alternateColumn =
false;
4285 int currentCol = -3;
4286 for (
double currentX = left; currentX <= right; currentX += width, alternateColumn = !alternateColumn )
4291 if ( needsExpressionContext )
4294 bool alternateRow =
false;
4295 const double columnX = currentX + widthOffset;
4296 int currentRow = -3;
4297 for (
double currentY = top; currentY <= bottom; currentY += height, alternateRow = !alternateRow )
4302 double y = currentY + heightOffset;
4305 x += displacementPixelX;
4307 if ( !alternateColumn )
4308 y -= displacementPixelY;
4314 invertedRotateTransform.map( xx, yy, &x, &y );
4317 if ( useRandomShift )
4319 x += ( 2 * uniformDist( mt ) - 1 ) * maxRandomDeviationPixelX;
4320 y += ( 2 * uniformDist( mt ) - 1 ) * maxRandomDeviationPixelY;
4323 if ( needsExpressionContext )
4331 bool renderPoint =
true;
4339 renderPoint = shapeEngine->intersects( &p );
4351 renderPoint = shapeEngine->intersects( markerBounds.
constGet() );
4377 map.insert( QStringLiteral(
"distance_x" ), QString::number(
mDistanceX ) );
4378 map.insert( QStringLiteral(
"distance_y" ), QString::number(
mDistanceY ) );
4379 map.insert( QStringLiteral(
"displacement_x" ), QString::number(
mDisplacementX ) );
4380 map.insert( QStringLiteral(
"displacement_y" ), QString::number(
mDisplacementY ) );
4381 map.insert( QStringLiteral(
"offset_x" ), QString::number(
mOffsetX ) );
4382 map.insert( QStringLiteral(
"offset_y" ), QString::number(
mOffsetY ) );
4398 map.insert( QStringLiteral(
"random_deviation_x" ), QString::number(
mRandomDeviationX ) );
4399 map.insert( QStringLiteral(
"random_deviation_y" ), QString::number(
mRandomDeviationY ) );
4404 map.insert( QStringLiteral(
"seed" ), QString::number(
mSeed ) );
4405 map.insert( QStringLiteral(
"angle" ),
mAngle );
4426 toSld( doc, element, context );
4432 for (
int symbolLayerIdx = 0; symbolLayerIdx <
mMarkerSymbol->symbolLayerCount(); symbolLayerIdx++ )
4434 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
4435 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
4436 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
4437 element.appendChild( symbolizerElem );
4442 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
4443 symbolizerElem.appendChild( fillElem );
4445 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
4446 fillElem.appendChild( graphicFillElem );
4451 bool exportOk {
false };
4455 if ( ! image.isNull() )
4457 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
4458 graphicFillElem.appendChild( graphicElem );
4460 QString pngPath { info.completeSuffix().isEmpty() ? context.
exportFilePath() : context.
exportFilePath().chopped( info.completeSuffix().length() ).append( QStringLiteral(
"png" ) ) };
4462 image.save( pngPath );
4481 symbolizerElem.appendChild( graphicMarginElem );
4485 markerLayer->writeSldMarker( doc, graphicFillElem, context );
4489 QgsDebugError( QStringLiteral(
"QgsMarkerSymbolLayer expected, %1 found. Skip it." ).arg( layer->
layerType() ) );
4493 QgsDebugError( QStringLiteral(
"Missing point pattern symbol layer. Skip it." ) );
4503 double angleRads { qDegreesToRadians(
mAngle ) };
4512 if ( displacementXPx != 0 )
4517 if ( displacementYPx != 0 )
4524 QPixmap pixmap( size );
4525 pixmap.fill( Qt::transparent );
4527 painter.begin( &pixmap );
4528 painter.setRenderHint( QPainter::Antialiasing );
4536 std::unique_ptr< QgsPointPatternFillSymbolLayer > layerClone(
clone() );
4538 layerClone->setAngle( qRadiansToDegrees( angleRads ) );
4541 layerClone->setMaximumRandomDeviationX( 0 );
4542 layerClone->setMaximumRandomDeviationY( 0 );
4544 layerClone->drawPreviewIcon( symbolContext, pixmap.size() );
4546 return pixmap.toImage();
4554 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
4555 if ( fillElem.isNull() )
4558 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
4559 if ( graphicFillElem.isNull() )
4562 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
4563 if ( graphicElem.isNull() )
4567 if ( !simpleMarkerSl )
4571 layers.append( simpleMarkerSl.release() );
4573 auto marker = std::make_unique< QgsMarkerSymbol >( layers );
4576 const double markerSize { marker->size() };
4578 auto pointPatternFillSl = std::make_unique< QgsPointPatternFillSymbolLayer >();
4579 pointPatternFillSl->setSubSymbol( marker.release() );
4584 auto distanceParser = [ & ](
const QStringList & values )
4586 switch ( values.count( ) )
4591 const double v { values.at( 0 ).toDouble( &ok ) };
4594 pointPatternFillSl->setDistanceX( v * 2 + markerSize );
4595 pointPatternFillSl->setDistanceY( v * 2 + markerSize );
4602 const double vX { values.at( 1 ).toDouble( &ok ) };
4605 pointPatternFillSl->setDistanceX( vX * 2 + markerSize );
4607 const double vY { values.at( 0 ).toDouble( &ok ) };
4610 pointPatternFillSl->setDistanceY( vY * 2 + markerSize );
4617 const double vX { values.at( 1 ).toDouble( &ok ) };
4620 pointPatternFillSl->setDistanceX( vX * 2 + markerSize );
4622 const double vYt { values.at( 0 ).toDouble( &ok ) };
4625 const double vYb { values.at( 2 ).toDouble( &ok ) };
4628 pointPatternFillSl->setDistanceY( ( vYt + vYb ) + markerSize );
4636 const double vYt { values.at( 0 ).toDouble( &ok ) };
4639 const double vYb { values.at( 2 ).toDouble( &ok ) };
4642 pointPatternFillSl->setDistanceY( ( vYt + vYb ) + markerSize );
4645 const double vXr { values.at( 1 ).toDouble( &ok ) };
4648 const double vXl { values.at( 3 ).toDouble( &ok ) };
4651 pointPatternFillSl->setDistanceX( ( vXr + vXl ) + markerSize );
4662 bool distanceFromVendorOption {
false };
4664 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
4667 if ( it.key() == QLatin1String(
"distance" ) )
4669 distanceParser( it.value().split(
',' ) );
4670 distanceFromVendorOption =
true;
4673 else if ( it.key() == QLatin1String(
"graphic-margin" ) )
4675 distanceParser( it.value().split(
' ' ) );
4676 distanceFromVendorOption =
true;
4681 if ( ! distanceFromVendorOption && ! graphicFillElem.elementsByTagName( QStringLiteral(
"Size" ) ).isEmpty() )
4683 const QDomElement sizeElement { graphicFillElem.elementsByTagName( QStringLiteral(
"Size" ) ).at( 0 ).toElement() };
4685 const double size { sizeElement.text().toDouble( &ok ) };
4688 pointPatternFillSl->setDistanceX( size );
4689 pointPatternFillSl->setDistanceY( size );
4693 return pointPatternFillSl.release();
4775 attributes.unite(
mMarkerSymbol->usedAttributes( context ) );
4813 auto sl = std::make_unique< QgsCentroidFillSymbolLayer >();
4815 if (
properties.contains( QStringLiteral(
"point_on_surface" ) ) )
4816 sl->setPointOnSurface(
properties[QStringLiteral(
"point_on_surface" )].toInt() != 0 );
4817 if (
properties.contains( QStringLiteral(
"point_on_all_parts" ) ) )
4818 sl->setPointOnAllParts(
properties[QStringLiteral(
"point_on_all_parts" )].toInt() != 0 );
4819 if (
properties.contains( QStringLiteral(
"clip_points" ) ) )
4820 sl->setClipPoints(
properties[QStringLiteral(
"clip_points" )].toInt() != 0 );
4821 if (
properties.contains( QStringLiteral(
"clip_on_current_part_only" ) ) )
4822 sl->setClipOnCurrentPartOnly(
properties[QStringLiteral(
"clip_on_current_part_only" )].toInt() != 0 );
4824 sl->restoreOldDataDefinedProperties(
properties );
4826 return sl.release();
4831 return QStringLiteral(
"CentroidFill" );
4859 part.exterior = points;
4861 part.rings = *rings;
4869 mCurrentParts << part;
4874 const double prevOpacity =
mMarker->opacity();
4878 mMarker->setOpacity( prevOpacity );
4887 mCurrentParts.clear();
4894 const double prevOpacity =
mMarker->opacity();
4900 mMarker->setOpacity( prevOpacity );
4905void QgsCentroidFillSymbolLayer::render(
QgsRenderContext &context,
const QVector<QgsCentroidFillSymbolLayer::Part> &parts,
const QgsFeature &feature,
bool selected )
4914 QVector< QgsGeometry > geometryParts;
4915 geometryParts.reserve( parts.size() );
4916 QPainterPath globalPath;
4919 int maxAreaPartIdx = 0;
4921 for (
int i = 0; i < parts.size(); i++ )
4923 const Part part = parts[i];
4926 if ( !geom.
isNull() && !part.rings.empty() )
4928 QgsPolygon *poly = qgsgeometry_cast< QgsPolygon * >( geom.
get() );
4932 int area = poly->
area();
4934 if ( area > maxArea )
4944 globalPath.addPolygon( part.exterior );
4945 for (
const QPolygonF &ring : part.rings )
4947 globalPath.addPolygon( ring );
4952 for (
int i = 0; i < parts.size(); i++ )
4957 const Part part = parts[i];
4965 path.addPolygon( part.exterior );
4966 for (
const QPolygonF &ring : part.rings )
4968 path.addPolygon( ring );
4977 context.
painter()->setClipPath( path );
4984 mMarker->renderPoint( centroid, feature.
isValid() ? &feature : nullptr, context, -1, selected );
4997 map[QStringLiteral(
"point_on_surface" )] = QString::number(
mPointOnSurface );
4998 map[QStringLiteral(
"point_on_all_parts" )] = QString::number(
mPointOnAllParts );
4999 map[QStringLiteral(
"clip_points" )] = QString::number(
mClipPoints );
5006 auto x = std::make_unique< QgsCentroidFillSymbolLayer >();
5009 x->setSubSymbol(
mMarker->clone() );
5023 toSld( doc, element, context );
5031 return mMarker->toSld( doc, element, context );
5041 layers.append( l.release() );
5042 auto marker = std::make_unique<QgsMarkerSymbol>( layers );
5044 auto sl = std::make_unique< QgsCentroidFillSymbolLayer >();
5045 sl->setSubSymbol( marker.release() );
5046 sl->setPointOnAllParts(
false );
5047 return sl.release();
5074 attributes.unite(
mMarker->usedAttributes( context ) );
5097 mMarker->setOutputUnit( unit );
5114 return mMarker->usesMapUnits();
5123 mMarker->setMapUnitScale( scale );
5131 return mMarker->mapUnitScale();
5141 , mImageFilePath( imageFilePath )
5158 if (
properties.contains( QStringLiteral(
"imageFile" ) ) )
5160 imagePath =
properties[QStringLiteral(
"imageFile" )].toString();
5162 if (
properties.contains( QStringLiteral(
"coordinate_mode" ) ) )
5166 if (
properties.contains( QStringLiteral(
"alpha" ) ) )
5168 alpha =
properties[QStringLiteral(
"alpha" )].toDouble();
5170 if (
properties.contains( QStringLiteral(
"offset" ) ) )
5174 if (
properties.contains( QStringLiteral(
"angle" ) ) )
5178 if (
properties.contains( QStringLiteral(
"width" ) ) )
5182 auto symbolLayer = std::make_unique< QgsRasterFillSymbolLayer >( imagePath );
5183 symbolLayer->setCoordinateMode( mode );
5184 symbolLayer->setOpacity( alpha );
5185 symbolLayer->setOffset(
offset );
5186 symbolLayer->setAngle(
angle );
5187 symbolLayer->setWidth(
width );
5188 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
5192 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
5196 if (
properties.contains( QStringLiteral(
"width_unit" ) ) )
5200 if (
properties.contains( QStringLiteral(
"width_map_unit_scale" ) ) )
5205 if (
properties.contains( QStringLiteral(
"height" ) ) )
5207 symbolLayer->setHeight(
properties[QStringLiteral(
"height" )].toDouble() );
5210 symbolLayer->restoreOldDataDefinedProperties(
properties );
5212 return symbolLayer.release();
5217 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
5218 if ( fillElem.isNull() )
5221 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
5222 if ( graphicFillElem.isNull() )
5225 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
5226 if ( graphicElem.isNull() )
5229 QString path, mimeType;
5237 if ( ! QFile::exists( path ) )
5242 auto sl = std::make_unique< QgsRasterFillSymbolLayer>( path );
5244 return sl.release();
5249 QVariantMap::iterator it =
properties.find( QStringLiteral(
"imageFile" ) );
5253 it.value() = pathResolver.
writePath( it.value().toString() );
5255 it.value() = pathResolver.
readPath( it.value().toString() );
5267 return QStringLiteral(
"RasterFill" );
5283 QPointF
offset = mOffset;
5301 QRectF boundingRect = points.boundingRect();
5302 mBrush.setTransform(
mBrush.transform().translate( boundingRect.left() -
mBrush.transform().dx(),
5303 boundingRect.top() -
mBrush.transform().dy() ) );
5315 applyPattern(
mBrush, mImageFilePath, mWidth, mHeight, mOpacity * context.
opacity(), context );
5326 map[QStringLiteral(
"imageFile" )] = mImageFilePath;
5327 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
static_cast< int >( mCoordinateMode ) );
5328 map[QStringLiteral(
"alpha" )] = QString::number( mOpacity );
5332 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
5334 map[QStringLiteral(
"width" )] = QString::number( mWidth );
5335 map[QStringLiteral(
"height" )] = QString::number( mHeight );
5344 auto sl = std::make_unique< QgsRasterFillSymbolLayer >( mImageFilePath );
5345 sl->setCoordinateMode( mCoordinateMode );
5346 sl->setOpacity( mOpacity );
5347 sl->setOffset( mOffset );
5348 sl->setOffsetUnit( mOffsetUnit );
5349 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
5351 sl->setWidth( mWidth );
5352 sl->setHeight( mHeight );
5353 sl->setSizeUnit( mSizeUnit );
5354 sl->setSizeMapUnitScale( mSizeMapUnitScale );
5358 return sl.release();
5363 return context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
5386 mImageFilePath = imagePath;
5391 mCoordinateMode = mode;
5410 if ( !hasWidthExpression && !hasHeightExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
5416 if ( hasAngleExpression )
5424 if ( !hasWidthExpression && !hasHeightExpression && !hasOpacityExpression && !hasFileExpression )
5429 double width = mWidth;
5430 if ( hasWidthExpression )
5436 if ( hasHeightExpression )
5442 if ( hasOpacityExpression )
5447 QString file = mImageFilePath;
5448 if ( hasFileExpression )
5461void QgsRasterFillSymbolLayer::applyPattern( QBrush &brush,
const QString &imageFilePath,
const double width,
const double height,
const double alpha,
const QgsSymbolRenderContext &context )
5463 double imageWidth = 0;
5464 double imageHeight = 0;
5479 if ( originalSize.isEmpty() )
5482 imageWidth = (
width * originalSize.width() ) / 100.0;
5485 if (
static_cast< int >( imageWidth ) < 1 || 10000.0 < imageWidth )
5498 if ( !originalSize.isValid() )
5501 if ( originalSize.isEmpty() )
5504 imageHeight = (
height * originalSize.height() ) / 100.0;
5507 if (
static_cast< int >( imageHeight ) < 1 || 10000.0 < imageHeight )
5512 if (
width == 0 && imageHeight > 0 )
5514 if ( !originalSize.isValid() )
5517 imageWidth = imageHeight * originalSize.width() / originalSize.height();
5519 else if (
height == 0 && imageWidth > 0 )
5521 if ( !originalSize.isValid() )
5524 imageHeight = imageWidth * originalSize.height() / originalSize.width();
5526 if ( imageWidth == 0 || imageHeight == 0 )
5528 if ( !originalSize.isValid() )
5531 imageWidth = originalSize.width();
5532 imageHeight = originalSize.height();
5540 brush.setTextureImage( img );
5549 : mCountMethod( method )
5550 , mPointCount( pointCount )
5551 , mDensityArea( densityArea )
5562 const int pointCount =
properties.value( QStringLiteral(
"point_count" ), QStringLiteral(
"10" ) ).toInt();
5563 const double densityArea =
properties.value( QStringLiteral(
"density_area" ), QStringLiteral(
"250.0" ) ).toDouble();
5565 unsigned long seed = 0;
5566 if (
properties.contains( QStringLiteral(
"seed" ) ) )
5572 std::random_device rd;
5573 std::mt19937 mt(
seed == 0 ? rd() :
seed );
5574 std::uniform_int_distribution<> uniformDist( 1, 999999999 );
5575 seed = uniformDist( mt );
5580 if (
properties.contains( QStringLiteral(
"density_area_unit" ) ) )
5582 if (
properties.contains( QStringLiteral(
"density_area_unit_scale" ) ) )
5585 if (
properties.contains( QStringLiteral(
"clip_points" ) ) )
5587 sl->setClipPoints(
properties[QStringLiteral(
"clip_points" )].toInt() );
5590 return sl.release();
5595 return QStringLiteral(
"RandomMarkerFill" );
5600 mMarker->setColor(
color );
5606 return mMarker ? mMarker->color() :
mColor;
5623 part.exterior = points;
5625 part.rings = *rings;
5627 if ( mRenderingFeature )
5631 mFeatureSymbolOpacity = context.
opacity();
5632 mCurrentParts << part;
5637 const double prevOpacity = mMarker->opacity();
5638 mMarker->setOpacity( mMarker->opacity() * context.
opacity() );
5641 mMarker->setOpacity( prevOpacity );
5645void QgsRandomMarkerFillSymbolLayer::render(
QgsRenderContext &context,
const QVector<QgsRandomMarkerFillSymbolLayer::Part> &parts,
const QgsFeature &feature,
bool selected )
5654 QVector< QgsGeometry > geometryParts;
5655 geometryParts.reserve( parts.size() );
5658 for (
const Part &part : parts )
5661 if ( !geom.
isNull() && !part.rings.empty() )
5663 QgsPolygon *poly = qgsgeometry_cast< QgsPolygon * >( geom.
get() );
5664 for (
const QPolygonF &ring : part.rings )
5672 geom = geom.
buffer( 0, 0 );
5674 geometryParts << geom;
5678 path.addPolygon( part.exterior );
5679 for (
const QPolygonF &ring : part.rings )
5681 path.addPolygon( ring );
5691 context.
painter()->setClipPath( path );
5695 int count = mPointCount;
5702 switch ( mCountMethod )
5714 count = std::max( 0.0, std::ceil( count * ( geom.
area() /
densityArea ) ) );
5721 unsigned long seed = mSeed;
5732 std::sort( randomPoints.begin(), randomPoints.end(), [](
const QgsPointXY & a,
const QgsPointXY & b )->bool
5734 return a.y() < b.y();
5740 const bool needsExpressionContext = mMarker->hasDataDefinedProperties();
5745 for (
const QgsPointXY &p : std::as_const( randomPoints ) )
5747 if ( needsExpressionContext )
5749 mMarker->renderPoint( QPointF( p.x(), p.y() ), feature.
isValid() ? &feature : nullptr, context, -1, selected );
5763 map.insert( QStringLiteral(
"count_method" ), QString::number(
static_cast< int >( mCountMethod ) ) );
5764 map.insert( QStringLiteral(
"point_count" ), QString::number( mPointCount ) );
5765 map.insert( QStringLiteral(
"density_area" ), QString::number( mDensityArea ) );
5768 map.insert( QStringLiteral(
"seed" ), QString::number( mSeed ) );
5769 map.insert( QStringLiteral(
"clip_points" ), QString::number( mClipPoints ) );
5775 auto res = std::make_unique< QgsRandomMarkerFillSymbolLayer >( mPointCount, mCountMethod, mDensityArea, mSeed );
5778 res->setDensityAreaUnit( mDensityAreaUnit );
5779 res->setDensityAreaUnitScale( mDensityAreaUnitScale );
5780 res->mClipPoints = mClipPoints;
5781 res->setSubSymbol( mMarker->clone() );
5784 return res.release();
5794 return mMarker.get();
5806 mColor = mMarker->color();
5815 attributes.unite( mMarker->usedAttributes( context ) );
5824 if ( mMarker && mMarker->hasDataDefinedProperties() )
5861 return mCountMethod;
5866 mCountMethod = method;
5871 return mDensityArea;
5876 mDensityArea = area;
5883 mRenderingFeature =
true;
5884 mCurrentParts.clear();
5889 mRenderingFeature =
false;
5891 const double prevOpacity = mMarker->opacity();
5892 mMarker->setOpacity( mMarker->opacity() * mFeatureSymbolOpacity );
5894 render( context, mCurrentParts, feature,
false );
5896 mFeatureSymbolOpacity = 1;
5897 mMarker->setOpacity( prevOpacity );
5905 mDensityAreaUnit = unit;
5908 mMarker->setOutputUnit( unit );
5916 return mMarker->outputUnit();
5925 return mMarker->usesMapUnits();
5934 mMarker->setMapUnitScale( scale );
5942 return mMarker->mapUnitScale();
MarkerClipMode
Marker clipping modes.
@ CompletelyWithin
Render complete markers wherever the completely fall within the polygon shape.
@ NoClipping
No clipping, render complete markers.
@ Shape
Clip to polygon shape.
@ CentroidWithin
Render complete markers wherever their centroid falls within the polygon shape.
@ IsSymbolLayerSubSymbol
Symbol is being rendered as a sub-symbol of a QgsSymbolLayer.
LineClipMode
Line clipping modes.
@ NoClipping
Lines are not clipped, will extend to shape's bounding box.
@ ClipPainterOnly
Applying clipping on the painter only (i.e. line endpoints will coincide with polygon bounding box,...
@ ClipToIntersection
Clip lines to intersection with polygon shape (slower) (i.e. line endpoints will coincide with polygo...
GradientColorSource
Gradient color sources.
@ ColorRamp
Gradient color ramp.
@ SimpleTwoColor
Simple two color gradient.
@ CanCalculateMaskGeometryPerFeature
If present, indicates that mask geometry can safely be calculated per feature for the symbol layer....
GradientSpread
Gradient spread options, which control how gradients are rendered outside of their start and end poin...
@ Reflect
Reflect gradient.
@ Pad
Pad out gradient using colors at endpoint of gradient.
@ Png
Export complex styles to separate PNG files for better compatibility with OGC servers.
PointCountMethod
Methods which define the number of points randomly filling a polygon.
@ Absolute
The point count is used as an absolute count of markers.
@ DensityBased
The point count is part of a marker density count.
QFlags< SymbolLayerFlag > SymbolLayerFlags
Symbol layer flags.
RenderUnit
Rendering size units.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size)
@ Unknown
Mixed or unknown units.
@ MetersInMapUnits
Meters value as Map units.
@ RenderingSubSymbol
Set whenever a sub-symbol of a parent symbol is currently being rendered. Can be used during symbol a...
@ RenderSymbolPreview
The render is for a symbol preview only and map based properties may not be available,...
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
@ HighQualityImageTransforms
Enable high quality image transformations, which results in better appearance of scaled or rotated ra...
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
GradientType
Gradient types.
@ Conical
Conical (polar) gradient.
@ Radial
Radial (circular) gradient.
QFlags< SymbolRenderHint > SymbolRenderHints
Symbol render hints.
SymbolCoordinateReference
Symbol coordinate reference modes.
@ Feature
Relative to feature/shape being rendered.
@ Viewport
Relative to the whole viewport/output device.
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.
int valueAsInt(int key, const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an integer.
bool valueAsBool(int key, const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an boolean.
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.
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 QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
A fill symbol layer which renders a marker symbol at the centroid of a polygon geometry.
static QgsSymbolLayer * createFromSld(QDomElement &element)
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
bool canCauseArtifactsBetweenAdjacentTiles() const override
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
bool pointOnSurface() const
QgsMapUnitScale mapUnitScale() const override
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called before the layer will be rendered for a particular feature.
std::unique_ptr< QgsMarkerSymbol > mMarker
QString layerType() const override
Returns a string that represents this layer type.
void setColor(const QColor &color) override
Sets the "representative" color for the symbol layer.
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features.
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
bool setSubSymbol(QgsSymbol *symbol) FINAL
Sets layer's subsymbol. takes ownership of the passed symbol.
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
bool clipPoints() const
Returns true if point markers should be clipped to the polygon boundary.
QgsCentroidFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsCentroidFillSymbolLayer using the specified properties map containing symbol propert...
~QgsCentroidFillSymbolLayer() override
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
double mFeatureSymbolOpacity
QgsCentroidFillSymbolLayer()
QColor color() const override
Returns the "representative" color of the symbol layer.
bool clipOnCurrentPartOnly() const
Returns true if point markers should be clipped to the current part boundary only.
bool mClipOnCurrentPartOnly
Abstract base class for color ramps.
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
virtual QString type() const =0
Returns a string representing the color ramp type.
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.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
double area() const override
Returns the planar, 2-dimensional area of the geometry.
Exports QGIS layers to the DXF format.
static double mapUnitScaleFactor(double scale, Qgis::RenderUnit symbolUnits, Qgis::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
Qgis::DistanceUnit mapUnits() const
Retrieve map units.
double symbologyScale() const
Returns the reference scale for output.
RAII class to pop scope from an expression context on destruction.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool isValid() const
Returns the validity of this feature.
bool isCanceled() const
Tells whether the operation has been canceled already.
static QString uniquePath(const QString &path)
Creates a unique file path name from a desired path by appending _<n> (where <n> is an integer number...
void _renderPolygon(QPainter *p, const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context)
Default method to render polygon.
double angle() const
Returns the rotation angle of the fill symbol, in degrees clockwise.
A geometry is the spatial representation of a feature.
QVector< QgsPointXY > randomPointsInPolygon(int count, const std::function< bool(const QgsPointXY &) > &acceptPoint, unsigned long seed=0, QgsFeedback *feedback=nullptr, int maxTriesPerPoint=0) const
Returns a list of count random points generated inside a (multi)polygon geometry (if acceptPoint is s...
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool contains(const QgsPointXY *p) const
Returns true if the geometry contains the point p.
bool isGeosValid(Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Checks validity of the geometry using GEOS.
double area() const
Returns the planar, 2-dimensional area of the geometry.
QgsGeometry buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries, const QgsGeometryParameters ¶meters=QgsGeometryParameters())
Compute the unary union on a list of geometries.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsColorRamp from a map of properties.
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
void addStopsToGradient(QGradient *gradient, double opacity=1) const
Copy color ramp stops to a QGradient.
A fill symbol layer which draws a smooth color gradient over a polygon.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient fill.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QColor color2() const
Returns the color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoC...
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
bool canCauseArtifactsBetweenAdjacentTiles() const override
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
QgsGradientFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsMapUnitScale mapUnitScale() const override
bool mReferencePoint1IsCentroid
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
Qgis::SymbolCoordinateReference coordinateMode() const
Returns the coordinate mode for gradient, which controls how the gradient stops are positioned.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Qgis::SymbolCoordinateReference mCoordinateMode
QgsGradientFillSymbolLayer(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, const QColor &color2=Qt::white, Qgis::GradientColorSource gradientColorType=Qgis::GradientColorSource::SimpleTwoColor, Qgis::GradientType gradientType=Qgis::GradientType::Linear, Qgis::SymbolCoordinateReference coordinateMode=Qgis::SymbolCoordinateReference::Feature, Qgis::GradientSpread gradientSpread=Qgis::GradientSpread::Pad)
Constructor for QgsGradientFillSymbolLayer.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsGradientFillSymbolLayer using the specified properties map containing symbol propert...
void setMapUnitScale(const QgsMapUnitScale &scale) override
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
Qgis::GradientSpread mGradientSpread
~QgsGradientFillSymbolLayer() override
Qgis::GradientType mGradientType
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QPointF referencePoint1() const
Returns the starting point of gradient fill, in the range [0,0] - [1,1].
Qgis::GradientSpread gradientSpread() const
Returns the gradient spread mode, which controls how the gradient behaves outside of the predefined s...
bool mReferencePoint2IsCentroid
QgsMapUnitScale mOffsetMapUnitScale
Qgis::GradientColorSource gradientColorType() const
Returns the gradient color mode, which controls how gradient color stops are created.
QPointF offset() const
Returns the offset by which polygons will be translated during rendering.
Qgis::GradientColorSource mGradientColorType
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
QString layerType() const override
Returns a string that represents this layer type.
Qgis::RenderUnit mOffsetUnit
Qgis::GradientType gradientType() const
Returns the type of gradient, e.g., linear or radial.
QPointF referencePoint2() const
Returns the end point of gradient fill, in the range [0,0] - [1,1].
std::unique_ptr< QgsColorRamp > mGradientRamp
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false, double targetDpi=96, int frameNumber=-1, bool *isMissing=nullptr)
Returns the specified path rendered as an image.
Base class for fill symbol layers which fill polygons with a repeated image.
QgsMapUnitScale mStrokeWidthMapUnitScale
QgsImageFillSymbolLayer()
Qgis::SymbolCoordinateReference coordinateReference() const
Returns the coordinate reference mode for fill which controls how the top left corner of the image fi...
double mStrokeWidth
Stroke width.
Qgis::SymbolCoordinateReference mCoordinateReference
double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets line width.
QgsMapUnitScale mapUnitScale() const override
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
Qgis::RenderUnit mStrokeWidthUnit
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual void applyDataDefinedSettings(QgsSymbolRenderContext &context)
Applies data defined settings prior to generating the fill symbol brush.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
~QgsImageFillSymbolLayer() override
virtual bool applyBrushTransformFromContext(QgsSymbolRenderContext *context=nullptr) const
Returns true if the image brush should be transformed using the render context's texture origin.
static void multiplyOpacity(QImage &image, double factor, QgsFeedback *feedback=nullptr)
Multiplies opacity of image pixel values by a factor.
static void stackBlur(QImage &image, int radius, bool alphaOnly=false, QgsFeedback *feedback=nullptr)
Performs a stack blur on an image.
A symbol fill consisting of repeated parallel lines.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mapUnitScale() const override
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QString layerType() const override
Returns a string that represents this layer type.
QgsLinePatternFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called before the layer will be rendered for a particular feature.
QColor color() const override
Returns the "representative" color of the symbol layer.
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
double lineWidth() const
Returns the width of the line subsymbol used to render the parallel lines in the fill.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Qgis::LineClipMode clipMode() const
Returns the line clipping mode, which defines how lines are clipped at the edges of shapes.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
void setLineWidth(double w)
Sets the width of the line subsymbol used to render the parallel lines in the fill.
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
Applies data defined settings prior to generating the fill symbol brush.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setColor(const QColor &c) override
Sets the "representative" color for the symbol layer.
QImage toTiledPatternImage() const override
Renders the symbol layer as an image that can be used as a seamless pattern fill for polygons,...
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
QgsLinePatternFillSymbolLayer()
double distance() const
Returns the distance between lines in the fill pattern.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QString ogrFeatureStyleWidth(double widthScaleFactor) const
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
~QgsLinePatternFillSymbolLayer() override
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsLinePatternFillSymbolLayer from a SLD element.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsLinePatternFillSymbolLayer from a properties map.
Line string geometry type, with support for z-dimension and m-values.
static std::unique_ptr< QgsLineString > fromQPolygonF(const QPolygonF &polygon)
Returns a new linestring from a QPolygonF polygon input.
QPolygonF asQPolygonF() const override
Returns a QPolygonF representing the points.
A line symbol type, for rendering LineString and MultiLineString geometries.
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
Struct for storing maximum and minimum scales for measurements in map units.
Line symbol layer type which draws repeating marker symbols along a line feature.
Abstract base class for marker symbol layers.
A marker symbol type, for rendering Point and MultiPoint geometries.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Resolves relative paths into absolute paths and vice versa.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
A fill symbol layer which fills polygon shapes with repeating marker symbols.
QgsMapUnitScale mapUnitScale() const override
QgsMapUnitScale mDisplacementYMapUnitScale
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QgsMapUnitScale mDisplacementXMapUnitScale
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
double distanceX() const
Returns the horizontal distance between rendered markers in the fill.
QgsMapUnitScale mDistanceYMapUnitScale
QImage toTiledPatternImage() const override
Renders the symbol layer as an image that can be used as a seamless pattern fill for polygons,...
double displacementY() const
Returns the vertical displacement for odd numbered columns in the pattern.
void setColor(const QColor &c) override
Sets the "representative" color for the symbol layer.
Qgis::RenderUnit mDistanceXUnit
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called before the layer will be rendered for a particular feature.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsPointPatternFillSymbolLayer using the specified properties map containing symbol pro...
unsigned long seed() const
Returns the random number seed to use when randomly shifting points, or 0 if a truly random sequence ...
Qgis::RenderUnit mDisplacementYUnit
Qgis::MarkerClipMode clipMode() const
Returns the marker clipping mode, which defines how markers are clipped at the edges of shapes.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
double offsetY() const
Returns the vertical offset values for points in the pattern.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
QgsMapUnitScale mDistanceXMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale) override
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QString layerType() const override
Returns a string that represents this layer type.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
Applies data defined settings prior to generating the fill symbol brush.
Qgis::RenderUnit mRandomDeviationXUnit
Qgis::RenderUnit mOffsetXUnit
Qgis::RenderUnit mDistanceYUnit
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale mOffsetXMapUnitScale
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
Qgis::RenderUnit mOffsetYUnit
QColor color() const override
Returns the "representative" color of the symbol layer.
Qgis::RenderUnit mRandomDeviationYUnit
QgsPointPatternFillSymbolLayer()
QgsMapUnitScale mRandomDeviationXMapUnitScale
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
double offsetX() const
Returns the horizontal offset values for points in the pattern.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Qgis::RenderUnit mDisplacementXUnit
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
QgsPointPatternFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsMapUnitScale mRandomDeviationYMapUnitScale
double displacementX() const
Returns the horizontal displacement for odd numbered rows in the pattern.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
~QgsPointPatternFillSymbolLayer() override
QgsMapUnitScale mOffsetYMapUnitScale
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
double distanceY() const
Returns the vertical distance between rendered markers in the fill.
void setClipMode(Qgis::MarkerClipMode mode)
Sets the marker clipping mode, which defines how markers are clipped at the edges of shapes.
static QgsSymbolLayer * createFromSld(QDomElement &element)
bool mMarkerSymbolRenderStarted
Point geometry type, with support for z-dimension and m-values.
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership)
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsPathResolver pathResolver() const
Returns path resolver object with considering whether the project uses absolute or relative paths and...
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const final
Returns the calculated value of the property with the specified key from within the collection.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
static QVariantMap propertyMapToVariantMap(const QMap< QString, QgsProperty > &propertyMap)
Convert a map of QgsProperty to a map of QVariant This is useful to save a map of properties.
static QMap< QString, QgsProperty > variantMapToPropertyMap(const QVariantMap &variantMap)
Convert a map of QVariant to a map of QgsProperty This is useful to restore a map of properties.
A fill symbol layer which places markers at random locations within polygons.
~QgsRandomMarkerFillSymbolLayer() override
int pointCount() const
Returns the count of random points to render in the fill.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called before the layer will be rendered for a particular feature.
QgsRandomMarkerFillSymbolLayer(int pointCount=10, Qgis::PointCountMethod method=Qgis::PointCountMethod::Absolute, double densityArea=250.0, unsigned long seed=0)
Constructor for QgsRandomMarkerFillSymbolLayer, with the specified pointCount.
unsigned long seed() const
Returns the random number seed to use when generating points, or 0 if a truly random sequence will be...
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsRandomMarkerFillSymbolLayer using the specified properties map containing symbol pro...
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
QString layerType() const override
Returns a string that represents this layer type.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsRandomMarkerFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setCountMethod(Qgis::PointCountMethod method)
Sets the count method used to randomly fill the polygon.
bool clipPoints() const
Returns true if point markers should be clipped to the polygon boundary.
bool canCauseArtifactsBetweenAdjacentTiles() const override
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
void setClipPoints(bool clipped)
Sets whether point markers should be clipped to the polygon boundary.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QColor color() const override
Returns the "representative" color of the symbol layer.
void setSeed(unsigned long seed)
Sets the random number seed to use when generating points, or 0 if a truly random sequence will be us...
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void setPointCount(int count)
Sets the count of random points to render in the fill.
Qgis::PointCountMethod countMethod() const
Returns the count method used to randomly fill the polygon.
double densityArea() const
Returns the density area used to count the number of points to randomly fill the polygon.
void setColor(const QColor &color) override
Sets the "representative" color for the symbol layer.
bool setSubSymbol(QgsSymbol *symbol) FINAL
Sets layer's subsymbol. takes ownership of the passed symbol.
void setDensityArea(double area)
Sets the density area used to count the number of points to randomly fill the polygon.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mapUnitScale() const override
A fill symbol layer which fills polygons with a repeated raster image.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
Applies data defined settings prior to generating the fill symbol brush.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
double width() const
Returns the width used for scaling the image used in the fill.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsRasterFillSymbolLayer from a SLD element.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsRasterFillSymbolLayer from a properties map.
QString layerType() const override
Returns a string that represents this layer type.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsRasterFillSymbolLayer(const QString &imageFilePath=QString())
Constructor for QgsRasterFillSymbolLayer, using a raster fill from the specified imageFilePath.
double opacity() const
Returns the opacity for the raster image used in the fill.
~QgsRasterFillSymbolLayer() override
void setOpacity(double opacity)
Sets the opacity for the raster image used in the fill.
QColor color() const override
Returns the "representative" color of the symbol layer.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QString imageFilePath() const
The path to the raster image used for the fill.
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
double height() const
Returns the height used for scaling the image used in the fill.
static void resolvePaths(QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
QPointF offset() const
Returns the offset for the fill.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsRasterFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
bool applyBrushTransformFromContext(QgsSymbolRenderContext *context=nullptr) const override
Returns true if the image brush should be transformed using the render context's texture origin.
void setCoordinateMode(Qgis::SymbolCoordinateReference mode)
Set the coordinate mode for fill.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
QSet< QString > disabledSymbolLayersV2() const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
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.
double rendererScale() const
Returns the renderer map scale.
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
QgsExpressionContext & expressionContext()
Gets the expression context.
void setDisabledSymbolLayersV2(const QSet< QString > &symbolLayers)
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
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.
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
QgsFeedback * feedback() const
Returns the feedback object that can be queried regularly during rendering to check if rendering shou...
QPointF textureOrigin() const
Returns the texture origin, which should be used as a brush transform when rendering using QBrush obj...
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
void setRendererScale(double scale)
Sets the renderer map scale.
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
A fill symbol layer which fills polygons with a repeated SVG file.
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
void setParameters(const QMap< QString, QgsProperty > ¶meters)
Sets the dynamic SVG parameters.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QColor dxfColor(QgsSymbolRenderContext &context) const override
Gets color.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSVGFillSymbolLayer from a SLD element.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Qgis::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
QString layerType() const override
Returns a string that represents this layer type.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
QgsSVGFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QgsSVGFillSymbolLayer(const QString &svgFilePath, double width=20, double rotation=0.0)
Constructor for QgsSVGFillSymbolLayer, using the SVG picture at the specified absolute file path.
void setSvgFilePath(const QString &svgPath)
Sets the path to the SVG file to render in the fill.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsSVGFillSymbolLayer from a properties map.
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
static void resolvePaths(QVariantMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
Qgis::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
~QgsSVGFillSymbolLayer() override
void setMapUnitScale(const QgsMapUnitScale &scale) override
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
Applies data defined settings prior to generating the fill symbol brush.
QgsMapUnitScale mapUnitScale() const override
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Scoped object for saving and restoring a QPainter object's state.
A fill symbol layer which applies a gradient from the outer edges of a symbol to the inside.
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
QgsShapeburstFillSymbolLayer(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, const QColor &color2=Qt::white, Qgis::GradientColorSource colorType=Qgis::GradientColorSource::SimpleTwoColor, int blurRadius=0, bool useWholeShape=true, double maxDistance=5)
Constructor for QgsShapeburstFillSymbolLayer.
QgsShapeburstFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
~QgsShapeburstFillSymbolLayer() override
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsMapUnitScale mapUnitScale() const override
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
bool canCauseArtifactsBetweenAdjacentTiles() const override
Returns true if the symbol layer rendering can cause visible artifacts across a single feature when t...
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsShapeburstFillSymbolLayer using the specified properties map containing symbol prope...
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QPointF offset() const
Returns the offset for the shapeburst fill.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
QString layerType() const override
Returns a string that represents this layer type.
Qgis::GradientColorSource colorType() const
Returns the color mode used for the shapeburst fill.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
Renders polygons using a single fill and stroke color.
QgsSimpleFillSymbolLayer(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, Qt::BrushStyle style=DEFAULT_SIMPLEFILL_STYLE, const QColor &strokeColor=DEFAULT_SIMPLEFILL_BORDERCOLOR, Qt::PenStyle strokeStyle=DEFAULT_SIMPLEFILL_BORDERSTYLE, double strokeWidth=DEFAULT_SIMPLEFILL_BORDERWIDTH, Qt::PenJoinStyle penJoinStyle=DEFAULT_SIMPLEFILL_JOINSTYLE)
double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets line width.
Qt::PenJoinStyle penJoinStyle() const
QColor strokeColor() const override
Returns the stroke color for the symbol layer.
QColor dxfBrushColor(QgsSymbolRenderContext &context) const override
Gets brush/fill color.
bool usesMapUnits() const override
Returns true if the symbol layer has any components which use map unit based sizes.
Qt::BrushStyle dxfBrushStyle() const override
Gets brush/fill style.
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
Qgis::RenderUnit mOffsetUnit
~QgsSimpleFillSymbolLayer() override
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props) const override
Saves the symbol layer as SLD.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
QColor dxfColor(QgsSymbolRenderContext &context) const override
Gets color.
QColor fillColor() const override
Returns the fill color for the symbol layer.
Qt::PenStyle strokeStyle() const
QString layerType() const override
Returns a string that represents this layer type.
double dxfAngle(QgsSymbolRenderContext &context) const override
Gets angle.
void setOutputUnit(Qgis::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mOffsetMapUnitScale
double strokeWidth() const
Qgis::RenderUnit mStrokeWidthUnit
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
QPointF offset() const
Returns the offset by which polygons will be translated during rendering.
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
QgsMapUnitScale mStrokeWidthMapUnitScale
QImage toTiledPatternImage() const override
Renders the symbol layer as an image that can be used as a seamless pattern fill for polygons,...
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Renders the fill symbol layer for the polygon whose outer ring is defined by points,...
QgsSimpleFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qt::PenStyle mStrokeStyle
QgsMapUnitScale mapUnitScale() const override
Qgis::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
Qt::PenJoinStyle mPenJoinStyle
Qt::BrushStyle mBrushStyle
void setMapUnitScale(const QgsMapUnitScale &scale) override
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsSimpleFillSymbolLayer using the specified properties map containing symbol propertie...
static QgsSymbolLayer * createFromSld(QDomElement &element)
Holds SLD export options and other information related to SLD export of a QGIS layer style.
QString exportFilePath() const
Returns the export file path for the SLD.
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
void pushWarning(const QString &warning)
Pushes a warning message generated during the conversion.
Qgis::SldExportOptions exportOptions() const
Returns the export options.
QVariantMap extraProperties() const
Returns the open ended set of properties that can drive/inform the SLD encoding.
QByteArray getImageData(const QString &path, bool blocking=false) const
Gets the SVG content corresponding to the given path.
QPicture svgAsPicture(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool forceVectorOutput=false, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QPicture.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an SVG file contains parameters for fill, stroke color, stroke width.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QImage.
Contains utility functions for working with symbols and symbol layers.
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
static Qgis::MarkerClipMode decodeMarkerClipMode(const QString &string, bool *ok=nullptr)
Decodes a string representing a marker clip mode.
static QString encodePenStyle(Qt::PenStyle style)
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QgsStringMap evaluatePropertiesMap(const QMap< QString, QgsProperty > &propertiesMap, const QgsExpressionContext &context)
Evaluates a map of properties using the given context and returns a variant map with evaluated expres...
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
static QPointF polygonCentroid(const QPolygonF &points)
Calculate the centroid point of a QPolygonF.
static QString encodeBrushStyle(Qt::BrushStyle style)
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &mime, const QColor &color, double size=-1)
static QPointF polygonPointOnSurface(const QPolygonF &points, const QVector< QPolygonF > *rings=nullptr)
Calculate a point on the surface of a QPolygonF.
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a point.
static void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
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 std::unique_ptr< QgsSymbolLayer > createMarkerLayerFromSld(QDomElement &element)
Creates a new marker layer from a SLD DOM element.
static QString ogrFeatureStylePen(double width, double mmScaleFactor, double mapUnitsScaleFactor, const QColor &c, Qt::PenJoinStyle joinStyle=Qt::MiterJoin, Qt::PenCapStyle capStyle=Qt::FlatCap, double offset=0.0, const QVector< qreal > *dashPattern=nullptr)
Create ogr feature style string for pen.
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
static Q_DECL_DEPRECATED void parametricSvgToSld(QDomDocument &doc, QDomElement &graphicElem, const QString &path, const QColor &fillColor, double size, const QColor &strokeColor, double strokeWidth)
Encodes a reference to a parametric SVG into SLD, as a succession of parametric SVG using URL paramet...
static bool lineFromSld(QDomElement &element, Qt::PenStyle &penStyle, QColor &color, double &width, Qt::PenJoinStyle *penJoinStyle=nullptr, Qt::PenCapStyle *penCapStyle=nullptr, QVector< qreal > *customDashPattern=nullptr, double *dashOffset=nullptr)
static std::unique_ptr< QgsSymbolLayer > createLineLayerFromSld(QDomElement &element)
Creates a new line layer from a SLD DOM element.
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
static QString encodeLineClipMode(Qgis::LineClipMode mode)
Encodes a line clip mode to a string.
static Qgis::LineClipMode decodeLineClipMode(const QString &string, bool *ok=nullptr)
Decodes a string representing a line clip mode.
static QPointF pointOnLineWithDistance(QPointF startPoint, QPointF directionPoint, double distance)
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
static QSize tileSize(int width, int height, double &angleRad)
Calculate the minimum size in pixels of a symbol tile given the symbol width and height and the symbo...
static Qt::BrushStyle decodeBrushStyle(const QString &str)
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 svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
static QString encodeColor(const QColor &color)
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
static Q_DECL_DEPRECATED void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, const QColor &color=QColor())
Exports fill details to an SLD element.
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 double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
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 Qgis::SymbolCoordinateReference decodeCoordinateReference(const QString &string, bool *ok=nullptr)
Decodes a string representing a symbol coordinate reference mode.
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.
static QString encodeCoordinateReference(Qgis::SymbolCoordinateReference coordinateReference)
Encodes a symbol coordinate reference mode to a string.
static QString encodeMarkerClipMode(Qgis::MarkerClipMode mode)
Encodes a marker clip mode to a string.
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, QgsSldExportContext &context, double width=-1, const Qt::PenJoinStyle *penJoinStyle=nullptr, const Qt::PenCapStyle *penCapStyle=nullptr, const QVector< qreal > *customDashPattern=nullptr, double dashOffset=0.0)
Abstract base class for symbol layers.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
bool shouldRenderUsingSelectionColor(const QgsSymbolRenderContext &context) const
Returns true if the symbol layer should be rendered using the selection color from the render context...
Qgis::SymbolType type() const
virtual QColor fillColor() const
Returns the fill color for the symbol layer.
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
bool installMasks(QgsRenderContext &context, bool recursive, const QRectF &rect=QRectF())
When rendering, install masks on context painter.
void removeMasks(QgsRenderContext &context, bool recursive)
When rendering, remove previously installed masks from context painter if recursive is true masks are...
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
@ GradientType
Gradient fill type.
@ SecondaryColor
Secondary color (eg for gradient fills)
@ File
Filename, eg for svg files.
@ GradientReference2Y
Gradient reference point 2 y.
@ GradientReference1X
Gradient reference point 1 x.
@ OffsetY
Vertical offset.
@ OffsetX
Horizontal offset.
@ GradientReference1Y
Gradient reference point 1 y.
@ GradientSpread
Gradient spread mode.
@ ShapeburstMaxDistance
Shapeburst fill from edge distance.
@ StrokeStyle
Stroke style (eg solid, dashed)
@ DistanceY
Vertical distance between points.
@ DensityArea
Density area.
@ ClipPoints
Whether markers should be clipped to polygon boundaries.
@ LineClipping
Line clipping mode.
@ ShapeburstIgnoreRings
Shapeburst ignore rings.
@ ShapeburstUseWholeShape
Shapeburst use whole shape.
@ DisplacementX
Horizontal displacement.
@ CoordinateMode
Gradient coordinate mode.
@ FillStyle
Fill style (eg solid, dots)
@ GradientReference2X
Gradient reference point 2 x.
@ StrokeColor
Stroke color.
@ BlurRadius
Shapeburst blur radius.
@ MarkerClipping
Marker clipping mode.
@ RandomSeed
Random number seed.
@ LineAngle
Line angle, or angle of hash lines for hash line symbols.
@ JoinStyle
Line join style.
@ RandomOffsetY
Random offset Y.
@ DisplacementY
Vertical displacement.
@ DistanceX
Horizontal distance between points.
@ GradientReference1IsCentroid
Gradient reference point 1 is centroid.
@ StrokeWidth
Stroke width.
@ GradientReference2IsCentroid
Gradient reference point 2 is centroid.
@ LineDistance
Distance between lines, or length of lines for hash line symbols.
@ RandomOffsetX
Random offset X.
void restoreOldDataDefinedProperties(const QVariantMap &stringMap)
Restores older data defined properties from string map.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
static const bool SELECT_FILL_BORDER
Whether fill styles for selected features also highlight symbol stroke.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual QColor color() const
Returns the "representative" color of the symbol layer.
virtual QColor strokeColor() const
Returns the stroke color for the symbol layer.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another 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.
static const bool SELECT_FILL_STYLE
Whether fill styles for selected features uses symbol layer style.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties.
Encapsulates the context in which a symbol is being rendered.
const QgsFeature * feature() const
Returns the current feature being rendered.
QgsFields fields() const
Fields of the layer.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
bool forceVectorRendering() const
Returns true if symbol must be rendered using vector methods, and optimisations like pre-rendered ima...
qreal opacity() const
Returns the opacity for the symbol.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Abstract base class for all rendered symbols.
QColor color() const
Returns the symbol's color.
Qgis::SymbolType type() const
Returns the symbol's type.
double interval() const
Returns the interval between individual symbols.
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
void setInterval(double interval)
Sets the interval between individual symbols.
Qgis::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
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.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
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
#define DEFAULT_SIMPLEFILL_JOINSTYLE
#define DEFAULT_SIMPLEFILL_COLOR
#define DEFAULT_SIMPLEFILL_STYLE
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
#define QgsDebugError(str)
QList< QgsSymbolLayer * > QgsSymbolLayerList
Single variable definition for use within a QgsExpressionContextScope.