34 #include <QSvgRenderer> 35 #include <QDomDocument> 36 #include <QDomElement> 39 Qt::PenJoinStyle penJoinStyle )
40 : mBrushStyle( style )
41 , mStrokeColor( strokeColor )
42 , mStrokeStyle( strokeStyle )
43 , mStrokeWidth( strokeWidth )
44 , mPenJoinStyle( penJoinStyle )
80 void QgsSimpleFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context, QBrush &brush, QPen &pen, QPen &selPen )
96 if ( exprVal.isValid() )
108 double width = exprVal.toDouble( &ok );
112 pen.setWidthF( width );
113 selPen.setWidthF( width );
149 if ( props.contains( QStringLiteral(
"color" ) ) )
151 if ( props.contains( QStringLiteral(
"style" ) ) )
153 if ( props.contains( QStringLiteral(
"color_border" ) ) )
158 else if ( props.contains( QStringLiteral(
"outline_color" ) ) )
162 else if ( props.contains( QStringLiteral(
"line_color" ) ) )
167 if ( props.contains( QStringLiteral(
"style_border" ) ) )
172 else if ( props.contains( QStringLiteral(
"outline_style" ) ) )
176 else if ( props.contains( QStringLiteral(
"line_style" ) ) )
180 if ( props.contains( QStringLiteral(
"width_border" ) ) )
183 strokeWidth = props[QStringLiteral(
"width_border" )].toDouble();
185 else if ( props.contains( QStringLiteral(
"outline_width" ) ) )
187 strokeWidth = props[QStringLiteral(
"outline_width" )].toDouble();
189 else if ( props.contains( QStringLiteral(
"line_width" ) ) )
191 strokeWidth = props[QStringLiteral(
"line_width" )].toDouble();
193 if ( props.contains( QStringLiteral(
"offset" ) ) )
195 if ( props.contains( QStringLiteral(
"joinstyle" ) ) )
199 sl->setOffset( offset );
200 if ( props.contains( QStringLiteral(
"border_width_unit" ) ) )
204 else if ( props.contains( QStringLiteral(
"outline_width_unit" ) ) )
208 else if ( props.contains( QStringLiteral(
"line_width_unit" ) ) )
212 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
215 if ( props.contains( QStringLiteral(
"border_width_map_unit_scale" ) ) )
217 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
220 sl->restoreOldDataDefinedProperties( props );
228 return QStringLiteral(
"SimpleFill" );
248 mPen = QPen( strokeColor );
278 p->translate( offset );
285 p->translate( -offset );
296 map[QStringLiteral(
"outline_width" )] = QString::number(
mStrokeWidth );
324 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
325 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
326 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
327 element.appendChild( symbolizerElem );
335 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
336 symbolizerElem.appendChild( fillElem );
343 QDomElement strokeElem = doc.createElement( QStringLiteral(
"se:Stroke" ) );
344 symbolizerElem.appendChild( strokeElem );
359 symbolStyle.append(
';' );
368 Qt::BrushStyle fillStyle;
372 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
375 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
381 QString uom = element.attribute( QStringLiteral(
"uom" ), QString() );
387 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
388 sl->setOffset( offset );
396 return penBleed + offsetBleed;
457 : mGradientColorType( colorType )
458 , mGradientType( gradientType )
459 , mCoordinateMode( coordinateMode )
460 , mGradientSpread( spread )
461 , mReferencePoint1( QPointF( 0.5, 0 ) )
462 , mReferencePoint2( QPointF( 0.5, 1 ) )
483 bool refPoint1IsCentroid =
false;
485 bool refPoint2IsCentroid =
false;
490 if ( props.contains( QStringLiteral(
"type" ) ) )
491 type = static_cast< GradientType >( props[QStringLiteral(
"type" )].toInt() );
492 if ( props.contains( QStringLiteral(
"coordinate_mode" ) ) )
493 coordinateMode = static_cast< GradientCoordinateMode >( props[QStringLiteral(
"coordinate_mode" )].toInt() );
494 if ( props.contains( QStringLiteral(
"spread" ) ) )
495 gradientSpread = static_cast< GradientSpread >( props[QStringLiteral(
"spread" )].toInt() );
496 if ( props.contains( QStringLiteral(
"color_type" ) ) )
497 colorType = static_cast< GradientColorType >( props[QStringLiteral(
"color_type" )].toInt() );
498 if ( props.contains( QStringLiteral(
"gradient_color" ) ) )
503 else if ( props.contains( QStringLiteral(
"color" ) ) )
507 if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
512 if ( props.contains( QStringLiteral(
"reference_point1" ) ) )
514 if ( props.contains( QStringLiteral(
"reference_point1_iscentroid" ) ) )
515 refPoint1IsCentroid = props[QStringLiteral(
"reference_point1_iscentroid" )].toInt();
516 if ( props.contains( QStringLiteral(
"reference_point2" ) ) )
518 if ( props.contains( QStringLiteral(
"reference_point2_iscentroid" ) ) )
519 refPoint2IsCentroid = props[QStringLiteral(
"reference_point2_iscentroid" )].toInt();
520 if ( props.contains( QStringLiteral(
"angle" ) ) )
521 angle = props[QStringLiteral(
"angle" )].toDouble();
523 if ( props.contains( QStringLiteral(
"offset" ) ) )
528 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
539 sl->setOffset( offset );
540 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
542 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
544 sl->setReferencePoint1( referencePoint1 );
545 sl->setReferencePoint1IsCentroid( refPoint1IsCentroid );
546 sl->setReferencePoint2( referencePoint2 );
547 sl->setReferencePoint2IsCentroid( refPoint2IsCentroid );
548 sl->setAngle( angle );
550 sl->setColorRamp( gradientRamp );
552 sl->restoreOldDataDefinedProperties( props );
565 return QStringLiteral(
"GradientFill" );
568 void QgsGradientFillSymbolLayer::applyDataDefinedSymbology(
QgsSymbolRenderContext &context,
const QPolygonF &points )
611 if ( currentType == QObject::tr(
"linear" ) )
615 else if ( currentType == QObject::tr(
"radial" ) )
619 else if ( currentType == QObject::tr(
"conical" ) )
633 if ( currentCoordMode == QObject::tr(
"feature" ) )
637 else if ( currentCoordMode == QObject::tr(
"viewport" ) )
651 if ( currentSpread == QObject::tr(
"pad" ) )
655 else if ( currentSpread == QObject::tr(
"repeat" ) )
659 else if ( currentSpread == QObject::tr(
"reflect" ) )
706 if ( refPoint1IsCentroid || refPoint2IsCentroid )
711 QRectF bbox = points.boundingRect();
712 double centroidX = ( centroid.x() - bbox.left() ) / bbox.width();
713 double centroidY = ( centroid.y() - bbox.top() ) / bbox.height();
715 if ( refPoint1IsCentroid )
717 refPoint1X = centroidX;
718 refPoint1Y = centroidY;
720 if ( refPoint2IsCentroid )
722 refPoint2X = centroidX;
723 refPoint2Y = centroidY;
729 spread, QPointF( refPoint1X, refPoint1Y ), QPointF( refPoint2X, refPoint2Y ), angle );
732 QPointF QgsGradientFillSymbolLayer::rotateReferencePoint( QPointF refPoint,
double angle )
737 QLineF refLine = QLineF( QPointF( 0.5, 0.5 ), refPoint );
739 refLine.setAngle( refLine.angle() +
angle );
741 QPointF rotatedReferencePoint = refLine.p2();
743 if ( rotatedReferencePoint.x() > 1 )
744 rotatedReferencePoint.setX( 1 );
745 if ( rotatedReferencePoint.x() < 0 )
746 rotatedReferencePoint.setX( 0 );
747 if ( rotatedReferencePoint.y() > 1 )
748 rotatedReferencePoint.setY( 1 );
749 if ( rotatedReferencePoint.y() < 0 )
750 rotatedReferencePoint.setY( 0 );
752 return rotatedReferencePoint;
763 fillColor.setAlphaF( context.
opacity() * fillColor.alphaF() );
764 QColor fillColor2 =
color2;
765 fillColor2.setAlphaF( context.
opacity() * fillColor2.alphaF() );
776 gradient = QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
779 gradient = QRadialGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
782 gradient = QConicalGradient( rotatedReferencePoint1, QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).
angle() );
788 gradient.setCoordinateMode( QGradient::ObjectBoundingMode );
791 gradient.setCoordinateMode( QGradient::StretchToDeviceMode );
797 gradient.setSpread( QGradient::PadSpread );
800 gradient.setSpread( QGradient::ReflectSpread );
803 gradient.setSpread( QGradient::RepeatSpread );
809 ( gradientRamp->
type() == QLatin1String(
"gradient" ) || gradientRamp->
type() == QLatin1String(
"cpt-city" ) ) )
818 gradient.setColorAt( 0.0, fillColor );
819 gradient.setColorAt( 1.0, fillColor2 );
823 brush = QBrush( gradient );
830 selColor.setAlphaF( context.
opacity() );
847 applyDataDefinedSymbology( context, points );
850 p->setPen( Qt::NoPen );
857 p->translate( offset );
864 p->translate( -offset );
874 map[QStringLiteral(
"type" )] = QString::number(
mGradientType );
875 map[QStringLiteral(
"coordinate_mode" )] = QString::number(
mCoordinateMode );
881 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
939 int blurRadius,
bool useWholeShape,
double maxDistance )
940 : mBlurRadius( blurRadius )
941 , mUseWholeShape( useWholeShape )
942 , mMaxDistance( maxDistance )
943 , mColorType( colorType )
962 if ( props.contains( QStringLiteral(
"color_type" ) ) )
964 colorType =
static_cast< ShapeburstColorType >( props[QStringLiteral(
"color_type" )].toInt() );
966 if ( props.contains( QStringLiteral(
"shapeburst_color" ) ) )
971 else if ( props.contains( QStringLiteral(
"color" ) ) )
976 if ( props.contains( QStringLiteral(
"shapeburst_color2" ) ) )
981 else if ( props.contains( QStringLiteral(
"gradient_color2" ) ) )
985 if ( props.contains( QStringLiteral(
"blur_radius" ) ) )
987 blurRadius = props[QStringLiteral(
"blur_radius" )].toInt();
989 if ( props.contains( QStringLiteral(
"use_whole_shape" ) ) )
991 useWholeShape = props[QStringLiteral(
"use_whole_shape" )].toInt();
993 if ( props.contains( QStringLiteral(
"max_distance" ) ) )
995 maxDistance = props[QStringLiteral(
"max_distance" )].toDouble();
997 if ( props.contains( QStringLiteral(
"offset" ) ) )
1004 if ( props.contains( QStringLiteral(
"rampType" ) ) && props[QStringLiteral(
"rampType" )] == QStringLiteral(
"cpt-city" ) )
1015 sl->setOffset( offset );
1016 if ( props.contains( QStringLiteral(
"offset_unit" ) ) )
1020 if ( props.contains( QStringLiteral(
"distance_unit" ) ) )
1024 if ( props.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
1028 if ( props.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
1032 if ( props.contains( QStringLiteral(
"ignore_rings" ) ) )
1034 sl->setIgnoreRings( props[QStringLiteral(
"ignore_rings" )].toInt() );
1038 sl->setColorRamp( gradientRamp );
1041 sl->restoreOldDataDefinedProperties( props );
1043 return sl.release();
1048 return QStringLiteral(
"ShapeburstFill" );
1053 if ( mGradientRamp.get() == ramp )
1056 mGradientRamp.reset( ramp );
1103 ignoreRings = mIgnoreRings;
1117 selColor.setAlphaF( context.
opacity() );
1118 mSelBrush = QBrush( selColor );
1123 Q_UNUSED( context );
1137 p->setBrush( mSelBrush );
1139 if ( !mOffset.isNull() )
1143 p->translate( offset );
1146 if ( !mOffset.isNull() )
1148 p->translate( -offset );
1159 applyDataDefinedSymbology( context, color1, color2, blurRadius, useWholeShape, maxDistance, ignoreRings );
1162 int outputPixelMaxDist = 0;
1170 std::unique_ptr< QgsGradientColorRamp > twoColorGradientRamp;
1173 twoColorGradientRamp = qgis::make_unique< QgsGradientColorRamp >( color1,
color2 );
1177 p->setPen( QPen( Qt::NoPen ) );
1180 int sideBuffer = 4 + ( blurRadius + 2 ) * 4;
1182 int pointsWidth =
static_cast< int >( std::round( points.boundingRect().width() ) );
1183 int pointsHeight =
static_cast< int >( std::round( points.boundingRect().height() ) );
1184 int imWidth = pointsWidth + ( sideBuffer * 2 );
1185 int imHeight = pointsHeight + ( sideBuffer * 2 );
1186 std::unique_ptr< QImage > fillImage = qgis::make_unique< QImage >( imWidth,
1187 imHeight, QImage::Format_ARGB32_Premultiplied );
1188 if ( fillImage->isNull() )
1195 std::unique_ptr< QImage > alphaImage = qgis::make_unique< QImage >( fillImage->width(), fillImage->height(), QImage::Format_ARGB32_Premultiplied );
1196 if ( alphaImage->isNull() )
1205 fillImage->fill( Qt::black );
1208 alphaImage->fill( Qt::transparent );
1211 QPainter imgPainter;
1212 imgPainter.begin( alphaImage.get() );
1213 imgPainter.setRenderHint( QPainter::Antialiasing,
true );
1214 imgPainter.setBrush( QBrush( Qt::white ) );
1215 imgPainter.setPen( QPen( Qt::black ) );
1216 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1222 imgPainter.begin( fillImage.get() );
1225 imgPainter.drawImage( 0, 0, *alphaImage );
1232 imgPainter.setBrush( QBrush( Qt::white ) );
1233 imgPainter.setPen( QPen( Qt::black ) );
1234 imgPainter.translate( -points.boundingRect().left() + sideBuffer, - points.boundingRect().top() + sideBuffer );
1240 double *dtArray = distanceTransform( fillImage.get(), context.
renderContext() );
1250 if ( blurRadius > 0 )
1256 imgPainter.begin( fillImage.get() );
1257 imgPainter.setCompositionMode( QPainter::CompositionMode_DestinationIn );
1258 imgPainter.drawImage( 0, 0, *alphaImage );
1267 if ( !mOffset.isNull() )
1271 p->translate( offset );
1274 p->drawImage( points.boundingRect().left() - sideBuffer, points.boundingRect().top() - sideBuffer, *fillImage );
1276 if ( !mOffset.isNull() )
1278 p->translate( -offset );
1287 void QgsShapeburstFillSymbolLayer::distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d )
1293 for (
int q = 1; q <= n - 1; q++ )
1295 double s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1299 s = ( ( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1308 for (
int q = 0; q <= n - 1; q++ )
1310 while ( z[k + 1] < q )
1312 d[q] = ( q - v[k] ) * ( q - v[k] ) + f[v[k]];
1317 void QgsShapeburstFillSymbolLayer::distanceTransform2d(
double *im,
int width,
int height,
QgsRenderContext &context )
1319 int maxDimension = std::max( width, height );
1320 double *f =
new double[ maxDimension ];
1321 int *v =
new int[ maxDimension ];
1322 double *z =
new double[ maxDimension + 1 ];
1323 double *d =
new double[ maxDimension ];
1326 for (
int x = 0; x < width; x++ )
1331 for (
int y = 0; y < height; y++ )
1333 f[y] = im[ x + y * width ];
1335 distanceTransform1d( f, height, v, z, d );
1336 for (
int y = 0; y < height; y++ )
1338 im[ x + y * width ] = d[y];
1343 for (
int y = 0; y < height; y++ )
1348 for (
int x = 0; x < width; x++ )
1350 f[x] = im[ x + y * width ];
1352 distanceTransform1d( f, width, v, z, d );
1353 for (
int x = 0; x < width; x++ )
1355 im[ x + y * width ] = d[x];
1366 double *QgsShapeburstFillSymbolLayer::distanceTransform( QImage *im,
QgsRenderContext &context )
1368 int width = im->width();
1369 int height = im->height();
1371 double *dtArray =
new double[width * height];
1376 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1381 const QRgb *scanLine =
reinterpret_cast< const QRgb *
>( im->constScanLine( heightIndex ) );
1382 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1384 tmpRgb = scanLine[widthIndex];
1385 if ( qRed( tmpRgb ) == 0 )
1393 dtArray[ idx ] =
INF;
1400 distanceTransform2d( dtArray, width, height, context );
1407 int width = im->width();
1408 int height = im->height();
1411 double maxDistanceValue;
1416 double dtMaxValue = array[0];
1417 for (
int i = 1; i < ( width * height ); ++i )
1419 if ( array[i] > dtMaxValue )
1421 dtMaxValue = array[i];
1426 maxDistanceValue = std::sqrt( dtMaxValue );
1431 maxDistanceValue = maxPixelDistance;
1436 double squaredVal = 0;
1439 bool layerHasAlpha = layerAlpha < 1.0;
1441 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1446 QRgb *scanLine =
reinterpret_cast< QRgb *
>( im->scanLine( heightIndex ) );
1447 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1450 squaredVal = array[idx];
1453 if ( maxDistanceValue > 0 )
1455 pixVal = squaredVal > 0 ? std::min( ( std::sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1463 pixColor = ramp->
color( pixVal );
1465 int pixAlpha = pixColor.alpha();
1466 if ( ( layerHasAlpha ) || ( pixAlpha != 255 ) )
1469 double alpha = pixAlpha * layerAlpha;
1474 scanLine[widthIndex] = pixColor.rgba();
1485 map[QStringLiteral(
"color_type" )] = QString::number( mColorType );
1486 map[QStringLiteral(
"blur_radius" )] = QString::number( mBlurRadius );
1487 map[QStringLiteral(
"use_whole_shape" )] = QString::number( mUseWholeShape );
1488 map[QStringLiteral(
"max_distance" )] = QString::number( mMaxDistance );
1491 map[QStringLiteral(
"ignore_rings" )] = QString::number( mIgnoreRings );
1495 if ( mGradientRamp )
1497 map.unite( mGradientRamp->properties() );
1505 std::unique_ptr< QgsShapeburstFillSymbolLayer > sl = qgis::make_unique< QgsShapeburstFillSymbolLayer >(
mColor, mColor2, mColorType, mBlurRadius, mUseWholeShape, mMaxDistance );
1506 if ( mGradientRamp )
1510 sl->setDistanceUnit( mDistanceUnit );
1511 sl->setDistanceMapUnitScale( mDistanceMapUnitScale );
1512 sl->setIgnoreRings( mIgnoreRings );
1513 sl->setOffset( mOffset );
1514 sl->setOffsetUnit( mOffsetUnit );
1515 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
1518 return sl.release();
1523 double offsetBleed = context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
1529 mDistanceUnit = unit;
1535 if ( mDistanceUnit == mOffsetUnit )
1537 return mDistanceUnit;
1544 mDistanceMapUnitScale = scale;
1545 mOffsetMapUnitScale = scale;
1550 if ( mDistanceMapUnitScale == mOffsetMapUnitScale )
1552 return mDistanceMapUnitScale;
1574 applyDataDefinedSettings( context );
1576 p->setPen( QPen( Qt::NoPen ) );
1578 QTransform bkTransform = mBrush.transform();
1582 QPointF leftCorner = points.boundingRect().topLeft();
1583 QTransform t = mBrush.transform();
1584 t.translate( leftCorner.x(), leftCorner.y() );
1585 mBrush.setTransform( t );
1594 p->setBrush( QBrush( selColor ) );
1600 QTransform t = mBrush.transform();
1601 t.rotate( mNextAngle );
1602 mBrush.setTransform( t );
1604 p->setBrush( mBrush );
1611 QList<QPolygonF>::const_iterator ringIt = rings->constBegin();
1612 for ( ; ringIt != rings->constEnd(); ++ringIt )
1619 mBrush.setTransform( bkTransform );
1626 mStroke.reset(
nullptr );
1639 mStroke.reset( lineSymbol );
1649 mStrokeWidthUnit = unit;
1654 return mStrokeWidthUnit;
1659 mStrokeWidthMapUnitScale = scale;
1664 return mStrokeWidthMapUnitScale;
1669 if ( mStroke && mStroke->symbolLayer( 0 ) )
1671 double subLayerBleed = mStroke->symbolLayer( 0 )->estimateMaxBleed( context );
1672 return subLayerBleed;
1679 double width = mStrokeWidth;
1690 Q_UNUSED( context );
1693 return QColor( Qt::black );
1695 return mStroke->color();
1700 return Qt::SolidLine;
1704 return Qt::SolidLine;
1708 return mStroke->dxfPenStyle();
1717 attr.unite( mStroke->usedAttributes( context ) );
1725 if ( mStroke && mStroke->hasDataDefinedProperties() )
1735 , mPatternWidth( width )
1739 mColor = QColor( 255, 255, 255 );
1745 , mPatternWidth( width )
1746 , mSvgData( svgData )
1751 mColor = QColor( 255, 255, 255 );
1753 setDefaultSvgParams();
1759 mPatternWidthUnit = unit;
1760 mSvgStrokeWidthUnit = unit;
1762 mStroke->setOutputUnit( unit );
1768 if ( mPatternWidthUnit != unit || mSvgStrokeWidthUnit != unit ||
mStrokeWidthUnit != unit )
1778 mPatternWidthMapUnitScale = scale;
1779 mSvgStrokeWidthMapUnitScale = scale;
1786 mPatternWidthMapUnitScale == mSvgStrokeWidthMapUnitScale &&
1789 return mPatternWidthMapUnitScale;
1799 mSvgFilePath = svgPath;
1800 setDefaultSvgParams();
1810 if ( properties.contains( QStringLiteral(
"width" ) ) )
1812 width = properties[QStringLiteral(
"width" )].toDouble();
1814 if ( properties.contains( QStringLiteral(
"svgFile" ) ) )
1816 svgFilePath = properties[QStringLiteral(
"svgFile" )];
1818 if ( properties.contains( QStringLiteral(
"angle" ) ) )
1820 angle = properties[QStringLiteral(
"angle" )].toDouble();
1823 std::unique_ptr< QgsSVGFillSymbolLayer > symbolLayer;
1824 if ( !svgFilePath.isEmpty() )
1826 symbolLayer = qgis::make_unique< QgsSVGFillSymbolLayer >(
svgFilePath, width,
angle );
1830 if ( properties.contains( QStringLiteral(
"data" ) ) )
1832 data = QByteArray::fromHex( properties[QStringLiteral(
"data" )].toLocal8Bit() );
1834 symbolLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( data, width,
angle );
1838 if ( properties.contains( QStringLiteral(
"svgFillColor" ) ) )
1843 else if ( properties.contains( QStringLiteral(
"color" ) ) )
1847 if ( properties.contains( QStringLiteral(
"svgOutlineColor" ) ) )
1852 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
1856 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
1860 if ( properties.contains( QStringLiteral(
"svgOutlineWidth" ) ) )
1863 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"svgOutlineWidth" )].toDouble() );
1865 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
1867 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"outline_width" )].toDouble() );
1869 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
1871 symbolLayer->setSvgStrokeWidth( properties[QStringLiteral(
"line_width" )].toDouble() );
1875 if ( properties.contains( QStringLiteral(
"pattern_width_unit" ) ) )
1879 if ( properties.contains( QStringLiteral(
"pattern_width_map_unit_scale" ) ) )
1883 if ( properties.contains( QStringLiteral(
"svg_outline_width_unit" ) ) )
1887 if ( properties.contains( QStringLiteral(
"svg_outline_width_map_unit_scale" ) ) )
1891 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
1895 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
1900 symbolLayer->restoreOldDataDefinedProperties( properties );
1902 return symbolLayer.release();
1907 QgsStringMap::iterator it = properties.find( QStringLiteral(
"svgFile" ) );
1908 if ( it != properties.end() )
1919 return QStringLiteral(
"SVGFill" );
1927 if ( mSvgViewBox.isNull() )
1934 if ( static_cast< int >( size ) < 1.0 || 10000.0 < size )
1936 brush.setTextureImage( QImage() );
1940 bool fitsInCache =
true;
1948 double hwRatio = 1.0;
1949 if ( patternPict.width() > 0 )
1951 hwRatio =
static_cast< double >( patternPict.height() ) / static_cast< double >( patternPict.width() );
1953 patternImage = QImage( static_cast< int >( size ), static_cast< int >( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
1954 patternImage.fill( 0 );
1956 QPainter p( &patternImage );
1957 p.drawPicture( QPointF( size / 2, size * hwRatio / 2 ), patternPict );
1960 QTransform brushTransform;
1963 QImage transparentImage = patternImage.copy();
1965 brush.setTextureImage( transparentImage );
1969 brush.setTextureImage( patternImage );
1971 brush.setTransform( brushTransform );
1978 applyPattern(
mBrush, mSvgFilePath, mPatternWidth, mPatternWidthUnit,
mColor, mSvgStrokeColor, mSvgStrokeWidth, mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale );
1997 if ( !mSvgFilePath.isEmpty() )
1999 map.insert( QStringLiteral(
"svgFile" ), mSvgFilePath );
2003 map.insert( QStringLiteral(
"data" ), QString( mSvgData.toHex() ) );
2006 map.insert( QStringLiteral(
"width" ), QString::number( mPatternWidth ) );
2007 map.insert( QStringLiteral(
"angle" ), QString::number(
mAngle ) );
2012 map.insert( QStringLiteral(
"outline_width" ), QString::number( mSvgStrokeWidth ) );
2026 std::unique_ptr< QgsSVGFillSymbolLayer > clonedLayer;
2027 if ( !mSvgFilePath.isEmpty() )
2029 clonedLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( mSvgFilePath, mPatternWidth,
mAngle );
2031 clonedLayer->setSvgStrokeColor( mSvgStrokeColor );
2032 clonedLayer->setSvgStrokeWidth( mSvgStrokeWidth );
2036 clonedLayer = qgis::make_unique< QgsSVGFillSymbolLayer >( mSvgData, mPatternWidth,
mAngle );
2039 clonedLayer->setPatternWidthUnit( mPatternWidthUnit );
2040 clonedLayer->setPatternWidthMapUnitScale( mPatternWidthMapUnitScale );
2041 clonedLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnit );
2042 clonedLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthMapUnitScale );
2048 clonedLayer->setSubSymbol(
mStroke->clone() );
2052 return clonedLayer.release();
2057 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2058 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
2059 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
2060 element.appendChild( symbolizerElem );
2064 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2065 symbolizerElem.appendChild( fillElem );
2067 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2068 fillElem.appendChild( graphicFillElem );
2070 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2071 graphicFillElem.appendChild( graphicElem );
2073 if ( !mSvgFilePath.isEmpty() )
2084 symbolizerElem.appendChild( doc.createComment( QStringLiteral(
"SVG from data not implemented yet" ) ) );
2090 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2093 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg(
mAngle );
2097 angleFunc = QString::number( angle +
mAngle );
2106 mStroke->toSld( doc, element, props );
2112 QString path, mimeType;
2114 Qt::PenStyle penStyle;
2115 double size, strokeWidth;
2117 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2118 if ( fillElem.isNull() )
2121 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2122 if ( graphicFillElem.isNull() )
2125 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2126 if ( graphicElem.isNull() )
2132 if ( mimeType != QLatin1String(
"image/svg+xml" ) )
2137 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2146 double d = angleFunc.toDouble( &ok );
2151 std::unique_ptr< QgsSVGFillSymbolLayer > sl = qgis::make_unique< QgsSVGFillSymbolLayer >( path, size,
angle );
2152 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2153 sl->setSvgFillColor( fillColor );
2154 sl->setSvgStrokeColor( strokeColor );
2155 sl->setSvgStrokeWidth( strokeWidth );
2158 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2159 if ( !strokeElem.isNull() )
2170 return sl.release();
2188 double width = mPatternWidth;
2194 QString svgFile = mSvgFilePath;
2213 double strokeWidth = mSvgStrokeWidth;
2219 applyPattern(
mBrush, svgFile, width, mPatternWidthUnit, svgFillColor, svgStrokeColor, strokeWidth,
2220 mSvgStrokeWidthUnit, context, mPatternWidthMapUnitScale, mSvgStrokeWidthMapUnitScale );
2224 void QgsSVGFillSymbolLayer::storeViewBox()
2226 if ( !mSvgData.isEmpty() )
2228 QSvgRenderer r( mSvgData );
2231 mSvgViewBox = r.viewBoxF();
2236 mSvgViewBox = QRectF();
2239 void QgsSVGFillSymbolLayer::setDefaultSvgParams()
2241 if ( mSvgFilePath.isEmpty() )
2246 bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2247 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2248 QColor defaultFillColor, defaultStrokeColor;
2249 double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2251 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2252 hasStrokeParam, hasDefaultStrokeColor, defaultStrokeColor,
2253 hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2254 hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2256 double newFillOpacity = hasFillOpacityParam ?
mColor.alphaF() : 1.0;
2257 double newStrokeOpacity = hasStrokeOpacityParam ? mSvgStrokeColor.alphaF() : 1.0;
2259 if ( hasDefaultFillColor )
2261 mColor = defaultFillColor;
2262 mColor.setAlphaF( newFillOpacity );
2264 if ( hasDefaultFillOpacity )
2266 mColor.setAlphaF( defaultFillOpacity );
2268 if ( hasDefaultStrokeColor )
2270 mSvgStrokeColor = defaultStrokeColor;
2271 mSvgStrokeColor.setAlphaF( newStrokeOpacity );
2273 if ( hasDefaultStrokeOpacity )
2275 mSvgStrokeColor.setAlphaF( defaultStrokeOpacity );
2277 if ( hasDefaultStrokeWidth )
2279 mSvgStrokeWidth = defaultStrokeWidth;
2305 return mFillLineSymbol ? mFillLineSymbol->
color() :
mColor;
2310 delete mFillLineSymbol;
2325 delete mFillLineSymbol;
2326 mFillLineSymbol = lineSymbol;
2337 return mFillLineSymbol;
2343 if ( mFillLineSymbol )
2365 mDistanceUnit = unit;
2366 mLineWidthUnit = unit;
2373 if ( mDistanceUnit != unit || mLineWidthUnit != unit || mOffsetUnit != unit )
2383 mDistanceMapUnitScale = scale;
2384 mLineWidthMapUnitScale = scale;
2385 mOffsetMapUnitScale = scale;
2391 mDistanceMapUnitScale == mLineWidthMapUnitScale &&
2392 mLineWidthMapUnitScale == mOffsetMapUnitScale )
2394 return mDistanceMapUnitScale;
2401 std::unique_ptr< QgsLinePatternFillSymbolLayer > patternLayer = qgis::make_unique< QgsLinePatternFillSymbolLayer >();
2407 QColor
color( Qt::black );
2410 if ( properties.contains( QStringLiteral(
"lineangle" ) ) )
2413 lineAngle = properties[QStringLiteral(
"lineangle" )].toDouble();
2415 else if ( properties.contains( QStringLiteral(
"angle" ) ) )
2417 lineAngle = properties[QStringLiteral(
"angle" )].toDouble();
2419 patternLayer->setLineAngle( lineAngle );
2421 if ( properties.contains( QStringLiteral(
"distance" ) ) )
2423 distance = properties[QStringLiteral(
"distance" )].toDouble();
2425 patternLayer->setDistance( distance );
2427 if ( properties.contains( QStringLiteral(
"linewidth" ) ) )
2430 lineWidth = properties[QStringLiteral(
"linewidth" )].toDouble();
2432 else if ( properties.contains( QStringLiteral(
"outline_width" ) ) )
2434 lineWidth = properties[QStringLiteral(
"outline_width" )].toDouble();
2436 else if ( properties.contains( QStringLiteral(
"line_width" ) ) )
2438 lineWidth = properties[QStringLiteral(
"line_width" )].toDouble();
2440 patternLayer->setLineWidth( lineWidth );
2442 if ( properties.contains( QStringLiteral(
"color" ) ) )
2446 else if ( properties.contains( QStringLiteral(
"outline_color" ) ) )
2450 else if ( properties.contains( QStringLiteral(
"line_color" ) ) )
2454 patternLayer->setColor( color );
2456 if ( properties.contains( QStringLiteral(
"offset" ) ) )
2458 offset = properties[QStringLiteral(
"offset" )].toDouble();
2460 patternLayer->setOffset( offset );
2463 if ( properties.contains( QStringLiteral(
"distance_unit" ) ) )
2467 if ( properties.contains( QStringLiteral(
"distance_map_unit_scale" ) ) )
2471 if ( properties.contains( QStringLiteral(
"line_width_unit" ) ) )
2475 else if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2479 if ( properties.contains( QStringLiteral(
"line_width_map_unit_scale" ) ) )
2483 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
2487 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
2491 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
2495 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
2500 patternLayer->restoreOldDataDefinedProperties( properties );
2502 return patternLayer.release();
2507 return QStringLiteral(
"LinePatternFill" );
2512 mBrush.setTextureImage( QImage() );
2514 if ( !mFillLineSymbol )
2519 std::unique_ptr< QgsLineSymbol > fillLineSymbol( mFillLineSymbol->
clone() );
2520 if ( !fillLineSymbol )
2527 double outputPixelDist = ctx.
convertToPainterUnits( distance, mDistanceUnit, mDistanceMapUnitScale );
2535 outputPixelOffset = std::fmod( outputPixelOffset, outputPixelDist );
2536 if ( outputPixelOffset > outputPixelDist / 2.0 )
2537 outputPixelOffset -= outputPixelDist;
2541 double outputPixelBleed = 0;
2542 double outputPixelInterval = 0;
2543 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2547 outputPixelBleed = std::max( outputPixelBleed, outputPixelLayerBleed );
2550 if ( markerLineLayer )
2559 outputPixelInterval = std::max( outputPixelInterval, outputPixelLayerInterval );
2563 if ( outputPixelInterval > 0 )
2567 double intervalScale = std::round( outputPixelInterval ) / outputPixelInterval;
2568 outputPixelInterval = std::round( outputPixelInterval );
2570 for (
int i = 0; i < fillLineSymbol->symbolLayerCount(); i++ )
2575 if ( markerLineLayer )
2589 height = outputPixelDist;
2590 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2594 width = outputPixelDist;
2595 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2599 height = outputPixelDist / std::cos(
lineAngle * M_PI / 180 );
2600 width = outputPixelDist / std::sin(
lineAngle * M_PI / 180 );
2603 lineAngle = 180 * std::atan2( static_cast< double >( height ), static_cast< double >( width ) ) / M_PI;
2609 height = std::abs( height );
2610 width = std::abs( width );
2612 outputPixelDist = std::abs( height * std::cos(
lineAngle * M_PI / 180 ) );
2616 int offsetHeight =
static_cast< int >( std::round( outputPixelOffset / std::cos(
lineAngle * M_PI / 180 ) ) );
2617 outputPixelOffset = offsetHeight * std::cos(
lineAngle * M_PI / 180 );
2626 int bufferMulti =
static_cast< int >( std::max( std::ceil( outputPixelBleed / width ), std::ceil( outputPixelBleed / width ) ) );
2630 bufferMulti = std::max( bufferMulti, 1 );
2632 int xBuffer = width * bufferMulti;
2633 int yBuffer = height * bufferMulti;
2634 int innerWidth = width;
2635 int innerHeight = height;
2636 width += 2 * xBuffer;
2637 height += 2 * yBuffer;
2640 if ( width > 10000 || height > 10000 || width == 0 || height == 0 )
2645 QImage patternImage( width, height, QImage::Format_ARGB32 );
2646 patternImage.fill( 0 );
2648 QPointF p1, p2, p3, p4, p5, p6;
2651 p1 = QPointF( 0, yBuffer );
2652 p2 = QPointF( width, yBuffer );
2653 p3 = QPointF( 0, yBuffer + innerHeight );
2654 p4 = QPointF( width, yBuffer + innerHeight );
2658 p1 = QPointF( xBuffer, height );
2659 p2 = QPointF( xBuffer, 0 );
2660 p3 = QPointF( xBuffer + innerWidth, height );
2661 p4 = QPointF( xBuffer + innerWidth, 0 );
2665 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2666 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2667 p1 = QPointF( 0, height );
2668 p2 = QPointF( width, 0 );
2669 p3 = QPointF( -dx, height - dy );
2670 p4 = QPointF( width - dx, -dy );
2671 p5 = QPointF( dx, height + dy );
2672 p6 = QPointF( width + dx, dy );
2676 dx = outputPixelDist * std::cos( ( 90 -
lineAngle ) * M_PI / 180.0 );
2677 dy = outputPixelDist * std::sin( ( 90 -
lineAngle ) * M_PI / 180.0 );
2678 p1 = QPointF( width, 0 );
2679 p2 = QPointF( 0, height );
2680 p3 = QPointF( width - dx, -dy );
2681 p4 = QPointF( -dx, height - dy );
2682 p5 = QPointF( width + dx, dy );
2683 p6 = QPointF( dx, height + dy );
2687 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2688 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2689 p1 = QPointF( 0, 0 );
2690 p2 = QPointF( width, height );
2691 p5 = QPointF( dx, -dy );
2692 p6 = QPointF( width + dx, height - dy );
2693 p3 = QPointF( -dx, dy );
2694 p4 = QPointF( width - dx, height + dy );
2698 dy = outputPixelDist * std::cos( ( 180 -
lineAngle ) * M_PI / 180 );
2699 dx = outputPixelDist * std::sin( ( 180 -
lineAngle ) * M_PI / 180 );
2700 p1 = QPointF( width, height );
2701 p2 = QPointF( 0, 0 );
2702 p5 = QPointF( width + dx, height - dy );
2703 p6 = QPointF( dx, -dy );
2704 p3 = QPointF( width - dx, height + dy );
2705 p4 = QPointF( -dx, dy );
2712 p3 = QPointF( tempPt.x(), tempPt.y() );
2714 p4 = QPointF( tempPt.x(), tempPt.y() );
2716 p5 = QPointF( tempPt.x(), tempPt.y() );
2718 p6 = QPointF( tempPt.x(), tempPt.y() );
2722 p1 = QPointF( tempPt.x(), tempPt.y() );
2724 p2 = QPointF( tempPt.x(), tempPt.y() );
2727 QPainter p( &patternImage );
2731 p.setRenderHint( QPainter::Antialiasing,
false );
2732 QPen pen( QColor( Qt::black ) );
2733 pen.setWidthF( 0.1 );
2734 pen.setCapStyle( Qt::FlatCap );
2739 QPolygon polygon = QPolygon() << QPoint( 0, 0 ) << QPoint( width - 1, 0 ) << QPoint( width - 1, height - 1 ) << QPoint( 0, height - 1 ) << QPoint( 0, 0 );
2740 p.drawPolygon( polygon );
2742 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 );
2743 p.drawPolygon( polygon );
2749 p.setRenderHint( QPainter::Antialiasing,
true );
2760 fillLineSymbol->startRender( lineRenderContext, context.
fields() );
2762 QVector<QPolygonF> polygons;
2763 polygons.append( QPolygonF() << p1 << p2 );
2764 polygons.append( QPolygonF() << p3 << p4 );
2767 polygons.append( QPolygonF() << p5 << p6 );
2770 for (
const QPolygonF &polygon : qgis::as_const( polygons ) )
2772 fillLineSymbol->renderPolyline( polygon, context.
feature(), lineRenderContext, -1, context.
selected() );
2775 fillLineSymbol->stopRender( lineRenderContext );
2779 patternImage = patternImage.copy( xBuffer, yBuffer, patternImage.width() - 2 * xBuffer, patternImage.height() - 2 * yBuffer );
2784 QImage transparentImage = patternImage.copy();
2786 brush.setTextureImage( transparentImage );
2790 brush.setTextureImage( patternImage );
2793 QTransform brushTransform;
2794 brush.setTransform( brushTransform );
2799 applyPattern( context,
mBrush, mLineAngle, mDistance );
2801 if ( mFillLineSymbol )
2809 if ( mFillLineSymbol )
2818 map.insert( QStringLiteral(
"angle" ), QString::number( mLineAngle ) );
2819 map.insert( QStringLiteral(
"distance" ), QString::number( mDistance ) );
2820 map.insert( QStringLiteral(
"line_width" ), QString::number( mLineWidth ) );
2822 map.insert( QStringLiteral(
"offset" ), QString::number( mOffset ) );
2837 if ( mFillLineSymbol )
2848 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
2849 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
2850 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
2851 element.appendChild( symbolizerElem );
2856 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
2857 symbolizerElem.appendChild( fillElem );
2859 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
2860 fillElem.appendChild( graphicFillElem );
2862 QDomElement graphicElem = doc.createElement( QStringLiteral(
"se:Graphic" ) );
2863 graphicFillElem.appendChild( graphicElem );
2866 QColor lineColor = mFillLineSymbol ? mFillLineSymbol->
color() : QColor();
2867 double lineWidth = mFillLineSymbol ? mFillLineSymbol->
width() : 0.0;
2875 double angle = props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ).toDouble( &ok );
2878 angleFunc = QStringLiteral(
"%1 + %2" ).arg( props.value( QStringLiteral(
"angle" ), QStringLiteral(
"0" ) ) ).arg( mLineAngle );
2882 angleFunc = QString::number( angle + mLineAngle );
2887 QPointF lineOffset( std::sin( mLineAngle ) * mOffset, std::cos( mLineAngle ) * mOffset );
2894 QString featureStyle;
2895 featureStyle.append(
"Brush(" );
2896 featureStyle.append( QStringLiteral(
"fc:%1" ).arg(
mColor.name() ) );
2897 featureStyle.append( QStringLiteral(
",bc:%1" ).arg( QStringLiteral(
"#00000000" ) ) );
2898 featureStyle.append(
",id:\"ogr-brush-2\"" );
2899 featureStyle.append( QStringLiteral(
",a:%1" ).arg( mLineAngle ) );
2900 featureStyle.append( QStringLiteral(
",s:%1" ).arg( mLineWidth * widthScaleFactor ) );
2901 featureStyle.append(
",dx:0mm" );
2902 featureStyle.append( QStringLiteral(
",dy:%1mm" ).arg( mDistance * widthScaleFactor ) );
2903 featureStyle.append(
')' );
2904 return featureStyle;
2927 applyPattern( context,
mBrush, lineAngle, distance );
2935 Qt::PenStyle lineStyle;
2937 QDomElement fillElem = element.firstChildElement( QStringLiteral(
"Fill" ) );
2938 if ( fillElem.isNull() )
2941 QDomElement graphicFillElem = fillElem.firstChildElement( QStringLiteral(
"GraphicFill" ) );
2942 if ( graphicFillElem.isNull() )
2945 QDomElement graphicElem = graphicFillElem.firstChildElement( QStringLiteral(
"Graphic" ) );
2946 if ( graphicElem.isNull() )
2952 if ( name != QLatin1String(
"horline" ) )
2960 double d = angleFunc.toDouble( &ok );
2969 offset = std::sqrt( std::pow( vectOffset.x(), 2 ) + std::pow( vectOffset.y(), 2 ) );
2972 QString uom = element.attribute( QStringLiteral(
"uom" ) );
2976 std::unique_ptr< QgsLinePatternFillSymbolLayer > sl = qgis::make_unique< QgsLinePatternFillSymbolLayer >();
2977 sl->setOutputUnit( QgsUnitTypes::RenderUnit::RenderPixels );
2978 sl->setColor( lineColor );
2979 sl->setLineWidth( lineWidth );
2980 sl->setLineAngle( angle );
2981 sl->setOffset( offset );
2982 sl->setDistance( size );
2985 QDomElement strokeElem = element.firstChildElement( QStringLiteral(
"Stroke" ) );
2986 if ( !strokeElem.isNull() )
2997 return sl.release();
3066 std::unique_ptr< QgsPointPatternFillSymbolLayer > layer = qgis::make_unique< QgsPointPatternFillSymbolLayer >();
3067 if ( properties.contains( QStringLiteral(
"distance_x" ) ) )
3069 layer->setDistanceX( properties[QStringLiteral(
"distance_x" )].toDouble() );
3071 if ( properties.contains( QStringLiteral(
"distance_y" ) ) )
3073 layer->setDistanceY( properties[QStringLiteral(
"distance_y" )].toDouble() );
3075 if ( properties.contains( QStringLiteral(
"displacement_x" ) ) )
3077 layer->setDisplacementX( properties[QStringLiteral(
"displacement_x" )].toDouble() );
3079 if ( properties.contains( QStringLiteral(
"displacement_y" ) ) )
3081 layer->setDisplacementY( properties[QStringLiteral(
"displacement_y" )].toDouble() );
3084 if ( properties.contains( QStringLiteral(
"distance_x_unit" ) ) )
3088 if ( properties.contains( QStringLiteral(
"distance_x_map_unit_scale" ) ) )
3092 if ( properties.contains( QStringLiteral(
"distance_y_unit" ) ) )
3096 if ( properties.contains( QStringLiteral(
"distance_y_map_unit_scale" ) ) )
3100 if ( properties.contains( QStringLiteral(
"displacement_x_unit" ) ) )
3104 if ( properties.contains( QStringLiteral(
"displacement_x_map_unit_scale" ) ) )
3108 if ( properties.contains( QStringLiteral(
"displacement_y_unit" ) ) )
3112 if ( properties.contains( QStringLiteral(
"displacement_y_map_unit_scale" ) ) )
3116 if ( properties.contains( QStringLiteral(
"outline_width_unit" ) ) )
3120 if ( properties.contains( QStringLiteral(
"outline_width_map_unit_scale" ) ) )
3127 return layer.release();
3132 return QStringLiteral(
"PointPatternFill" );
3143 if ( width > 10000 || height > 10000 )
3146 brush.setTextureImage( img );
3150 QImage patternImage( width, height, QImage::Format_ARGB32 );
3151 patternImage.fill( 0 );
3155 QPainter p( &patternImage );
3165 p.setRenderHint( QPainter::Antialiasing,
true );
3194 QImage transparentImage = patternImage.copy();
3196 brush.setTextureImage( transparentImage );
3200 brush.setTextureImage( patternImage );
3202 QTransform brushTransform;
3203 brush.setTransform( brushTransform );
3227 map.insert( QStringLiteral(
"distance_x" ), QString::number(
mDistanceX ) );
3228 map.insert( QStringLiteral(
"distance_y" ), QString::number(
mDistanceY ) );
3229 map.insert( QStringLiteral(
"displacement_x" ), QString::number(
mDisplacementX ) );
3230 map.insert( QStringLiteral(
"displacement_y" ), QString::number(
mDisplacementY ) );
3260 QDomElement symbolizerElem = doc.createElement( QStringLiteral(
"se:PolygonSymbolizer" ) );
3261 if ( !props.value( QStringLiteral(
"uom" ), QString() ).isEmpty() )
3262 symbolizerElem.setAttribute( QStringLiteral(
"uom" ), props.value( QStringLiteral(
"uom" ), QString() ) );
3263 element.appendChild( symbolizerElem );
3268 QDomElement fillElem = doc.createElement( QStringLiteral(
"se:Fill" ) );
3269 symbolizerElem.appendChild( fillElem );
3271 QDomElement graphicFillElem = doc.createElement( QStringLiteral(
"se:GraphicFill" ) );
3272 fillElem.appendChild( graphicFillElem );
3279 symbolizerElem.appendChild( distanceElem );
3285 QString errorMsg = QStringLiteral(
"MarkerSymbolLayerV2 expected, %1 found. Skip it." ).arg( layer->
layerType() );
3286 graphicFillElem.appendChild( doc.createComment( errorMsg ) );
3297 Q_UNUSED( element );
3350 applyPattern( context,
mBrush, distanceX, distanceY, displacementX, displacementY );
3399 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3401 if ( properties.contains( QStringLiteral(
"point_on_surface" ) ) )
3402 sl->setPointOnSurface( properties[QStringLiteral(
"point_on_surface" )].toInt() != 0 );
3403 if ( properties.contains( QStringLiteral(
"point_on_all_parts" ) ) )
3404 sl->setPointOnAllParts( properties[QStringLiteral(
"point_on_all_parts" )].toInt() != 0 );
3408 return sl.release();
3413 return QStringLiteral(
"CentroidFill" );
3418 mMarker->setColor( color );
3424 return mMarker ? mMarker->color() :
mColor;
3429 mMarker->setOpacity( context.
opacity() );
3432 mCurrentFeatureId = -1;
3433 mBiggestPartIndex = 0;
3443 if ( !mPointOnAllParts )
3448 if ( feature->
id() != mCurrentFeatureId )
3450 mCurrentFeatureId = feature->
id();
3451 mBiggestPartIndex = 1;
3459 double areaBiggest = 0;
3463 if ( area > areaBiggest )
3466 mBiggestPartIndex = i + 1;
3474 if ( mPointOnAllParts || ( context.
geometryPartNum() == mBiggestPartIndex ) )
3484 map[QStringLiteral(
"point_on_surface" )] = QString::number( mPointOnSurface );
3485 map[QStringLiteral(
"point_on_all_parts" )] = QString::number( mPointOnAllParts );
3491 std::unique_ptr< QgsCentroidFillSymbolLayer > x = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3494 x->setSubSymbol( mMarker->clone() );
3495 x->setPointOnSurface( mPointOnSurface );
3496 x->setPointOnAllParts( mPointOnAllParts );
3507 mMarker->toSld( doc, element, props );
3518 std::unique_ptr< QgsMarkerSymbol > marker(
new QgsMarkerSymbol( layers ) );
3520 std::unique_ptr< QgsCentroidFillSymbolLayer > sl = qgis::make_unique< QgsCentroidFillSymbolLayer >();
3521 sl->setSubSymbol( marker.release() );
3522 sl->setPointOnAllParts(
false );
3523 return sl.release();
3529 return mMarker.get();
3540 mMarker.reset( static_cast<QgsMarkerSymbol *>( symbol ) );
3541 mColor = mMarker->color();
3550 attributes.unite( mMarker->usedAttributes( context ) );
3559 if ( mMarker && mMarker->hasDataDefinedProperties() )
3568 mMarker->setOutputUnit( unit );
3576 return mMarker->outputUnit();
3585 mMarker->setMapUnitScale( scale );
3593 return mMarker->mapUnitScale();
3603 , mImageFilePath( imageFilePath )
3617 if ( properties.contains( QStringLiteral(
"imageFile" ) ) )
3619 imagePath = properties[QStringLiteral(
"imageFile" )];
3621 if ( properties.contains( QStringLiteral(
"coordinate_mode" ) ) )
3623 mode =
static_cast< FillCoordinateMode >( properties[QStringLiteral(
"coordinate_mode" )].toInt() );
3625 if ( properties.contains( QStringLiteral(
"alpha" ) ) )
3627 alpha = properties[QStringLiteral(
"alpha" )].toDouble();
3629 if ( properties.contains( QStringLiteral(
"offset" ) ) )
3633 if ( properties.contains( QStringLiteral(
"angle" ) ) )
3635 angle = properties[QStringLiteral(
"angle" )].toDouble();
3637 if ( properties.contains( QStringLiteral(
"width" ) ) )
3639 width = properties[QStringLiteral(
"width" )].toDouble();
3641 std::unique_ptr< QgsRasterFillSymbolLayer > symbolLayer = qgis::make_unique< QgsRasterFillSymbolLayer >( imagePath );
3642 symbolLayer->setCoordinateMode( mode );
3643 symbolLayer->setOpacity( alpha );
3644 symbolLayer->setOffset( offset );
3645 symbolLayer->setAngle( angle );
3646 symbolLayer->setWidth( width );
3647 if ( properties.contains( QStringLiteral(
"offset_unit" ) ) )
3651 if ( properties.contains( QStringLiteral(
"offset_map_unit_scale" ) ) )
3655 if ( properties.contains( QStringLiteral(
"width_unit" ) ) )
3659 if ( properties.contains( QStringLiteral(
"width_map_unit_scale" ) ) )
3664 symbolLayer->restoreOldDataDefinedProperties( properties );
3666 return symbolLayer.release();
3671 QgsStringMap::iterator it = properties.find( QStringLiteral(
"imageFile" ) );
3672 if ( it != properties.end() )
3675 it.value() = pathResolver.
writePath( it.value() );
3677 it.value() = pathResolver.
readPath( it.value() );
3689 return QStringLiteral(
"RasterFill" );
3701 if ( !mOffset.isNull() )
3705 p->translate( offset );
3707 if ( mCoordinateMode ==
Feature )
3709 QRectF boundingRect = points.boundingRect();
3710 mBrush.setTransform(
mBrush.transform().translate( boundingRect.left() -
mBrush.transform().dx(),
3711 boundingRect.top() -
mBrush.transform().dy() ) );
3715 if ( !mOffset.isNull() )
3717 p->translate( -offset );
3723 applyPattern(
mBrush, mImageFilePath, mWidth, mOpacity, context );
3728 Q_UNUSED( context );
3734 map[QStringLiteral(
"imageFile" )] = mImageFilePath;
3735 map[QStringLiteral(
"coordinate_mode" )] = QString::number( mCoordinateMode );
3736 map[QStringLiteral(
"alpha" )] = QString::number( mOpacity );
3740 map[QStringLiteral(
"angle" )] = QString::number(
mAngle );
3741 map[QStringLiteral(
"width" )] = QString::number( mWidth );
3749 std::unique_ptr< QgsRasterFillSymbolLayer > sl = qgis::make_unique< QgsRasterFillSymbolLayer >( mImageFilePath );
3751 sl->setOpacity( mOpacity );
3752 sl->setOffset( mOffset );
3753 sl->setOffsetUnit( mOffsetUnit );
3754 sl->setOffsetMapUnitScale( mOffsetMapUnitScale );
3756 sl->setWidth( mWidth );
3757 sl->setWidthUnit( mWidthUnit );
3758 sl->setWidthMapUnitScale( mWidthMapUnitScale );
3761 return sl.release();
3766 return context.
convertToPainterUnits( std::max( std::fabs( mOffset.x() ), std::fabs( mOffset.y() ) ), mOffsetUnit, mOffsetMapUnitScale );
3771 mImageFilePath = imagePath;
3776 mCoordinateMode = mode;
3794 if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
3800 if ( hasAngleExpression )
3808 if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
3813 double width = mWidth;
3814 if ( hasWidthExpression )
3820 if ( hasOpacityExpression )
3825 QString file = mImageFilePath;
3826 if ( hasFileExpression )
3831 applyPattern(
mBrush, file, width, opacity, context );
3837 if ( image.isNull() )
3841 if ( !image.hasAlphaChannel() )
3843 image = image.convertToFormat( QImage::Format_ARGB32 );
3853 pixelWidth = image.width();
3861 p.setCompositionMode( QPainter::CompositionMode_DestinationIn );
3862 QColor alphaColor( 0, 0, 0 );
3863 alphaColor.setAlphaF( alpha );
3864 p.fillRect( image.rect(), alphaColor );
3871 image = image.scaledToWidth( pixelWidth, Qt::SmoothTransformation );
3874 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)
QgsMapUnitScale mapUnitScale() const override
#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()
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...
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)
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
Qt::PenJoinStyle penJoinStyle() const
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.
Qt::BrushStyle mBrushStyle
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
QgsUnitTypes::RenderUnit mDisplacementXUnit
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient fill.
QString ogrFeatureStyleWidth(double widthScaleFactor) const
Qt::PenStyle strokeStyle() const
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)
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.
virtual QColor strokeColor() const
Gets stroke color.
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
double symbologyScale() const
Returns the reference scale for output.
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.
void setColor(const QColor &c) override
The fill color.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
Use antialiasing while drawing.
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
QgsMapUnitScale mapUnitScale() const override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
QColor selectionColor() const
Returns the color to use when rendering selected features.
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...
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.
A symbol fill consisting of repeated parallel lines.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
QgsLinePatternFillSymbolLayer()
double displacementX() const
QgsUnitTypes::RenderUnit mOffsetUnit
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
double interval() const
Returns the interval between individual markers.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
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
double rendererScale() const
Returns the renderer map scale.
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.
const QgsMapUnitScale & intervalMapUnitScale() const
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
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.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
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 hasDataDefinedProperties() const override
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
QgsMapUnitScale mapUnitScale() const override
static QPointF polygonPointOnSurface(const QPolygonF &points, QList< QPolygonF > *rings=nullptr)
Calculate a point on the surface of a QPolygonF.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
~QgsGradientFillSymbolLayer() override
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
A geometry is the spatial representation of a feature.
void restoreOldDataDefinedProperties(const QgsStringMap &stringMap)
Restores older data defined properties from string map.
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsSVGFillSymbolLayer from a properties map.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
void _renderPolygon(QPainter *p, const QPolygonF &points, const QList< QPolygonF > *rings, QgsSymbolRenderContext &context)
Default method to render polygon.
static QgsSymbolLayer * createFromSld(QDomElement &element)
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
#define DEFAULT_SIMPLEFILL_COLOR
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context) override
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
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)
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
QgsGradientFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
double strokeWidth() const
double opacity() const
Returns the opacity for the raster image used in the fill.
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
GradientColorType mGradientColorType
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
QColor color() const override
The fill color.
QgsMapUnitScale mDistanceYMapUnitScale
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.
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.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
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 setCoordinateMode(FillCoordinateMode mode)
Set the coordinate mode for fill.
bool setSubSymbol(QgsSymbol *symbol) override
Sets 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.
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...
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.
static QString encodePenStyle(Qt::PenStyle style)
Perform transforms between map coordinates and device coordinates.
bool hasDataDefinedProperties() const
Returns whether the symbol utilizes any data defined properties.
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
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 dxfWidth(const QgsDxfExport &e, QgsSymbolRenderContext &context) const override
Gets line width.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
std::unique_ptr< QgsLineSymbol > mStroke
Custom stroke.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
QgsUnitTypes::DistanceUnit mapUnits() const
Retrieve map units.
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.
void copyDataDefinedProperties(QgsSymbolLayer *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
static const bool SELECT_FILL_STYLE
Whether fill styles for selected features uses symbol layer style.
QByteArray getImageData(const QString &path) const
Gets image data.
void setColor(const QColor &color) override
The fill color.
bool renderingStopped() const
Returns TRUE if the rendering operation has been stopped and any ongoing rendering should be canceled...
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
GradientType mGradientType
void setWidth(double width)
Sets the width for the whole line symbol.
QgsSymbol::SymbolType type() const
static QgsSymbolLayer * createFromSld(QDomElement &element)
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.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
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...
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
QString imageFilePath() const
The path to the raster image used for the fill.
static double mapUnitScaleFactor(double scale, QgsUnitTypes::RenderUnit symbolUnits, QgsUnitTypes::DistanceUnit mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
double lineWidth() const
Returns the width of the line subsymbol used to render the parallel lines in the fill.
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.
QgsGradientFillSymbolLayer(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, const QColor &color2=Qt::white, GradientColorType gradientColorType=SimpleTwoColor, GradientType gradientType=Linear, GradientCoordinateMode coordinateMode=Feature, GradientSpread gradientSpread=Pad)
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
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.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
Shapeburst fill from edge distance.
void setMapUnitScale(const QgsMapUnitScale &scale) override
double mapUnitsPerPixel() const
Returns current map units per pixel.
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)
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
void stopRender(QgsSymbolRenderContext &context) override
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
QColor fillColor() const override
Gets fill color.
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
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...
QgsShapeburstFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Gradient reference point 1 y.
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...
~QgsPointPatternFillSymbolLayer() override
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops...
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)
QgsFields fields() const
Fields of the layer.
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
virtual QColor fillColor() const
Gets fill color.
QgsExpressionContext & expressionContext()
Gets the expression context.
qreal opacity() const
Returns the opacity for the symbol.
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.
GradientCoordinateMode mCoordinateMode
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.
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.
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.
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...
QgsUnitTypes::RenderUnit outputUnit() const override
Returns the units to use for sizes and widths within the symbol layer.
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.
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
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.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
Qt::BrushStyle dxfBrushStyle() const override
Gets brush/fill style.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
QPointF offset() const
Returns the offset for the fill.
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.
QgsPointPatternFillSymbolLayer()
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
~QgsShapeburstFillSymbolLayer() override
Struct for storing maximum and minimum scales for measurements in map units.
static QString encodeBrushStyle(Qt::BrushStyle style)
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.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
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.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns the set of attributes referenced by the layer.
static const bool SELECTION_IS_OPAQUE
Whether styles for selected features ignore symbol alpha.
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
Qt::PenJoinStyle mPenJoinStyle
const QgsFeature * feature() const
Current feature being rendered - may be null.
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
virtual double area() const
Returns the area of the geometry.
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
SymbolType type() const
Returns the symbol's type.
virtual double estimateMaxBleed(const QgsRenderContext &context) const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
QColor dxfColor(QgsSymbolRenderContext &context) const override
Gets color.
static QgsSymbolLayer * createFromSld(QDomElement &element)
Creates a new QgsLinePatternFillSymbolLayer from a SLD element.
Flags flags() const
Returns combination of flags used for rendering.
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
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between markers.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
void applyDataDefinedSettings(QgsSymbolRenderContext &context) override
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
QPointF referencePoint1() const
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
double estimateMaxBleed(const QgsRenderContext &context) const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape when ...
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
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())
void copyPaintEffect(QgsSymbolLayer *destLayer) const
Copies paint effect of this layer to another symbol layer.
double distance() const
Returns the distance between lines in the fill pattern.
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.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
QgsUnitTypes::RenderUnit mDistanceXUnit
QgsUnitTypes::RenderUnit mDisplacementYUnit
void stopRender(QgsSymbolRenderContext &context) override
Resolves relative paths into absolute paths and vice versa.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
double width() const
Returns the width used for scaling the image used in the fill.
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.
int geometryPartCount() const
Part count of current geometry.
void startRender(QgsSymbolRenderContext &context) override
void addStopsToGradient(QGradient *gradient, double opacity=1)
Copy color ramp stops to a QGradient.
void stopRender(QgsSymbolRenderContext &context) override
int geometryPartNum() const
Part number of current geometry.
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
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
QColor color() const
Returns the symbol's color.
Fill style (eg solid, dots)
GradientType gradientType() const
Type of gradient, e.g., linear or radial.
virtual QColor color() const
The fill color.
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.
QgsSVGFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Gradient reference point 2 is centroid.
double displacementY() const
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
Qt::PenStyle dxfPenStyle() const override
Gets pen style.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
~QgsLinePatternFillSymbolLayer() override
QPointF offset() const
Returns the offset for the shapeburst fill.
RenderUnit
Rendering size units.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
static QColor decodeColor(const QString &str)
QgsMapUnitScale mStrokeWidthMapUnitScale
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...
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the layer.
QPointF referencePoint2() const
QgsLineSymbol * clone() const override
Returns a deep copy of this symbol.
Horizontal distance between points.
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