37 #include <QSvgRenderer> 38 #include <QDomDocument> 39 #include <QDomElement> 42 Qt::PenJoinStyle penJoinStyle )
43 : mBrushStyle( style )
44 , mStrokeColor( strokeColor )
45 , mStrokeStyle( strokeStyle )
46 , mStrokeWidth( strokeWidth )
47 , mPenJoinStyle( penJoinStyle )
83 void QgsSimpleFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen )
99 if ( exprVal.isValid() )
111 double width = exprVal.toDouble( &ok );
115 pen.setWidthF( width );
116 selPen.setWidthF( width );
152 if ( props.contains( QStringLiteral(
"color" ) ) )
154 if ( props.contains( QStringLiteral(
"style" ) ) )
156 if ( props.contains( QStringLiteral(
"color_border" ) ) )
161 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
165 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
170 if ( props.contains( QStringLiteral(
"style_border" ) ) )
175 else if ( props.contains( QStringLiteral(
"outline_style" ) ) )
179 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
183 if ( props.contains( QStringLiteral(
"width_border" ) ) )
186 strokeWidth = props[QStringLiteral(
"width_border" )].toDouble();
188 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
190 strokeWidth = props[QStringLiteral(
"outline_width" )].toDouble();
192 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
194 strokeWidth = props[QStringLiteral(
"line_width" )].toDouble();
196 if ( props.contains( QStringLiteral(
"offset" ) ) )
198 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
202 sl->setOffset( offset );
203 if ( props.contains( QStringLiteral(
"border_width_unit" ) ) )
207 else if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
211 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
215 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
218 if ( props.contains( QStringLiteral(
"border_width_map_unit_scale" ) ) )
220 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
223 sl->restoreOldDataDefinedProperties( props );
231 return QStringLiteral(
"SimpleFill" );
251 mPen = QPen( strokeColor );
281 p->translate( offset );
288 p->translate( -offset );
299 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
327 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
328 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
329 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
330 element.appendChild( symbolizerElem );
338 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
339 symbolizerElem.appendChild( fillElem );
346 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
347 symbolizerElem.appendChild( strokeElem );
362 symbolStyle.append(
';' );
371 Qt::BrushStyle fillStyle;
375 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
378 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
384 QString uom = element.attribute( QStringLiteral(
"uom" ), QString() );
390 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
391 sl->setOffset( offset );
399 return penBleed + offsetBleed;
460 : mGradientColorType( colorType )
461 , mGradientType( gradientType )
462 , mCoordinateMode( coordinateMode )
463 , mGradientSpread( spread )
464 , mReferencePoint1( QPointF( 0.5, 0 ) )
465 , mReferencePoint2( QPointF( 0.5, 1 ) )
486 bool refPoint1IsCentroid =
false;
488 bool refPoint2IsCentroid =
false;
493 if ( props.contains( QStringLiteral(
"type" ) ) )
494 type = static_cast< GradientType >( props[QStringLiteral(
"type" )].toInt() );
495 if ( props.contains( QStringLiteral(
"coordinate_mode" ) ) )
496 coordinateMode = static_cast< GradientCoordinateMode >( props[QStringLiteral(
"coordinate_mode" )].toInt() );
497 if ( props.contains( QStringLiteral(
"spread" ) ) )
498 gradientSpread = static_cast< GradientSpread >( props[QStringLiteral(
"spread" )].toInt() );
499 if ( props.contains( QStringLiteral(
"color_type" ) ) )
500 colorType = static_cast< GradientColorType >( props[QStringLiteral(
"color_type" )].toInt() );
501 if ( props.contains( QStringLiteral(
"gradient_color" ) ) )
506 else if ( props.contains( QStringLiteral(
"color" ) ) )
510 if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
515 if ( props.contains( QStringLiteral(
"reference_point1" ) ) )
517 if ( props.contains( QStringLiteral(
"reference_point1_iscentroid" ) ) )
518 refPoint1IsCentroid = props[QStringLiteral(
"reference_point1_iscentroid" )].toInt();
519 if ( props.contains( QStringLiteral(
"reference_point2" ) ) )
521 if ( props.contains( QStringLiteral(
"reference_point2_iscentroid" ) ) )
522 refPoint2IsCentroid = props[QStringLiteral(
"reference_point2_iscentroid" )].toInt();
523 if ( props.contains( QStringLiteral(
"angle" ) ) )
524 angle = props[QStringLiteral(
"angle" )].toDouble();
526 if ( props.contains( QStringLiteral(
"offset" ) ) )
531 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
542 sl->setOffset( offset );
543 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
545 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
547 sl->setReferencePoint1( referencePoint1 );
548 sl->setReferencePoint1IsCentroid( refPoint1IsCentroid );
549 sl->setReferencePoint2( referencePoint2 );
550 sl->setReferencePoint2IsCentroid( refPoint2IsCentroid );
551 sl->setAngle( angle );
553 sl->setColorRamp( gradientRamp );
555 sl->restoreOldDataDefinedProperties( props );
568 return QStringLiteral(
"GradientFill" );
571 void QgsGradientFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context,
const QPolygonF &points )
614 if ( currentType == QObject::tr(
"linear" ) )
618 else if ( currentType == QObject::tr(
"radial" ) )
622 else if ( currentType == QObject::tr(
"conical" ) )
636 if ( currentCoordMode == QObject::tr(
"feature" ) )
640 else if ( currentCoordMode == QObject::tr(
"viewport" ) )
654 if ( currentSpread == QObject::tr(
"pad" ) )
658 else if ( currentSpread == QObject::tr(
"repeat" ) )
662 else if ( currentSpread == QObject::tr(
"reflect" ) )
709 if ( refPoint1IsCentroid || refPoint2IsCentroid )
714 QRectF bbox = points.boundingRect();
715 double centroidX = ( centroid.x() - bbox.left() ) / bbox.width();
716 double centroidY = ( centroid.y() - bbox.top() ) / bbox.height();
718 if ( refPoint1IsCentroid )
720 refPoint1X = centroidX;
721 refPoint1Y = centroidY;
723 if ( refPoint2IsCentroid )
725 refPoint2X = centroidX;
726 refPoint2Y = centroidY;
732 spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ), angle );
735 QPointF QgsGradientFillSymbolLayer::rotateReferencePoint( QPointF refPoint,
double angle )
740 QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
742 refLine.setAngle( refLine.angle() +
angle );
744 QPointF rotatedReferencePoint = refLine.p2();
746 if ( rotatedReferencePoint.x() > 1 )
747 rotatedReferencePoint.setX( 1 );
748 if ( rotatedReferencePoint.x() < 0 )
749 rotatedReferencePoint.setX( 0 );
750 if ( rotatedReferencePoint.y() > 1 )
751 rotatedReferencePoint.setY( 1 );
752 if ( rotatedReferencePoint.y() < 0 )
753 rotatedReferencePoint.setY( 0 );
755 return rotatedReferencePoint;
766 fillColor.setAlphaF( context.
opacity() * fillColor.alphaF() );
767 QColor fillColor2 =
color2;
768 fillColor2.setAlphaF( context.
opacity() * fillColor2.alphaF() );
779 gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
782 gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
785 gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
791 gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
794 gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
800 gradient.setSpread( QGradient::PadSpread );
803 gradient.setSpread( QGradient::ReflectSpread );
806 gradient.setSpread( QGradient::RepeatSpread );
812 ( gradientRamp->
type() == QLatin1String(
"gradient" ) || gradientRamp->
type() == QLatin1String(
"cpt-city" ) ) )
821 gradient.setColorAt( 0.0, fillColor );
822 gradient.setColorAt( 1.0, fillColor2 );
826 brush = QBrush( gradient );
833 selColor.setAlphaF( context.
opacity() );
850 applyDataDefinedSymbology( context, points );
853 p->setPen( Qt::NoPen );
860 p->translate( offset );
867 p->translate( -offset );
877 map[QStringLiteral(
"type" )] = QString::number(
mGradientType );
878 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
mCoordinateMode );
884 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
942 int blurRadius,
bool useWholeShape,
double maxDistance )
943 : mBlurRadius( blurRadius )
944 , mUseWholeShape( useWholeShape )
945 , mMaxDistance( maxDistance )
946 , mColorType( colorType )
965 if ( props.contains( QStringLiteral(
"color_type" ) ) )
967 colorType =
static_cast< ShapeburstColorType >( props[QStringLiteral(
"color_type" )].toInt() );
969 if ( props.contains( QStringLiteral(
"shapeburst_color" ) ) )
974 else if ( props.contains( QStringLiteral(
"color" ) ) )
979 if ( props.contains( QStringLiteral(
"shapeburst_color2" ) ) )
984 else if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
988 if ( props.contains( QStringLiteral(
"blur_radius" ) ) )
990 blurRadius = props[QStringLiteral(
"blur_radius" )].toInt();
992 if ( props.contains( QStringLiteral(
"use_whole_shape" ) ) )
994 useWholeShape = props[QStringLiteral(
"use_whole_shape" )].toInt();
996 if ( props.contains( QStringLiteral(
"max_distance" ) ) )
998 maxDistance = props[QStringLiteral(
"max_distance" )].toDouble();
1000 if ( props.contains( QStringLiteral(
"offset" ) ) )
1007 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
1018 sl->setOffset( offset );
1019 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1023 if ( props.contains( QStringLiteral(
"distance_unit" ) ) )
1027 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1031 if ( props.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
1035 if ( props.contains( QStringLiteral(
"ignore_rings" ) ) )
1037 sl->setIgnoreRings( props[QStringLiteral(
"ignore_rings" )].toInt() );
1041 sl->setColorRamp( gradientRamp );
1044 sl->restoreOldDataDefinedProperties( props );
1046 return sl.release();
1051 return QStringLiteral(
"ShapeburstFill" );
1056 if ( mGradientRamp.get() == ramp )
1059 mGradientRamp.reset( ramp );
1106 ignoreRings = mIgnoreRings;
1120 selColor.setAlphaF( context.
opacity() );
1121 mSelBrush = QBrush( selColor );
1140 p->setBrush( mSelBrush );
1142 if ( !mOffset.isNull() )
1146 p->translate( offset );
1149 if ( !mOffset.isNull() )
1151 p->translate( -offset );
1162 applyDataDefinedSymbology( context, color1, color2, blurRadius, useWholeShape, maxDistance, ignoreRings );
1165 int outputPixelMaxDist = 0;
1173 std::unique_ptr< QgsGradientColorRamp > twoColorGradientRamp;
1176 twoColorGradientRamp = qgis::make_unique< QgsGradientColorRamp >( color1,
color2 );
1180 p->setPen( QPen( Qt::NoPen ) );
1183 int sideBuffer = 4 + ( blurRadius + 2 ) * 4;
1185 int pointsWidth =
static_cast< int >( std::round( points.boundingRect().width() ) );
1186 int pointsHeight =
static_cast< int >( std::round( points.boundingRect().height() ) );
1187 int imWidth = pointsWidth + ( sideBuffer * 2 );
1188 int imHeight = pointsHeight + ( sideBuffer * 2 );
1189 std::unique_ptr< QImage > fillImage = qgis::make_unique< QImage >( imWidth,
1190 imHeight, QImage::Format_ARGB32_Premultiplied );
1191 if ( fillImage->isNull() )
1198 std::unique_ptr< QImage > alphaImage = qgis::make_unique< QImage >( fillImage->width(), fillImage->height(), QImage::Format_ARGB32_Premultiplied );
1199 if ( alphaImage->isNull() )
1208 fillImage->fill( Qt::black );
1211 alphaImage->fill( Qt::transparent );
1214 QPainter imgPainter;
1215 imgPainter.begin( alphaImage.get() );
1216 imgPainter.setRenderHint( QPainter::Antialiasing,
true );
1217 imgPainter.setBrush( QBrush( Qt::white ) );
1218 imgPainter.setPen( QPen( Qt::black ) );
1219 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1225 imgPainter.begin( fillImage.get() );
1228 imgPainter.drawImage( 0, 0, *alphaImage );
1235 imgPainter.setBrush( QBrush( Qt::white ) );
1236 imgPainter.setPen( QPen( Qt::black ) );
1237 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1243 double *dtArray = distanceTransform( fillImage.get(), context.
renderContext() );
1257 if ( blurRadius > 0 )
1263 imgPainter.begin( fillImage.get() );
1264 imgPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
1265 imgPainter.drawImage( 0, 0, *alphaImage );
1274 if ( !mOffset.isNull() )
1278 p->translate( offset );
1281 p->drawImage( points.boundingRect().left() - sideBuffer, points.boundingRect().top() - sideBuffer, *fillImage );
1283 if ( !mOffset.isNull() )
1285 p->translate( -offset );
1294 void QgsShapeburstFillSymbolLayer::distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d )
1300 for (
int q = 1; q <= n - 1; q++ )
1302 double s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1306 s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1315 for (
int q = 0; q <= n - 1; q++ )
1317 while ( z[k + 1] < q )
1319 d[q] = ( q - v[k] ) * ( q - v[k] ) + f[v[k]];
1324 void QgsShapeburstFillSymbolLayer::distanceTransform2d(
double *im,
int width,
int height,
QgsRenderContext &context )
1326 int maxDimension = std::max( width, height );
1327 double *f =
new double[ maxDimension ];
1328 int *v =
new int[ maxDimension ];
1329 double *z =
new double[ maxDimension + 1 ];
1330 double *d =
new double[ maxDimension ];
1333 for (
int x = 0; x < width; x++ )
1338 for (
int y = 0; y < height; y++ )
1340 f[y] = im[ x + y * width ];
1342 distanceTransform1d( f, height, v, z, d );
1343 for (
int y = 0; y < height; y++ )
1345 im[ x + y * width ] = d[y];
1350 for (
int y = 0; y < height; y++ )
1355 for (
int x = 0; x < width; x++ )
1357 f[x] = im[ x + y * width ];
1359 distanceTransform1d( f, width, v, z, d );
1360 for (
int x = 0; x < width; x++ )
1362 im[ x + y * width ] = d[x];
1373 double *QgsShapeburstFillSymbolLayer::distanceTransform( QImage *im,
QgsRenderContext &context )
1375 int width = im->width();
1376 int height = im->height();
1378 double *dtArray =
new double[width * height];
1383 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1388 const QRgb *scanLine =
reinterpret_cast< const QRgb *
>( im->constScanLine( heightIndex ) );
1389 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1391 tmpRgb = scanLine[widthIndex];
1392 if ( qRed( tmpRgb ) == 0 )
1400 dtArray[ idx ] =
INF;
1407 distanceTransform2d( dtArray, width, height, context );
1414 int width = im->width();
1415 int height = im->height();
1418 double maxDistanceValue;
1423 double dtMaxValue = array[0];
1424 for (
int i = 1; i < ( width * height ); ++i )
1426 if ( array[i] > dtMaxValue )
1428 dtMaxValue = array[i];
1433 maxDistanceValue = std::sqrt( dtMaxValue );
1438 maxDistanceValue = maxPixelDistance;
1443 double squaredVal = 0;
1446 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1451 QRgb *scanLine =
reinterpret_cast< QRgb *
>( im->scanLine( heightIndex ) );
1452 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1455 squaredVal = array[idx];
1458 if ( maxDistanceValue > 0 )
1460 pixVal = squaredVal > 0 ? std::min( ( std::sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1469 scanLine[widthIndex] = qPremultiply( ramp->
color( pixVal ).rgba() );
1480 map[QStringLiteral(
"color_type" )] = QString::number( mColorType );
1481 map[QStringLiteral(
"blur_radius" )] = QString::number( mBlurRadius );
1482 map[QStringLiteral(
"use_whole_shape" )] = QString::number( mUseWholeShape );
1483 map[QStringLiteral(
"max_distance" )] = QString::number( mMaxDistance );
1486 map[QStringLiteral(
"ignore_rings" )] = QString::number( mIgnoreRings );
1490 if ( mGradientRamp )
1492 map.unite( mGradientRamp->properties() );
1500 std::unique_ptr< QgsShapeburstFillSymbolLayer > sl = qgis::make_unique< QgsShapeburstFillSymbolLayer >(
mColor, mColor2, mColorType, mBlurRadius, mUseWholeShape, mMaxDistance );
1501 if ( mGradientRamp )
1505 sl->setDistanceUnit( mDistanceUnit );
1506 sl->setDistanceMapUnitScale( mDistanceMapUnitScale );
1507 sl->setIgnoreRings( mIgnoreRings );
1508 sl->setOffset( mOffset );
1509 sl->setOffsetUnit( mOffsetUnit );
1510 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
1513 return sl.release();
1518 double offsetBleed = context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
1524 mDistanceUnit = unit;
1530 if ( mDistanceUnit == mOffsetUnit )
1532 return mDistanceUnit;
1539 mDistanceMapUnitScale = scale;
1540 mOffsetMapUnitScale = scale;
1545 if ( mDistanceMapUnitScale == mOffsetMapUnitScale )
1547 return mDistanceMapUnitScale;
1569 applyDataDefinedSettings( context );
1571 p->setPen( QPen( Qt::NoPen ) );
1573 QTransform bkTransform = mBrush.transform();
1577 QPointF leftCorner = points.boundingRect().topLeft();
1578 QTransform t = mBrush.transform();
1579 t.translate( leftCorner.x(), leftCorner.y() );
1580 mBrush.setTransform( t );
1589 p->setBrush( QBrush( selColor ) );
1595 QTransform t = mBrush.transform();
1596 t.rotate( mNextAngle );
1597 mBrush.setTransform( t );
1599 p->setBrush( mBrush );
1606 QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
1607 for ( ; ringIt != rings->constEnd(); ++ringIt )
1614 mBrush.setTransform( bkTransform );
1621 mStroke.reset(
nullptr );
1634 mStroke.reset( lineSymbol );
1644 mStrokeWidthUnit = unit;
1649 return mStrokeWidthUnit;
1654 mStrokeWidthMapUnitScale = scale;
1659 return mStrokeWidthMapUnitScale;
1664 if ( mStroke && mStroke->symbolLayer( 0 ) )
1666 double subLayerBleed = mStroke->symbolLayer( 0 )->estimateMaxBleed( context );
1667 return subLayerBleed;
1674 double width = mStrokeWidth;
1688 return QColor( Qt::black );
1690 return mStroke->color();
1695 return Qt::SolidLine;
1699 return Qt::SolidLine;
1703 return mStroke->dxfPenStyle();
1712 attr.unite( mStroke->usedAttributes( context ) );
1720 if ( mStroke && mStroke->hasDataDefinedProperties() )
1730 , mPatternWidth( width )
1734 mColor = QColor( 255, 255, 255 );
1740 , mPatternWidth( width )
1741 , mSvgData( svgData )
1746 mColor = QColor( 255, 255, 255 );
1748 setDefaultSvgParams();
1754 mPatternWidthUnit = unit;
1755 mSvgStrokeWidthUnit = unit;
1757 mStroke->setOutputUnit( unit );
1763 if ( mPatternWidthUnit != unit || mSvgStrokeWidthUnit != unit ||
mStrokeWidthUnit != unit )
1773 mPatternWidthMapUnitScale = scale;
1774 mSvgStrokeWidthMapUnitScale = scale;
1781 mPatternWidthMapUnitScale == mSvgStrokeWidthMapUnitScale &&
1784 return mPatternWidthMapUnitScale;
1794 mSvgFilePath = svgPath;
1795 setDefaultSvgParams();
1805 if ( properties.contains( QStringLiteral(
"width" ) ) )
1807 width = properties[QStringLiteral(
"width" )].toDouble();
1809 if ( properties.contains( QStringLiteral(
"svgFile" ) ) )
1811 svgFilePath = properties[QStringLiteral(
"svgFile" )];
1813 if ( properties.contains( QStringLiteral(
"angle" ) ) )
1815 angle = properties[QStringLiteral(
"angle" )].toDouble();
1818 std::unique_ptr< QgsSVGFillSymbolLayer > symbolLayer;
1819 if ( !svgFilePath.isEmpty() )
1821 symbolLayer = qgis::make_unique< QgsSVGFillSymbolLayer >(
svgFilePath, width,
angle );
1825 if ( properties.contains( QStringLiteral(
"data" ) ) )
1827 data = QByteArray::fromHex( properties[QStringLiteral(
"data" )].toLocal8Bit() );
1829 symbolLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( data, width,
angle );
1833 if ( properties.contains( QStringLiteral(
"svgFillColor" ) ) )
1838 else if ( properties.contains( QStringLiteral(
"color" ) ) )
1842 if ( properties.contains( QStringLiteral(
"svgOutlineColor" ) ) )
1847 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
1851 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
1855 if ( properties.contains( QStringLiteral(
"svgOutlineWidth" ) ) )
1858 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"svgOutlineWidth" )].toDouble() );
1860 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
1862 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"outline_width" )].toDouble() );
1864 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
1866 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"line_width" )].toDouble() );
1870 if ( properties.contains( QStringLiteral(
"pattern_width_unit" ) ) )
1874 if ( properties.contains( QStringLiteral(
"pattern_width_map_unit_scale" ) ) )
1878 if ( properties.contains( QStringLiteral(
"svg_outline_width_unit" ) ) )
1882 if ( properties.contains( QStringLiteral(
"svg_outline_width_map_unit_scale" ) ) )
1886 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
1890 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1895 symbolLayer->restoreOldDataDefinedProperties( properties );
1897 return symbolLayer.release();
1902 QgsStringMap::iterator it = properties.find( QStringLiteral(
"svgFile" ) );
1903 if ( it != properties.end() )
1914 return QStringLiteral(
"SVGFill" );
1922 if ( mSvgViewBox.isNull() )
1929 if ( static_cast< int >( size ) < 1.0 || 10000.0 < size )
1931 brush.setTextureImage( QImage() );
1935 bool fitsInCache =
true;
1943 double hwRatio = 1.0;
1944 if ( patternPict.width() > 0 )
1946 hwRatio =
static_cast< double >( patternPict.height() ) / static_cast< double >( patternPict.width() );
1948 patternImage = QImage( static_cast< int >( size ), static_cast< int >( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
1949 patternImage.fill( 0 );
1951 QPainter p( &patternImage );
1952 p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
1955 QTransform brushTransform;
1958 QImage transparentImage = patternImage.copy();
1960 brush.setTextureImage( transparentImage );
1964 brush.setTextureImage( patternImage );
1966 brush.setTransform( brushTransform );
1973 applyPattern(
mBrush, mSvgFilePath, mPatternWidth, mPatternWidthUnit,
mColor, mSvgStrokeColor, mSvgStrokeWidth, mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale );
1992 if ( !mSvgFilePath.isEmpty() )
1994 map.insert( QStringLiteral(
"svgFile" ), mSvgFilePath );
1998 map.insert( QStringLiteral(
"data" ), QString( mSvgData.toHex() ) );
2001 map.insert( QStringLiteral(
"width" ), QString::number( mPatternWidth ) );
2002 map.insert( QStringLiteral(
"angle" ), QString::number(
mAngle ) );
2007 map.insert( QStringLiteral(
"outline_width" ), QString::number( mSvgStrokeWidth ) );
2021 std::unique_ptr< QgsSVGFillSymbolLayer > clonedLayer;
2022 if ( !mSvgFilePath.isEmpty() )
2024 clonedLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( mSvgFilePath, mPatternWidth,
mAngle );
2026 clonedLayer->setSvgStrokeColor( mSvgStrokeColor );
2027 clonedLayer->setSvgStrokeWidth( mSvgStrokeWidth );
2031 clonedLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( mSvgData, mPatternWidth,
mAngle );
2034 clonedLayer->setPatternWidthUnit( mPatternWidthUnit );
2035 clonedLayer->setPatternWidthMapUnitScale( mPatternWidthMapUnitScale );
2036 clonedLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnit );
2037 clonedLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthMapUnitScale );
2043 clonedLayer->setSubSymbol(
mStroke->clone() );
2047 return clonedLayer.release();
2052 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2053 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
2054 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
2055 element.appendChild( symbolizerElem );
2059 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2060 symbolizerElem.appendChild( fillElem );
2062 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2063 fillElem.appendChild( graphicFillElem );
2065 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2066 graphicFillElem.appendChild( graphicElem );
2068 if ( !mSvgFilePath.isEmpty() )
2079 symbolizerElem.appendChild( doc.createComment( QStringLiteral(
"SVG from data not implemented yet" ) ) );
2085 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2088 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2092 angleFunc = QString::number( angle +
mAngle );
2101 mStroke->toSld( doc, element, props );
2107 QString path, mimeType;
2109 Qt::PenStyle penStyle;
2110 double size, strokeWidth;
2112 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2113 if ( fillElem.isNull() )
2116 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2117 if ( graphicFillElem.isNull() )
2120 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2121 if ( graphicElem.isNull() )
2127 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2132 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2141 double d = angleFunc.toDouble( &ok );
2146 std::unique_ptr< QgsSVGFillSymbolLayer > sl = qgis::make_unique< QgsSVGFillSymbolLayer >( path, size,
angle );
2147 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2148 sl->setSvgFillColor( fillColor );
2149 sl->setSvgStrokeColor( strokeColor );
2150 sl->setSvgStrokeWidth( strokeWidth );
2153 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2154 if ( !strokeElem.isNull() )
2165 return sl.release();
2183 double width = mPatternWidth;
2189 QString svgFile = mSvgFilePath;
2208 double strokeWidth = mSvgStrokeWidth;
2214 applyPattern(
mBrush, svgFile, width, mPatternWidthUnit, svgFillColor, svgStrokeColor, strokeWidth,
2215 mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale );
2219 void QgsSVGFillSymbolLayer::storeViewBox()
2221 if ( !mSvgData.isEmpty() )
2223 QSvgRenderer r( mSvgData );
2226 mSvgViewBox = r.viewBoxF();
2231 mSvgViewBox = QRectF();
2234 void QgsSVGFillSymbolLayer::setDefaultSvgParams()
2236 if ( mSvgFilePath.isEmpty() )
2241 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2242 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2243 QColor defaultFillColor, defaultStrokeColor;
2244 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2246 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2247 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2248 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2249 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2251 double newFillOpacity = hasFillOpacityParam ?
mColor.alphaF() : 1.0;
2252 double newStrokeOpacity = hasStrokeOpacityParam ? mSvgStrokeColor.alphaF() : 1.0;
2254 if ( hasDefaultFillColor )
2256 mColor = defaultFillColor;
2257 mColor.setAlphaF( newFillOpacity );
2259 if ( hasDefaultFillOpacity )
2261 mColor.setAlphaF( defaultFillOpacity );
2263 if ( hasDefaultStrokeColor )
2265 mSvgStrokeColor = defaultStrokeColor;
2266 mSvgStrokeColor.setAlphaF( newStrokeOpacity );
2268 if ( hasDefaultStrokeOpacity )
2270 mSvgStrokeColor.setAlphaF( defaultStrokeOpacity );
2272 if ( hasDefaultStrokeWidth )
2274 mSvgStrokeWidth = defaultStrokeWidth;
2300 return mFillLineSymbol ? mFillLineSymbol->
color() :
mColor;
2305 delete mFillLineSymbol;
2320 delete mFillLineSymbol;
2321 mFillLineSymbol = lineSymbol;
2332 return mFillLineSymbol;
2338 if ( mFillLineSymbol )
2360 mDistanceUnit = unit;
2361 mLineWidthUnit = unit;
2368 if ( mDistanceUnit != unit || mLineWidthUnit != unit || mOffsetUnit != unit )
2378 mDistanceMapUnitScale = scale;
2379 mLineWidthMapUnitScale = scale;
2380 mOffsetMapUnitScale = scale;
2386 mDistanceMapUnitScale == mLineWidthMapUnitScale &&
2387 mLineWidthMapUnitScale == mOffsetMapUnitScale )
2389 return mDistanceMapUnitScale;
2396 std::unique_ptr< QgsLinePatternFillSymbolLayer > patternLayer = qgis::make_unique< QgsLinePatternFillSymbolLayer >();
2402 QColor
color( Qt::black );
2405 if ( properties.contains( QStringLiteral(
"lineangle" ) ) )
2408 lineAngle = properties[QStringLiteral(
"lineangle" )].toDouble();
2410 else if ( properties.contains( QStringLiteral(
"angle" ) ) )
2412 lineAngle = properties[QStringLiteral(
"angle" )].toDouble();
2414 patternLayer->setLineAngle( lineAngle );
2416 if ( properties.contains( QStringLiteral(
"distance" ) ) )
2418 distance = properties[QStringLiteral(
"distance" )].toDouble();
2420 patternLayer->setDistance( distance );
2422 if ( properties.contains( QStringLiteral(
"linewidth" ) ) )
2425 lineWidth = properties[QStringLiteral(
"linewidth" )].toDouble();
2427 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
2429 lineWidth = properties[QStringLiteral(
"outline_width" )].toDouble();
2431 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
2433 lineWidth = properties[QStringLiteral(
"line_width" )].toDouble();
2435 patternLayer->setLineWidth( lineWidth );
2437 if ( properties.contains( QStringLiteral(
"color" ) ) )
2441 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
2445 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
2449 patternLayer->setColor( color );
2451 if ( properties.contains( QStringLiteral(
"offset" ) ) )
2453 offset = properties[QStringLiteral(
"offset" )].toDouble();
2455 patternLayer->setOffset( offset );
2458 if ( properties.contains( QStringLiteral(
"distance_unit" ) ) )
2462 if ( properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
2466 if ( properties.contains( QStringLiteral(
"line_width_unit" ) ) )
2470 else if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2474 if ( properties.contains( QStringLiteral(
"line_width_map_unit_scale" ) ) )
2478 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
2482 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2486 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2490 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2495 patternLayer->restoreOldDataDefinedProperties( properties );
2497 return patternLayer.release();
2502 return QStringLiteral(
"LinePatternFill" );
2507 mBrush.setTextureImage( QImage() );
2509 if ( !mFillLineSymbol )
2514 std::unique_ptr< QgsLineSymbol > fillLineSymbol( mFillLineSymbol->
clone() );
2515 if ( !fillLineSymbol )
2522 double outputPixelDist = ctx.
convertToPainterUnits( distance, mDistanceUnit, mDistanceMapUnitScale );
2530 outputPixelOffset = std::fmod( outputPixelOffset, outputPixelDist );
2531 if ( outputPixelOffset > outputPixelDist / 2.0 )
2532 outputPixelOffset -= outputPixelDist;
2536 double outputPixelBleed = 0;
2537 double outputPixelInterval = 0;
2538 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2542 outputPixelBleed = std::max( outputPixelBleed, outputPixelLayerBleed );
2545 if ( markerLineLayer )
2554 outputPixelInterval = std::max( outputPixelInterval, outputPixelLayerInterval );
2558 if ( outputPixelInterval > 0 )
2562 double intervalScale = std::round( outputPixelInterval ) / outputPixelInterval;
2563 outputPixelInterval = std::round( outputPixelInterval );
2565 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2570 if ( markerLineLayer )
2584 height = outputPixelDist;
2585 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2589 width = outputPixelDist;
2590 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2594 height = outputPixelDist / std::cos(
lineAngle * M_PI / 180 );
2595 width = outputPixelDist / std::sin(
lineAngle * M_PI / 180 );
2598 lineAngle = 180 * std::atan2( static_cast< double >( height ), static_cast< double >( width ) ) / M_PI;
2604 height = std::abs( height );
2605 width = std::abs( width );
2607 outputPixelDist = std::abs( height * std::cos(
lineAngle * M_PI / 180 ) );
2611 int offsetHeight =
static_cast< int >( std::round( outputPixelOffset / std::cos(
lineAngle * M_PI / 180 ) ) );
2612 outputPixelOffset = offsetHeight * std::cos(
lineAngle * M_PI / 180 );
2621 int bufferMulti =
static_cast< int >( std::max( std::ceil( outputPixelBleed / width ), std::ceil( outputPixelBleed / width ) ) );
2625 bufferMulti = std::max( bufferMulti, 1 );
2627 int xBuffer = width * bufferMulti;
2628 int yBuffer = height * bufferMulti;
2629 int innerWidth = width;
2630 int innerHeight = height;
2631 width += 2 * xBuffer;
2632 height += 2 * yBuffer;
2635 if ( width > 10000 || height > 10000 || width == 0 || height == 0 )
2640 QImage patternImage( width, height, QImage::Format_ARGB32 );
2641 patternImage.fill( 0 );
2643 QPointF p1, p2, p3, p4, p5, p6;
2646 p1 = QPointF( 0, yBuffer );
2647 p2 = QPointF( width, yBuffer );
2648 p3 = QPointF( 0, yBuffer + innerHeight );
2649 p4 = QPointF( width, yBuffer + innerHeight );
2653 p1 = QPointF( xBuffer, height );
2654 p2 = QPointF( xBuffer, 0 );
2655 p3 = QPointF( xBuffer + innerWidth, height );
2656 p4 = QPointF( xBuffer + innerWidth, 0 );
2660 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2661 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2662 p1 = QPointF( 0, height );
2663 p2 = QPointF( width, 0 );
2664 p3 = QPointF( -dx, height - dy );
2665 p4 = QPointF( width - dx, -dy );
2666 p5 = QPointF( dx, height + dy );
2667 p6 = QPointF( width + dx, dy );
2671 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2672 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2673 p1 = QPointF( width, 0 );
2674 p2 = QPointF( 0, height );
2675 p3 = QPointF( width - dx, -dy );
2676 p4 = QPointF( -dx, height - dy );
2677 p5 = QPointF( width + dx, dy );
2678 p6 = QPointF( dx, height + dy );
2682 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2683 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2684 p1 = QPointF( 0, 0 );
2685 p2 = QPointF( width, height );
2686 p5 = QPointF( dx, -dy );
2687 p6 = QPointF( width + dx, height - dy );
2688 p3 = QPointF( -dx, dy );
2689 p4 = QPointF( width - dx, height + dy );
2693 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2694 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2695 p1 = QPointF( width, height );
2696 p2 = QPointF( 0, 0 );
2697 p5 = QPointF( width + dx, height - dy );
2698 p6 = QPointF( dx, -dy );
2699 p3 = QPointF( width - dx, height + dy );
2700 p4 = QPointF( -dx, dy );
2707 p3 = QPointF( tempPt.x(), tempPt.y() );
2709 p4 = QPointF( tempPt.x(), tempPt.y() );
2711 p5 = QPointF( tempPt.x(), tempPt.y() );
2713 p6 = QPointF( tempPt.x(), tempPt.y() );
2717 p1 = QPointF( tempPt.x(), tempPt.y() );
2719 p2 = QPointF( tempPt.x(), tempPt.y() );
2722 QPainter p( &patternImage );
2726 p.setRenderHint( QPainter::Antialiasing,
false );
2727 QPen pen( QColor( Qt::black ) );
2728 pen.setWidthF( 0.1 );
2729 pen.setCapStyle( Qt::FlatCap );
2734 QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 );
2735 p.drawPolygon( polygon );
2737 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 );
2738 p.drawPolygon( polygon );
2744 p.setRenderHint( QPainter::Antialiasing,
true );
2755 fillLineSymbol->startRender( lineRenderContext, context.
fields() );
2757 QVector<QPolygonF> polygons;
2758 polygons.append( QPolygonF() << p1 << p2 );
2759 polygons.append( QPolygonF() << p3 << p4 );
2762 polygons.append( QPolygonF() << p5 << p6 );
2765 for (
const QPolygonF &polygon : qgis::as_const( polygons ) )
2767 fillLineSymbol->renderPolyline( polygon, context.
feature(), lineRenderContext, -1, context.
selected() );
2770 fillLineSymbol->stopRender( lineRenderContext );
2774 patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
2779 QImage transparentImage = patternImage.copy();
2781 brush.setTextureImage( transparentImage );
2785 brush.setTextureImage( patternImage );
2788 QTransform brushTransform;
2789 brush.setTransform( brushTransform );
2794 applyPattern( context,
mBrush, mLineAngle, mDistance );
2796 if ( mFillLineSymbol )
2804 if ( mFillLineSymbol )
2813 map.insert( QStringLiteral(
"angle" ), QString::number( mLineAngle ) );
2814 map.insert( QStringLiteral(
"distance" ), QString::number( mDistance ) );
2815 map.insert( QStringLiteral(
"line_width" ), QString::number( mLineWidth ) );
2817 map.insert( QStringLiteral(
"offset" ), QString::number( mOffset ) );
2832 if ( mFillLineSymbol )
2843 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2844 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
2845 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
2846 element.appendChild( symbolizerElem );
2851 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2852 symbolizerElem.appendChild( fillElem );
2854 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2855 fillElem.appendChild( graphicFillElem );
2857 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2858 graphicFillElem.appendChild( graphicElem );
2861 QColor lineColor = mFillLineSymbol ? mFillLineSymbol->
color() : QColor();
2862 double lineWidth = mFillLineSymbol ? mFillLineSymbol->
width() : 0.0;
2870 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2873 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg( mLineAngle );
2877 angleFunc = QString::number( angle + mLineAngle );
2882 QPointF lineOffset( std::sin( mLineAngle ) * mOffset, std::cos( mLineAngle ) * mOffset );
2889 QString featureStyle;
2890 featureStyle.append(
"Brush(" );
2891 featureStyle.append( QStringLiteral(
"fc:%1" ).arg(
mColor.name() ) );
2892 featureStyle.append( QStringLiteral(
",bc:%1" ).arg( QStringLiteral(
"#00000000" ) ) );
2893 featureStyle.append(
",id:\"ogr-brush-2\"" );
2894 featureStyle.append( QStringLiteral(
",a:%1" ).arg( mLineAngle ) );
2895 featureStyle.append( QStringLiteral(
",s:%1" ).arg( mLineWidth * widthScaleFactor ) );
2896 featureStyle.append(
",dx:0mm" );
2897 featureStyle.append( QStringLiteral(
",dy:%1mm" ).arg( mDistance * widthScaleFactor ) );
2898 featureStyle.append(
')' );
2899 return featureStyle;
2922 applyPattern( context,
mBrush, lineAngle, distance );
2930 Qt::PenStyle lineStyle;
2932 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2933 if ( fillElem.isNull() )
2936 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2937 if ( graphicFillElem.isNull() )
2940 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2941 if ( graphicElem.isNull() )
2947 if ( name != QLatin1String(
"horline" ) )
2955 double d = angleFunc.toDouble( &ok );
2964 offset = std::sqrt( std::pow( vectOffset.x(), 2 ) + std::pow( vectOffset.y(), 2 ) );
2967 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2971 std::unique_ptr< QgsLinePatternFillSymbolLayer > sl = qgis::make_unique< QgsLinePatternFillSymbolLayer >();
2972 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2973 sl->setColor( lineColor );
2974 sl->setLineWidth( lineWidth );
2975 sl->setLineAngle( angle );
2976 sl->setOffset( offset );
2977 sl->setDistance( size );
2980 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2981 if ( !strokeElem.isNull() )
2992 return sl.release();
3069 std::unique_ptr< QgsPointPatternFillSymbolLayer > layer = qgis::make_unique< QgsPointPatternFillSymbolLayer >();
3070 if ( properties.contains( QStringLiteral(
"distance_x" ) ) )
3072 layer->setDistanceX( properties[QStringLiteral(
"distance_x" )].toDouble() );
3074 if ( properties.contains( QStringLiteral(
"distance_y" ) ) )
3076 layer->setDistanceY( properties[QStringLiteral(
"distance_y" )].toDouble() );
3078 if ( properties.contains( QStringLiteral(
"displacement_x" ) ) )
3080 layer->setDisplacementX( properties[QStringLiteral(
"displacement_x" )].toDouble() );
3082 if ( properties.contains( QStringLiteral(
"displacement_y" ) ) )
3084 layer->setDisplacementY( properties[QStringLiteral(
"displacement_y" )].toDouble() );
3086 if ( properties.contains( QStringLiteral(
"offset_x" ) ) )
3088 layer->setOffsetX( properties[QStringLiteral(
"offset_x" )].toDouble() );
3090 if ( properties.contains( QStringLiteral(
"offset_y" ) ) )
3092 layer->setOffsetY( properties[QStringLiteral(
"offset_y" )].toDouble() );
3095 if ( properties.contains( QStringLiteral(
"distance_x_unit" ) ) )
3099 if ( properties.contains( QStringLiteral(
"distance_x_map_unit_scale" ) ) )
3103 if ( properties.contains( QStringLiteral(
"distance_y_unit" ) ) )
3107 if ( properties.contains( QStringLiteral(
"distance_y_map_unit_scale" ) ) )
3111 if ( properties.contains( QStringLiteral(
"displacement_x_unit" ) ) )
3115 if ( properties.contains( QStringLiteral(
"displacement_x_map_unit_scale" ) ) )
3119 if ( properties.contains( QStringLiteral(
"displacement_y_unit" ) ) )
3123 if ( properties.contains( QStringLiteral(
"displacement_y_map_unit_scale" ) ) )
3127 if ( properties.contains( QStringLiteral(
"offset_x_unit" ) ) )
3131 if ( properties.contains( QStringLiteral(
"offset_x_map_unit_scale" ) ) )
3135 if ( properties.contains( QStringLiteral(
"offset_y_unit" ) ) )
3139 if ( properties.contains( QStringLiteral(
"offset_y_map_unit_scale" ) ) )
3144 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
3148 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3155 return layer.release();
3160 return QStringLiteral(
"PointPatternFill" );
3174 if ( width > 10000 || height > 10000 )
3177 brush.setTextureImage( img );
3181 QImage patternImage( width, height, QImage::Format_ARGB32 );
3182 patternImage.fill( 0 );
3186 QPainter p( &patternImage );
3196 p.setRenderHint( QPainter::Antialiasing,
true );
3206 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3208 for (
double currentY = -height; currentY <= height * 2.0; currentY += height )
3217 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3219 for (
double currentY = -height / 2.0; currentY <= height * 2.0; currentY += height )
3225 for (
double currentX = -width / 2.0; currentX <= width * 2.0; currentX += width )
3227 for (
double currentY = -height; currentY <= height * 2.0; currentY += height / 2.0 )
3229 mMarkerSymbol->
renderPoint( QPointF( currentX + widthOffset + ( std::fmod( currentY, height ) != 0 ? displacementPixelX : 0 ), currentY + heightOffset - displacementPixelY ), context.
feature(), pointRenderContext );
3238 QImage transparentImage = patternImage.copy();
3240 brush.setTextureImage( transparentImage );
3244 brush.setTextureImage( patternImage );
3246 QTransform brushTransform;
3247 brush.setTransform( brushTransform );
3271 map.insert( QStringLiteral(
"distance_x" ), QString::number(
mDistanceX ) );
3272 map.insert( QStringLiteral(
"distance_y" ), QString::number(
mDistanceY ) );
3273 map.insert( QStringLiteral(
"displacement_x" ), QString::number(
mDisplacementX ) );
3274 map.insert( QStringLiteral(
"displacement_y" ), QString::number(
mDisplacementY ) );
3275 map.insert( QStringLiteral(
"offset_x" ), QString::number(
mOffsetX ) );
3276 map.insert( QStringLiteral(
"offset_y" ), QString::number(
mOffsetY ) );
3310 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
3311 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
3312 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
3313 element.appendChild( symbolizerElem );
3318 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
3319 symbolizerElem.appendChild( fillElem );
3321 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
3322 fillElem.appendChild( graphicFillElem );
3329 symbolizerElem.appendChild( distanceElem );
3335 QString errorMsg = QStringLiteral(
"MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->
layerType() );
3336 graphicFillElem.appendChild( doc.createComment( errorMsg ) );
3412 applyPattern( context,
mBrush, distanceX, distanceY, displacementX, displacementY, offsetX, offsetY );
3461 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3463 if ( properties.contains( QStringLiteral(
"point_on_surface" ) ) )
3464 sl->setPointOnSurface( properties[QStringLiteral(
"point_on_surface" )].toInt() != 0 );
3465 if ( properties.contains( QStringLiteral(
"point_on_all_parts" ) ) )
3466 sl->setPointOnAllParts( properties[QStringLiteral(
"point_on_all_parts" )].toInt() != 0 );
3470 return sl.release();
3475 return QStringLiteral(
"CentroidFill" );
3480 mMarker->setColor( color );
3486 return mMarker ? mMarker->color() :
mColor;
3491 mMarker->setOpacity( context.
opacity() );
3494 mCurrentFeatureId = -1;
3495 mBiggestPartIndex = 0;
3505 if ( !mPointOnAllParts )
3510 if ( feature->
id() != mCurrentFeatureId )
3512 mCurrentFeatureId = feature->
id();
3513 mBiggestPartIndex = 1;
3521 double areaBiggest = 0;
3525 if ( area > areaBiggest )
3528 mBiggestPartIndex = i + 1;
3536 if ( mPointOnAllParts || ( context.
geometryPartNum() == mBiggestPartIndex ) )
3546 map[QStringLiteral(
"point_on_surface" )] = QString::number( mPointOnSurface );
3547 map[QStringLiteral(
"point_on_all_parts" )] = QString::number( mPointOnAllParts );
3553 std::unique_ptr< QgsCentroidFillSymbolLayer > x = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3556 x->setSubSymbol( mMarker->clone() );
3557 x->setPointOnSurface( mPointOnSurface );
3558 x->setPointOnAllParts( mPointOnAllParts );
3569 mMarker->toSld( doc, element, props );
3580 std::unique_ptr< QgsMarkerSymbol > marker(
new QgsMarkerSymbol( layers ) );
3582 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3583 sl->setSubSymbol( marker.release() );
3584 sl->setPointOnAllParts(
false );
3585 return sl.release();
3591 return mMarker.get();
3602 mMarker.reset( static_cast<QgsMarkerSymbol *>( symbol ) );
3603 mColor = mMarker->color();
3612 attributes.unite( mMarker->usedAttributes( context ) );
3621 if ( mMarker && mMarker->hasDataDefinedProperties() )
3630 mMarker->setOutputUnit( unit );
3638 return mMarker->outputUnit();
3647 mMarker->setMapUnitScale( scale );
3655 return mMarker->mapUnitScale();
3665 , mImageFilePath( imageFilePath )
3679 if ( properties.contains( QStringLiteral(
"imageFile" ) ) )
3681 imagePath = properties[QStringLiteral(
"imageFile" )];
3683 if ( properties.contains( QStringLiteral(
"coordinate_mode" ) ) )
3685 mode =
static_cast< FillCoordinateMode >( properties[QStringLiteral(
"coordinate_mode" )].toInt() );
3687 if ( properties.contains( QStringLiteral(
"alpha" ) ) )
3689 alpha = properties[QStringLiteral(
"alpha" )].toDouble();
3691 if ( properties.contains( QStringLiteral(
"offset" ) ) )
3695 if ( properties.contains( QStringLiteral(
"angle" ) ) )
3697 angle = properties[QStringLiteral(
"angle" )].toDouble();
3699 if ( properties.contains( QStringLiteral(
"width" ) ) )
3701 width = properties[QStringLiteral(
"width" )].toDouble();
3703 std::unique_ptr< QgsRasterFillSymbolLayer > symbolLayer = qgis::make_unique< QgsRasterFillSymbolLayer >( imagePath );
3704 symbolLayer->setCoordinateMode( mode );
3705 symbolLayer->setOpacity( alpha );
3706 symbolLayer->setOffset( offset );
3707 symbolLayer->setAngle( angle );
3708 symbolLayer->setWidth( width );
3709 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
3713 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3717 if ( properties.contains( QStringLiteral(
"width_unit" ) ) )
3721 if ( properties.contains( QStringLiteral(
"width_map_unit_scale" ) ) )
3726 symbolLayer->restoreOldDataDefinedProperties( properties );
3728 return symbolLayer.release();
3733 QgsStringMap::iterator it = properties.find( QStringLiteral(
"imageFile" ) );
3734 if ( it != properties.end() )
3737 it.value() = pathResolver.
writePath( it.value() );
3739 it.value() = pathResolver.
readPath( it.value() );
3751 return QStringLiteral(
"RasterFill" );
3763 if ( !mOffset.isNull() )
3767 p->translate( offset );
3769 if ( mCoordinateMode ==
Feature )
3771 QRectF boundingRect = points.boundingRect();
3772 mBrush.setTransform(
mBrush.transform().translate( boundingRect.left() -
mBrush.transform().dx(),
3773 boundingRect.top() -
mBrush.transform().dy() ) );
3777 if ( !mOffset.isNull() )
3779 p->translate( -offset );
3785 applyPattern(
mBrush, mImageFilePath, mWidth, mOpacity, context );
3796 map[QStringLiteral(
"imageFile" )] = mImageFilePath;
3797 map[QStringLiteral(
"coordinate_mode" )] = QString::number( mCoordinateMode );
3798 map[QStringLiteral(
"alpha" )] = QString::number( mOpacity );
3802 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3803 map[QStringLiteral(
"width" )] = QString::number( mWidth );
3811 std::unique_ptr< QgsRasterFillSymbolLayer > sl = qgis::make_unique< QgsRasterFillSymbolLayer >( mImageFilePath );
3813 sl->setOpacity( mOpacity );
3814 sl->setOffset( mOffset );
3815 sl->setOffsetUnit( mOffsetUnit );
3816 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
3818 sl->setWidth( mWidth );
3819 sl->setWidthUnit( mWidthUnit );
3820 sl->setWidthMapUnitScale( mWidthMapUnitScale );
3823 return sl.release();
3828 return context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
3833 mImageFilePath = imagePath;
3838 mCoordinateMode = mode;
3856 if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
3862 if ( hasAngleExpression )
3870 if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
3875 double width = mWidth;
3876 if ( hasWidthExpression )
3882 if ( hasOpacityExpression )
3887 QString file = mImageFilePath;
3888 if ( hasFileExpression )
3893 applyPattern(
mBrush, file, width, opacity, context );
3902 size.setHeight( 0 );
3910 brush.setTextureImage( img );
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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)
QgsMapUnitScale mapUnitScale() const override
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
QgsUnitTypes::RenderUnit mStrokeWidthUnit
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
QgsMapUnitScale mapUnitScale() const override
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
static QgsSymbolLayer * createFromSld(QDomElement &element)
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
QgsImageFillSymbolLayer()
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
void stopRender(QgsSymbolRenderContext &context) override
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)
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...
static void multiplyOpacity(QImage &image, double factor)
Multiplies opacity of image pixel values by a factor.
Gradient reference point 1 is centroid.
QgsSimpleFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
double mStrokeWidth
Stroke width.
double rendererScale() const
Returns the renderer map scale.
Qt::BrushStyle mBrushStyle
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit mDisplacementXUnit
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
double symbologyScale() const
Returns the reference scale for output.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient fill.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
QColor strokeColor() const override
Gets stroke color.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
static Qt::BrushStyle decodeBrushStyle(const QString &str)
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
QgsMapUnitScale mOffsetYMapUnitScale
QgsSVGFillSymbolLayer(const QString &svgFilePath, double width=20, double rotation=0.0)
Constructor for QgsSVGFillSymbolLayer, using the SVG picture at the specified absolute file path...
#define DEFAULT_SIMPLEFILL_JOINSTYLE
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Gradient reference point 1 x.
QgsFields fields() const
Fields of the layer.
QgsMapUnitScale mStrokeWidthMapUnitScale
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsRasterFillSymbolLayer from a properties map.
QgsRasterFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qt::PenStyle mStrokeStyle
void stopRender(QgsSymbolRenderContext &context) override
void setSvgFillColor(const QColor &c)
Sets the fill color used for rendering the SVG content.
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.
Abstract base class for all rendered symbols.
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...
void setColor(const QColor &c) override
The fill color.
QString imageFilePath() const
The path to the raster image used for the fill.
QPointF offset() const
Returns the offset for the shapeburst fill.
Use antialiasing while drawing.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
QgsMapUnitScale mapUnitScale() const override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
QColor dxfColor(QgsSymbolRenderContext &context) const override
Gets color.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
void startRender(QgsSymbolRenderContext &context) override
void stopRender(QgsSymbolRenderContext &context) override
QgsPointPatternFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qt::PenJoinStyle penJoinStyle() const
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops...
A symbol fill consisting of repeated parallel lines.
QgsLinePatternFillSymbolLayer()
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)
Gets SVG as QImage.
QgsUnitTypes::RenderUnit mOffsetUnit
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.
QgsMapUnitScale mapUnitScale() const override
Base class for polygon renderers generating texture images.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
void startRender(QgsSymbolRenderContext &context) override
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images...
void stopRender(QgsSymbolRenderContext &context) override
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
void startRender(QgsSymbolRenderContext &context) override
Abstract base class for color ramps.
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
void setRendererScale(double scale)
Sets the renderer map scale.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
virtual QColor strokeColor() const
Gets stroke color.
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
QString layerType() const override
Returns a string that represents this layer type.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsLinePatternFillSymbolLayer from a properties map.
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
bool hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mapUnitScale() const override
static QPointF polygonPointOnSurface(const QPolygonF &points, QList< QPolygonF > *rings=nullptr)
Calculate a point on the surface of a QPolygonF.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
~QgsGradientFillSymbolLayer() override
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
A geometry is the spatial representation of a feature.
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsSVGFillSymbolLayer from a properties map.
void _renderPolygon(QPainter *p, const QPolygonF &points, const QList< QPolygonF > *rings, QgsSymbolRenderContext &context)
Default method to render polygon.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
Flags flags() const
Returns combination of flags used for rendering.
static QgsSymbolLayer * createFromSld(QDomElement &element)
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
#define DEFAULT_SIMPLEFILL_COLOR
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
void startRender(QgsSymbolRenderContext &context) override
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
QgsGradientFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
GradientColorType mGradientColorType
double interval() const
Returns the interval between individual symbols.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
QColor color() const override
The fill color.
QgsMapUnitScale mDistanceYMapUnitScale
QPointF referencePoint1() const
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QString layerType() const override
Returns a string that represents this layer type.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QMap< QString, QString > QgsStringMap
Shapeburst use whole shape.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
void setInterval(double interval)
Sets the interval between individual symbols.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsSVGFillSymbolLayer from a SLD element.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
A marker symbol type, for rendering Point and MultiPoint geometries.
QColor color() const override
The fill color.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
A line symbol type, for rendering LineString and MultiLineString geometries.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
Gradient reference point 2 y.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale mapUnitScale() const override
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
#define DEFAULT_SIMPLEFILL_STYLE
static QString encodeColor(const QColor &color)
QgsMapUnitScale mDisplacementYMapUnitScale
void setCoordinateMode(FillCoordinateMode mode)
Set the coordinate mode for fill.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
double offsetY() const
Returns the vertical offset values for points in the pattern.
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
void setOffset(QPointF offset)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
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
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...
QPointF referencePoint2() const
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...
void renderPoint(QPointF point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
Renders the symbol at the specified point, using the given render context.
QString layerType() const override
Returns a string that represents this layer type.
QgsUnitTypes::RenderUnit mOffsetUnit
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
static QString encodePenStyle(Qt::PenStyle style)
Perform transforms between map coordinates and device coordinates.
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
static double rescaleUom(double size, QgsUnitTypes::RenderUnit unit, const QgsStringMap &props)
Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified.
QgsLinePatternFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
double strokeWidth() const
double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets line width.
std::unique_ptr< QgsLineSymbol > mStroke
Custom stroke.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
A class for filling symbols with a repeated raster image.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mDistanceXMapUnitScale
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
QColor dxfBrushColor(QgsSymbolRenderContext &context) const override
Gets brush/fill color.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
double offsetX() const
Returns the horizontal offset values for points in the pattern.
static const bool SELECT_FILL_STYLE
Whether fill styles for selected features uses symbol layer style.
void setColor(const QColor &color) override
The fill color.
GradientType mGradientType
void setWidth(double width)
Sets the width for the whole line symbol.
qreal opacity() const
Returns the opacity for the symbol.
static QgsSymbolLayer * createFromSld(QDomElement &element)
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets line width.
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Gradient coordinate mode.
bool mReferencePoint1IsCentroid
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides...
double displacementX() const
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
QByteArray getImageData(const QString &path, bool blocking=false) const
Gets the SVG content corresponding to the given path.
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
virtual QColor color() const
The fill color.
static void resolvePaths(QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing...
static QgsSymbolLayer * createMarkerLayerFromSld(QDomElement &element)
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Filename, eg for svg files.
QColor selectionColor() const
Returns the color to use when rendering selected features.
QgsUnitTypes::RenderUnit mOffsetYUnit
QgsGradientFillSymbolLayer(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, const QColor &color2=Qt::white, GradientColorType gradientColorType=SimpleTwoColor, GradientType gradientType=Linear, GradientCoordinateMode coordinateMode=Feature, GradientSpread gradientSpread=Pad)
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
void startRender(QgsSymbolRenderContext &context) override
QList< QgsSymbolLayer * > QgsSymbolLayerList
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QColor color() const
Returns the symbol's color.
Shapeburst fill from edge distance.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsSymbol::SymbolType type() const
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
virtual double area() const
Returns the planar, 2-dimensional area of the geometry.
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...
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QString type() const =0
Returns a string representing the color ramp type.
QString layerType() const override
Returns a string that represents this layer type.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
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)
void stopRender(QgsSymbolRenderContext &context) override
double mapUnitsPerPixel() const
Returns current map units per pixel.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QColor fillColor() const override
Gets fill color.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
QgsMapUnitScale mDisplacementXMapUnitScale
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
void stopRender(QgsSymbolRenderContext &context) override
QColor color() const override
The fill color.
Tiling is based on feature bounding box.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
static Qt::PenStyle decodePenStyle(const QString &str)
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
bool mReferencePoint2IsCentroid
static void resolvePaths(QgsStringMap &properties, const QgsPathResolver &pathResolver, bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing...
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
bool selected() const
Returns true if symbols should be rendered using the selected symbol coloring and style...
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
double lineWidth() const
Returns the width of the line subsymbol used to render the parallel lines in the fill.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale mOffsetXMapUnitScale
QgsShapeburstFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Gradient reference point 1 y.
~QgsPointPatternFillSymbolLayer() override
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale mapUnitScale() const override
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
QgsMapUnitScale mapUnitScale() const override
double dxfAngle(QgsSymbolRenderContext &context) const override
Gets angle.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
void setMapUnitScale(const QgsMapUnitScale &scale) override
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsExpressionContext & expressionContext()
Gets the expression context.
QString layerType() const override
Returns a string that represents this layer type.
void startRender(QgsSymbolRenderContext &context) override
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
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.
int geometryPartNum() const
Part number of current geometry.
Line angle, or angle of hash lines for hash line symbols.
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...
GradientCoordinateMode mCoordinateMode
GradientType gradientType() const
Type of gradient, e.g., linear or radial.
QgsRasterFillSymbolLayer(const QString &imageFilePath=QString())
Constructor for QgsRasterFillSymbolLayer, using a raster fill from the specified imageFilePath.
GradientSpread mGradientSpread
void setLineWidth(double w)
Sets the width of the line subsymbol used to render the parallel lines in the fill.
void setMapUnitScale(const QgsMapUnitScale &scale) override
static QPointF polygonCentroid(const QPolygonF &points)
Calculate the centroid point of a QPolygonF.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsColorRamp from a map of properties.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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...
A class for filling symbols with a repeated SVG file.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Stroke style (eg solid, dashed)
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
QString layerType() const override
Returns a string that represents this layer type.
QgsCentroidFillSymbolLayer()
QgsCentroidFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QPainter * painter()
Returns the destination QPainter for the render operation.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Qt::BrushStyle dxfBrushStyle() const override
Gets brush/fill style.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Line symbol layer type which draws repeating marker symbols along a line feature. ...
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
bool hasDataDefinedProperties() const
Returns whether the symbol utilizes any data defined properties.
QgsPointPatternFillSymbolLayer()
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
SymbolType type() const
Returns the symbol's type.
~QgsShapeburstFillSymbolLayer() override
Struct for storing maximum and minimum scales for measurements in map units.
static QString encodeBrushStyle(Qt::BrushStyle style)
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
static void stackBlur(QImage &image, int radius, bool alphaOnly=false)
Performs a stack blur on an image.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
void setSvgFilePath(const QString &svgPath)
Sets the path to the SVG file to render in the fill.
virtual QgsStringMap properties() const =0
Returns a string map containing all the color ramp's properties.
QString ogrFeatureStyleWidth(double widthScaleFactor) const
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
Qt::PenStyle strokeStyle() const
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
const QgsFeature * feature() const
Returns the current feature being rendered.
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
Distance between lines, or length of lines for hash line symbols.
Qt::PenJoinStyle mPenJoinStyle
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
QgsColorRamp * mGradientRamp
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
QColor dxfColor(QgsSymbolRenderContext &context) const override
Gets color.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsLinePatternFillSymbolLayer from a SLD element.
Secondary color (eg for gradient fills)
static bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
QgsMarkerSymbol * mMarkerSymbol
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
double opacity() const
Returns the opacity for the raster image used in the fill.
QgsUnitTypes::RenderUnit mOffsetXUnit
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static QgsSymbolLayer * createLineLayerFromSld(QDomElement &element)
void setMapUnitScale(const QgsMapUnitScale &scale) override
static const bool SELECT_FILL_BORDER
Whether fill styles for selected features also highlight symbol stroke.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
void setMapUnitScale(const QgsMapUnitScale &scale) override
static void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, const QColor &color=QColor())
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)
void setColor(const QColor &c) override
The fill color.
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
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)
Gets SVG as QPicture&.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
QgsUnitTypes::RenderUnit mDistanceXUnit
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
QgsUnitTypes::RenderUnit mDisplacementYUnit
void stopRender(QgsSymbolRenderContext &context) override
Resolves relative paths into absolute paths and vice versa.
Draw map such that there are no problems between adjacent tiles.
void setOpacity(double opacity)
Sets the opacity for the raster image used in the fill.
void startRender(QgsSymbolRenderContext &context) override
void addStopsToGradient(QGradient *gradient, double opacity=1)
Copy color ramp stops to a QGradient.
double distance() const
Returns the distance between lines in the fill pattern.
void stopRender(QgsSymbolRenderContext &context) override
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Fill style (eg solid, dots)
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false)
Returns the specified path rendered as an image.
double displacementY() const
virtual QColor fillColor() const
Gets fill 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...
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 void multiplyImageOpacity(QImage *image, qreal opacity)
Multiplies opacity of image pixel values with a (global) transparency value.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
double width() const
Returns the width used for scaling the image used in the fill.
QgsSVGFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Gradient reference point 2 is centroid.
FillCoordinateMode
Fill coordinate modes, dictates fill tiling behavior.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsShapeburstFillSymbolLayer(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, const QColor &color2=Qt::white, ShapeburstColorType colorType=SimpleTwoColor, int blurRadius=0, bool useWholeShape=true, double maxDistance=5)
QgsMapUnitScale mOffsetMapUnitScale
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
Gradient reference point 2 x.
QgsPropertyCollection mDataDefinedProperties
QgsUnitTypes::RenderUnit mDistanceYUnit
void startRender(QgsSymbolRenderContext &context) override
int geometryPartCount() const
Part count of current geometry.
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
~QgsLinePatternFillSymbolLayer() override
RenderUnit
Rendering size units.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
static QColor decodeColor(const QString &str)
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
QgsMapUnitScale mStrokeWidthMapUnitScale
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QgsLineSymbol * clone() const override
Returns a deep copy of this symbol.
Horizontal distance between points.
QPointF offset() const
Returns the offset for the fill.
virtual QString layerType() const =0
Returns a string that represents this layer type.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
void setColor(const QColor &color)
Sets the color for the symbol.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
Vertical distance between points.
QgsMapUnitScale mOffsetMapUnitScale