21 #include "qgsexpression.h" 33 #include <QSvgRenderer> 34 #include <QDomDocument> 35 #include <QDomElement> 38 Qt::PenJoinStyle penJoinStyle )
39 : mBrushStyle( style )
40 , mStrokeColor( strokeColor )
41 , mStrokeStyle( strokeStyle )
42 , mStrokeWidth( strokeWidth )
43 , mPenJoinStyle( penJoinStyle )
79 void QgsSimpleFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen )
95 if ( exprVal.isValid() )
107 double width = exprVal.toDouble( &ok );
111 pen.setWidthF( width );
112 selPen.setWidthF( width );
148 if ( props.contains( QStringLiteral(
"color" ) ) )
150 if ( props.contains( QStringLiteral(
"style" ) ) )
152 if ( props.contains( QStringLiteral(
"color_border" ) ) )
157 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
161 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
166 if ( props.contains( QStringLiteral(
"style_border" ) ) )
171 else if ( props.contains( QStringLiteral(
"outline_style" ) ) )
175 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
179 if ( props.contains( QStringLiteral(
"width_border" ) ) )
182 strokeWidth = props[QStringLiteral(
"width_border" )].toDouble();
184 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
186 strokeWidth = props[QStringLiteral(
"outline_width" )].toDouble();
188 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
190 strokeWidth = props[QStringLiteral(
"line_width" )].toDouble();
192 if ( props.contains( QStringLiteral(
"offset" ) ) )
194 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
199 if ( props.contains( QStringLiteral(
"border_width_unit" ) ) )
203 else if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
207 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
211 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
214 if ( props.contains( QStringLiteral(
"border_width_map_unit_scale" ) ) )
216 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
227 return QStringLiteral(
"SimpleFill" );
247 mPen = QPen( strokeColor );
277 p->translate( offset );
284 p->translate( -offset );
295 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
323 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
324 if ( !props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ).isEmpty() )
325 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ) );
326 element.appendChild( symbolizerElem );
334 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
335 symbolizerElem.appendChild( fillElem );
342 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
343 symbolizerElem.appendChild( strokeElem );
358 symbolStyle.append(
';' );
369 Qt::BrushStyle fillStyle;
373 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
376 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
382 QString uom = element.attribute( QStringLiteral(
"uom" ), QString() );
397 return penBleed + offsetBleed;
458 : mGradientColorType( colorType )
459 , mGradientType( gradientType )
460 , mCoordinateMode( coordinateMode )
461 , mGradientSpread( spread )
462 , mReferencePoint1( QPointF( 0.5, 0 ) )
463 , mReferencePoint2( QPointF( 0.5, 1 ) )
484 bool refPoint1IsCentroid =
false;
486 bool refPoint2IsCentroid =
false;
491 if ( props.contains( QStringLiteral(
"type" ) ) )
492 type = static_cast< GradientType >( props[QStringLiteral(
"type" )].toInt() );
493 if ( props.contains( QStringLiteral(
"coordinate_mode" ) ) )
494 coordinateMode = static_cast< GradientCoordinateMode >( props[QStringLiteral(
"coordinate_mode" )].toInt() );
495 if ( props.contains( QStringLiteral(
"spread" ) ) )
496 gradientSpread = static_cast< GradientSpread >( props[QStringLiteral(
"spread" )].toInt() );
497 if ( props.contains( QStringLiteral(
"color_type" ) ) )
498 colorType = static_cast< GradientColorType >( props[QStringLiteral(
"color_type" )].toInt() );
499 if ( props.contains( QStringLiteral(
"gradient_color" ) ) )
504 else if ( props.contains( QStringLiteral(
"color" ) ) )
508 if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
513 if ( props.contains( QStringLiteral(
"reference_point1" ) ) )
515 if ( props.contains( QStringLiteral(
"reference_point1_iscentroid" ) ) )
516 refPoint1IsCentroid = props[QStringLiteral(
"reference_point1_iscentroid" )].toInt();
517 if ( props.contains( QStringLiteral(
"reference_point2" ) ) )
519 if ( props.contains( QStringLiteral(
"reference_point2_iscentroid" ) ) )
520 refPoint2IsCentroid = props[QStringLiteral(
"reference_point2_iscentroid" )].toInt();
521 if ( props.contains( QStringLiteral(
"angle" ) ) )
522 angle = props[QStringLiteral(
"angle" )].toDouble();
524 if ( props.contains( QStringLiteral(
"offset" ) ) )
529 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
541 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
543 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
566 return QStringLiteral(
"GradientFill" );
569 void QgsGradientFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context,
const QPolygonF &points )
612 if ( currentType == QObject::tr(
"linear" ) )
616 else if ( currentType == QObject::tr(
"radial" ) )
620 else if ( currentType == QObject::tr(
"conical" ) )
634 if ( currentCoordMode == QObject::tr(
"feature" ) )
638 else if ( currentCoordMode == QObject::tr(
"viewport" ) )
652 if ( currentSpread == QObject::tr(
"pad" ) )
656 else if ( currentSpread == QObject::tr(
"repeat" ) )
660 else if ( currentSpread == QObject::tr(
"reflect" ) )
707 if ( refPoint1IsCentroid || refPoint2IsCentroid )
712 QRectF bbox = points.boundingRect();
713 double centroidX = ( centroid.x() - bbox.left() ) / bbox.width();
714 double centroidY = ( centroid.y() - bbox.top() ) / bbox.height();
716 if ( refPoint1IsCentroid )
718 refPoint1X = centroidX;
719 refPoint1Y = centroidY;
721 if ( refPoint2IsCentroid )
723 refPoint2X = centroidX;
724 refPoint2Y = centroidY;
730 spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ), angle );
733 QPointF QgsGradientFillSymbolLayer::rotateReferencePoint( QPointF refPoint,
double angle )
738 QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
740 refLine.setAngle( refLine.angle() +
angle );
742 QPointF rotatedReferencePoint = refLine.p2();
744 if ( rotatedReferencePoint.x() > 1 )
745 rotatedReferencePoint.setX( 1 );
746 if ( rotatedReferencePoint.x() < 0 )
747 rotatedReferencePoint.setX( 0 );
748 if ( rotatedReferencePoint.y() > 1 )
749 rotatedReferencePoint.setY( 1 );
750 if ( rotatedReferencePoint.y() < 0 )
751 rotatedReferencePoint.setY( 0 );
753 return rotatedReferencePoint;
764 fillColor.setAlphaF( context.
opacity() * fillColor.alphaF() );
765 QColor fillColor2 =
color2;
766 fillColor2.setAlphaF( context.
opacity() * fillColor2.alphaF() );
777 gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
780 gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
783 gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
789 gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
792 gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
798 gradient.setSpread( QGradient::PadSpread );
801 gradient.setSpread( QGradient::ReflectSpread );
804 gradient.setSpread( QGradient::RepeatSpread );
810 ( gradientRamp->
type() == QLatin1String(
"gradient" ) || gradientRamp->
type() == QLatin1String(
"cpt-city" ) ) )
819 gradient.setColorAt( 0.0, fillColor );
820 gradient.setColorAt( 1.0, fillColor2 );
824 brush = QBrush( gradient );
831 selColor.setAlphaF( context.
opacity() );
848 applyDataDefinedSymbology( context, points );
851 p->setPen( Qt::NoPen );
858 p->translate( offset );
865 p->translate( -offset );
875 map[QStringLiteral(
"type" )] = QString::number(
mGradientType );
876 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
mCoordinateMode );
882 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
940 int blurRadius,
bool useWholeShape,
double maxDistance )
941 : mBlurRadius( blurRadius )
942 , mUseWholeShape( useWholeShape )
943 , mMaxDistance( maxDistance )
944 , mColorType( colorType )
966 if ( props.contains( QStringLiteral(
"color_type" ) ) )
968 colorType =
static_cast< ShapeburstColorType >( props[QStringLiteral(
"color_type" )].toInt() );
970 if ( props.contains( QStringLiteral(
"shapeburst_color" ) ) )
975 else if ( props.contains( QStringLiteral(
"color" ) ) )
980 if ( props.contains( QStringLiteral(
"shapeburst_color2" ) ) )
985 else if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
989 if ( props.contains( QStringLiteral(
"blur_radius" ) ) )
991 blurRadius = props[QStringLiteral(
"blur_radius" )].toInt();
993 if ( props.contains( QStringLiteral(
"use_whole_shape" ) ) )
995 useWholeShape = props[QStringLiteral(
"use_whole_shape" )].toInt();
997 if ( props.contains( QStringLiteral(
"max_distance" ) ) )
999 maxDistance = props[QStringLiteral(
"max_distance" )].toDouble();
1001 if ( props.contains( QStringLiteral(
"offset" ) ) )
1008 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
1020 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1024 if ( props.contains( QStringLiteral(
"distance_unit" ) ) )
1028 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1032 if ( props.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
1036 if ( props.contains( QStringLiteral(
"ignore_rings" ) ) )
1038 sl->
setIgnoreRings( props[QStringLiteral(
"ignore_rings" )].toInt() );
1052 return QStringLiteral(
"ShapeburstFill" );
1119 selColor.setAlphaF( context.
opacity() );
1125 Q_UNUSED( context );
1145 p->translate( offset );
1150 p->translate( -offset );
1161 applyDataDefinedSymbology( context, color1, color2, blurRadius, useWholeShape, maxDistance, ignoreRings );
1164 int outputPixelMaxDist = 0;
1178 p->setPen( QPen( Qt::NoPen ) );
1181 int sideBuffer = 4 + ( blurRadius + 2 ) * 4;
1183 double imWidth = points.boundingRect().width() + ( sideBuffer * 2 );
1184 double imHeight = points.boundingRect().height() + ( sideBuffer * 2 );
1185 QImage *fillImage =
new QImage( imWidth,
1186 imHeight, QImage::Format_ARGB32_Premultiplied );
1190 fillImage->fill( Qt::black );
1193 QImage *alphaImage =
new QImage( fillImage->width(), fillImage->height(), QImage::Format_ARGB32_Premultiplied );
1195 alphaImage->fill( Qt::transparent );
1198 QPainter imgPainter;
1199 imgPainter.begin( alphaImage );
1200 imgPainter.setRenderHint( QPainter::Antialiasing,
true );
1201 imgPainter.setBrush( QBrush( Qt::white ) );
1202 imgPainter.setPen( QPen( Qt::black ) );
1203 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1209 imgPainter.begin( fillImage );
1212 imgPainter.drawImage( 0, 0, *alphaImage );
1219 imgPainter.setBrush( QBrush( Qt::white ) );
1220 imgPainter.setPen( QPen( Qt::black ) );
1221 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1227 double *dtArray = distanceTransform( fillImage );
1241 if ( blurRadius > 0 )
1247 imgPainter.begin( fillImage );
1248 imgPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
1249 imgPainter.drawImage( 0, 0, *alphaImage );
1262 p->translate( offset );
1265 p->drawImage( points.boundingRect().left() - sideBuffer, points.boundingRect().top() - sideBuffer, *fillImage );
1271 p->translate( -offset );
1280 void QgsShapeburstFillSymbolLayer::distanceTransform1d(
double *
f,
int n,
int *v,
double *z,
double *d )
1286 for (
int q = 1; q <= n - 1; q++ )
1288 double s = ( (
f[q] + q * q ) - (
f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1292 s = ( (
f[q] + q * q ) - (
f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1301 for (
int q = 0; q <= n - 1; q++ )
1303 while ( z[k + 1] < q )
1305 d[q] = ( q - v[k] ) * ( q - v[k] ) +
f[v[k]];
1310 void QgsShapeburstFillSymbolLayer::distanceTransform2d(
double *im,
int width,
int height )
1312 int maxDimension = std::max( width, height );
1313 double *
f =
new double[ maxDimension ];
1314 int *v =
new int[ maxDimension ];
1315 double *z =
new double[ maxDimension + 1 ];
1316 double *d =
new double[ maxDimension ];
1319 for (
int x = 0; x < width; x++ )
1321 for (
int y = 0; y < height; y++ )
1323 f[y] = im[ x + y * width ];
1325 distanceTransform1d( f, height, v, z, d );
1326 for (
int y = 0; y < height; y++ )
1328 im[ x + y * width ] = d[y];
1333 for (
int y = 0; y < height; y++ )
1335 for (
int x = 0; x < width; x++ )
1337 f[x] = im[ x + y * width ];
1339 distanceTransform1d( f, width, v, z, d );
1340 for (
int x = 0; x < width; x++ )
1342 im[ x + y * width ] = d[x];
1353 double *QgsShapeburstFillSymbolLayer::distanceTransform( QImage *im )
1355 int width = im->width();
1356 int height = im->height();
1358 double *dtArray =
new double[width * height];
1363 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1365 const QRgb *scanLine =
reinterpret_cast< const QRgb *
>( im->constScanLine( heightIndex ) );
1366 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1368 tmpRgb = scanLine[widthIndex];
1369 if ( qRed( tmpRgb ) == 0 )
1377 dtArray[ idx ] =
INF;
1384 distanceTransform2d( dtArray, width, height );
1389 void QgsShapeburstFillSymbolLayer::dtArrayToQImage(
double *array, QImage *im,
QgsColorRamp *ramp,
double layerAlpha,
bool useWholeShape,
int maxPixelDistance )
1391 int width = im->width();
1392 int height = im->height();
1395 double maxDistanceValue;
1400 double dtMaxValue = array[0];
1401 for (
int i = 1; i < ( width * height ); ++i )
1403 if ( array[i] > dtMaxValue )
1405 dtMaxValue = array[i];
1410 maxDistanceValue = std::sqrt( dtMaxValue );
1415 maxDistanceValue = maxPixelDistance;
1420 double squaredVal = 0;
1423 bool layerHasAlpha = layerAlpha < 1.0;
1425 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1427 QRgb *scanLine =
reinterpret_cast< QRgb *
>( im->scanLine( heightIndex ) );
1428 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1431 squaredVal = array[idx];
1434 if ( maxDistanceValue > 0 )
1436 pixVal = squaredVal > 0 ? std::min( ( std::sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1444 pixColor = ramp->
color( pixVal );
1446 int pixAlpha = pixColor.alpha();
1447 if ( ( layerHasAlpha ) || ( pixAlpha != 255 ) )
1450 double alpha = pixAlpha * layerAlpha;
1455 scanLine[widthIndex] = pixColor.rgba();
1466 map[QStringLiteral(
"color_type" )] = QString::number(
mColorType );
1467 map[QStringLiteral(
"blur_radius" )] = QString::number(
mBlurRadius );
1468 map[QStringLiteral(
"use_whole_shape" )] = QString::number(
mUseWholeShape );
1469 map[QStringLiteral(
"max_distance" )] = QString::number(
mMaxDistance );
1472 map[QStringLiteral(
"ignore_rings" )] = QString::number(
mIgnoreRings );
1555 applyDataDefinedSettings( context );
1557 p->setPen( QPen( Qt::NoPen ) );
1559 QTransform bkTransform =
mBrush.transform();
1563 QPointF leftCorner = points.boundingRect().topLeft();
1564 QTransform t =
mBrush.transform();
1565 t.translate( leftCorner.x(), leftCorner.y() );
1566 mBrush.setTransform( t );
1575 p->setBrush( QBrush( selColor ) );
1581 QTransform t =
mBrush.transform();
1582 t.rotate( mNextAngle );
1583 mBrush.setTransform( t );
1592 QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
1593 for ( ; ringIt != rings->constEnd(); ++ringIt )
1600 mBrush.setTransform( bkTransform );
1607 mStroke.reset(
nullptr );
1620 mStroke.reset( lineSymbol );
1630 mStrokeWidthUnit = unit;
1635 return mStrokeWidthUnit;
1640 mStrokeWidthMapUnitScale = scale;
1645 return mStrokeWidthMapUnitScale;
1650 if ( mStroke && mStroke->symbolLayer( 0 ) )
1652 double subLayerBleed = mStroke->symbolLayer( 0 )->estimateMaxBleed( context );
1653 return subLayerBleed;
1660 double width = mStrokeWidth;
1671 Q_UNUSED( context );
1674 return QColor( Qt::black );
1676 return mStroke->color();
1681 return Qt::SolidLine;
1685 return Qt::SolidLine;
1689 return mStroke->dxfPenStyle();
1698 attr.unite( mStroke->usedAttributes( context ) );
1707 , mPatternWidth( width )
1709 , mSvgStrokeWidthUnit(
QgsUnitTypes::RenderMillimeters )
1714 mColor = QColor( 255, 255, 255 );
1717 setDefaultSvgParams();
1731 mColor = QColor( 255, 255, 255 );
1735 setDefaultSvgParams();
1750 mStroke->setOutputUnit( unit );
1788 setDefaultSvgParams();
1798 if ( properties.contains( QStringLiteral(
"width" ) ) )
1800 width = properties[QStringLiteral(
"width" )].toDouble();
1802 if ( properties.contains( QStringLiteral(
"svgFile" ) ) )
1804 svgFilePath = properties[QStringLiteral(
"svgFile" )];
1806 if ( properties.contains( QStringLiteral(
"angle" ) ) )
1808 angle = properties[QStringLiteral(
"angle" )].toDouble();
1812 if ( !svgFilePath.isEmpty() )
1818 if ( properties.contains( QStringLiteral(
"data" ) ) )
1820 data = QByteArray::fromHex( properties[QStringLiteral(
"data" )].toLocal8Bit() );
1826 if ( properties.contains( QStringLiteral(
"svgFillColor" ) ) )
1831 else if ( properties.contains( QStringLiteral(
"color" ) ) )
1835 if ( properties.contains( QStringLiteral(
"svgOutlineColor" ) ) )
1840 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
1844 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
1848 if ( properties.contains( QStringLiteral(
"svgOutlineWidth" ) ) )
1851 symbolLayer->
setSvgStrokeWidth( properties[QStringLiteral(
"svgOutlineWidth" )].toDouble() );
1853 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
1855 symbolLayer->
setSvgStrokeWidth( properties[QStringLiteral(
"outline_width" )].toDouble() );
1857 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
1859 symbolLayer->
setSvgStrokeWidth( properties[QStringLiteral(
"line_width" )].toDouble() );
1863 if ( properties.contains( QStringLiteral(
"pattern_width_unit" ) ) )
1867 if ( properties.contains( QStringLiteral(
"pattern_width_map_unit_scale" ) ) )
1871 if ( properties.contains( QStringLiteral(
"svg_outline_width_unit" ) ) )
1875 if ( properties.contains( QStringLiteral(
"svg_outline_width_map_unit_scale" ) ) )
1879 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
1883 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1895 QgsStringMap::iterator it = properties.find( QStringLiteral(
"svgFile" ) );
1896 if ( it != properties.end() )
1907 return QStringLiteral(
"SVGFill" );
1924 if ( static_cast< int >( size ) < 1.0 || 10000.0 < size )
1931 bool fitsInCache =
true;
1939 double hwRatio = 1.0;
1940 if ( patternPict.width() > 0 )
1942 hwRatio =
static_cast< double >( patternPict.height() ) / static_cast< double >( patternPict.width() );
1944 mSvgPattern =
new QImage( static_cast< int >( size ), static_cast< int >( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
1948 p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
1951 QTransform brushTransform;
1954 QImage transparentImage = fitsInCache ? patternImage.copy() :
mSvgPattern->copy();
1956 brush.setTextureImage( transparentImage );
1960 brush.setTextureImage( fitsInCache ? patternImage : *
mSvgPattern );
1962 brush.setTransform( brushTransform );
1969 applyPattern(
mBrush,
mSvgFilePath,
mPatternWidth,
mPatternWidthUnit,
mColor,
mSvgStrokeColor,
mSvgStrokeWidth,
mSvgStrokeWidthUnit, context,
mPatternWidthMapUnitScale,
mSvgStrokeWidthMapUnitScale );
1990 map.insert( QStringLiteral(
"svgFile" ),
mSvgFilePath );
1994 map.insert( QStringLiteral(
"data" ), QString(
mSvgData.toHex() ) );
1997 map.insert( QStringLiteral(
"width" ), QString::number(
mPatternWidth ) );
1998 map.insert( QStringLiteral(
"angle" ), QString::number(
mAngle ) );
2003 map.insert( QStringLiteral(
"outline_width" ), QString::number(
mSvgStrokeWidth ) );
2048 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2049 if ( !props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ).isEmpty() )
2050 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ) );
2051 element.appendChild( symbolizerElem );
2055 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2056 symbolizerElem.appendChild( fillElem );
2058 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2059 fillElem.appendChild( graphicFillElem );
2061 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2062 graphicFillElem.appendChild( graphicElem );
2075 symbolizerElem.appendChild( doc.createComment( QStringLiteral(
"SVG from data not implemented yet" ) ) );
2081 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2084 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2088 angleFunc = QString::number( angle +
mAngle );
2097 mStroke->toSld( doc, element, props );
2105 QString path, mimeType;
2107 Qt::PenStyle penStyle;
2108 double size, strokeWidth;
2110 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2111 if ( fillElem.isNull() )
2114 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2115 if ( graphicFillElem.isNull() )
2118 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2119 if ( graphicElem.isNull() )
2125 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2130 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2139 double d = angleFunc.toDouble( &ok );
2145 sl->
setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2151 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2152 if ( !strokeElem.isNull() )
2217 void QgsSVGFillSymbolLayer::storeViewBox()
2232 void QgsSVGFillSymbolLayer::setDefaultSvgParams()
2239 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2240 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2241 QColor defaultFillColor, defaultStrokeColor;
2242 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2244 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2245 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2246 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2247 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2249 double newFillOpacity = hasFillOpacityParam ?
mColor.alphaF() : 1.0;
2250 double newStrokeOpacity = hasStrokeOpacityParam ?
mSvgStrokeColor.alphaF() : 1.0;
2252 if ( hasDefaultFillColor )
2254 mColor = defaultFillColor;
2255 mColor.setAlphaF( newFillOpacity );
2257 if ( hasDefaultFillOpacity )
2259 mColor.setAlphaF( defaultFillOpacity );
2261 if ( hasDefaultStrokeColor )
2266 if ( hasDefaultStrokeOpacity )
2270 if ( hasDefaultStrokeWidth )
2298 return mFillLineSymbol ? mFillLineSymbol->
color() :
mColor;
2303 delete mFillLineSymbol;
2318 delete mFillLineSymbol;
2319 mFillLineSymbol = lineSymbol;
2330 return mFillLineSymbol;
2336 if ( mFillLineSymbol )
2391 QColor
color( Qt::black );
2394 if ( properties.contains( QStringLiteral(
"lineangle" ) ) )
2397 lineAngle = properties[QStringLiteral(
"lineangle" )].toDouble();
2399 else if ( properties.contains( QStringLiteral(
"angle" ) ) )
2401 lineAngle = properties[QStringLiteral(
"angle" )].toDouble();
2405 if ( properties.contains( QStringLiteral(
"distance" ) ) )
2407 distance = properties[QStringLiteral(
"distance" )].toDouble();
2411 if ( properties.contains( QStringLiteral(
"linewidth" ) ) )
2414 lineWidth = properties[QStringLiteral(
"linewidth" )].toDouble();
2416 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
2418 lineWidth = properties[QStringLiteral(
"outline_width" )].toDouble();
2420 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
2422 lineWidth = properties[QStringLiteral(
"line_width" )].toDouble();
2426 if ( properties.contains( QStringLiteral(
"color" ) ) )
2430 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
2434 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
2440 if ( properties.contains( QStringLiteral(
"offset" ) ) )
2442 offset = properties[QStringLiteral(
"offset" )].toDouble();
2447 if ( properties.contains( QStringLiteral(
"distance_unit" ) ) )
2451 if ( properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
2455 if ( properties.contains( QStringLiteral(
"line_width_unit" ) ) )
2459 else if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2463 if ( properties.contains( QStringLiteral(
"line_width_map_unit_scale" ) ) )
2467 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
2471 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2475 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2479 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2486 return patternLayer;
2491 return QStringLiteral(
"LinePatternFill" );
2496 mBrush.setTextureImage( QImage() );
2498 if ( !mFillLineSymbol )
2504 if ( !fillLineSymbol )
2516 double outputPixelBleed = 0;
2517 double outputPixelInterval = 0;
2522 outputPixelBleed = std::max( outputPixelBleed, outputPixelLayerBleed );
2525 if ( markerLineLayer )
2534 outputPixelInterval = std::max( outputPixelInterval, outputPixelLayerInterval );
2538 if ( outputPixelInterval > 0 )
2542 double intervalScale = std::round( outputPixelInterval ) / outputPixelInterval;
2543 outputPixelInterval = std::round( outputPixelInterval );
2550 if ( markerLineLayer )
2561 height = outputPixelDist;
2562 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2566 width = outputPixelDist;
2567 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2571 height = outputPixelDist / std::cos(
lineAngle * M_PI / 180 );
2572 width = outputPixelDist / std::sin(
lineAngle * M_PI / 180 );
2575 lineAngle = 180 * std::atan2( static_cast< double >( height ), static_cast< double >( width ) ) / M_PI;
2581 height = std::abs( height );
2582 width = std::abs( width );
2584 outputPixelDist = height * std::cos(
lineAngle * M_PI / 180 );
2588 int offsetHeight = std::round( std::fabs( outputPixelOffset / std::cos(
lineAngle * M_PI / 180 ) ) );
2589 outputPixelOffset = offsetHeight * std::cos(
lineAngle * M_PI / 180 );
2598 int bufferMulti = std::max( std::ceil( outputPixelBleed / width ), std::ceil( outputPixelBleed / width ) );
2602 bufferMulti = std::max( bufferMulti, 1 );
2604 int xBuffer = width * bufferMulti;
2605 int yBuffer = height * bufferMulti;
2606 int innerWidth = width;
2607 int innerHeight = height;
2608 width += 2 * xBuffer;
2609 height += 2 * yBuffer;
2612 if ( width > 10000 || height > 10000 || width == 0 || height == 0 )
2617 QImage patternImage( width, height, QImage::Format_ARGB32 );
2618 patternImage.fill( 0 );
2620 QPointF p1, p2, p3, p4, p5, p6;
2623 p1 = QPointF( 0, yBuffer );
2624 p2 = QPointF( width, yBuffer );
2625 p3 = QPointF( 0, yBuffer + innerHeight );
2626 p4 = QPointF( width, yBuffer + innerHeight );
2630 p1 = QPointF( xBuffer, height );
2631 p2 = QPointF( xBuffer, 0 );
2632 p3 = QPointF( xBuffer + innerWidth, height );
2633 p4 = QPointF( xBuffer + innerWidth, 0 );
2637 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2638 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2639 p1 = QPointF( 0, height );
2640 p2 = QPointF( width, 0 );
2641 p3 = QPointF( -dx, height - dy );
2642 p4 = QPointF( width - dx, -dy );
2643 p5 = QPointF( dx, height + dy );
2644 p6 = QPointF( width + dx, dy );
2648 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2649 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2650 p1 = QPointF( width, 0 );
2651 p2 = QPointF( 0, height );
2652 p3 = QPointF( width - dx, -dy );
2653 p4 = QPointF( -dx, height - dy );
2654 p5 = QPointF( width + dx, dy );
2655 p6 = QPointF( dx, height + dy );
2659 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2660 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2661 p1 = QPointF( 0, 0 );
2662 p2 = QPointF( width, height );
2663 p5 = QPointF( dx, -dy );
2664 p6 = QPointF( width + dx, height - dy );
2665 p3 = QPointF( -dx, dy );
2666 p4 = QPointF( width - dx, height + dy );
2670 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2671 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2672 p1 = QPointF( width, height );
2673 p2 = QPointF( 0, 0 );
2674 p5 = QPointF( width + dx, height - dy );
2675 p6 = QPointF( dx, -dy );
2676 p3 = QPointF( width - dx, height + dy );
2677 p4 = QPointF( -dx, dy );
2684 p3 = QPointF( tempPt.x(), tempPt.y() );
2686 p4 = QPointF( tempPt.x(), tempPt.y() );
2688 p5 = QPointF( tempPt.x(), tempPt.y() );
2690 p6 = QPointF( tempPt.x(), tempPt.y() );
2694 p1 = QPointF( tempPt.x(), tempPt.y() );
2696 p2 = QPointF( tempPt.x(), tempPt.y() );
2699 QPainter p( &patternImage );
2703 p.setRenderHint( QPainter::Antialiasing,
false );
2704 QPen pen( QColor( Qt::black ) );
2705 pen.setWidthF( 0.1 );
2706 pen.setCapStyle( Qt::FlatCap );
2711 QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 );
2712 p.drawPolygon( polygon );
2714 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 );
2715 p.drawPolygon( polygon );
2721 p.setRenderHint( QPainter::Antialiasing,
true );
2734 QVector<QPolygonF> polygons;
2735 polygons.append( QPolygonF() << p1 << p2 );
2736 polygons.append( QPolygonF() << p3 << p4 );
2739 polygons.append( QPolygonF() << p5 << p6 );
2742 Q_FOREACH (
const QPolygonF &polygon, polygons )
2747 fillLineSymbol->
stopRender( lineRenderContext );
2751 patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
2756 QImage transparentImage = patternImage.copy();
2758 brush.setTextureImage( transparentImage );
2762 brush.setTextureImage( patternImage );
2765 QTransform brushTransform;
2766 brush.setTransform( brushTransform );
2768 delete fillLineSymbol;
2775 if ( mFillLineSymbol )
2783 if ( mFillLineSymbol )
2792 map.insert( QStringLiteral(
"angle" ), QString::number(
mLineAngle ) );
2793 map.insert( QStringLiteral(
"distance" ), QString::number(
mDistance ) );
2794 map.insert( QStringLiteral(
"line_width" ), QString::number(
mLineWidth ) );
2796 map.insert( QStringLiteral(
"offset" ), QString::number(
mOffset ) );
2811 if ( mFillLineSymbol )
2822 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2823 if ( !props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ).isEmpty() )
2824 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ) );
2825 element.appendChild( symbolizerElem );
2830 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2831 symbolizerElem.appendChild( fillElem );
2833 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2834 fillElem.appendChild( graphicFillElem );
2836 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2837 graphicFillElem.appendChild( graphicElem );
2840 QColor lineColor = mFillLineSymbol ? mFillLineSymbol->
color() : QColor();
2841 double lineWidth = mFillLineSymbol ? mFillLineSymbol->
width() : 0.0;
2849 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2852 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mLineAngle );
2856 angleFunc = QString::number( angle +
mLineAngle );
2868 QString featureStyle;
2869 featureStyle.append(
"Brush(" );
2870 featureStyle.append( QStringLiteral(
"fc:%1" ).arg(
mColor.name() ) );
2871 featureStyle.append( QStringLiteral(
",bc:%1" ).arg( QStringLiteral(
"#00000000" ) ) );
2872 featureStyle.append(
",id:\"ogr-brush-2\"" );
2873 featureStyle.append( QStringLiteral(
",a:%1" ).arg(
mLineAngle ) );
2874 featureStyle.append( QStringLiteral(
",s:%1" ).arg(
mLineWidth * widthScaleFactor ) );
2875 featureStyle.append(
",dx:0mm" );
2876 featureStyle.append( QStringLiteral(
",dy:%1mm" ).arg(
mDistance * widthScaleFactor ) );
2877 featureStyle.append(
')' );
2878 return featureStyle;
2901 applyPattern( context,
mBrush, lineAngle, distance );
2911 Qt::PenStyle lineStyle;
2913 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2914 if ( fillElem.isNull() )
2917 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2918 if ( graphicFillElem.isNull() )
2921 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2922 if ( graphicElem.isNull() )
2928 if ( name != QLatin1String(
"horline" ) )
2936 double d = angleFunc.toDouble( &ok );
2945 offset = std::sqrt( std::pow( vectOffset.x(), 2 ) + std::pow( vectOffset.y(), 2 ) );
2948 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2953 sl->
setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2961 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2962 if ( !strokeElem.isNull() )
3043 if ( properties.contains( QStringLiteral(
"distance_x" ) ) )
3045 layer->
setDistanceX( properties[QStringLiteral(
"distance_x" )].toDouble() );
3047 if ( properties.contains( QStringLiteral(
"distance_y" ) ) )
3049 layer->
setDistanceY( properties[QStringLiteral(
"distance_y" )].toDouble() );
3051 if ( properties.contains( QStringLiteral(
"displacement_x" ) ) )
3053 layer->
setDisplacementX( properties[QStringLiteral(
"displacement_x" )].toDouble() );
3055 if ( properties.contains( QStringLiteral(
"displacement_y" ) ) )
3057 layer->
setDisplacementY( properties[QStringLiteral(
"displacement_y" )].toDouble() );
3060 if ( properties.contains( QStringLiteral(
"distance_x_unit" ) ) )
3064 if ( properties.contains( QStringLiteral(
"distance_x_map_unit_scale" ) ) )
3068 if ( properties.contains( QStringLiteral(
"distance_y_unit" ) ) )
3072 if ( properties.contains( QStringLiteral(
"distance_y_map_unit_scale" ) ) )
3076 if ( properties.contains( QStringLiteral(
"displacement_x_unit" ) ) )
3080 if ( properties.contains( QStringLiteral(
"displacement_x_map_unit_scale" ) ) )
3084 if ( properties.contains( QStringLiteral(
"displacement_y_unit" ) ) )
3088 if ( properties.contains( QStringLiteral(
"displacement_y_map_unit_scale" ) ) )
3092 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
3096 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3108 return QStringLiteral(
"PointPatternFill" );
3119 if ( width > 10000 || height > 10000 )
3122 brush.setTextureImage( img );
3126 QImage patternImage( width, height, QImage::Format_ARGB32 );
3127 patternImage.fill( 0 );
3131 QPainter p( &patternImage );
3141 p.setRenderHint( QPainter::Antialiasing,
true );
3170 QImage transparentImage = patternImage.copy();
3172 brush.setTextureImage( transparentImage );
3176 brush.setTextureImage( patternImage );
3178 QTransform brushTransform;
3179 brush.setTransform( brushTransform );
3203 map.insert( QStringLiteral(
"distance_x" ), QString::number(
mDistanceX ) );
3204 map.insert( QStringLiteral(
"distance_y" ), QString::number(
mDistanceY ) );
3205 map.insert( QStringLiteral(
"displacement_x" ), QString::number(
mDisplacementX ) );
3206 map.insert( QStringLiteral(
"displacement_y" ), QString::number(
mDisplacementY ) );
3236 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
3237 if ( !props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ).isEmpty() )
3238 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QLatin1String(
"" ) ) );
3239 element.appendChild( symbolizerElem );
3244 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
3245 symbolizerElem.appendChild( fillElem );
3247 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
3248 fillElem.appendChild( graphicFillElem );
3255 symbolizerElem.appendChild( distanceElem );
3261 QString errorMsg = QStringLiteral(
"MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->
layerType() );
3262 graphicFillElem.appendChild( doc.createComment( errorMsg ) );
3273 Q_UNUSED( element );
3326 applyPattern( context,
mBrush, distanceX, distanceY, displacementX, displacementY );
3368 if ( properties.contains( QStringLiteral(
"point_on_surface" ) ) )
3369 sl->
setPointOnSurface( properties[QStringLiteral(
"point_on_surface" )].toInt() != 0 );
3370 if ( properties.contains( QStringLiteral(
"point_on_all_parts" ) ) )
3371 sl->
setPointOnAllParts( properties[QStringLiteral(
"point_on_all_parts" )].toInt() != 0 );
3380 return QStringLiteral(
"CentroidFill" );
3385 mMarker->setColor( color );
3391 return mMarker ? mMarker->color() :
mColor;
3396 mMarker->setOpacity( context.
opacity() );
3399 mCurrentFeatureId = -1;
3400 mBiggestPartIndex = 0;
3412 if ( !mPointOnAllParts )
3417 if ( feature->
id() != mCurrentFeatureId )
3419 mCurrentFeatureId = feature->
id();
3420 mBiggestPartIndex = 1;
3428 double areaBiggest = 0;
3432 if ( area > areaBiggest )
3435 mBiggestPartIndex = i + 1;
3443 if ( mPointOnAllParts || ( context.
geometryPartNum() == mBiggestPartIndex ) )
3453 map[QStringLiteral(
"point_on_surface" )] = QString::number( mPointOnSurface );
3454 map[QStringLiteral(
"point_on_all_parts" )] = QString::number( mPointOnAllParts );
3476 mMarker->toSld( doc, element, props );
3489 std::unique_ptr< QgsMarkerSymbol > marker(
new QgsMarkerSymbol( layers ) );
3499 return mMarker.get();
3510 mMarker.reset( static_cast<QgsMarkerSymbol *>( symbol ) );
3511 mColor = mMarker->color();
3520 attributes.unite( mMarker->usedAttributes( context ) );
3529 mMarker->setOutputUnit( unit );
3537 return mMarker->outputUnit();
3546 mMarker->setMapUnitScale( scale );
3554 return mMarker->mapUnitScale();
3564 , mImageFilePath( imageFilePath )
3578 if ( properties.contains( QStringLiteral(
"imageFile" ) ) )
3580 imagePath = properties[QStringLiteral(
"imageFile" )];
3582 if ( properties.contains( QStringLiteral(
"coordinate_mode" ) ) )
3584 mode =
static_cast< FillCoordinateMode >( properties[QStringLiteral(
"coordinate_mode" )].toInt() );
3586 if ( properties.contains( QStringLiteral(
"alpha" ) ) )
3588 alpha = properties[QStringLiteral(
"alpha" )].toDouble();
3590 if ( properties.contains( QStringLiteral(
"offset" ) ) )
3594 if ( properties.contains( QStringLiteral(
"angle" ) ) )
3596 angle = properties[QStringLiteral(
"angle" )].toDouble();
3598 if ( properties.contains( QStringLiteral(
"width" ) ) )
3600 width = properties[QStringLiteral(
"width" )].toDouble();
3608 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
3612 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3616 if ( properties.contains( QStringLiteral(
"width_unit" ) ) )
3620 if ( properties.contains( QStringLiteral(
"width_map_unit_scale" ) ) )
3632 QgsStringMap::iterator it = properties.find( QStringLiteral(
"imageFile" ) );
3633 if ( it != properties.end() )
3636 it.value() = pathResolver.
writePath( it.value() );
3638 it.value() = pathResolver.
readPath( it.value() );
3650 return QStringLiteral(
"RasterFill" );
3666 p->translate( offset );
3670 QRectF boundingRect = points.boundingRect();
3671 mBrush.setTransform(
mBrush.transform().translate( boundingRect.left() -
mBrush.transform().dx(),
3672 boundingRect.top() -
mBrush.transform().dy() ) );
3678 p->translate( -offset );
3689 Q_UNUSED( context );
3696 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
mCoordinateMode );
3697 map[QStringLiteral(
"alpha" )] = QString::number(
mOpacity );
3701 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3702 map[QStringLiteral(
"width" )] = QString::number(
mWidth );
3755 if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
3761 if ( hasAngleExpression )
3769 if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
3775 if ( hasWidthExpression )
3781 if ( hasOpacityExpression )
3787 if ( hasFileExpression )
3792 applyPattern(
mBrush, file, width, opacity, context );
3798 if ( image.isNull() )
3802 if ( !image.hasAlphaChannel() )
3804 image = image.convertToFormat( QImage::Format_ARGB32 );
3814 pixelWidth = image.width();
3822 p.setCompositionMode( QPainter::CompositionMode_DestinationIn );
3823 QColor alphaColor( 0, 0, 0 );
3824 alphaColor.setAlphaF( alpha );
3825 p.fillRect( image.rect(), alphaColor );
3832 image = image.scaledToWidth( pixelWidth, Qt::SmoothTransformation );
3835 brush.setTextureImage( image );
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)
const QgsMapUnitScale & intervalMapUnitScale() const
QgsMapUnitScale mapUnitScale() const override
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
#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)
Get SVG as QPicture&.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
QgsMapUnitScale mapUnitScale() const override
void setForceVectorOutput(bool force)
static QgsSymbolLayer * createFromSld(QDomElement &element)
QgsImageFillSymbolLayer()
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
double interval() const
Returns the interval between individual markers.
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...
void setDistance(double d)
Sets the distance between lines in the fill pattern.
Gradient reference point 1 is centroid.
QgsSimpleFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
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
void setPatternWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the SVG images in the pattern.
QColor strokeColor() const override
Get 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)
FillCoordinateMode mCoordinateMode
QgsSVGFillSymbolLayer(const QString &svgFilePath, double width=20, double rotation=0.0)
Constructs SVG fill symbol layer with picture from given absolute path to a SVG file.
#define DEFAULT_SIMPLEFILL_JOINSTYLE
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Gradient reference point 1 x.
QByteArray getImageData(const QString &path) const
Get image data.
QgsFields fields() const
Fields of the layer.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the fill's offset.
QgsMapUnitScale mStrokeWidthMapUnitScale
static QString svgSymbolPathToName(QString path, const QgsPathResolver &pathResolver)
Get SVG symbols's name from its path.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
QgsRasterFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mLineWidthMapUnitScale
Qt::PenStyle mStrokeStyle
void stopRender(QgsSymbolRenderContext &context) override
void setSvgFillColor(const QColor &c)
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
QString layerType() const override
Returns a string that represents this layer type.
~QgsSVGFillSymbolLayer() override
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.
QgsColorRamp * mTwoColorGradientRamp
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)
Get SVG as QImage.
QColor dxfColor(QgsSymbolRenderContext &context) const override
get 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.
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
Qt::PenJoinStyle penJoinStyle() const
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops...
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits)
Calculates a scaling factor to convert from map units to a specified symbol unit. ...
QgsLinePatternFillSymbolLayer()
QgsUnitTypes::RenderUnit mOffsetUnit
QgsMapUnitScale mapUnitScale() const override
Base class for polygon renderers generating texture images.
QgsMapUnitScale mPatternWidthMapUnitScale
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
void startRender(QgsSymbolRenderContext &context) override
void setDisplacementYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
void stopRender(QgsSymbolRenderContext &context) override
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
bool setSubSymbol(QgsSymbol *symbol) override
set 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.
void setAngle(double angle)
void startRender(QgsSymbolRenderContext &context) override
Abstract base class for color ramps.
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
Helper functions for various unit types.
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
Get stroke color.
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
QgsUnitTypes::RenderUnit mSvgStrokeWidthUnit
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
QgsUnitTypes::RenderUnit mDistanceUnit
QString layerType() const override
Returns a string that represents this layer type.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
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.
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)
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the distance between lines in the fill pattern.
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())
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.
void setOffsetUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the fill's offset.
Flags flags() const
Return combination of flags used for rendering.
static QgsSymbolLayer * createFromSld(QDomElement &element)
int symbolLayerCount() const
Returns total number of symbol layers contained in the symbol.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
static QString svgSymbolNameToPath(QString name, const QgsPathResolver &pathResolver)
Get SVG symbol's path from its name.
#define DEFAULT_SIMPLEFILL_COLOR
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
double mDistance
Distance (in mm or map units) between lines.
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.
double mLineAngle
Vector line angle in degrees (0 = horizontal, counterclockwise)
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
QgsUnitTypes::RenderUnit mDistanceUnit
GradientColorType mGradientColorType
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
QColor color() const override
The fill color.
QgsMapUnitScale mDistanceYMapUnitScale
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features...
QPointF referencePoint1() const
bool setSubSymbol(QgsSymbol *symbol) override
set 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.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
static QgsSymbolLayer * createFromSld(QDomElement &element)
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's stroke width.
QColor color() const override
The fill color.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
QgsUnitTypes::RenderUnit mStrokeWidthUnit
Gradient reference point 2 y.
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 setInterval(double interval)
Sets the interval between individual markers.
void setMapUnitScale(const QgsMapUnitScale &scale) override
#define DEFAULT_SIMPLEFILL_STYLE
static QString encodeColor(const QColor &color)
QgsMapUnitScale mDisplacementYMapUnitScale
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line pattern's offset.
bool setSubSymbol(QgsSymbol *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
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.
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)
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.
QString mImageFilePath
Path to the image file.
static QString encodePenStyle(Qt::PenStyle style)
Perform transforms between map coordinates and device coordinates.
QgsColorRamp * mGradientRamp
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
QgsMapUnitScale mDistanceMapUnitScale
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit mOffsetUnit
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.
void setLineAngle(double a)
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
get line width
std::unique_ptr< QgsLineSymbol > mStroke
Custom stroke.
virtual bool setSubSymbol(QgsSymbol *symbol)
set layer's subsymbol. takes ownership of the passed symbol
A class for filling symbols with a repeated raster image.
QByteArray mSvgData
SVG data.
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mDistanceXMapUnitScale
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
QColor dxfBrushColor(QgsSymbolRenderContext &context) const override
get brush/fill color
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
double mOffset
Offset perpendicular to line direction.
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.
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
QgsUnitTypes::RenderUnit mWidthUnit
void setSvgStrokeWidth(double w)
GradientType mGradientType
void setWidth(double width)
qreal opacity() const
Returns the opacity for the symbol.
static QgsSymbolLayer * createFromSld(QDomElement &element)
double dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
get line width
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Gradient coordinate mode.
bool mReferencePoint1IsCentroid
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width.
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())
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 setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
Filename, eg for svg files.
QColor selectionColor() const
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
QgsMapUnitScale mOffsetMapUnitScale
void startRender(QgsSymbolRenderContext &context) override
QList< QgsSymbolLayer * > QgsSymbolLayerList
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QgsUnitTypes::RenderUnit mOffsetUnit
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QgsMapUnitScale mOffsetMapUnitScale
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...
void setCoordinateMode(const FillCoordinateMode mode)
Set the coordinate mode for fill.
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)
QgsGeometry geometry() const
Returns the geometry associated with this feature.
void stopRender(QgsSymbolRenderContext &context) override
double mapUnitsPerPixel() const
Return current map units per pixel.
bool setSubSymbol(QgsSymbol *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
QColor fillColor() const override
Get fill color.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
QColor svgStrokeColor() const
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
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
QColor color() const override
The fill color.
QgsSymbolLayer * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mOffsetMapUnitScale
static Qt::PenStyle decodePenStyle(const QString &str)
void setOffset(QPointF offset)
Sets the offset for the fill.
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...
ShapeburstColorType mColorType
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
QString mSvgFilePath
Path to the svg file (or empty if constructed directly from data)
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
double mLineWidth
Line width (in mm or map units)
QgsShapeburstFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setSvgStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
Gradient reference point 1 y.
~QgsPointPatternFillSymbolLayer() override
void setOffset(QPointF offset)
Offset for gradient fill.
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
get angle
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
void setDistanceXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal distance between points in the pattern.
void setMapUnitScale(const QgsMapUnitScale &scale) override
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
void setDisplacementY(double d)
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.
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())
GradientSpread mGradientSpread
void setLineWidth(double w)
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.
QgsMapUnitScale mWidthMapUnitScale
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 svg fill patterns.
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
Return 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).
QgsUnitTypes::RenderUnit mLineWidthUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
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
Qt::BrushStyle dxfBrushStyle() const override
get brush/fill style
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
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
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
void setWidthUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the image's width.
~QgsShapeburstFillSymbolLayer() override
Struct for storing maximum and minimum scales for measurements in map units.
QgsMapUnitScale mDistanceMapUnitScale
static QString encodeBrushStyle(Qt::BrushStyle style)
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
const QgsMapUnitScale & patternWidthMapUnitScale() const
QgsUnitTypes::RenderUnit mOffsetUnit
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)
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
set layer's subsymbol. takes ownership of the passed symbol
Qt::PenStyle strokeStyle() const
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the fill's stroke.
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
const QgsFeature * feature() const
Current feature being rendered - may be null.
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
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)
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
get color
double patternWidth() const
static QgsSymbolLayer * createFromSld(QDomElement &element)
void setDisplacementXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal displacement between rows in the pattern.
void setDistanceY(double d)
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 setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
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.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static QgsSymbolLayer * createLineLayerFromSld(QDomElement &element)
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setOpacity(const double opacity)
Sets the opacity for the raster image used in the fill.
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 setDistanceX(double d)
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
get pen style
double svgStrokeWidth() const
QgsUnitTypes::RenderUnit mDistanceXUnit
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the offset for the shapeburst 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.
void setOffset(double offset)
QgsUnitTypes::RenderUnit mDisplacementYUnit
void stopRender(QgsSymbolRenderContext &context) override
Resolves relative paths into absolute paths and vice versa.
void setLineWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line's width.
Draw map such that there are no problems between adjacent tiles.
void startRender(QgsSymbolRenderContext &context) override
void setSvgStrokeColor(const QColor &c)
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Units for gradient fill offset.
void addStopsToGradient(QGradient *gradient, double opacity=1)
Copy color ramp stops to a QGradient.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
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.
void setDistanceYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical distance between points in the pattern.
double displacementY() const
virtual QColor fillColor() const
Get 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 setDisplacementX(double d)
void stopRender(QgsRenderContext &context)
Ends the rendering process.
double width() const
Returns the width used for scaling the image used in the fill.
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between markers.
QgsSVGFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Gradient reference point 2 is centroid.
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)
QgsUnitTypes::RenderUnit mPatternWidthUnit
QgsMapUnitScale mOffsetMapUnitScale
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
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.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenStyle dxfPenStyle() const override
get pen style
QgsMarkerSymbol * clone() const override
Get a deep copy of this symbol.
~QgsLinePatternFillSymbolLayer() override
QgsMapUnitScale mSvgStrokeWidthMapUnitScale
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
void setPointOnSurface(bool pointOnSurface)
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QRectF mSvgViewBox
SVG view box (to keep the aspect ratio.
QImage * mSvgPattern
SVG pattern image.
QgsLineSymbol * clone() const override
Get 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)
double mPatternWidth
Width of the pattern (in output units)
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
Vertical distance between points.
QgsMapUnitScale mOffsetMapUnitScale