36 #include <QSvgRenderer> 37 #include <QDomDocument> 38 #include <QDomElement> 41 Qt::PenJoinStyle penJoinStyle )
42 : mBrushStyle( style )
43 , mStrokeColor( strokeColor )
44 , mStrokeStyle( strokeStyle )
45 , mStrokeWidth( strokeWidth )
46 , mPenJoinStyle( penJoinStyle )
82 void QgsSimpleFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen )
98 if ( exprVal.isValid() )
110 double width = exprVal.toDouble( &ok );
114 pen.setWidthF( width );
115 selPen.setWidthF( width );
151 if ( props.contains( QStringLiteral(
"color" ) ) )
153 if ( props.contains( QStringLiteral(
"style" ) ) )
155 if ( props.contains( QStringLiteral(
"color_border" ) ) )
160 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
164 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
169 if ( props.contains( QStringLiteral(
"style_border" ) ) )
174 else if ( props.contains( QStringLiteral(
"outline_style" ) ) )
178 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
182 if ( props.contains( QStringLiteral(
"width_border" ) ) )
185 strokeWidth = props[QStringLiteral(
"width_border" )].toDouble();
187 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
189 strokeWidth = props[QStringLiteral(
"outline_width" )].toDouble();
191 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
193 strokeWidth = props[QStringLiteral(
"line_width" )].toDouble();
195 if ( props.contains( QStringLiteral(
"offset" ) ) )
197 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
201 sl->setOffset( offset );
202 if ( props.contains( QStringLiteral(
"border_width_unit" ) ) )
206 else if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
210 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
214 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
217 if ( props.contains( QStringLiteral(
"border_width_map_unit_scale" ) ) )
219 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
222 sl->restoreOldDataDefinedProperties( props );
230 return QStringLiteral(
"SimpleFill" );
250 mPen = QPen( strokeColor );
280 p->translate( offset );
287 p->translate( -offset );
298 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
326 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
327 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
328 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
329 element.appendChild( symbolizerElem );
337 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
338 symbolizerElem.appendChild( fillElem );
345 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
346 symbolizerElem.appendChild( strokeElem );
361 symbolStyle.append(
';' );
370 Qt::BrushStyle fillStyle;
374 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
377 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
383 QString uom = element.attribute( QStringLiteral(
"uom" ), QString() );
389 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
390 sl->setOffset( offset );
398 return penBleed + offsetBleed;
459 : mGradientColorType( colorType )
460 , mGradientType( gradientType )
461 , mCoordinateMode( coordinateMode )
462 , mGradientSpread( spread )
463 , mReferencePoint1( QPointF( 0.5, 0 ) )
464 , mReferencePoint2( QPointF( 0.5, 1 ) )
485 bool refPoint1IsCentroid =
false;
487 bool refPoint2IsCentroid =
false;
492 if ( props.contains( QStringLiteral(
"type" ) ) )
493 type = static_cast< GradientType >( props[QStringLiteral(
"type" )].toInt() );
494 if ( props.contains( QStringLiteral(
"coordinate_mode" ) ) )
495 coordinateMode = static_cast< GradientCoordinateMode >( props[QStringLiteral(
"coordinate_mode" )].toInt() );
496 if ( props.contains( QStringLiteral(
"spread" ) ) )
497 gradientSpread = static_cast< GradientSpread >( props[QStringLiteral(
"spread" )].toInt() );
498 if ( props.contains( QStringLiteral(
"color_type" ) ) )
499 colorType = static_cast< GradientColorType >( props[QStringLiteral(
"color_type" )].toInt() );
500 if ( props.contains( QStringLiteral(
"gradient_color" ) ) )
505 else if ( props.contains( QStringLiteral(
"color" ) ) )
509 if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
514 if ( props.contains( QStringLiteral(
"reference_point1" ) ) )
516 if ( props.contains( QStringLiteral(
"reference_point1_iscentroid" ) ) )
517 refPoint1IsCentroid = props[QStringLiteral(
"reference_point1_iscentroid" )].toInt();
518 if ( props.contains( QStringLiteral(
"reference_point2" ) ) )
520 if ( props.contains( QStringLiteral(
"reference_point2_iscentroid" ) ) )
521 refPoint2IsCentroid = props[QStringLiteral(
"reference_point2_iscentroid" )].toInt();
522 if ( props.contains( QStringLiteral(
"angle" ) ) )
523 angle = props[QStringLiteral(
"angle" )].toDouble();
525 if ( props.contains( QStringLiteral(
"offset" ) ) )
530 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
541 sl->setOffset( offset );
542 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
544 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
546 sl->setReferencePoint1( referencePoint1 );
547 sl->setReferencePoint1IsCentroid( refPoint1IsCentroid );
548 sl->setReferencePoint2( referencePoint2 );
549 sl->setReferencePoint2IsCentroid( refPoint2IsCentroid );
550 sl->setAngle( angle );
552 sl->setColorRamp( gradientRamp );
554 sl->restoreOldDataDefinedProperties( props );
567 return QStringLiteral(
"GradientFill" );
570 void QgsGradientFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context,
const QPolygonF &points )
613 if ( currentType == QObject::tr(
"linear" ) )
617 else if ( currentType == QObject::tr(
"radial" ) )
621 else if ( currentType == QObject::tr(
"conical" ) )
635 if ( currentCoordMode == QObject::tr(
"feature" ) )
639 else if ( currentCoordMode == QObject::tr(
"viewport" ) )
653 if ( currentSpread == QObject::tr(
"pad" ) )
657 else if ( currentSpread == QObject::tr(
"repeat" ) )
661 else if ( currentSpread == QObject::tr(
"reflect" ) )
708 if ( refPoint1IsCentroid || refPoint2IsCentroid )
713 QRectF bbox = points.boundingRect();
714 double centroidX = ( centroid.x() - bbox.left() ) / bbox.width();
715 double centroidY = ( centroid.y() - bbox.top() ) / bbox.height();
717 if ( refPoint1IsCentroid )
719 refPoint1X = centroidX;
720 refPoint1Y = centroidY;
722 if ( refPoint2IsCentroid )
724 refPoint2X = centroidX;
725 refPoint2Y = centroidY;
731 spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ), angle );
734 QPointF QgsGradientFillSymbolLayer::rotateReferencePoint( QPointF refPoint,
double angle )
739 QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
741 refLine.setAngle( refLine.angle() +
angle );
743 QPointF rotatedReferencePoint = refLine.p2();
745 if ( rotatedReferencePoint.x() > 1 )
746 rotatedReferencePoint.setX( 1 );
747 if ( rotatedReferencePoint.x() < 0 )
748 rotatedReferencePoint.setX( 0 );
749 if ( rotatedReferencePoint.y() > 1 )
750 rotatedReferencePoint.setY( 1 );
751 if ( rotatedReferencePoint.y() < 0 )
752 rotatedReferencePoint.setY( 0 );
754 return rotatedReferencePoint;
765 fillColor.setAlphaF( context.
opacity() * fillColor.alphaF() );
766 QColor fillColor2 =
color2;
767 fillColor2.setAlphaF( context.
opacity() * fillColor2.alphaF() );
778 gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
781 gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
784 gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
790 gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
793 gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
799 gradient.setSpread( QGradient::PadSpread );
802 gradient.setSpread( QGradient::ReflectSpread );
805 gradient.setSpread( QGradient::RepeatSpread );
811 ( gradientRamp->
type() == QLatin1String(
"gradient" ) || gradientRamp->
type() == QLatin1String(
"cpt-city" ) ) )
820 gradient.setColorAt( 0.0, fillColor );
821 gradient.setColorAt( 1.0, fillColor2 );
825 brush = QBrush( gradient );
832 selColor.setAlphaF( context.
opacity() );
849 applyDataDefinedSymbology( context, points );
852 p->setPen( Qt::NoPen );
859 p->translate( offset );
866 p->translate( -offset );
876 map[QStringLiteral(
"type" )] = QString::number(
mGradientType );
877 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
mCoordinateMode );
883 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
941 int blurRadius,
bool useWholeShape,
double maxDistance )
942 : mBlurRadius( blurRadius )
943 , mUseWholeShape( useWholeShape )
944 , mMaxDistance( maxDistance )
945 , mColorType( colorType )
964 if ( props.contains( QStringLiteral(
"color_type" ) ) )
966 colorType =
static_cast< ShapeburstColorType >( props[QStringLiteral(
"color_type" )].toInt() );
968 if ( props.contains( QStringLiteral(
"shapeburst_color" ) ) )
973 else if ( props.contains( QStringLiteral(
"color" ) ) )
978 if ( props.contains( QStringLiteral(
"shapeburst_color2" ) ) )
983 else if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
987 if ( props.contains( QStringLiteral(
"blur_radius" ) ) )
989 blurRadius = props[QStringLiteral(
"blur_radius" )].toInt();
991 if ( props.contains( QStringLiteral(
"use_whole_shape" ) ) )
993 useWholeShape = props[QStringLiteral(
"use_whole_shape" )].toInt();
995 if ( props.contains( QStringLiteral(
"max_distance" ) ) )
997 maxDistance = props[QStringLiteral(
"max_distance" )].toDouble();
999 if ( props.contains( QStringLiteral(
"offset" ) ) )
1006 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
1017 sl->setOffset( offset );
1018 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1022 if ( props.contains( QStringLiteral(
"distance_unit" ) ) )
1026 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1030 if ( props.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
1034 if ( props.contains( QStringLiteral(
"ignore_rings" ) ) )
1036 sl->setIgnoreRings( props[QStringLiteral(
"ignore_rings" )].toInt() );
1040 sl->setColorRamp( gradientRamp );
1043 sl->restoreOldDataDefinedProperties( props );
1045 return sl.release();
1050 return QStringLiteral(
"ShapeburstFill" );
1055 if ( mGradientRamp.get() == ramp )
1058 mGradientRamp.reset( ramp );
1105 ignoreRings = mIgnoreRings;
1119 selColor.setAlphaF( context.
opacity() );
1120 mSelBrush = QBrush( selColor );
1139 p->setBrush( mSelBrush );
1141 if ( !mOffset.isNull() )
1145 p->translate( offset );
1148 if ( !mOffset.isNull() )
1150 p->translate( -offset );
1161 applyDataDefinedSymbology( context, color1, color2, blurRadius, useWholeShape, maxDistance, ignoreRings );
1164 int outputPixelMaxDist = 0;
1172 std::unique_ptr< QgsGradientColorRamp > twoColorGradientRamp;
1175 twoColorGradientRamp = qgis::make_unique< QgsGradientColorRamp >( color1,
color2 );
1179 p->setPen( QPen( Qt::NoPen ) );
1182 int sideBuffer = 4 + ( blurRadius + 2 ) * 4;
1184 int pointsWidth =
static_cast< int >( std::round( points.boundingRect().width() ) );
1185 int pointsHeight =
static_cast< int >( std::round( points.boundingRect().height() ) );
1186 int imWidth = pointsWidth + ( sideBuffer * 2 );
1187 int imHeight = pointsHeight + ( sideBuffer * 2 );
1188 std::unique_ptr< QImage > fillImage = qgis::make_unique< QImage >( imWidth,
1189 imHeight, QImage::Format_ARGB32_Premultiplied );
1190 if ( fillImage->isNull() )
1197 std::unique_ptr< QImage > alphaImage = qgis::make_unique< QImage >( fillImage->width(), fillImage->height(), QImage::Format_ARGB32_Premultiplied );
1198 if ( alphaImage->isNull() )
1207 fillImage->fill( Qt::black );
1210 alphaImage->fill( Qt::transparent );
1213 QPainter imgPainter;
1214 imgPainter.begin( alphaImage.get() );
1215 imgPainter.setRenderHint( QPainter::Antialiasing,
true );
1216 imgPainter.setBrush( QBrush( Qt::white ) );
1217 imgPainter.setPen( QPen( Qt::black ) );
1218 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1224 imgPainter.begin( fillImage.get() );
1227 imgPainter.drawImage( 0, 0, *alphaImage );
1234 imgPainter.setBrush( QBrush( Qt::white ) );
1235 imgPainter.setPen( QPen( Qt::black ) );
1236 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1242 double *dtArray = distanceTransform( fillImage.get(), context.
renderContext() );
1252 if ( blurRadius > 0 )
1258 imgPainter.begin( fillImage.get() );
1259 imgPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
1260 imgPainter.drawImage( 0, 0, *alphaImage );
1269 if ( !mOffset.isNull() )
1273 p->translate( offset );
1276 p->drawImage( points.boundingRect().left() - sideBuffer, points.boundingRect().top() - sideBuffer, *fillImage );
1278 if ( !mOffset.isNull() )
1280 p->translate( -offset );
1289 void QgsShapeburstFillSymbolLayer::distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d )
1295 for (
int q = 1; q <= n - 1; q++ )
1297 double s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1301 s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1310 for (
int q = 0; q <= n - 1; q++ )
1312 while ( z[k + 1] < q )
1314 d[q] = ( q - v[k] ) * ( q - v[k] ) + f[v[k]];
1319 void QgsShapeburstFillSymbolLayer::distanceTransform2d(
double *im,
int width,
int height,
QgsRenderContext &context )
1321 int maxDimension = std::max( width, height );
1322 double *f =
new double[ maxDimension ];
1323 int *v =
new int[ maxDimension ];
1324 double *z =
new double[ maxDimension + 1 ];
1325 double *d =
new double[ maxDimension ];
1328 for (
int x = 0; x < width; x++ )
1333 for (
int y = 0; y < height; y++ )
1335 f[y] = im[ x + y * width ];
1337 distanceTransform1d( f, height, v, z, d );
1338 for (
int y = 0; y < height; y++ )
1340 im[ x + y * width ] = d[y];
1345 for (
int y = 0; y < height; y++ )
1350 for (
int x = 0; x < width; x++ )
1352 f[x] = im[ x + y * width ];
1354 distanceTransform1d( f, width, v, z, d );
1355 for (
int x = 0; x < width; x++ )
1357 im[ x + y * width ] = d[x];
1368 double *QgsShapeburstFillSymbolLayer::distanceTransform( QImage *im,
QgsRenderContext &context )
1370 int width = im->width();
1371 int height = im->height();
1373 double *dtArray =
new double[width * height];
1378 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1383 const QRgb *scanLine =
reinterpret_cast< const QRgb *
>( im->constScanLine( heightIndex ) );
1384 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1386 tmpRgb = scanLine[widthIndex];
1387 if ( qRed( tmpRgb ) == 0 )
1395 dtArray[ idx ] =
INF;
1402 distanceTransform2d( dtArray, width, height, context );
1409 int width = im->width();
1410 int height = im->height();
1413 double maxDistanceValue;
1418 double dtMaxValue = array[0];
1419 for (
int i = 1; i < ( width * height ); ++i )
1421 if ( array[i] > dtMaxValue )
1423 dtMaxValue = array[i];
1428 maxDistanceValue = std::sqrt( dtMaxValue );
1433 maxDistanceValue = maxPixelDistance;
1438 double squaredVal = 0;
1441 bool layerHasAlpha = layerAlpha < 1.0;
1443 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1448 QRgb *scanLine =
reinterpret_cast< QRgb *
>( im->scanLine( heightIndex ) );
1449 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1452 squaredVal = array[idx];
1455 if ( maxDistanceValue > 0 )
1457 pixVal = squaredVal > 0 ? std::min( ( std::sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1465 pixColor = ramp->
color( pixVal );
1467 int pixAlpha = pixColor.alpha();
1468 if ( ( layerHasAlpha ) || ( pixAlpha != 255 ) )
1471 double alpha = pixAlpha * layerAlpha;
1476 scanLine[widthIndex] = pixColor.rgba();
1487 map[QStringLiteral(
"color_type" )] = QString::number( mColorType );
1488 map[QStringLiteral(
"blur_radius" )] = QString::number( mBlurRadius );
1489 map[QStringLiteral(
"use_whole_shape" )] = QString::number( mUseWholeShape );
1490 map[QStringLiteral(
"max_distance" )] = QString::number( mMaxDistance );
1493 map[QStringLiteral(
"ignore_rings" )] = QString::number( mIgnoreRings );
1497 if ( mGradientRamp )
1499 map.unite( mGradientRamp->properties() );
1507 std::unique_ptr< QgsShapeburstFillSymbolLayer > sl = qgis::make_unique< QgsShapeburstFillSymbolLayer >(
mColor, mColor2, mColorType, mBlurRadius, mUseWholeShape, mMaxDistance );
1508 if ( mGradientRamp )
1512 sl->setDistanceUnit( mDistanceUnit );
1513 sl->setDistanceMapUnitScale( mDistanceMapUnitScale );
1514 sl->setIgnoreRings( mIgnoreRings );
1515 sl->setOffset( mOffset );
1516 sl->setOffsetUnit( mOffsetUnit );
1517 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
1520 return sl.release();
1525 double offsetBleed = context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
1531 mDistanceUnit = unit;
1537 if ( mDistanceUnit == mOffsetUnit )
1539 return mDistanceUnit;
1546 mDistanceMapUnitScale = scale;
1547 mOffsetMapUnitScale = scale;
1552 if ( mDistanceMapUnitScale == mOffsetMapUnitScale )
1554 return mDistanceMapUnitScale;
1576 applyDataDefinedSettings( context );
1578 p->setPen( QPen( Qt::NoPen ) );
1580 QTransform bkTransform = mBrush.transform();
1584 QPointF leftCorner = points.boundingRect().topLeft();
1585 QTransform t = mBrush.transform();
1586 t.translate( leftCorner.x(), leftCorner.y() );
1587 mBrush.setTransform( t );
1596 p->setBrush( QBrush( selColor ) );
1602 QTransform t = mBrush.transform();
1603 t.rotate( mNextAngle );
1604 mBrush.setTransform( t );
1606 p->setBrush( mBrush );
1613 QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
1614 for ( ; ringIt != rings->constEnd(); ++ringIt )
1621 mBrush.setTransform( bkTransform );
1628 mStroke.reset(
nullptr );
1641 mStroke.reset( lineSymbol );
1651 mStrokeWidthUnit = unit;
1656 return mStrokeWidthUnit;
1661 mStrokeWidthMapUnitScale = scale;
1666 return mStrokeWidthMapUnitScale;
1671 if ( mStroke && mStroke->symbolLayer( 0 ) )
1673 double subLayerBleed = mStroke->symbolLayer( 0 )->estimateMaxBleed( context );
1674 return subLayerBleed;
1681 double width = mStrokeWidth;
1695 return QColor( Qt::black );
1697 return mStroke->color();
1702 return Qt::SolidLine;
1706 return Qt::SolidLine;
1710 return mStroke->dxfPenStyle();
1719 attr.unite( mStroke->usedAttributes( context ) );
1727 if ( mStroke && mStroke->hasDataDefinedProperties() )
1737 , mPatternWidth( width )
1741 mColor = QColor( 255, 255, 255 );
1747 , mPatternWidth( width )
1748 , mSvgData( svgData )
1753 mColor = QColor( 255, 255, 255 );
1755 setDefaultSvgParams();
1761 mPatternWidthUnit = unit;
1762 mSvgStrokeWidthUnit = unit;
1764 mStroke->setOutputUnit( unit );
1770 if ( mPatternWidthUnit != unit || mSvgStrokeWidthUnit != unit ||
mStrokeWidthUnit != unit )
1780 mPatternWidthMapUnitScale = scale;
1781 mSvgStrokeWidthMapUnitScale = scale;
1788 mPatternWidthMapUnitScale == mSvgStrokeWidthMapUnitScale &&
1791 return mPatternWidthMapUnitScale;
1801 mSvgFilePath = svgPath;
1802 setDefaultSvgParams();
1812 if ( properties.contains( QStringLiteral(
"width" ) ) )
1814 width = properties[QStringLiteral(
"width" )].toDouble();
1816 if ( properties.contains( QStringLiteral(
"svgFile" ) ) )
1818 svgFilePath = properties[QStringLiteral(
"svgFile" )];
1820 if ( properties.contains( QStringLiteral(
"angle" ) ) )
1822 angle = properties[QStringLiteral(
"angle" )].toDouble();
1825 std::unique_ptr< QgsSVGFillSymbolLayer > symbolLayer;
1826 if ( !svgFilePath.isEmpty() )
1828 symbolLayer = qgis::make_unique< QgsSVGFillSymbolLayer >(
svgFilePath, width,
angle );
1832 if ( properties.contains( QStringLiteral(
"data" ) ) )
1834 data = QByteArray::fromHex( properties[QStringLiteral(
"data" )].toLocal8Bit() );
1836 symbolLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( data, width,
angle );
1840 if ( properties.contains( QStringLiteral(
"svgFillColor" ) ) )
1845 else if ( properties.contains( QStringLiteral(
"color" ) ) )
1849 if ( properties.contains( QStringLiteral(
"svgOutlineColor" ) ) )
1854 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
1858 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
1862 if ( properties.contains( QStringLiteral(
"svgOutlineWidth" ) ) )
1865 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"svgOutlineWidth" )].toDouble() );
1867 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
1869 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"outline_width" )].toDouble() );
1871 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
1873 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"line_width" )].toDouble() );
1877 if ( properties.contains( QStringLiteral(
"pattern_width_unit" ) ) )
1881 if ( properties.contains( QStringLiteral(
"pattern_width_map_unit_scale" ) ) )
1885 if ( properties.contains( QStringLiteral(
"svg_outline_width_unit" ) ) )
1889 if ( properties.contains( QStringLiteral(
"svg_outline_width_map_unit_scale" ) ) )
1893 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
1897 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1902 symbolLayer->restoreOldDataDefinedProperties( properties );
1904 return symbolLayer.release();
1909 QgsStringMap::iterator it = properties.find( QStringLiteral(
"svgFile" ) );
1910 if ( it != properties.end() )
1921 return QStringLiteral(
"SVGFill" );
1929 if ( mSvgViewBox.isNull() )
1936 if ( static_cast< int >( size ) < 1.0 || 10000.0 < size )
1938 brush.setTextureImage( QImage() );
1942 bool fitsInCache =
true;
1950 double hwRatio = 1.0;
1951 if ( patternPict.width() > 0 )
1953 hwRatio =
static_cast< double >( patternPict.height() ) / static_cast< double >( patternPict.width() );
1955 patternImage = QImage( static_cast< int >( size ), static_cast< int >( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
1956 patternImage.fill( 0 );
1958 QPainter p( &patternImage );
1959 p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
1962 QTransform brushTransform;
1965 QImage transparentImage = patternImage.copy();
1967 brush.setTextureImage( transparentImage );
1971 brush.setTextureImage( patternImage );
1973 brush.setTransform( brushTransform );
1980 applyPattern(
mBrush, mSvgFilePath, mPatternWidth, mPatternWidthUnit,
mColor, mSvgStrokeColor, mSvgStrokeWidth, mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale );
1999 if ( !mSvgFilePath.isEmpty() )
2001 map.insert( QStringLiteral(
"svgFile" ), mSvgFilePath );
2005 map.insert( QStringLiteral(
"data" ), QString( mSvgData.toHex() ) );
2008 map.insert( QStringLiteral(
"width" ), QString::number( mPatternWidth ) );
2009 map.insert( QStringLiteral(
"angle" ), QString::number(
mAngle ) );
2014 map.insert( QStringLiteral(
"outline_width" ), QString::number( mSvgStrokeWidth ) );
2028 std::unique_ptr< QgsSVGFillSymbolLayer > clonedLayer;
2029 if ( !mSvgFilePath.isEmpty() )
2031 clonedLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( mSvgFilePath, mPatternWidth,
mAngle );
2033 clonedLayer->setSvgStrokeColor( mSvgStrokeColor );
2034 clonedLayer->setSvgStrokeWidth( mSvgStrokeWidth );
2038 clonedLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( mSvgData, mPatternWidth,
mAngle );
2041 clonedLayer->setPatternWidthUnit( mPatternWidthUnit );
2042 clonedLayer->setPatternWidthMapUnitScale( mPatternWidthMapUnitScale );
2043 clonedLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnit );
2044 clonedLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthMapUnitScale );
2050 clonedLayer->setSubSymbol(
mStroke->clone() );
2054 return clonedLayer.release();
2059 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2060 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
2061 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
2062 element.appendChild( symbolizerElem );
2066 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2067 symbolizerElem.appendChild( fillElem );
2069 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2070 fillElem.appendChild( graphicFillElem );
2072 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2073 graphicFillElem.appendChild( graphicElem );
2075 if ( !mSvgFilePath.isEmpty() )
2086 symbolizerElem.appendChild( doc.createComment( QStringLiteral(
"SVG from data not implemented yet" ) ) );
2092 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2095 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2099 angleFunc = QString::number( angle +
mAngle );
2108 mStroke->toSld( doc, element, props );
2114 QString path, mimeType;
2116 Qt::PenStyle penStyle;
2117 double size, strokeWidth;
2119 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2120 if ( fillElem.isNull() )
2123 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2124 if ( graphicFillElem.isNull() )
2127 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2128 if ( graphicElem.isNull() )
2134 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2139 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2148 double d = angleFunc.toDouble( &ok );
2153 std::unique_ptr< QgsSVGFillSymbolLayer > sl = qgis::make_unique< QgsSVGFillSymbolLayer >( path, size,
angle );
2154 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2155 sl->setSvgFillColor( fillColor );
2156 sl->setSvgStrokeColor( strokeColor );
2157 sl->setSvgStrokeWidth( strokeWidth );
2160 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2161 if ( !strokeElem.isNull() )
2172 return sl.release();
2190 double width = mPatternWidth;
2196 QString svgFile = mSvgFilePath;
2215 double strokeWidth = mSvgStrokeWidth;
2221 applyPattern(
mBrush, svgFile, width, mPatternWidthUnit, svgFillColor, svgStrokeColor, strokeWidth,
2222 mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale );
2226 void QgsSVGFillSymbolLayer::storeViewBox()
2228 if ( !mSvgData.isEmpty() )
2230 QSvgRenderer r( mSvgData );
2233 mSvgViewBox = r.viewBoxF();
2238 mSvgViewBox = QRectF();
2241 void QgsSVGFillSymbolLayer::setDefaultSvgParams()
2243 if ( mSvgFilePath.isEmpty() )
2248 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2249 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2250 QColor defaultFillColor, defaultStrokeColor;
2251 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2253 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2254 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2255 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2256 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2258 double newFillOpacity = hasFillOpacityParam ?
mColor.alphaF() : 1.0;
2259 double newStrokeOpacity = hasStrokeOpacityParam ? mSvgStrokeColor.alphaF() : 1.0;
2261 if ( hasDefaultFillColor )
2263 mColor = defaultFillColor;
2264 mColor.setAlphaF( newFillOpacity );
2266 if ( hasDefaultFillOpacity )
2268 mColor.setAlphaF( defaultFillOpacity );
2270 if ( hasDefaultStrokeColor )
2272 mSvgStrokeColor = defaultStrokeColor;
2273 mSvgStrokeColor.setAlphaF( newStrokeOpacity );
2275 if ( hasDefaultStrokeOpacity )
2277 mSvgStrokeColor.setAlphaF( defaultStrokeOpacity );
2279 if ( hasDefaultStrokeWidth )
2281 mSvgStrokeWidth = defaultStrokeWidth;
2307 return mFillLineSymbol ? mFillLineSymbol->
color() :
mColor;
2312 delete mFillLineSymbol;
2327 delete mFillLineSymbol;
2328 mFillLineSymbol = lineSymbol;
2339 return mFillLineSymbol;
2345 if ( mFillLineSymbol )
2367 mDistanceUnit = unit;
2368 mLineWidthUnit = unit;
2375 if ( mDistanceUnit != unit || mLineWidthUnit != unit || mOffsetUnit != unit )
2385 mDistanceMapUnitScale = scale;
2386 mLineWidthMapUnitScale = scale;
2387 mOffsetMapUnitScale = scale;
2393 mDistanceMapUnitScale == mLineWidthMapUnitScale &&
2394 mLineWidthMapUnitScale == mOffsetMapUnitScale )
2396 return mDistanceMapUnitScale;
2403 std::unique_ptr< QgsLinePatternFillSymbolLayer > patternLayer = qgis::make_unique< QgsLinePatternFillSymbolLayer >();
2409 QColor
color( Qt::black );
2412 if ( properties.contains( QStringLiteral(
"lineangle" ) ) )
2415 lineAngle = properties[QStringLiteral(
"lineangle" )].toDouble();
2417 else if ( properties.contains( QStringLiteral(
"angle" ) ) )
2419 lineAngle = properties[QStringLiteral(
"angle" )].toDouble();
2421 patternLayer->setLineAngle( lineAngle );
2423 if ( properties.contains( QStringLiteral(
"distance" ) ) )
2425 distance = properties[QStringLiteral(
"distance" )].toDouble();
2427 patternLayer->setDistance( distance );
2429 if ( properties.contains( QStringLiteral(
"linewidth" ) ) )
2432 lineWidth = properties[QStringLiteral(
"linewidth" )].toDouble();
2434 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
2436 lineWidth = properties[QStringLiteral(
"outline_width" )].toDouble();
2438 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
2440 lineWidth = properties[QStringLiteral(
"line_width" )].toDouble();
2442 patternLayer->setLineWidth( lineWidth );
2444 if ( properties.contains( QStringLiteral(
"color" ) ) )
2448 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
2452 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
2456 patternLayer->setColor( color );
2458 if ( properties.contains( QStringLiteral(
"offset" ) ) )
2460 offset = properties[QStringLiteral(
"offset" )].toDouble();
2462 patternLayer->setOffset( offset );
2465 if ( properties.contains( QStringLiteral(
"distance_unit" ) ) )
2469 if ( properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
2473 if ( properties.contains( QStringLiteral(
"line_width_unit" ) ) )
2477 else if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2481 if ( properties.contains( QStringLiteral(
"line_width_map_unit_scale" ) ) )
2485 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
2489 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2493 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2497 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2502 patternLayer->restoreOldDataDefinedProperties( properties );
2504 return patternLayer.release();
2509 return QStringLiteral(
"LinePatternFill" );
2514 mBrush.setTextureImage( QImage() );
2516 if ( !mFillLineSymbol )
2521 std::unique_ptr< QgsLineSymbol > fillLineSymbol( mFillLineSymbol->
clone() );
2522 if ( !fillLineSymbol )
2529 double outputPixelDist = ctx.
convertToPainterUnits( distance, mDistanceUnit, mDistanceMapUnitScale );
2537 outputPixelOffset = std::fmod( outputPixelOffset, outputPixelDist );
2538 if ( outputPixelOffset > outputPixelDist / 2.0 )
2539 outputPixelOffset -= outputPixelDist;
2543 double outputPixelBleed = 0;
2544 double outputPixelInterval = 0;
2545 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2549 outputPixelBleed = std::max( outputPixelBleed, outputPixelLayerBleed );
2552 if ( markerLineLayer )
2561 outputPixelInterval = std::max( outputPixelInterval, outputPixelLayerInterval );
2565 if ( outputPixelInterval > 0 )
2569 double intervalScale = std::round( outputPixelInterval ) / outputPixelInterval;
2570 outputPixelInterval = std::round( outputPixelInterval );
2572 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2577 if ( markerLineLayer )
2591 height = outputPixelDist;
2592 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2596 width = outputPixelDist;
2597 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2601 height = outputPixelDist / std::cos(
lineAngle * M_PI / 180 );
2602 width = outputPixelDist / std::sin(
lineAngle * M_PI / 180 );
2605 lineAngle = 180 * std::atan2( static_cast< double >( height ), static_cast< double >( width ) ) / M_PI;
2611 height = std::abs( height );
2612 width = std::abs( width );
2614 outputPixelDist = std::abs( height * std::cos(
lineAngle * M_PI / 180 ) );
2618 int offsetHeight =
static_cast< int >( std::round( outputPixelOffset / std::cos(
lineAngle * M_PI / 180 ) ) );
2619 outputPixelOffset = offsetHeight * std::cos(
lineAngle * M_PI / 180 );
2628 int bufferMulti =
static_cast< int >( std::max( std::ceil( outputPixelBleed / width ), std::ceil( outputPixelBleed / width ) ) );
2632 bufferMulti = std::max( bufferMulti, 1 );
2634 int xBuffer = width * bufferMulti;
2635 int yBuffer = height * bufferMulti;
2636 int innerWidth = width;
2637 int innerHeight = height;
2638 width += 2 * xBuffer;
2639 height += 2 * yBuffer;
2642 if ( width > 10000 || height > 10000 || width == 0 || height == 0 )
2647 QImage patternImage( width, height, QImage::Format_ARGB32 );
2648 patternImage.fill( 0 );
2650 QPointF p1, p2, p3, p4, p5, p6;
2653 p1 = QPointF( 0, yBuffer );
2654 p2 = QPointF( width, yBuffer );
2655 p3 = QPointF( 0, yBuffer + innerHeight );
2656 p4 = QPointF( width, yBuffer + innerHeight );
2660 p1 = QPointF( xBuffer, height );
2661 p2 = QPointF( xBuffer, 0 );
2662 p3 = QPointF( xBuffer + innerWidth, height );
2663 p4 = QPointF( xBuffer + innerWidth, 0 );
2667 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2668 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2669 p1 = QPointF( 0, height );
2670 p2 = QPointF( width, 0 );
2671 p3 = QPointF( -dx, height - dy );
2672 p4 = QPointF( width - dx, -dy );
2673 p5 = QPointF( dx, height + dy );
2674 p6 = QPointF( width + dx, dy );
2678 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2679 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2680 p1 = QPointF( width, 0 );
2681 p2 = QPointF( 0, height );
2682 p3 = QPointF( width - dx, -dy );
2683 p4 = QPointF( -dx, height - dy );
2684 p5 = QPointF( width + dx, dy );
2685 p6 = QPointF( dx, height + dy );
2689 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2690 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2691 p1 = QPointF( 0, 0 );
2692 p2 = QPointF( width, height );
2693 p5 = QPointF( dx, -dy );
2694 p6 = QPointF( width + dx, height - dy );
2695 p3 = QPointF( -dx, dy );
2696 p4 = QPointF( width - dx, height + dy );
2700 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2701 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2702 p1 = QPointF( width, height );
2703 p2 = QPointF( 0, 0 );
2704 p5 = QPointF( width + dx, height - dy );
2705 p6 = QPointF( dx, -dy );
2706 p3 = QPointF( width - dx, height + dy );
2707 p4 = QPointF( -dx, dy );
2714 p3 = QPointF( tempPt.x(), tempPt.y() );
2716 p4 = QPointF( tempPt.x(), tempPt.y() );
2718 p5 = QPointF( tempPt.x(), tempPt.y() );
2720 p6 = QPointF( tempPt.x(), tempPt.y() );
2724 p1 = QPointF( tempPt.x(), tempPt.y() );
2726 p2 = QPointF( tempPt.x(), tempPt.y() );
2729 QPainter p( &patternImage );
2733 p.setRenderHint( QPainter::Antialiasing,
false );
2734 QPen pen( QColor( Qt::black ) );
2735 pen.setWidthF( 0.1 );
2736 pen.setCapStyle( Qt::FlatCap );
2741 QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 );
2742 p.drawPolygon( polygon );
2744 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 );
2745 p.drawPolygon( polygon );
2751 p.setRenderHint( QPainter::Antialiasing,
true );
2762 fillLineSymbol->startRender( lineRenderContext, context.
fields() );
2764 QVector<QPolygonF> polygons;
2765 polygons.append( QPolygonF() << p1 << p2 );
2766 polygons.append( QPolygonF() << p3 << p4 );
2769 polygons.append( QPolygonF() << p5 << p6 );
2772 for (
const QPolygonF &polygon : qgis::as_const( polygons ) )
2774 fillLineSymbol->renderPolyline( polygon, context.
feature(), lineRenderContext, -1, context.
selected() );
2777 fillLineSymbol->stopRender( lineRenderContext );
2781 patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
2786 QImage transparentImage = patternImage.copy();
2788 brush.setTextureImage( transparentImage );
2792 brush.setTextureImage( patternImage );
2795 QTransform brushTransform;
2796 brush.setTransform( brushTransform );
2801 applyPattern( context,
mBrush, mLineAngle, mDistance );
2803 if ( mFillLineSymbol )
2811 if ( mFillLineSymbol )
2820 map.insert( QStringLiteral(
"angle" ), QString::number( mLineAngle ) );
2821 map.insert( QStringLiteral(
"distance" ), QString::number( mDistance ) );
2822 map.insert( QStringLiteral(
"line_width" ), QString::number( mLineWidth ) );
2824 map.insert( QStringLiteral(
"offset" ), QString::number( mOffset ) );
2839 if ( mFillLineSymbol )
2850 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2851 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
2852 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
2853 element.appendChild( symbolizerElem );
2858 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2859 symbolizerElem.appendChild( fillElem );
2861 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2862 fillElem.appendChild( graphicFillElem );
2864 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2865 graphicFillElem.appendChild( graphicElem );
2868 QColor lineColor = mFillLineSymbol ? mFillLineSymbol->
color() : QColor();
2869 double lineWidth = mFillLineSymbol ? mFillLineSymbol->
width() : 0.0;
2877 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2880 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg( mLineAngle );
2884 angleFunc = QString::number( angle + mLineAngle );
2889 QPointF lineOffset( std::sin( mLineAngle ) * mOffset, std::cos( mLineAngle ) * mOffset );
2896 QString featureStyle;
2897 featureStyle.append(
"Brush(" );
2898 featureStyle.append( QStringLiteral(
"fc:%1" ).arg(
mColor.name() ) );
2899 featureStyle.append( QStringLiteral(
",bc:%1" ).arg( QStringLiteral(
"#00000000" ) ) );
2900 featureStyle.append(
",id:\"ogr-brush-2\"" );
2901 featureStyle.append( QStringLiteral(
",a:%1" ).arg( mLineAngle ) );
2902 featureStyle.append( QStringLiteral(
",s:%1" ).arg( mLineWidth * widthScaleFactor ) );
2903 featureStyle.append(
",dx:0mm" );
2904 featureStyle.append( QStringLiteral(
",dy:%1mm" ).arg( mDistance * widthScaleFactor ) );
2905 featureStyle.append(
')' );
2906 return featureStyle;
2929 applyPattern( context,
mBrush, lineAngle, distance );
2937 Qt::PenStyle lineStyle;
2939 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2940 if ( fillElem.isNull() )
2943 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2944 if ( graphicFillElem.isNull() )
2947 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2948 if ( graphicElem.isNull() )
2954 if ( name != QLatin1String(
"horline" ) )
2962 double d = angleFunc.toDouble( &ok );
2971 offset = std::sqrt( std::pow( vectOffset.x(), 2 ) + std::pow( vectOffset.y(), 2 ) );
2974 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2978 std::unique_ptr< QgsLinePatternFillSymbolLayer > sl = qgis::make_unique< QgsLinePatternFillSymbolLayer >();
2979 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2980 sl->setColor( lineColor );
2981 sl->setLineWidth( lineWidth );
2982 sl->setLineAngle( angle );
2983 sl->setOffset( offset );
2984 sl->setDistance( size );
2987 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2988 if ( !strokeElem.isNull() )
2999 return sl.release();
3076 std::unique_ptr< QgsPointPatternFillSymbolLayer > layer = qgis::make_unique< QgsPointPatternFillSymbolLayer >();
3077 if ( properties.contains( QStringLiteral(
"distance_x" ) ) )
3079 layer->setDistanceX( properties[QStringLiteral(
"distance_x" )].toDouble() );
3081 if ( properties.contains( QStringLiteral(
"distance_y" ) ) )
3083 layer->setDistanceY( properties[QStringLiteral(
"distance_y" )].toDouble() );
3085 if ( properties.contains( QStringLiteral(
"displacement_x" ) ) )
3087 layer->setDisplacementX( properties[QStringLiteral(
"displacement_x" )].toDouble() );
3089 if ( properties.contains( QStringLiteral(
"displacement_y" ) ) )
3091 layer->setDisplacementY( properties[QStringLiteral(
"displacement_y" )].toDouble() );
3093 if ( properties.contains( QStringLiteral(
"offset_x" ) ) )
3095 layer->setOffsetX( properties[QStringLiteral(
"offset_x" )].toDouble() );
3097 if ( properties.contains( QStringLiteral(
"offset_y" ) ) )
3099 layer->setOffsetY( properties[QStringLiteral(
"offset_y" )].toDouble() );
3102 if ( properties.contains( QStringLiteral(
"distance_x_unit" ) ) )
3106 if ( properties.contains( QStringLiteral(
"distance_x_map_unit_scale" ) ) )
3110 if ( properties.contains( QStringLiteral(
"distance_y_unit" ) ) )
3114 if ( properties.contains( QStringLiteral(
"distance_y_map_unit_scale" ) ) )
3118 if ( properties.contains( QStringLiteral(
"displacement_x_unit" ) ) )
3122 if ( properties.contains( QStringLiteral(
"displacement_x_map_unit_scale" ) ) )
3126 if ( properties.contains( QStringLiteral(
"displacement_y_unit" ) ) )
3130 if ( properties.contains( QStringLiteral(
"displacement_y_map_unit_scale" ) ) )
3134 if ( properties.contains( QStringLiteral(
"offset_x_unit" ) ) )
3138 if ( properties.contains( QStringLiteral(
"offset_x_map_unit_scale" ) ) )
3142 if ( properties.contains( QStringLiteral(
"offset_y_unit" ) ) )
3146 if ( properties.contains( QStringLiteral(
"offset_y_map_unit_scale" ) ) )
3151 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
3155 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3162 return layer.release();
3167 return QStringLiteral(
"PointPatternFill" );
3181 if ( width > 10000 || height > 10000 )
3184 brush.setTextureImage( img );
3188 QImage patternImage( width, height, QImage::Format_ARGB32 );
3189 patternImage.fill( 0 );
3193 QPainter p( &patternImage );
3203 p.setRenderHint( QPainter::Antialiasing,
true );
3213 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3215 for (
double currentY = -height; currentY <= height * 2.0; currentY += height )
3224 for (
double currentX = -width; currentX <= width * 2.0; currentX += width )
3226 for (
double currentY = -height / 2.0; currentY <= height * 2.0; currentY += height )
3232 for (
double currentX = -width / 2.0; currentX <= width * 2.0; currentX += width )
3234 for (
double currentY = -height; currentY <= height * 2.0; currentY += height / 2.0 )
3236 mMarkerSymbol->
renderPoint( QPointF( currentX + widthOffset + ( std::fmod( currentY, height ) != 0 ? displacementPixelX : 0 ), currentY + heightOffset - displacementPixelY ), context.
feature(), pointRenderContext );
3245 QImage transparentImage = patternImage.copy();
3247 brush.setTextureImage( transparentImage );
3251 brush.setTextureImage( patternImage );
3253 QTransform brushTransform;
3254 brush.setTransform( brushTransform );
3278 map.insert( QStringLiteral(
"distance_x" ), QString::number(
mDistanceX ) );
3279 map.insert( QStringLiteral(
"distance_y" ), QString::number(
mDistanceY ) );
3280 map.insert( QStringLiteral(
"displacement_x" ), QString::number(
mDisplacementX ) );
3281 map.insert( QStringLiteral(
"displacement_y" ), QString::number(
mDisplacementY ) );
3282 map.insert( QStringLiteral(
"offset_x" ), QString::number(
mOffsetX ) );
3283 map.insert( QStringLiteral(
"offset_y" ), QString::number(
mOffsetY ) );
3317 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
3318 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
3319 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
3320 element.appendChild( symbolizerElem );
3325 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
3326 symbolizerElem.appendChild( fillElem );
3328 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
3329 fillElem.appendChild( graphicFillElem );
3336 symbolizerElem.appendChild( distanceElem );
3342 QString errorMsg = QStringLiteral(
"MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->
layerType() );
3343 graphicFillElem.appendChild( doc.createComment( errorMsg ) );
3419 applyPattern( context,
mBrush, distanceX, distanceY, displacementX, displacementY, offsetX, offsetY );
3468 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3470 if ( properties.contains( QStringLiteral(
"point_on_surface" ) ) )
3471 sl->setPointOnSurface( properties[QStringLiteral(
"point_on_surface" )].toInt() != 0 );
3472 if ( properties.contains( QStringLiteral(
"point_on_all_parts" ) ) )
3473 sl->setPointOnAllParts( properties[QStringLiteral(
"point_on_all_parts" )].toInt() != 0 );
3477 return sl.release();
3482 return QStringLiteral(
"CentroidFill" );
3487 mMarker->setColor( color );
3493 return mMarker ? mMarker->color() :
mColor;
3498 mMarker->setOpacity( context.
opacity() );
3501 mCurrentFeatureId = -1;
3502 mBiggestPartIndex = 0;
3514 if ( !mPointOnAllParts )
3519 if ( feature->
id() != mCurrentFeatureId )
3521 mCurrentFeatureId = feature->
id();
3522 mBiggestPartIndex = 1;
3530 double areaBiggest = 0;
3534 if ( area > areaBiggest )
3537 mBiggestPartIndex = i + 1;
3545 if ( mPointOnAllParts || ( context.
geometryPartNum() == mBiggestPartIndex ) )
3555 map[QStringLiteral(
"point_on_surface" )] = QString::number( mPointOnSurface );
3556 map[QStringLiteral(
"point_on_all_parts" )] = QString::number( mPointOnAllParts );
3562 std::unique_ptr< QgsCentroidFillSymbolLayer > x = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3565 x->setSubSymbol( mMarker->clone() );
3566 x->setPointOnSurface( mPointOnSurface );
3567 x->setPointOnAllParts( mPointOnAllParts );
3578 mMarker->toSld( doc, element, props );
3589 std::unique_ptr< QgsMarkerSymbol > marker(
new QgsMarkerSymbol( layers ) );
3591 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3592 sl->setSubSymbol( marker.release() );
3593 sl->setPointOnAllParts(
false );
3594 return sl.release();
3600 return mMarker.get();
3611 mMarker.reset( static_cast<QgsMarkerSymbol *>( symbol ) );
3612 mColor = mMarker->color();
3621 attributes.unite( mMarker->usedAttributes( context ) );
3630 if ( mMarker && mMarker->hasDataDefinedProperties() )
3639 mMarker->setOutputUnit( unit );
3647 return mMarker->outputUnit();
3656 mMarker->setMapUnitScale( scale );
3664 return mMarker->mapUnitScale();
3674 , mImageFilePath( imageFilePath )
3688 if ( properties.contains( QStringLiteral(
"imageFile" ) ) )
3690 imagePath = properties[QStringLiteral(
"imageFile" )];
3692 if ( properties.contains( QStringLiteral(
"coordinate_mode" ) ) )
3694 mode =
static_cast< FillCoordinateMode >( properties[QStringLiteral(
"coordinate_mode" )].toInt() );
3696 if ( properties.contains( QStringLiteral(
"alpha" ) ) )
3698 alpha = properties[QStringLiteral(
"alpha" )].toDouble();
3700 if ( properties.contains( QStringLiteral(
"offset" ) ) )
3704 if ( properties.contains( QStringLiteral(
"angle" ) ) )
3706 angle = properties[QStringLiteral(
"angle" )].toDouble();
3708 if ( properties.contains( QStringLiteral(
"width" ) ) )
3710 width = properties[QStringLiteral(
"width" )].toDouble();
3712 std::unique_ptr< QgsRasterFillSymbolLayer > symbolLayer = qgis::make_unique< QgsRasterFillSymbolLayer >( imagePath );
3713 symbolLayer->setCoordinateMode( mode );
3714 symbolLayer->setOpacity( alpha );
3715 symbolLayer->setOffset( offset );
3716 symbolLayer->setAngle( angle );
3717 symbolLayer->setWidth( width );
3718 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
3722 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3726 if ( properties.contains( QStringLiteral(
"width_unit" ) ) )
3730 if ( properties.contains( QStringLiteral(
"width_map_unit_scale" ) ) )
3735 symbolLayer->restoreOldDataDefinedProperties( properties );
3737 return symbolLayer.release();
3742 QgsStringMap::iterator it = properties.find( QStringLiteral(
"imageFile" ) );
3743 if ( it != properties.end() )
3746 it.value() = pathResolver.
writePath( it.value() );
3748 it.value() = pathResolver.
readPath( it.value() );
3760 return QStringLiteral(
"RasterFill" );
3772 if ( !mOffset.isNull() )
3776 p->translate( offset );
3778 if ( mCoordinateMode ==
Feature )
3780 QRectF boundingRect = points.boundingRect();
3781 mBrush.setTransform(
mBrush.transform().translate( boundingRect.left() -
mBrush.transform().dx(),
3782 boundingRect.top() -
mBrush.transform().dy() ) );
3786 if ( !mOffset.isNull() )
3788 p->translate( -offset );
3794 applyPattern(
mBrush, mImageFilePath, mWidth, mOpacity, context );
3805 map[QStringLiteral(
"imageFile" )] = mImageFilePath;
3806 map[QStringLiteral(
"coordinate_mode" )] = QString::number( mCoordinateMode );
3807 map[QStringLiteral(
"alpha" )] = QString::number( mOpacity );
3811 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3812 map[QStringLiteral(
"width" )] = QString::number( mWidth );
3820 std::unique_ptr< QgsRasterFillSymbolLayer > sl = qgis::make_unique< QgsRasterFillSymbolLayer >( mImageFilePath );
3822 sl->setOpacity( mOpacity );
3823 sl->setOffset( mOffset );
3824 sl->setOffsetUnit( mOffsetUnit );
3825 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
3827 sl->setWidth( mWidth );
3828 sl->setWidthUnit( mWidthUnit );
3829 sl->setWidthMapUnitScale( mWidthMapUnitScale );
3832 return sl.release();
3837 return context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
3842 mImageFilePath = imagePath;
3847 mCoordinateMode = mode;
3865 if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
3871 if ( hasAngleExpression )
3879 if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
3884 double width = mWidth;
3885 if ( hasWidthExpression )
3891 if ( hasOpacityExpression )
3896 QString file = mImageFilePath;
3897 if ( hasFileExpression )
3902 applyPattern(
mBrush, file, width, opacity, context );
3911 size.setHeight( 0 );
3919 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
QPicture svgAsPicture(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool forceVectorOutput=false, double fixedAspectRatio=0)
Gets SVG as QPicture&.
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...
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.
QByteArray getImageData(const QString &path) const
Gets image data.
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.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0)
Gets SVG as QImage.
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()
QgsUnitTypes::RenderUnit mOffsetUnit
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
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())
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 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 a specific symbol layer contained in the symbol.
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 premultiplyColor(QColor &rgb, int alpha)
Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value.
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)
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.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth) const
Tests if an svg file contains parameters for fill, stroke color, stroke width.
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. ...
static void blurImageInPlace(QImage &image, QRect rect, int radius, bool alphaOnly)
Blurs an image in place, e.g. creating Qt-independent drop shadows.
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())
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache)
Returns the specified path rendered as an image.
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.
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.
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.
static QPointF polygonPointOnSurface(const QPolygonF &points)
Calculate a point within of a QPolygonF.
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.
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