46 #include <QSvgRenderer>
47 #include <QDomDocument>
48 #include <QDomElement>
56 Qt::PenJoinStyle penJoinStyle )
57 : mBrushStyle( style )
58 , mStrokeColor( strokeColor )
59 , mStrokeStyle( strokeStyle )
60 , mStrokeWidth( strokeWidth )
61 , mPenJoinStyle( penJoinStyle )
105 void QgsSimpleFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen )
123 if ( !exprVal.isNull() )
130 penColor.setAlphaF( context.
opacity() * penColor.alphaF() );
131 pen.setColor( penColor );
137 if ( !exprVal.isNull() )
139 double width = exprVal.toDouble( &ok );
143 pen.setWidthF( width );
144 selPen.setWidthF( width );
181 if ( props.contains( QStringLiteral(
"color" ) ) )
183 if ( props.contains( QStringLiteral(
"style" ) ) )
185 if ( props.contains( QStringLiteral(
"color_border" ) ) )
190 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
194 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
199 if ( props.contains( QStringLiteral(
"style_border" ) ) )
204 else if ( props.contains( QStringLiteral(
"outline_style" ) ) )
208 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
212 if ( props.contains( QStringLiteral(
"width_border" ) ) )
215 strokeWidth = props[QStringLiteral(
"width_border" )].toDouble();
217 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
219 strokeWidth = props[QStringLiteral(
"outline_width" )].toDouble();
221 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
223 strokeWidth = props[QStringLiteral(
"line_width" )].toDouble();
225 if ( props.contains( QStringLiteral(
"offset" ) ) )
227 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
232 if ( props.contains( QStringLiteral(
"border_width_unit" ) ) )
236 else if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
240 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
244 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
247 if ( props.contains( QStringLiteral(
"border_width_map_unit_scale" ) ) )
249 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
252 sl->restoreOldDataDefinedProperties( props );
260 return QStringLiteral(
"SimpleFill" );
272 selColor.setAlphaF( context.
opacity() );
329 #ifndef QT_NO_PRINTER
330 if (
mBrush.style() == Qt::SolidPattern ||
mBrush.style() == Qt::NoBrush || !
dynamic_cast<QPrinter *
>( p->device() ) )
337 #ifndef QT_NO_PRINTER
344 p->setPen( Qt::NoPen );
348 p->setBrush( Qt::NoBrush );
366 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
394 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
395 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
396 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
397 element.appendChild( symbolizerElem );
405 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
406 symbolizerElem.appendChild( fillElem );
413 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
414 symbolizerElem.appendChild( strokeElem );
429 symbolStyle.append(
';' );
438 Qt::BrushStyle fillStyle;
442 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
445 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
451 QString uom = element.attribute( QStringLiteral(
"uom" ), QString() );
457 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
466 return penBleed + offsetBleed;
527 : mGradientColorType( colorType )
528 , mGradientType( gradientType )
529 , mCoordinateMode( coordinateMode )
530 , mGradientSpread( spread )
531 , mReferencePoint1( QPointF( 0.5, 0 ) )
532 , mReferencePoint2( QPointF( 0.5, 1 ) )
553 bool refPoint1IsCentroid =
false;
555 bool refPoint2IsCentroid =
false;
560 if ( props.contains( QStringLiteral(
"type" ) ) )
562 if ( props.contains( QStringLiteral(
"coordinate_mode" ) ) )
564 if ( props.contains( QStringLiteral(
"spread" ) ) )
566 if ( props.contains( QStringLiteral(
"color_type" ) ) )
568 if ( props.contains( QStringLiteral(
"gradient_color" ) ) )
573 else if ( props.contains( QStringLiteral(
"color" ) ) )
577 if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
582 if ( props.contains( QStringLiteral(
"reference_point1" ) ) )
584 if ( props.contains( QStringLiteral(
"reference_point1_iscentroid" ) ) )
585 refPoint1IsCentroid = props[QStringLiteral(
"reference_point1_iscentroid" )].toInt();
586 if ( props.contains( QStringLiteral(
"reference_point2" ) ) )
588 if ( props.contains( QStringLiteral(
"reference_point2_iscentroid" ) ) )
589 refPoint2IsCentroid = props[QStringLiteral(
"reference_point2_iscentroid" )].toInt();
590 if ( props.contains( QStringLiteral(
"angle" ) ) )
591 angle = props[QStringLiteral(
"angle" )].toDouble();
593 if ( props.contains( QStringLiteral(
"offset" ) ) )
610 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
612 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
615 sl->setReferencePoint1IsCentroid( refPoint1IsCentroid );
617 sl->setReferencePoint2IsCentroid( refPoint2IsCentroid );
618 sl->setAngle(
angle );
620 sl->setColorRamp( gradientRamp );
622 sl->restoreOldDataDefinedProperties( props );
635 return QStringLiteral(
"GradientFill" );
638 void QgsGradientFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context,
const QPolygonF &points )
683 if ( currentType == QObject::tr(
"linear" ) )
687 else if ( currentType == QObject::tr(
"radial" ) )
691 else if ( currentType == QObject::tr(
"conical" ) )
705 if ( currentCoordMode == QObject::tr(
"feature" ) )
709 else if ( currentCoordMode == QObject::tr(
"viewport" ) )
723 if ( currentSpread == QObject::tr(
"pad" ) )
727 else if ( currentSpread == QObject::tr(
"repeat" ) )
731 else if ( currentSpread == QObject::tr(
"reflect" ) )
778 if ( refPoint1IsCentroid || refPoint2IsCentroid )
783 QRectF bbox = points.boundingRect();
784 double centroidX = (
centroid.
x() - bbox.left() ) / bbox.width();
785 double centroidY = (
centroid.
y() - bbox.top() ) / bbox.height();
787 if ( refPoint1IsCentroid )
789 refPoint1X = centroidX;
790 refPoint1Y = centroidY;
792 if ( refPoint2IsCentroid )
794 refPoint2X = centroidX;
795 refPoint2Y = centroidY;
801 spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ),
angle );
804 QPointF QgsGradientFillSymbolLayer::rotateReferencePoint( QPointF refPoint,
double angle )
809 QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
811 refLine.setAngle( refLine.angle() +
angle );
813 QPointF rotatedReferencePoint = refLine.p2();
815 if ( rotatedReferencePoint.x() > 1 )
816 rotatedReferencePoint.setX( 1 );
817 if ( rotatedReferencePoint.x() < 0 )
818 rotatedReferencePoint.setX( 0 );
819 if ( rotatedReferencePoint.y() > 1 )
820 rotatedReferencePoint.setY( 1 );
821 if ( rotatedReferencePoint.y() < 0 )
822 rotatedReferencePoint.setY( 0 );
824 return rotatedReferencePoint;
831 QPointF referencePoint1, QPointF referencePoint2,
const double angle )
836 QColor fillColor2 =
color2;
837 fillColor2.setAlphaF( context.
opacity() * fillColor2.alphaF() );
848 gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
851 gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
854 gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
860 gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
863 gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
869 gradient.setSpread( QGradient::PadSpread );
872 gradient.setSpread( QGradient::ReflectSpread );
875 gradient.setSpread( QGradient::RepeatSpread );
891 gradient.setColorAt( 1.0, fillColor2 );
895 brush = QBrush( gradient );
902 selColor.setAlphaF( context.
opacity() );
919 applyDataDefinedSymbology( context, points );
922 p->setPen( Qt::NoPen );
955 map[QStringLiteral(
"color_type" )] = QString::number(
static_cast< int >(
mGradientColorType ) );
956 map[QStringLiteral(
"type" )] = QString::number(
static_cast<int>(
mGradientType ) );
957 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
static_cast< int >(
mCoordinateMode ) );
958 map[QStringLiteral(
"spread" )] = QString::number(
static_cast< int >(
mGradientSpread ) );
963 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
969 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1035 int blurRadius,
bool useWholeShape,
double maxDistance )
1036 : mBlurRadius( blurRadius )
1037 , mUseWholeShape( useWholeShape )
1038 , mMaxDistance( maxDistance )
1039 , mColorType( colorType )
1058 if ( props.contains( QStringLiteral(
"color_type" ) ) )
1062 if ( props.contains( QStringLiteral(
"shapeburst_color" ) ) )
1067 else if ( props.contains( QStringLiteral(
"color" ) ) )
1072 if ( props.contains( QStringLiteral(
"shapeburst_color2" ) ) )
1077 else if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
1081 if ( props.contains( QStringLiteral(
"blur_radius" ) ) )
1083 blurRadius = props[QStringLiteral(
"blur_radius" )].toInt();
1085 if ( props.contains( QStringLiteral(
"use_whole_shape" ) ) )
1087 useWholeShape = props[QStringLiteral(
"use_whole_shape" )].toInt();
1089 if ( props.contains( QStringLiteral(
"max_distance" ) ) )
1091 maxDistance = props[QStringLiteral(
"max_distance" )].toDouble();
1093 if ( props.contains( QStringLiteral(
"offset" ) ) )
1112 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1116 if ( props.contains( QStringLiteral(
"distance_unit" ) ) )
1120 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1124 if ( props.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
1128 if ( props.contains( QStringLiteral(
"ignore_rings" ) ) )
1130 sl->setIgnoreRings( props[QStringLiteral(
"ignore_rings" )].toInt() );
1134 sl->setColorRamp( gradientRamp );
1137 sl->restoreOldDataDefinedProperties( props );
1139 return sl.release();
1144 return QStringLiteral(
"ShapeburstFill" );
1149 if ( mGradientRamp.get() == ramp )
1152 mGradientRamp.reset( ramp );
1155 void QgsShapeburstFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QColor &color, QColor &color2,
int &blurRadius,
bool &useWholeShape,
1156 double &maxDistance,
bool &ignoreRings )
1213 selColor.setAlphaF( context.
opacity() );
1214 mSelBrush = QBrush( selColor );
1233 p->setBrush( mSelBrush );
1234 QPointF
offset = mOffset;
1269 int outputPixelMaxDist = 0;
1277 std::unique_ptr< QgsGradientColorRamp > twoColorGradientRamp;
1280 twoColorGradientRamp = std::make_unique< QgsGradientColorRamp >( color1,
color2 );
1284 p->setPen( QPen( Qt::NoPen ) );
1289 int pointsWidth =
static_cast< int >( std::round( points.boundingRect().width() ) );
1290 int pointsHeight =
static_cast< int >( std::round( points.boundingRect().height() ) );
1291 int imWidth = pointsWidth + ( sideBuffer * 2 );
1292 int imHeight = pointsHeight + ( sideBuffer * 2 );
1298 std::unique_ptr< QImage > fillImage = std::make_unique< QImage >( imWidth,
1299 imHeight, QImage::Format_ARGB32_Premultiplied );
1300 if ( fillImage->isNull() )
1310 std::unique_ptr< QImage > alphaImage = std::make_unique< QImage >( fillImage->width(), fillImage->height(), QImage::Format_ARGB32_Premultiplied );
1311 if ( alphaImage->isNull() )
1323 fillImage->fill( Qt::black );
1329 alphaImage->fill( Qt::transparent );
1335 QPainter imgPainter;
1336 imgPainter.begin( alphaImage.get() );
1337 imgPainter.setRenderHint( QPainter::Antialiasing,
true );
1338 imgPainter.setBrush( QBrush( Qt::white ) );
1339 imgPainter.setPen( QPen( Qt::black ) );
1340 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1349 imgPainter.begin( fillImage.get() );
1352 imgPainter.drawImage( 0, 0, *alphaImage );
1359 imgPainter.setBrush( QBrush( Qt::white ) );
1360 imgPainter.setPen( QPen( Qt::black ) );
1361 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1370 double *dtArray = distanceTransform( fillImage.get(), context.
renderContext() );
1390 imgPainter.begin( fillImage.get() );
1391 imgPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
1392 imgPainter.drawImage( 0, 0, *alphaImage );
1400 QPointF
offset = mOffset;
1417 p->drawImage( points.boundingRect().left() - sideBuffer, points.boundingRect().top() - sideBuffer, *fillImage );
1428 void QgsShapeburstFillSymbolLayer::distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d )
1434 for (
int q = 1; q <= n - 1; q++ )
1436 double s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1440 s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1449 for (
int q = 0; q <= n - 1; q++ )
1451 while ( z[k + 1] < q )
1453 d[q] = ( q - v[k] ) * ( q - v[k] ) + f[v[k]];
1458 void QgsShapeburstFillSymbolLayer::distanceTransform2d(
double *im,
int width,
int height,
QgsRenderContext &context )
1460 int maxDimension = std::max( width, height );
1461 double *f =
new double[ maxDimension ];
1462 int *v =
new int[ maxDimension ];
1463 double *z =
new double[ maxDimension + 1 ];
1464 double *d =
new double[ maxDimension ];
1467 for (
int x = 0; x < width; x++ )
1472 for (
int y = 0; y < height; y++ )
1474 f[y] = im[ x + y * width ];
1476 distanceTransform1d( f, height, v, z, d );
1477 for (
int y = 0; y < height; y++ )
1479 im[ x + y * width ] = d[y];
1484 for (
int y = 0; y < height; y++ )
1489 for (
int x = 0; x < width; x++ )
1491 f[x] = im[ x + y * width ];
1493 distanceTransform1d( f, width, v, z, d );
1494 for (
int x = 0; x < width; x++ )
1496 im[ x + y * width ] = d[x];
1507 double *QgsShapeburstFillSymbolLayer::distanceTransform( QImage *im,
QgsRenderContext &context )
1509 int width = im->width();
1510 int height = im->height();
1512 double *dtArray =
new double[width * height];
1517 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1522 const QRgb *scanLine =
reinterpret_cast< const QRgb *
>( im->constScanLine( heightIndex ) );
1523 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1525 tmpRgb = scanLine[widthIndex];
1526 if ( qRed( tmpRgb ) == 0 )
1534 dtArray[ idx ] =
INF;
1541 distanceTransform2d( dtArray, width, height, context );
1546 void QgsShapeburstFillSymbolLayer::dtArrayToQImage(
double *array, QImage *im,
QgsColorRamp *ramp,
QgsRenderContext &context,
bool useWholeShape,
int maxPixelDistance )
1548 int width = im->width();
1549 int height = im->height();
1552 double maxDistanceValue;
1557 double dtMaxValue = array[0];
1558 for (
int i = 1; i < ( width * height ); ++i )
1560 if ( array[i] > dtMaxValue )
1562 dtMaxValue = array[i];
1567 maxDistanceValue = std::sqrt( dtMaxValue );
1572 maxDistanceValue = maxPixelDistance;
1577 double squaredVal = 0;
1580 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1585 QRgb *scanLine =
reinterpret_cast< QRgb *
>( im->scanLine( heightIndex ) );
1586 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1589 squaredVal = array[idx];
1592 if ( maxDistanceValue > 0 )
1594 pixVal = squaredVal > 0 ? std::min( ( std::sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1603 scanLine[widthIndex] = qPremultiply( ramp->
color( pixVal ).rgba() );
1614 map[QStringLiteral(
"color_type" )] = QString::number(
static_cast< int >( mColorType ) );
1615 map[QStringLiteral(
"blur_radius" )] = QString::number( mBlurRadius );
1616 map[QStringLiteral(
"use_whole_shape" )] = QString::number( mUseWholeShape );
1617 map[QStringLiteral(
"max_distance" )] = QString::number( mMaxDistance );
1620 map[QStringLiteral(
"ignore_rings" )] = QString::number( mIgnoreRings );
1624 if ( mGradientRamp )
1626 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
1627 map.unite( mGradientRamp->properties() );
1629 map.insert( mGradientRamp->properties() );
1638 std::unique_ptr< QgsShapeburstFillSymbolLayer > sl = std::make_unique< QgsShapeburstFillSymbolLayer >(
mColor, mColor2, mColorType, mBlurRadius, mUseWholeShape, mMaxDistance );
1639 if ( mGradientRamp )
1641 sl->setColorRamp( mGradientRamp->clone() );
1643 sl->setDistanceUnit( mDistanceUnit );
1644 sl->setDistanceMapUnitScale( mDistanceMapUnitScale );
1645 sl->setIgnoreRings( mIgnoreRings );
1646 sl->setOffset( mOffset );
1647 sl->setOffsetUnit( mOffsetUnit );
1648 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
1651 return sl.release();
1656 double offsetBleed = context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
1667 mDistanceUnit = unit;
1673 if ( mDistanceUnit == mOffsetUnit )
1675 return mDistanceUnit;
1688 mDistanceMapUnitScale = scale;
1689 mOffsetMapUnitScale = scale;
1694 if ( mDistanceMapUnitScale == mOffsetMapUnitScale )
1696 return mDistanceMapUnitScale;
1721 p->setPen( QPen( Qt::NoPen ) );
1723 QTransform bkTransform =
mBrush.transform();
1727 QTransform t =
mBrush.transform();
1728 t.translate( leftCorner.x(), leftCorner.y() );
1729 mBrush.setTransform( t );
1733 QTransform t =
mBrush.transform();
1734 t.translate( 0, 0 );
1735 mBrush.setTransform( t );
1741 p->setBrush( QBrush( selColor ) );
1747 QTransform t =
mBrush.transform();
1749 mBrush.setTransform( t );
1754 mBrush.setTransform( bkTransform );
1790 return Qt::SolidLine;
1794 return Qt::SolidLine;
1798 return mStroke->dxfPenStyle();
1834 , mPatternWidth( width )
1838 mColor = QColor( 255, 255, 255 );
1844 , mPatternWidth( width )
1845 , mSvgData( svgData )
1850 mColor = QColor( 255, 255, 255 );
1851 setDefaultSvgParams();
1859 mPatternWidthUnit = unit;
1860 mSvgStrokeWidthUnit = unit;
1863 mStroke->setOutputUnit( unit );
1869 if ( mPatternWidthUnit != unit || mSvgStrokeWidthUnit != unit ||
mStrokeWidthUnit != unit )
1879 mPatternWidthMapUnitScale = scale;
1880 mSvgStrokeWidthMapUnitScale = scale;
1887 mPatternWidthMapUnitScale == mSvgStrokeWidthMapUnitScale &&
1890 return mPatternWidthMapUnitScale;
1900 mSvgFilePath = svgPath;
1901 setDefaultSvgParams();
1911 if (
properties.contains( QStringLiteral(
"width" ) ) )
1913 width =
properties[QStringLiteral(
"width" )].toDouble();
1915 if (
properties.contains( QStringLiteral(
"svgFile" ) ) )
1919 if (
properties.contains( QStringLiteral(
"angle" ) ) )
1924 std::unique_ptr< QgsSVGFillSymbolLayer > symbolLayer;
1927 symbolLayer = std::make_unique< QgsSVGFillSymbolLayer >(
svgFilePath, width,
angle );
1931 if (
properties.contains( QStringLiteral(
"data" ) ) )
1933 data = QByteArray::fromHex(
properties[QStringLiteral(
"data" )].toString().toLocal8Bit() );
1935 symbolLayer = std::make_unique< QgsSVGFillSymbolLayer >( data, width,
angle );
1939 if (
properties.contains( QStringLiteral(
"svgFillColor" ) ) )
1944 else if (
properties.contains( QStringLiteral(
"color" ) ) )
1948 if (
properties.contains( QStringLiteral(
"svgOutlineColor" ) ) )
1953 else if (
properties.contains( QStringLiteral(
"outline_color" ) ) )
1957 else if (
properties.contains( QStringLiteral(
"line_color" ) ) )
1961 if (
properties.contains( QStringLiteral(
"svgOutlineWidth" ) ) )
1964 symbolLayer->setSvgStrokeWidth(
properties[QStringLiteral(
"svgOutlineWidth" )].toDouble() );
1966 else if (
properties.contains( QStringLiteral(
"outline_width" ) ) )
1968 symbolLayer->setSvgStrokeWidth(
properties[QStringLiteral(
"outline_width" )].toDouble() );
1970 else if (
properties.contains( QStringLiteral(
"line_width" ) ) )
1972 symbolLayer->setSvgStrokeWidth(
properties[QStringLiteral(
"line_width" )].toDouble() );
1976 if (
properties.contains( QStringLiteral(
"pattern_width_unit" ) ) )
1980 if (
properties.contains( QStringLiteral(
"pattern_width_map_unit_scale" ) ) )
1984 if (
properties.contains( QStringLiteral(
"svg_outline_width_unit" ) ) )
1988 if (
properties.contains( QStringLiteral(
"svg_outline_width_map_unit_scale" ) ) )
1992 if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
1996 if (
properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2001 if (
properties.contains( QStringLiteral(
"parameters" ) ) )
2007 symbolLayer->restoreOldDataDefinedProperties(
properties );
2009 return symbolLayer.release();
2014 QVariantMap::iterator it =
properties.find( QStringLiteral(
"svgFile" ) );
2026 return QStringLiteral(
"SVGFill" );
2029 void QgsSVGFillSymbolLayer::applyPattern( QBrush &brush,
const QString &svgFilePath,
double patternWidth,
QgsUnitTypes::RenderUnit patternWidthUnit,
2030 const QColor &svgFillColor,
const QColor &svgStrokeColor,
double svgStrokeWidth,
2034 if ( mSvgViewBox.isNull() )
2041 if (
static_cast< int >( size ) < 1.0 || 10000.0 < size )
2043 brush.setTextureImage( QImage() );
2047 bool fitsInCache =
true;
2055 double hwRatio = 1.0;
2056 if ( patternPict.width() > 0 )
2058 hwRatio =
static_cast< double >( patternPict.height() ) /
static_cast< double >( patternPict.width() );
2060 patternImage = QImage(
static_cast< int >( size ),
static_cast< int >( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
2061 patternImage.fill( 0 );
2063 QPainter p( &patternImage );
2064 p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
2067 QTransform brushTransform;
2070 QImage transparentImage = patternImage.copy();
2072 brush.setTextureImage( transparentImage );
2076 brush.setTextureImage( patternImage );
2078 brush.setTransform( brushTransform );
2086 applyPattern(
mBrush, mSvgFilePath, mPatternWidth, mPatternWidthUnit,
mColor, mSvgStrokeColor, mSvgStrokeWidth, mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale, evaluatedParameters );
2111 for (
auto ringIt = rings->constBegin(); ringIt != rings->constEnd(); ++ringIt )
2122 if ( !mSvgFilePath.isEmpty() )
2124 map.insert( QStringLiteral(
"svgFile" ), mSvgFilePath );
2128 map.insert( QStringLiteral(
"data" ), QString( mSvgData.toHex() ) );
2131 map.insert( QStringLiteral(
"width" ), QString::number( mPatternWidth ) );
2132 map.insert( QStringLiteral(
"angle" ), QString::number(
mAngle ) );
2137 map.insert( QStringLiteral(
"outline_width" ), QString::number( mSvgStrokeWidth ) );
2154 std::unique_ptr< QgsSVGFillSymbolLayer > clonedLayer;
2155 if ( !mSvgFilePath.isEmpty() )
2157 clonedLayer = std::make_unique< QgsSVGFillSymbolLayer >( mSvgFilePath, mPatternWidth,
mAngle );
2158 clonedLayer->setSvgFillColor(
mColor );
2159 clonedLayer->setSvgStrokeColor( mSvgStrokeColor );
2160 clonedLayer->setSvgStrokeWidth( mSvgStrokeWidth );
2164 clonedLayer = std::make_unique< QgsSVGFillSymbolLayer >( mSvgData, mPatternWidth,
mAngle );
2167 clonedLayer->setPatternWidthUnit( mPatternWidthUnit );
2168 clonedLayer->setPatternWidthMapUnitScale( mPatternWidthMapUnitScale );
2169 clonedLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnit );
2170 clonedLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthMapUnitScale );
2174 clonedLayer->setParameters( mParameters );
2178 clonedLayer->setSubSymbol( mStroke->clone() );
2182 return clonedLayer.release();
2187 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2188 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
2189 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
2190 element.appendChild( symbolizerElem );
2194 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2195 symbolizerElem.appendChild( fillElem );
2197 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2198 fillElem.appendChild( graphicFillElem );
2200 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2201 graphicFillElem.appendChild( graphicElem );
2203 if ( !mSvgFilePath.isEmpty() )
2214 symbolizerElem.appendChild( doc.createComment( QStringLiteral(
"SVG from data not implemented yet" ) ) );
2220 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2223 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg(
mAngle );
2236 mStroke->toSld( doc, element, props );
2248 return mStroke.get();
2255 mStroke.reset(
nullptr );
2268 mStroke.reset( lineSymbol );
2278 if ( mStroke && mStroke->symbolLayer( 0 ) )
2280 double subLayerBleed = mStroke->symbolLayer( 0 )->estimateMaxBleed( context );
2281 return subLayerBleed;
2291 return QColor( Qt::black );
2293 return mStroke->color();
2300 attr.unite( mStroke->usedAttributes( context ) );
2308 if ( mStroke && mStroke->hasDataDefinedProperties() )
2315 QString path, mimeType;
2317 Qt::PenStyle penStyle;
2318 double size, strokeWidth;
2320 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2321 if ( fillElem.isNull() )
2324 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2325 if ( graphicFillElem.isNull() )
2328 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2329 if ( graphicElem.isNull() )
2335 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2340 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2349 double d = angleFunc.toDouble( &ok );
2354 std::unique_ptr< QgsSVGFillSymbolLayer > sl = std::make_unique< QgsSVGFillSymbolLayer >( path, size,
angle );
2355 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2358 sl->setSvgStrokeWidth( strokeWidth );
2361 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2362 if ( !strokeElem.isNull() )
2373 return sl.release();
2391 double width = mPatternWidth;
2397 QString svgFile = mSvgFilePath;
2416 double strokeWidth = mSvgStrokeWidth;
2425 mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale, evaluatedParameters );
2429 void QgsSVGFillSymbolLayer::storeViewBox()
2431 if ( !mSvgData.isEmpty() )
2433 QSvgRenderer r( mSvgData );
2436 mSvgViewBox = r.viewBoxF();
2441 mSvgViewBox = QRectF();
2444 void QgsSVGFillSymbolLayer::setDefaultSvgParams()
2446 if ( mSvgFilePath.isEmpty() )
2451 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2452 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2453 QColor defaultFillColor, defaultStrokeColor;
2454 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2456 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2457 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2458 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2459 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2461 double newFillOpacity = hasFillOpacityParam ?
mColor.alphaF() : 1.0;
2462 double newStrokeOpacity = hasStrokeOpacityParam ? mSvgStrokeColor.alphaF() : 1.0;
2464 if ( hasDefaultFillColor )
2466 mColor = defaultFillColor;
2467 mColor.setAlphaF( newFillOpacity );
2469 if ( hasDefaultFillOpacity )
2471 mColor.setAlphaF( defaultFillOpacity );
2473 if ( hasDefaultStrokeColor )
2475 mSvgStrokeColor = defaultStrokeColor;
2476 mSvgStrokeColor.setAlphaF( newStrokeOpacity );
2478 if ( hasDefaultStrokeOpacity )
2480 mSvgStrokeColor.setAlphaF( defaultStrokeOpacity );
2482 if ( hasDefaultStrokeWidth )
2484 mSvgStrokeWidth = defaultStrokeWidth;
2505 mFillLineSymbol->setWidth( w );
2511 mFillLineSymbol->setColor(
c );
2517 return mFillLineSymbol ? mFillLineSymbol->color() :
mColor;
2529 mFillLineSymbol.reset( qgis::down_cast<QgsLineSymbol *>( symbol ) );
2538 return mFillLineSymbol.get();
2544 if ( mFillLineSymbol )
2545 attr.unite( mFillLineSymbol->usedAttributes( context ) );
2553 if ( mFillLineSymbol && mFillLineSymbol->hasDataDefinedProperties() )
2576 mDistanceUnit = unit;
2577 mLineWidthUnit = unit;
2601 mDistanceMapUnitScale = scale;
2602 mLineWidthMapUnitScale = scale;
2603 mOffsetMapUnitScale = scale;
2609 mDistanceMapUnitScale == mLineWidthMapUnitScale &&
2610 mLineWidthMapUnitScale == mOffsetMapUnitScale )
2612 return mDistanceMapUnitScale;
2619 std::unique_ptr< QgsLinePatternFillSymbolLayer > patternLayer = std::make_unique< QgsLinePatternFillSymbolLayer >();
2625 QColor
color( Qt::black );
2628 if (
properties.contains( QStringLiteral(
"lineangle" ) ) )
2633 else if (
properties.contains( QStringLiteral(
"angle" ) ) )
2637 patternLayer->setLineAngle(
lineAngle );
2639 if (
properties.contains( QStringLiteral(
"distance" ) ) )
2643 patternLayer->setDistance(
distance );
2645 if (
properties.contains( QStringLiteral(
"linewidth" ) ) )
2650 else if (
properties.contains( QStringLiteral(
"outline_width" ) ) )
2654 else if (
properties.contains( QStringLiteral(
"line_width" ) ) )
2658 patternLayer->setLineWidth(
lineWidth );
2660 if (
properties.contains( QStringLiteral(
"color" ) ) )
2664 else if (
properties.contains( QStringLiteral(
"outline_color" ) ) )
2668 else if (
properties.contains( QStringLiteral(
"line_color" ) ) )
2672 patternLayer->setColor(
color );
2674 if (
properties.contains( QStringLiteral(
"offset" ) ) )
2678 patternLayer->setOffset(
offset );
2681 if (
properties.contains( QStringLiteral(
"distance_unit" ) ) )
2685 if (
properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
2689 if (
properties.contains( QStringLiteral(
"line_width_unit" ) ) )
2693 else if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2697 if (
properties.contains( QStringLiteral(
"line_width_map_unit_scale" ) ) )
2701 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
2705 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2709 if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2713 if (
properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2717 if (
properties.contains( QStringLiteral(
"coordinate_reference" ) ) )
2721 if (
properties.contains( QStringLiteral(
"clip_mode" ) ) )
2726 patternLayer->restoreOldDataDefinedProperties(
properties );
2728 return patternLayer.release();
2733 return QStringLiteral(
"LinePatternFill" );
2736 void QgsLinePatternFillSymbolLayer::applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double lineAngle,
double distance )
2738 mBrush.setTextureImage( QImage() );
2740 if ( !mFillLineSymbol )
2745 std::unique_ptr< QgsLineSymbol > fillLineSymbol( mFillLineSymbol->clone() );
2746 if ( !fillLineSymbol )
2762 outputPixelOffset = std::fmod( outputPixelOffset, outputPixelDist );
2763 if ( outputPixelOffset > outputPixelDist / 2.0 )
2764 outputPixelOffset -= outputPixelDist;
2768 double outputPixelBleed = 0;
2769 double outputPixelInterval = 0;
2770 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2774 outputPixelBleed = std::max( outputPixelBleed, outputPixelLayerBleed );
2777 if ( markerLineLayer )
2786 outputPixelInterval = std::max( outputPixelInterval, outputPixelLayerInterval );
2790 if ( outputPixelInterval > 0 )
2794 double intervalScale = std::round( outputPixelInterval ) / outputPixelInterval;
2795 outputPixelInterval = std::round( outputPixelInterval );
2797 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2802 if ( markerLineLayer )
2816 height = outputPixelDist;
2817 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2821 width = outputPixelDist;
2822 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2826 height = outputPixelDist / std::cos(
lineAngle * M_PI / 180 );
2827 width = outputPixelDist / std::sin(
lineAngle * M_PI / 180 );
2830 lineAngle = 180 * std::atan2(
static_cast< double >( height ),
static_cast< double >( width ) ) / M_PI;
2836 height = std::abs( height );
2837 width = std::abs( width );
2839 outputPixelDist = std::abs( height * std::cos(
lineAngle * M_PI / 180 ) );
2843 int offsetHeight =
static_cast< int >( std::round( outputPixelOffset / std::cos(
lineAngle * M_PI / 180 ) ) );
2844 outputPixelOffset = offsetHeight * std::cos(
lineAngle * M_PI / 180 );
2853 int bufferMulti =
static_cast< int >( std::max( std::ceil( outputPixelBleed / width ), std::ceil( outputPixelBleed / width ) ) );
2857 bufferMulti = std::max( bufferMulti, 1 );
2859 int xBuffer = width * bufferMulti;
2860 int yBuffer = height * bufferMulti;
2861 int innerWidth = width;
2862 int innerHeight = height;
2863 width += 2 * xBuffer;
2864 height += 2 * yBuffer;
2867 if ( width > 10000 || height > 10000 || width == 0 || height == 0 )
2872 QImage patternImage( width, height, QImage::Format_ARGB32 );
2873 patternImage.fill( 0 );
2875 QPointF p1, p2, p3, p4, p5, p6;
2878 p1 = QPointF( 0, yBuffer );
2879 p2 = QPointF( width, yBuffer );
2880 p3 = QPointF( 0, yBuffer + innerHeight );
2881 p4 = QPointF( width, yBuffer + innerHeight );
2885 p1 = QPointF( xBuffer, height );
2886 p2 = QPointF( xBuffer, 0 );
2887 p3 = QPointF( xBuffer + innerWidth, height );
2888 p4 = QPointF( xBuffer + innerWidth, 0 );
2892 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2893 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2894 p1 = QPointF( 0, height );
2895 p2 = QPointF( width, 0 );
2896 p3 = QPointF( -dx, height - dy );
2897 p4 = QPointF( width - dx, -dy );
2898 p5 = QPointF( dx, height + dy );
2899 p6 = QPointF( width + dx, dy );
2903 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2904 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2905 p1 = QPointF( width, 0 );
2906 p2 = QPointF( 0, height );
2907 p3 = QPointF( width - dx, -dy );
2908 p4 = QPointF( -dx, height - dy );
2909 p5 = QPointF( width + dx, dy );
2910 p6 = QPointF( dx, height + dy );
2914 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2915 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2916 p1 = QPointF( 0, 0 );
2917 p2 = QPointF( width, height );
2918 p5 = QPointF( dx, -dy );
2919 p6 = QPointF( width + dx, height - dy );
2920 p3 = QPointF( -dx, dy );
2921 p4 = QPointF( width - dx, height + dy );
2925 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2926 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2927 p1 = QPointF( width, height );
2928 p2 = QPointF( 0, 0 );
2929 p5 = QPointF( width + dx, height - dy );
2930 p6 = QPointF( dx, -dy );
2931 p3 = QPointF( width - dx, height + dy );
2932 p4 = QPointF( -dx, dy );
2939 p3 = QPointF( tempPt.x(), tempPt.y() );
2941 p4 = QPointF( tempPt.x(), tempPt.y() );
2943 p5 = QPointF( tempPt.x(), tempPt.y() );
2945 p6 = QPointF( tempPt.x(), tempPt.y() );
2949 p1 = QPointF( tempPt.x(), tempPt.y() );
2951 p2 = QPointF( tempPt.x(), tempPt.y() );
2954 QPainter p( &patternImage );
2958 p.setRenderHint( QPainter::Antialiasing,
false );
2959 QPen pen( QColor( Qt::black ) );
2960 pen.setWidthF( 0.1 );
2961 pen.setCapStyle( Qt::FlatCap );
2966 QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 );
2967 p.drawPolygon( polygon );
2969 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 );
2970 p.drawPolygon( polygon );
2976 p.setRenderHint( QPainter::Antialiasing,
true );
2988 fillLineSymbol->startRender( lineRenderContext, context.
fields() );
2990 QVector<QPolygonF> polygons;
2991 polygons.append( QPolygonF() << p1 << p2 );
2992 polygons.append( QPolygonF() << p3 << p4 );
2995 polygons.append( QPolygonF() << p5 << p6 );
2998 for (
const QPolygonF &polygon : std::as_const( polygons ) )
3000 fillLineSymbol->renderPolyline( polygon, context.
feature(), lineRenderContext, -1, context.
selected() );
3003 fillLineSymbol->stopRender( lineRenderContext );
3007 patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
3012 QImage transparentImage = patternImage.copy();
3014 brush.setTextureImage( transparentImage );
3018 brush.setTextureImage( patternImage );
3021 QTransform brushTransform;
3022 brush.setTransform( brushTransform );
3030 || mFillLineSymbol->hasDataDefinedProperties()
3034 if ( mRenderUsingLines )
3036 if ( mFillLineSymbol )
3042 applyPattern( context,
mBrush, mLineAngle, mDistance );
3048 if ( mRenderUsingLines && mFillLineSymbol )
3056 if ( !mRenderUsingLines )
3090 outputPixelOffset = std::fmod( outputPixelOffset, outputPixelDistance );
3091 if ( outputPixelOffset > outputPixelDistance / 2.0 )
3092 outputPixelOffset -= outputPixelDistance;
3094 p->setPen( QPen( Qt::NoPen ) );
3099 p->setBrush( QBrush( selColor ) );
3123 std::unique_ptr< QgsPolygon > shapePolygon;
3124 std::unique_ptr< QgsGeometryEngine > shapeEngine;
3132 shapePolygon = std::make_unique< QgsPolygon >();
3136 for (
const QPolygonF &ring : *rings )
3142 shapeEngine->prepareGeometry();
3149 path.addPolygon( points );
3152 for (
const QPolygonF &ring : *rings )
3154 path.addPolygon( ring );
3157 p->setClipPath( path, Qt::IntersectClip );
3163 const QRectF boundingRect = points.boundingRect();
3165 QTransform invertedRotateTransform;
3171 QTransform transform;
3172 if ( applyBrushTransform )
3175 transform.translate( -boundingRect.center().x(),
3176 -boundingRect.center().y() );
3178 transform.translate( boundingRect.center().x(),
3179 boundingRect.center().y() );
3187 const QRectF transformedBounds = transform.map( points ).boundingRect();
3191 left = transformedBounds.left() - buffer * 2;
3192 top = transformedBounds.top() - buffer * 2;
3193 right = transformedBounds.right() + buffer * 2;
3194 bottom = transformedBounds.bottom() + buffer * 2;
3195 invertedRotateTransform = transform.inverted();
3197 if ( !applyBrushTransform )
3199 top -= transformedBounds.top() - ( outputPixelDistance * std::floor( transformedBounds.top() / outputPixelDistance ) );
3204 const bool needsExpressionContext = mFillLineSymbol->hasDataDefinedProperties();
3209 int currentLine = 0;
3210 for (
double currentY = top; currentY <= bottom; currentY += outputPixelDistance )
3215 if ( needsExpressionContext )
3219 double y1 = currentY;
3221 double y2 = currentY;
3222 invertedRotateTransform.map( left, currentY - outputPixelOffset, &x1, &y1 );
3223 invertedRotateTransform.map( right, currentY - outputPixelOffset, &x2, &y2 );
3228 std::unique_ptr< QgsAbstractGeometry > intersection( shapeEngine->intersection( &ls ) );
3229 for (
auto it = intersection->const_parts_begin(); it != intersection->const_parts_end(); ++it )
3231 if (
const QgsLineString *ls = qgsgeometry_cast< const QgsLineString * >( *it ) )
3239 mFillLineSymbol->renderPolyline( QPolygonF() << QPointF( x1, y1 ) << QPointF( x2, y2 ), context.
feature(), context.
renderContext() );
3251 map.insert( QStringLiteral(
"angle" ), QString::number( mLineAngle ) );
3252 map.insert( QStringLiteral(
"distance" ), QString::number( mDistance ) );
3253 map.insert( QStringLiteral(
"line_width" ), QString::number( mLineWidth ) );
3255 map.insert( QStringLiteral(
"offset" ), QString::number( mOffset ) );
3271 if ( mFillLineSymbol )
3282 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
3283 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
3284 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
3285 element.appendChild( symbolizerElem );
3290 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
3291 symbolizerElem.appendChild( fillElem );
3293 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
3294 fillElem.appendChild( graphicFillElem );
3296 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
3297 graphicFillElem.appendChild( graphicElem );
3300 QColor lineColor = mFillLineSymbol ? mFillLineSymbol->color() : QColor();
3301 double lineWidth = mFillLineSymbol ? mFillLineSymbol->width() : 0.0;
3309 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
3312 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toString() ).arg( mLineAngle );
3316 angleFunc = QString::number(
angle + mLineAngle );
3321 QPointF lineOffset( std::sin( mLineAngle ) * mOffset, std::cos( mLineAngle ) * mOffset );
3328 QString featureStyle;
3329 featureStyle.append(
"Brush(" );
3330 featureStyle.append( QStringLiteral(
"fc:%1" ).arg(
mColor.name() ) );
3331 featureStyle.append( QStringLiteral(
",bc:%1" ).arg( QLatin1String(
"#00000000" ) ) );
3332 featureStyle.append(
",id:\"ogr-brush-2\"" );
3333 featureStyle.append( QStringLiteral(
",a:%1" ).arg( mLineAngle ) );
3334 featureStyle.append( QStringLiteral(
",s:%1" ).arg( mLineWidth * widthScaleFactor ) );
3335 featureStyle.append(
",dx:0mm" );
3336 featureStyle.append( QStringLiteral(
",dy:%1mm" ).arg( mDistance * widthScaleFactor ) );
3337 featureStyle.append(
')' );
3338 return featureStyle;
3344 && ( !mFillLineSymbol || !mFillLineSymbol->hasDataDefinedProperties() ) )
3369 Qt::PenStyle lineStyle;
3371 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
3372 if ( fillElem.isNull() )
3375 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
3376 if ( graphicFillElem.isNull() )
3379 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
3380 if ( graphicElem.isNull() )
3386 if ( name != QLatin1String(
"horline" ) )
3394 double d = angleFunc.toDouble( &ok );
3403 offset = std::sqrt( std::pow( vectOffset.x(), 2 ) + std::pow( vectOffset.y(), 2 ) );
3406 QString uom = element.attribute( QStringLiteral(
"uom" ) );
3410 std::unique_ptr< QgsLinePatternFillSymbolLayer > sl = std::make_unique< QgsLinePatternFillSymbolLayer >();
3411 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
3412 sl->setColor( lineColor );
3414 sl->setLineAngle(
angle );
3416 sl->setDistance( size );
3419 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
3420 if ( !strokeElem.isNull() )
3431 return sl.release();
3531 std::unique_ptr< QgsPointPatternFillSymbolLayer > layer = std::make_unique< QgsPointPatternFillSymbolLayer >();
3532 if (
properties.contains( QStringLiteral(
"distance_x" ) ) )
3534 layer->setDistanceX(
properties[QStringLiteral(
"distance_x" )].toDouble() );
3536 if (
properties.contains( QStringLiteral(
"distance_y" ) ) )
3538 layer->setDistanceY(
properties[QStringLiteral(
"distance_y" )].toDouble() );
3540 if (
properties.contains( QStringLiteral(
"displacement_x" ) ) )
3542 layer->setDisplacementX(
properties[QStringLiteral(
"displacement_x" )].toDouble() );
3544 if (
properties.contains( QStringLiteral(
"displacement_y" ) ) )
3546 layer->setDisplacementY(
properties[QStringLiteral(
"displacement_y" )].toDouble() );
3548 if (
properties.contains( QStringLiteral(
"offset_x" ) ) )
3550 layer->setOffsetX(
properties[QStringLiteral(
"offset_x" )].toDouble() );
3552 if (
properties.contains( QStringLiteral(
"offset_y" ) ) )
3554 layer->setOffsetY(
properties[QStringLiteral(
"offset_y" )].toDouble() );
3557 if (
properties.contains( QStringLiteral(
"distance_x_unit" ) ) )
3561 if (
properties.contains( QStringLiteral(
"distance_x_map_unit_scale" ) ) )
3565 if (
properties.contains( QStringLiteral(
"distance_y_unit" ) ) )
3569 if (
properties.contains( QStringLiteral(
"distance_y_map_unit_scale" ) ) )
3573 if (
properties.contains( QStringLiteral(
"displacement_x_unit" ) ) )
3577 if (
properties.contains( QStringLiteral(
"displacement_x_map_unit_scale" ) ) )
3581 if (
properties.contains( QStringLiteral(
"displacement_y_unit" ) ) )
3585 if (
properties.contains( QStringLiteral(
"displacement_y_map_unit_scale" ) ) )
3589 if (
properties.contains( QStringLiteral(
"offset_x_unit" ) ) )
3593 if (
properties.contains( QStringLiteral(
"offset_x_map_unit_scale" ) ) )
3597 if (
properties.contains( QStringLiteral(
"offset_y_unit" ) ) )
3601 if (
properties.contains( QStringLiteral(
"offset_y_map_unit_scale" ) ) )
3606 if (
properties.contains( QStringLiteral(
"random_deviation_x" ) ) )
3608 layer->setMaximumRandomDeviationX(
properties[QStringLiteral(
"random_deviation_x" )].toDouble() );
3610 if (
properties.contains( QStringLiteral(
"random_deviation_y" ) ) )
3612 layer->setMaximumRandomDeviationY(
properties[QStringLiteral(
"random_deviation_y" )].toDouble() );
3614 if (
properties.contains( QStringLiteral(
"random_deviation_x_unit" ) ) )
3618 if (
properties.contains( QStringLiteral(
"random_deviation_x_map_unit_scale" ) ) )
3622 if (
properties.contains( QStringLiteral(
"random_deviation_y_unit" ) ) )
3626 if (
properties.contains( QStringLiteral(
"random_deviation_y_map_unit_scale" ) ) )
3630 unsigned long seed = 0;
3631 if (
properties.contains( QStringLiteral(
"seed" ) ) )
3637 std::random_device rd;
3638 std::mt19937 mt(
seed == 0 ? rd() :
seed );
3639 std::uniform_int_distribution<> uniformDist( 1, 999999999 );
3640 seed = uniformDist( mt );
3642 layer->setSeed(
seed );
3644 if (
properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
3648 if (
properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3652 if (
properties.contains( QStringLiteral(
"clip_mode" ) ) )
3656 if (
properties.contains( QStringLiteral(
"coordinate_reference" ) ) )
3661 if (
properties.contains( QStringLiteral(
"angle" ) ) )
3663 layer->setAngle(
properties[QStringLiteral(
"angle" )].toDouble() );
3666 layer->restoreOldDataDefinedProperties(
properties );
3668 return layer.release();
3673 return QStringLiteral(
"PointPatternFill" );
3676 void QgsPointPatternFillSymbolLayer::applyPattern(
const QgsSymbolRenderContext &context, QBrush &brush,
double distanceX,
double distanceY,
3677 double displacementX,
double displacementY,
double offsetX,
double offsetY )
3684 double widthOffset = std::fmod(
3687 double heightOffset = std::fmod(
3691 if ( width > 10000 || height > 10000 )
3694 brush.setTextureImage( img );
3698 QImage patternImage( width, height, QImage::Format_ARGB32 );
3699 patternImage.fill( 0 );
3700 if ( patternImage.isNull() )
3702 brush.setTextureImage( QImage() );
3707 QPainter p( &patternImage );
3725 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3727 for (
double currentY = -height; currentY <= height * 2.0; currentY += height )
3729 mMarkerSymbol->renderPoint( QPointF( currentX + widthOffset, currentY + heightOffset ), context.
feature(), pointRenderContext );
3740 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3742 for (
double currentY = -height / 2.0; currentY <= height * 2.0; currentY += height )
3744 mMarkerSymbol->renderPoint( QPointF( currentX + widthOffset + displacementPixelX, currentY + heightOffset ), context.
feature(), pointRenderContext );
3748 for (
double currentX = -width / 2.0; currentX <= width * 2.0; currentX += width )
3750 for (
double currentY = -height; currentY <= height * 2.0; currentY += height / 2.0 )
3752 mMarkerSymbol->renderPoint( QPointF( currentX + widthOffset + ( std::fmod( currentY, height ) != 0 ? displacementPixelX : 0 ), currentY + heightOffset - displacementPixelY ), context.
feature(), pointRenderContext );
3761 QImage transparentImage = patternImage.copy();
3763 brush.setTextureImage( transparentImage );
3767 brush.setTextureImage( patternImage );
3769 QTransform brushTransform;
3770 brush.setTransform( brushTransform );
3788 if ( mRenderUsingMarkers )
3801 if ( mRenderUsingMarkers )
3823 if ( !mRenderUsingMarkers )
3866 const double widthOffset = std::fmod(
3878 const double heightOffset = std::fmod(
3904 p->setPen( QPen( Qt::NoPen ) );
3909 p->setBrush( QBrush( selColor ) );
3933 std::unique_ptr< QgsPolygon > shapePolygon;
3934 std::unique_ptr< QgsGeometryEngine > shapeEngine;
3941 shapePolygon = std::make_unique< QgsPolygon >();
3945 for (
const QPolygonF &ring : *rings )
3951 shapeEngine->prepareGeometry();
3958 path.addPolygon( points );
3961 for (
const QPolygonF &ring : *rings )
3963 path.addPolygon( ring );
3966 p->setClipPath( path, Qt::IntersectClip );
3972 const QRectF boundingRect = points.boundingRect();
3974 QTransform invertedRotateTransform;
3982 QTransform transform;
3983 if ( applyBrushTransform )
3986 transform.translate( -boundingRect.center().x(),
3987 -boundingRect.center().y() );
3988 transform.rotate( -
angle );
3989 transform.translate( boundingRect.center().x(),
3990 boundingRect.center().y() );
3995 transform.rotate( -
angle );
3998 const QRectF transformedBounds = transform.map( points ).boundingRect();
3999 left = transformedBounds.left() - 2 * width;
4000 top = transformedBounds.top() - 2 * height;
4001 right = transformedBounds.right() + 2 * width;
4002 bottom = transformedBounds.bottom() + 2 * height;
4003 invertedRotateTransform = transform.inverted();
4005 if ( !applyBrushTransform )
4007 left -= transformedBounds.left() - ( width * std::floor( transformedBounds.left() / width ) );
4008 top -= transformedBounds.top() - ( height * std::floor( transformedBounds.top() / height ) );
4013 left = boundingRect.left() - 2 * width;
4014 top = boundingRect.top() - 2 * height;
4015 right = boundingRect.right() + 2 * width;
4016 bottom = boundingRect.bottom() + 2 * height;
4018 if ( !applyBrushTransform )
4020 left -= boundingRect.left() - ( width * std::floor( boundingRect.left() / width ) );
4021 top -= boundingRect.top() - ( height * std::floor( boundingRect.top() / height ) );
4050 std::random_device rd;
4051 std::mt19937 mt(
seed == 0 ? rd() :
seed );
4052 std::uniform_real_distribution<> uniformDist( 0, 1 );
4058 const bool needsExpressionContext =
mMarkerSymbol->hasDataDefinedProperties();
4063 bool alternateColumn =
false;
4064 int currentCol = -3;
4065 for (
double currentX = left; currentX <= right; currentX += width, alternateColumn = !alternateColumn )
4070 if ( needsExpressionContext )
4073 bool alternateRow =
false;
4074 const double columnX = currentX + widthOffset;
4075 int currentRow = -3;
4076 for (
double currentY = top; currentY <= bottom; currentY += height, alternateRow = !alternateRow )
4081 double y = currentY + heightOffset;
4084 x += displacementPixelX;
4086 if ( !alternateColumn )
4087 y -= displacementPixelY;
4093 invertedRotateTransform.map( xx, yy, &x, &y );
4096 if ( useRandomShift )
4098 x += ( 2 * uniformDist( mt ) - 1 ) * maxRandomDeviationPixelX;
4099 y += ( 2 * uniformDist( mt ) - 1 ) * maxRandomDeviationPixelY;
4102 if ( needsExpressionContext )
4110 bool renderPoint =
true;
4118 renderPoint = shapeEngine->intersects( &p );
4128 renderPoint = shapeEngine->contains( markerBounds.
constGet() );
4130 renderPoint = shapeEngine->intersects( markerBounds.
constGet() );
4154 map.insert( QStringLiteral(
"distance_x" ), QString::number(
mDistanceX ) );
4155 map.insert( QStringLiteral(
"distance_y" ), QString::number(
mDistanceY ) );
4156 map.insert( QStringLiteral(
"displacement_x" ), QString::number(
mDisplacementX ) );
4157 map.insert( QStringLiteral(
"displacement_y" ), QString::number(
mDisplacementY ) );
4158 map.insert( QStringLiteral(
"offset_x" ), QString::number(
mOffsetX ) );
4159 map.insert( QStringLiteral(
"offset_y" ), QString::number(
mOffsetY ) );
4175 map.insert( QStringLiteral(
"random_deviation_x" ), QString::number(
mRandomDeviationX ) );
4176 map.insert( QStringLiteral(
"random_deviation_y" ), QString::number(
mRandomDeviationY ) );
4181 map.insert( QStringLiteral(
"seed" ), QString::number(
mSeed ) );
4182 map.insert( QStringLiteral(
"angle" ),
mAngle );
4201 for (
int i = 0; i <
mMarkerSymbol->symbolLayerCount(); i++ )
4203 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
4204 if ( !props.value( QStringLiteral(
"uom" ), QString() ).toString().isEmpty() )
4205 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ).toString() );
4206 element.appendChild( symbolizerElem );
4211 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
4212 symbolizerElem.appendChild( fillElem );
4214 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
4215 fillElem.appendChild( graphicFillElem );
4222 symbolizerElem.appendChild( distanceElem );
4227 markerLayer->writeSldMarker( doc, graphicFillElem, props );
4231 QString errorMsg = QStringLiteral(
"QgsMarkerSymbolLayer expected, %1 found. Skip it." ).arg( layer->
layerType() );
4232 graphicFillElem.appendChild( doc.createComment( errorMsg ) );
4236 QString errorMsg = QStringLiteral(
"Missing point pattern symbol layer. Skip it." );
4237 graphicFillElem.appendChild( doc.createComment( errorMsg ) );
4327 attributes.unite(
mMarkerSymbol->usedAttributes( context ) );
4365 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = std::make_unique< QgsCentroidFillSymbolLayer >();
4367 if (
properties.contains( QStringLiteral(
"point_on_surface" ) ) )
4368 sl->setPointOnSurface(
properties[QStringLiteral(
"point_on_surface" )].toInt() != 0 );
4369 if (
properties.contains( QStringLiteral(
"point_on_all_parts" ) ) )
4370 sl->setPointOnAllParts(
properties[QStringLiteral(
"point_on_all_parts" )].toInt() != 0 );
4371 if (
properties.contains( QStringLiteral(
"clip_points" ) ) )
4372 sl->setClipPoints(
properties[QStringLiteral(
"clip_points" )].toInt() != 0 );
4373 if (
properties.contains( QStringLiteral(
"clip_on_current_part_only" ) ) )
4374 sl->setClipOnCurrentPartOnly(
properties[QStringLiteral(
"clip_on_current_part_only" )].toInt() != 0 );
4376 sl->restoreOldDataDefinedProperties(
properties );
4378 return sl.release();
4383 return QStringLiteral(
"CentroidFill" );
4410 part.exterior = points;
4412 part.rings = *rings;
4419 mCurrentParts << part;
4424 const double prevOpacity =
mMarker->opacity();
4427 mMarker->setOpacity( prevOpacity );
4434 mCurrentParts.clear();
4441 const double prevOpacity =
mMarker->opacity();
4444 render( context, mCurrentParts, feature,
false );
4446 mMarker->setOpacity( prevOpacity );
4449 void QgsCentroidFillSymbolLayer::render(
QgsRenderContext &context,
const QVector<QgsCentroidFillSymbolLayer::Part> &parts,
const QgsFeature &feature,
bool selected )
4458 QVector< QgsGeometry > geometryParts;
4459 geometryParts.reserve( parts.size() );
4460 QPainterPath globalPath;
4463 int maxAreaPartIdx = 0;
4465 for (
int i = 0; i < parts.size(); i++ )
4467 const Part part = parts[i];
4470 if ( !geom.
isNull() && !part.rings.empty() )
4472 QgsPolygon *poly = qgsgeometry_cast< QgsPolygon * >( geom.
get() );
4476 int area = poly->
area();
4478 if ( area > maxArea )
4488 globalPath.addPolygon( part.exterior );
4489 for (
const QPolygonF &ring : part.rings )
4491 globalPath.addPolygon( ring );
4496 for (
int i = 0; i < parts.size(); i++ )
4501 const Part part = parts[i];
4509 path.addPolygon( part.exterior );
4510 for (
const QPolygonF &ring : part.rings )
4512 path.addPolygon( ring );
4521 context.
painter()->setClipPath( path );
4541 map[QStringLiteral(
"point_on_surface" )] = QString::number(
mPointOnSurface );
4542 map[QStringLiteral(
"point_on_all_parts" )] = QString::number(
mPointOnAllParts );
4543 map[QStringLiteral(
"clip_points" )] = QString::number(
mClipPoints );
4550 std::unique_ptr< QgsCentroidFillSymbolLayer > x = std::make_unique< QgsCentroidFillSymbolLayer >();
4553 x->setSubSymbol(
mMarker->clone() );
4568 mMarker->toSld( doc, element, props );
4579 std::unique_ptr< QgsMarkerSymbol > marker(
new QgsMarkerSymbol( layers ) );
4581 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = std::make_unique< QgsCentroidFillSymbolLayer >();
4582 sl->setSubSymbol( marker.release() );
4583 sl->setPointOnAllParts(
false );
4584 return sl.release();
4611 attributes.unite(
mMarker->usedAttributes( context ) );
4634 mMarker->setOutputUnit( unit );
4651 return mMarker->usesMapUnits();
4660 mMarker->setMapUnitScale( scale );
4668 return mMarker->mapUnitScale();
4678 , mImageFilePath( imageFilePath )
4695 if (
properties.contains( QStringLiteral(
"imageFile" ) ) )
4697 imagePath =
properties[QStringLiteral(
"imageFile" )].toString();
4699 if (
properties.contains( QStringLiteral(
"coordinate_mode" ) ) )
4703 if (
properties.contains( QStringLiteral(
"alpha" ) ) )
4705 alpha =
properties[QStringLiteral(
"alpha" )].toDouble();
4707 if (
properties.contains( QStringLiteral(
"offset" ) ) )
4711 if (
properties.contains( QStringLiteral(
"angle" ) ) )
4715 if (
properties.contains( QStringLiteral(
"width" ) ) )
4719 std::unique_ptr< QgsRasterFillSymbolLayer > symbolLayer = std::make_unique< QgsRasterFillSymbolLayer >( imagePath );
4720 symbolLayer->setCoordinateMode( mode );
4721 symbolLayer->setOpacity( alpha );
4722 symbolLayer->setOffset(
offset );
4723 symbolLayer->setAngle(
angle );
4724 symbolLayer->setWidth(
width );
4725 if (
properties.contains( QStringLiteral(
"offset_unit" ) ) )
4729 if (
properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
4733 if (
properties.contains( QStringLiteral(
"width_unit" ) ) )
4737 if (
properties.contains( QStringLiteral(
"width_map_unit_scale" ) ) )
4742 symbolLayer->restoreOldDataDefinedProperties(
properties );
4744 return symbolLayer.release();
4749 QVariantMap::iterator it =
properties.find( QStringLiteral(
"imageFile" ) );
4753 it.value() = pathResolver.
writePath( it.value().toString() );
4755 it.value() = pathResolver.
readPath( it.value().toString() );
4767 return QStringLiteral(
"RasterFill" );
4778 QPointF
offset = mOffset;
4796 QRectF boundingRect = points.boundingRect();
4797 mBrush.setTransform(
mBrush.transform().translate( boundingRect.left() -
mBrush.transform().dx(),
4798 boundingRect.top() -
mBrush.transform().dy() ) );
4810 applyPattern(
mBrush, mImageFilePath, mWidth, mOpacity * context.
opacity(), context );
4821 map[QStringLiteral(
"imageFile" )] = mImageFilePath;
4822 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
static_cast< int >( mCoordinateMode ) );
4823 map[QStringLiteral(
"alpha" )] = QString::number( mOpacity );
4827 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
4828 map[QStringLiteral(
"width" )] = QString::number( mWidth );
4836 std::unique_ptr< QgsRasterFillSymbolLayer > sl = std::make_unique< QgsRasterFillSymbolLayer >( mImageFilePath );
4837 sl->setCoordinateMode( mCoordinateMode );
4838 sl->setOpacity( mOpacity );
4839 sl->setOffset( mOffset );
4840 sl->setOffsetUnit( mOffsetUnit );
4841 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
4843 sl->setWidth( mWidth );
4844 sl->setWidthUnit( mWidthUnit );
4845 sl->setWidthMapUnitScale( mWidthMapUnitScale );
4848 return sl.release();
4853 return context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
4869 mImageFilePath = imagePath;
4874 mCoordinateMode = mode;
4892 if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
4898 if ( hasAngleExpression )
4906 if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
4911 double width = mWidth;
4912 if ( hasWidthExpression )
4918 if ( hasOpacityExpression )
4923 QString file = mImageFilePath;
4924 if ( hasFileExpression )
4937 void QgsRasterFillSymbolLayer::applyPattern( QBrush &brush,
const QString &imageFilePath,
const double width,
const double alpha,
const QgsSymbolRenderContext &context )
4950 if ( size.isEmpty() )
4953 size.setWidth( (
width * size.width() ) / 100.0 );
4956 if (
static_cast< int >( size.width() ) < 1 || 10000.0 < size.width() )
4960 size.setHeight( 0 );
4968 brush.setTextureImage( img );
4977 : mCountMethod( method )
4978 , mPointCount( pointCount )
4979 , mDensityArea( densityArea )
4990 const int pointCount =
properties.value( QStringLiteral(
"point_count" ), QStringLiteral(
"10" ) ).toInt();
4991 const double densityArea =
properties.value( QStringLiteral(
"density_area" ), QStringLiteral(
"250.0" ) ).toDouble();
4993 unsigned long seed = 0;
4994 if (
properties.contains( QStringLiteral(
"seed" ) ) )
5000 std::random_device rd;
5001 std::mt19937 mt(
seed == 0 ? rd() :
seed );
5002 std::uniform_int_distribution<> uniformDist( 1, 999999999 );
5003 seed = uniformDist( mt );
5008 if (
properties.contains( QStringLiteral(
"density_area_unit" ) ) )
5010 if (
properties.contains( QStringLiteral(
"density_area_unit_scale" ) ) )
5013 if (
properties.contains( QStringLiteral(
"clip_points" ) ) )
5015 sl->setClipPoints(
properties[QStringLiteral(
"clip_points" )].toInt() );
5018 return sl.release();
5023 return QStringLiteral(
"RandomMarkerFill" );
5028 mMarker->setColor(
color );
5034 return mMarker ? mMarker->color() :
mColor;
5050 part.exterior = points;
5052 part.rings = *rings;
5054 if ( mRenderingFeature )
5058 mFeatureSymbolOpacity = context.
opacity();
5059 mCurrentParts << part;
5064 const double prevOpacity = mMarker->opacity();
5065 mMarker->setOpacity( mMarker->opacity() * context.
opacity() );
5067 mMarker->setOpacity( prevOpacity );
5071 void QgsRandomMarkerFillSymbolLayer::render(
QgsRenderContext &context,
const QVector<QgsRandomMarkerFillSymbolLayer::Part> &parts,
const QgsFeature &feature,
bool selected )
5080 QVector< QgsGeometry > geometryParts;
5081 geometryParts.reserve( parts.size() );
5084 for (
const Part &part : parts )
5087 if ( !geom.
isNull() && !part.rings.empty() )
5089 QgsPolygon *poly = qgsgeometry_cast< QgsPolygon * >( geom.
get() );
5090 for (
const QPolygonF &ring : part.rings )
5097 geom = geom.
buffer( 0, 0 );
5099 geometryParts << geom;
5103 path.addPolygon( part.exterior );
5104 for (
const QPolygonF &ring : part.rings )
5106 path.addPolygon( ring );
5116 context.
painter()->setClipPath( path );
5120 int count = mPointCount;
5127 switch ( mCountMethod )
5129 case Qgis::PointCountMethod::DensityBased:
5139 count = std::max( 0.0, std::ceil( count * ( geom.
area() /
densityArea ) ) );
5142 case Qgis::PointCountMethod::Absolute:
5146 unsigned long seed = mSeed;
5157 std::sort( randomPoints.begin(), randomPoints.end(), [](
const QgsPointXY & a,
const QgsPointXY & b )->bool
5159 return a.y() < b.y();
5165 const bool needsExpressionContext = mMarker->hasDataDefinedProperties();
5170 for (
const QgsPointXY &p : std::as_const( randomPoints ) )
5172 if ( needsExpressionContext )
5174 mMarker->renderPoint( QPointF( p.x(), p.y() ), feature.
isValid() ? &feature :
nullptr, context, -1, selected );
5188 map.insert( QStringLiteral(
"count_method" ), QString::number(
static_cast< int >( mCountMethod ) ) );
5189 map.insert( QStringLiteral(
"point_count" ), QString::number( mPointCount ) );
5190 map.insert( QStringLiteral(
"density_area" ), QString::number( mDensityArea ) );
5193 map.insert( QStringLiteral(
"seed" ), QString::number( mSeed ) );
5194 map.insert( QStringLiteral(
"clip_points" ), QString::number( mClipPoints ) );
5200 std::unique_ptr< QgsRandomMarkerFillSymbolLayer > res = std::make_unique< QgsRandomMarkerFillSymbolLayer >( mPointCount, mCountMethod, mDensityArea, mSeed );
5203 res->setDensityAreaUnit( mDensityAreaUnit );
5204 res->setDensityAreaUnitScale( mDensityAreaUnitScale );
5205 res->mClipPoints = mClipPoints;
5206 res->setSubSymbol( mMarker->clone() );
5209 return res.release();
5219 return mMarker.get();
5231 mColor = mMarker->color();
5240 attributes.unite( mMarker->usedAttributes( context ) );
5249 if ( mMarker && mMarker->hasDataDefinedProperties() )
5286 return mCountMethod;
5291 mCountMethod = method;
5296 return mDensityArea;
5301 mDensityArea = area;
5306 mRenderingFeature =
true;
5307 mCurrentParts.clear();
5312 mRenderingFeature =
false;
5314 const double prevOpacity = mMarker->opacity();
5315 mMarker->setOpacity( mMarker->opacity() * mFeatureSymbolOpacity );
5317 render( context, mCurrentParts, feature,
false );
5319 mFeatureSymbolOpacity = 1;
5320 mMarker->setOpacity( prevOpacity );
5328 mMarker->setOutputUnit( unit );
5336 return mMarker->outputUnit();
5345 return mMarker->usesMapUnits();
5354 mMarker->setMapUnitScale( scale );
5362 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.
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.
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.
PointCountMethod
Methods which define the number of points randomly filling a polygon.
@ RenderingSubSymbol
Set whenever a sub-symbol of a parent symbol is currently being rendered. Can be used during symbol a...
@ 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.
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...
static QgsSymbolLayer * createFromSld(QDomElement &element)
void setOutputUnit(QgsUnitTypes::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.
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.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
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.
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context) override
Called after the layer has been rendered for a particular feature.
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.
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...
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
~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 QVariantMap properties() const =0
Returns a string map containing all the color ramp's properties.
virtual QString type() const =0
Returns a string representing the color ramp type.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
double area() const override SIP_HOLDGIL
Returns the planar, 2-dimensional area of the geometry.
Exports QGIS layers to the DXF format.
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
QgsUnitTypes::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 SIP_HOLDGIL
Tells whether the operation has been canceled already.
void _renderPolygon(QPainter *p, const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context)
Default method to render polygon.
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...
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries)
Compute the unary union on a list of geometries.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
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.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified 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...
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.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient fill.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit mOffsetUnit
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
QgsColorRamp * mGradientRamp
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
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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.
QString layerType() const override
Returns a string that represents this layer type.
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].
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, bool *isMissing=nullptr)
Returns the specified path rendered as an image.
Base class for polygon renderers generating texture images.
QgsMapUnitScale mStrokeWidthMapUnitScale
QgsImageFillSymbolLayer()
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mapUnitScale() const override
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
void setMapUnitScale(const QgsMapUnitScale &scale) override
virtual void applyDataDefinedSettings(QgsSymbolRenderContext &context)
Applies data defined settings prior to generating the fill symbol brush.
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,...
QgsUnitTypes::RenderUnit mStrokeWidthUnit
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.
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.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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.
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 setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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.
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.
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.
QPolygonF asQPolygonF() const override
Returns a QPolygonF representing the points.
static QgsLineString * fromQPolygonF(const QPolygonF &polygon)
Returns a new linestring from a QPolygonF polygon input.
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)
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
QgsUnitTypes::RenderUnit mRandomDeviationYUnit
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,...
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
double distanceX() const
Returns the horizontal distance between rendered markers in the fill.
QgsMapUnitScale mDistanceYMapUnitScale
QgsUnitTypes::RenderUnit mDisplacementXUnit
double displacementY() const
Returns the vertical displacement for odd numbered columns in the pattern.
QgsUnitTypes::RenderUnit mDistanceYUnit
void setColor(const QColor &c) override
Sets the "representative" color for the symbol layer.
QgsUnitTypes::RenderUnit mOffsetXUnit
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::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.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit mRandomDeviationXUnit
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.
QColor color() const override
Returns the "representative" color of the symbol layer.
QgsPointPatternFillSymbolLayer()
QgsMapUnitScale mRandomDeviationXMapUnitScale
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.
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
QgsUnitTypes::RenderUnit mDistanceXUnit
QgsUnitTypes::RenderUnit mOffsetYUnit
double displacementX() const
Returns the horizontal displacement for odd numbered rows in the pattern.
double angle() const
Returns the rotation angle of the pattern, in degrees clockwise.
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.
QgsUnitTypes::RenderUnit mDisplacementYUnit
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)
A class to represent a 2D point.
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)
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection.
bool isActive(int key) const override
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,...
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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.
void setMapUnitScale(const QgsMapUnitScale &scale) override
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
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.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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.
void setDensityArea(double area)
Sets the density area used to count the number of points to randomly fill the polygon.
QgsMapUnitScale mapUnitScale() const override
A class for filling symbols 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 ...
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 * 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.
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.
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.
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
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.
QPainter * painter()
Returns the destination QPainter for the render operation.
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
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...
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 class for filling symbols 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,...
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
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.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
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.
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.
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
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
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
Scoped object for saving and restoring a QPainter object's state.
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 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...
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.
QString layerType() const override
Returns a string that represents this layer type.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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 ...
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
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.
QgsUnitTypes::RenderUnit mOffsetUnit
~QgsSimpleFillSymbolLayer() override
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 ...
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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.
QgsMapUnitScale mOffsetMapUnitScale
double strokeWidth() const
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
QgsMapUnitScale mStrokeWidthMapUnitScale
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.
QPointF offset()
Returns the offset by which polygons will be translated during rendering.
Qt::PenStyle mStrokeStyle
QgsMapUnitScale mapUnitScale() const override
Qt::PenJoinStyle mPenJoinStyle
Qt::BrushStyle mBrushStyle
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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)
QgsUnitTypes::RenderUnit mStrokeWidthUnit
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.
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 QColor decodeColor(const QString &str)
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 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 double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QVariantMap &props)
Rescales the given size based on the uomScale found in the props, if any is found,...
static void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
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 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 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 Qt::BrushStyle decodeBrushStyle(const QString &str)
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=nullptr, const Qt::PenCapStyle *penCapStyle=nullptr, const QVector< qreal > *customDashPattern=nullptr, double dashOffset=0.0)
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
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 void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, const QColor &color=QColor())
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
static double estimateMaxSymbolBleed(QgsSymbol *symbol, const QgsRenderContext &context)
Returns the maximum estimated bleed for the symbol.
static void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
static Qt::PenStyle decodePenStyle(const QString &str)
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
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 QgsSymbolLayer * createMarkerLayerFromSld(QDomElement &element)
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
static QgsSymbolLayer * createLineLayerFromSld(QDomElement &element)
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.
@ PropertyGradientReference1X
Gradient reference point 1 x.
@ PropertyShapeburstIgnoreRings
Shapeburst ignore rings.
@ PropertyGradientReference2X
Gradient reference point 2 x.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
@ PropertyDistanceX
Horizontal distance between points.
@ PropertyFile
Filename, eg for svg files.
@ PropertyGradientType
Gradient fill type.
@ PropertyAngle
Symbol angle.
@ PropertyLineClipping
Line clipping mode (since QGIS 3.24)
@ PropertyDistanceY
Vertical distance between points.
@ PropertyDisplacementX
Horizontal displacement.
@ PropertyGradientSpread
Gradient spread mode.
@ PropertyOffsetY
Vertical offset.
@ PropertyGradientReference1Y
Gradient reference point 1 y.
@ PropertyLineDistance
Distance between lines, or length of lines for hash line symbols.
@ PropertyBlurRadius
Shapeburst blur radius.
@ PropertyGradientReference2Y
Gradient reference point 2 y.
@ PropertyMarkerClipping
Marker clipping mode (since QGIS 3.24)
@ PropertyDensityArea
Density area.
@ PropertyGradientReference1IsCentroid
Gradient reference point 1 is centroid.
@ PropertyShapeburstUseWholeShape
Shapeburst use whole shape.
@ PropertyOffsetX
Horizontal offset.
@ PropertyJoinStyle
Line join style.
@ PropertyOpacity
Opacity.
@ PropertySecondaryColor
Secondary color (eg for gradient fills)
@ PropertyCoordinateMode
Gradient coordinate mode.
@ PropertyRandomOffsetY
Random offset Y (since QGIS 3.24)
@ PropertyLineAngle
Line angle, or angle of hash lines for hash line symbols.
@ PropertyShapeburstMaxDistance
Shapeburst fill from edge distance.
@ PropertyOffset
Symbol offset.
@ PropertyStrokeWidth
Stroke width.
@ PropertyFillColor
Fill color.
@ PropertyClipPoints
Whether markers should be clipped to polygon boundaries.
@ PropertyPointCount
Point count.
@ PropertyRandomSeed
Random number seed.
@ PropertyRandomOffsetX
Random offset X (since QGIS 3.24)
@ PropertyFillStyle
Fill style (eg solid, dots)
@ PropertyDisplacementY
Vertical displacement.
@ PropertyStrokeColor
Stroke color.
@ PropertyGradientReference2IsCentroid
Gradient reference point 2 is centroid.
@ PropertyWidth
Symbol width.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
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.
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.
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.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
QgsPropertyCollection mDataDefinedProperties
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.
QgsFields fields() const
Fields of the layer.
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
const QgsFeature * feature() const
Returns the current feature being rendered.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
qreal opacity() const
Returns the opacity for the symbol.
Abstract base class for all rendered symbols.
Qgis::SymbolType type() const
Returns the symbol's type.
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
double interval() const
Returns the interval between individual symbols.
void setInterval(double interval)
Sets the interval between individual symbols.
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
RenderUnit
Rendering size units.
@ RenderUnknownUnit
Mixed or unknown units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
@ RenderMapUnits
Map units.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
CORE_EXPORT QgsMeshVertex centroid(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns the centroid of the face.
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
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
QList< QgsSymbolLayer * > QgsSymbolLayerList
Single variable definition for use within a QgsExpressionContextScope.