33 #include <QSvgRenderer> 34 #include <QDomDocument> 35 #include <QDomElement> 38 Qt::PenJoinStyle penJoinStyle )
39 : mBrushStyle( style )
40 , mBorderColor( borderColor )
41 , mBorderStyle( borderStyle )
42 , mBorderWidth( borderWidth )
44 , mPenJoinStyle( penJoinStyle )
154 if ( props.
contains(
"color_border" ) )
159 else if ( props.
contains(
"outline_color" ) )
163 else if ( props.
contains(
"line_color" ) )
168 if ( props.
contains(
"style_border" ) )
173 else if ( props.
contains(
"outline_style" ) )
177 else if ( props.
contains(
"line_style" ) )
181 if ( props.
contains(
"width_border" ) )
184 borderWidth = props[
"width_border"].toDouble();
186 else if ( props.
contains(
"outline_width" ) )
188 borderWidth = props[
"outline_width"].toDouble();
190 else if ( props.
contains(
"line_width" ) )
192 borderWidth = props[
"line_width"].toDouble();
196 if ( props.
contains(
"joinstyle" ) )
201 if ( props.
contains(
"border_width_unit" ) )
205 else if ( props.
contains(
"outline_width_unit" ) )
209 else if ( props.
contains(
"line_width_unit" ) )
213 if ( props.
contains(
"offset_unit" ) )
216 if ( props.
contains(
"border_width_map_unit_scale" ) )
218 if ( props.
contains(
"offset_map_unit_scale" ) )
240 if ( rasterScaleFactor != 1.0 )
335 if ( !props.
value(
"uom",
"" ).isEmpty() )
369 symbolStyle.
append(
';' );
380 Qt::BrushStyle fillStyle;
408 return penBleed + offsetBleed;
474 : mGradientColorType( colorType )
475 , mGradientRamp( nullptr )
476 , mGradientType( gradientType )
477 , mCoordinateMode( coordinateMode )
478 , mGradientSpread( spread )
479 , mReferencePoint1(
QPointF( 0.5, 0 ) )
480 , mReferencePoint1IsCentroid( false )
481 , mReferencePoint2(
QPointF( 0.5, 1 ) )
482 , mReferencePoint2IsCentroid( false )
504 bool refPoint1IsCentroid =
false;
506 bool refPoint2IsCentroid =
false;
512 type = static_cast< GradientType >( props[
"type"].toInt() );
513 if ( props.
contains(
"coordinate_mode" ) )
514 coordinateMode = static_cast< GradientCoordinateMode >( props[
"coordinate_mode"].toInt() );
516 gradientSpread = static_cast< GradientSpread >( props[
"spread"].toInt() );
517 if ( props.
contains(
"color_type" ) )
518 colorType = static_cast< GradientColorType >( props[
"color_type"].toInt() );
519 if ( props.
contains(
"gradient_color" ) )
524 else if ( props.
contains(
"color" ) )
528 if ( props.
contains(
"gradient_color2" ) )
533 if ( props.
contains(
"reference_point1" ) )
535 if ( props.
contains(
"reference_point1_iscentroid" ) )
536 refPoint1IsCentroid = props[
"reference_point1_iscentroid"].toInt();
537 if ( props.
contains(
"reference_point2" ) )
539 if ( props.
contains(
"reference_point2_iscentroid" ) )
540 refPoint2IsCentroid = props[
"reference_point2_iscentroid"].toInt();
542 angle = props[
"angle"].toDouble();
553 if ( props.
contains(
"offset_unit" ) )
555 if ( props.
contains(
"offset_map_unit_scale" ) )
578 return "GradientFill";
636 else if ( currentType ==
QObject::tr(
"conical" ) )
650 if ( currentCoordMode ==
QObject::tr(
"feature" ) )
654 else if ( currentCoordMode ==
QObject::tr(
"viewport" ) )
672 else if ( currentSpread ==
QObject::tr(
"repeat" ) )
676 else if ( currentSpread ==
QObject::tr(
"reflect" ) )
723 if ( refPoint1IsCentroid || refPoint2IsCentroid )
729 double centroidX = ( centroid.
x() - bbox.
left() ) / bbox.
width();
730 double centroidY = ( centroid.
y() - bbox.
top() ) / bbox.
height();
732 if ( refPoint1IsCentroid )
734 refPoint1X = centroidX;
735 refPoint1Y = centroidY;
737 if ( refPoint2IsCentroid )
739 refPoint2X = centroidX;
740 refPoint2Y = centroidY;
746 spread,
QPointF( refPoint1X, refPoint1Y ),
QPointF( refPoint2X, refPoint2Y ), angle );
749 QPointF QgsGradientFillSymbolLayerV2::rotateReferencePoint(
QPointF refPoint,
double angle )
758 QPointF rotatedReferencePoint = refLine.
p2();
760 if ( rotatedReferencePoint.
x() > 1 )
761 rotatedReferencePoint.
setX( 1 );
762 if ( rotatedReferencePoint.
x() < 0 )
763 rotatedReferencePoint.
setX( 0 );
764 if ( rotatedReferencePoint.
y() > 1 )
765 rotatedReferencePoint.
setY( 1 );
766 if ( rotatedReferencePoint.
y() < 0 )
767 rotatedReferencePoint.
setY( 0 );
769 return rotatedReferencePoint;
793 gradient =
QLinearGradient( rotatedReferencePoint1, rotatedReferencePoint2 );
796 gradient =
QRadialGradient( rotatedReferencePoint1,
QLineF( rotatedReferencePoint1, rotatedReferencePoint2 ).length() );
814 gradient.
setSpread( QGradient::PadSpread );
817 gradient.
setSpread( QGradient::ReflectSpread );
820 gradient.
setSpread( QGradient::RepeatSpread );
839 brush =
QBrush( gradient );
865 applyDataDefinedSymbology( context, points );
958 int blurRadius,
bool useWholeShape,
double maxDistance )
959 : mBlurRadius( blurRadius )
960 , mUseWholeShape( useWholeShape )
961 , mMaxDistance( maxDistance )
963 , mColorType( colorType )
966 , mTwoColorGradientRamp( nullptr )
967 , mIgnoreRings( false )
989 if ( props.
contains(
"color_type" ) )
993 if ( props.
contains(
"shapeburst_color" ) )
998 else if ( props.
contains(
"color" ) )
1003 if ( props.
contains(
"shapeburst_color2" ) )
1008 else if ( props.
contains(
"gradient_color2" ) )
1012 if ( props.
contains(
"blur_radius" ) )
1014 blurRadius = props[
"blur_radius"].toInt();
1016 if ( props.
contains(
"use_whole_shape" ) )
1018 useWholeShape = props[
"use_whole_shape"].toInt();
1020 if ( props.
contains(
"max_distance" ) )
1022 maxDistance = props[
"max_distance"].toDouble();
1035 if ( props.
contains(
"offset_unit" ) )
1039 if ( props.
contains(
"distance_unit" ) )
1043 if ( props.
contains(
"offset_map_unit_scale" ) )
1047 if ( props.
contains(
"distance_map_unit_scale" ) )
1051 if ( props.
contains(
"ignore_rings" ) )
1067 return "ShapeburstFill";
1147 Q_UNUSED( context );
1183 applyDataDefinedSymbology( context, color1, color2, blurRadius, useWholeShape, maxDistance, ignoreRings );
1186 int outputPixelMaxDist = 0;
1204 int sideBuffer = 4 + ( blurRadius + 2 ) * 4;
1213 fillImage->
fill( Qt::black );
1216 QImage * alphaImage =
new QImage( fillImage->
width(), fillImage->
height(), QImage::Format_ARGB32_Premultiplied );
1218 alphaImage->
fill( Qt::transparent );
1222 imgPainter.
begin( alphaImage );
1233 imgPainter.
begin( fillImage );
1236 imgPainter.
drawImage( 0, 0, *alphaImage );
1252 double * dtArray = distanceTransform( fillImage );
1266 if ( blurRadius > 0 )
1272 imgPainter.
begin( fillImage );
1274 imgPainter.
drawImage( 0, 0, *alphaImage );
1306 void QgsShapeburstFillSymbolLayerV2::distanceTransform1d(
double *f,
int n,
int *v,
double *z,
double *d )
1312 for (
int q = 1; q <= n - 1; q++ )
1314 double s = (( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1318 s = (( f[q] + q * q ) - ( f[v[k]] + ( v[k] * v[k] ) ) ) / ( 2 * q - 2 * v[k] );
1327 for (
int q = 0; q <= n - 1; q++ )
1329 while ( z[k+1] < q )
1331 d[q] = ( q - v[k] ) * ( q - v[k] ) + f[v[k]];
1336 void QgsShapeburstFillSymbolLayerV2::distanceTransform2d(
double * im,
int width,
int height )
1338 int maxDimension = qMax( width, height );
1339 double *f =
new double[ maxDimension ];
1340 int *v =
new int[ maxDimension ];
1341 double *z =
new double[ maxDimension + 1 ];
1342 double *d =
new double[ maxDimension ];
1345 for (
int x = 0; x < width; x++ )
1347 for (
int y = 0; y < height; y++ )
1349 f[y] = im[ x + y * width ];
1351 distanceTransform1d( f, height, v, z, d );
1352 for (
int y = 0; y < height; y++ )
1354 im[ x + y * width ] = d[y];
1359 for (
int y = 0; y < height; y++ )
1361 for (
int x = 0; x < width; x++ )
1363 f[x] = im[ x + y*width ];
1365 distanceTransform1d( f, width, v, z, d );
1366 for (
int x = 0; x < width; x++ )
1368 im[ x + y*width ] = d[x];
1379 double * QgsShapeburstFillSymbolLayerV2::distanceTransform(
QImage *im )
1381 int width = im->
width();
1382 int height = im->
height();
1384 double * dtArray =
new double[width * height];
1389 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1391 const QRgb* scanLine =
reinterpret_cast< const QRgb*
>( im->
constScanLine( heightIndex ) );
1392 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1394 tmpRgb = scanLine[widthIndex];
1395 if ( qRed( tmpRgb ) == 0 )
1403 dtArray[ idx ] =
INF;
1410 distanceTransform2d( dtArray, width, height );
1417 int width = im->
width();
1418 int height = im->
height();
1421 double maxDistanceValue;
1426 double dtMaxValue = array[0];
1427 for (
int i = 1; i < ( width * height ); ++i )
1429 if ( array[i] > dtMaxValue )
1431 dtMaxValue = array[i];
1436 maxDistanceValue = sqrt( dtMaxValue );
1441 maxDistanceValue = maxPixelDistance;
1446 double squaredVal = 0;
1449 bool layerHasAlpha = layerAlpha < 1.0;
1451 for (
int heightIndex = 0; heightIndex < height; ++heightIndex )
1453 QRgb* scanLine =
reinterpret_cast< QRgb*
>( im->
scanLine( heightIndex ) );
1454 for (
int widthIndex = 0; widthIndex < width; ++widthIndex )
1457 squaredVal = array[idx];
1460 if ( maxDistanceValue > 0 )
1462 pixVal = squaredVal > 0 ? qMin(( sqrt( squaredVal ) / maxDistanceValue ), 1.0 ) : 0;
1470 pixColor = ramp->
color( pixVal );
1472 int pixAlpha = pixColor.
alpha();
1473 if (( layerHasAlpha ) || ( pixAlpha != 255 ) )
1476 double alpha = pixAlpha * layerAlpha;
1481 scanLine[widthIndex] = pixColor.
rgba();
1572 , mOutlineWidth( 0.0 )
1574 , mOutline( nullptr )
1630 for ( ; ringIt != rings->
constEnd(); ++ringIt )
1692 return subLayerBleed;
1710 Q_UNUSED( context );
1713 return QColor( Qt::black );
1720 return Qt::SolidLine;
1724 return Qt::SolidLine;
1746 , mPatternWidth( width )
1756 setDefaultSvgParams();
1774 setDefaultSvgParams();
1827 setDefaultSvgParams();
1837 if ( properties.
contains(
"width" ) )
1839 width = properties[
"width"].toDouble();
1841 if ( properties.
contains(
"svgFile" ) )
1843 QString svgName = properties[
"svgFile"];
1845 svgFilePath = ( savePath.
isEmpty() ? svgName : savePath );
1847 if ( properties.
contains(
"angle" ) )
1849 angle = properties[
"angle"].toDouble();
1859 if ( properties.
contains(
"data" ) )
1867 if ( properties.
contains(
"svgFillColor" ) )
1872 else if ( properties.
contains(
"color" ) )
1876 if ( properties.
contains(
"svgOutlineColor" ) )
1881 else if ( properties.
contains(
"outline_color" ) )
1885 else if ( properties.
contains(
"line_color" ) )
1889 if ( properties.
contains(
"svgOutlineWidth" ) )
1894 else if ( properties.
contains(
"outline_width" ) )
1898 else if ( properties.
contains(
"line_width" ) )
1904 if ( properties.
contains(
"pattern_width_unit" ) )
1908 if ( properties.
contains(
"pattern_width_map_unit_scale" ) )
1912 if ( properties.
contains(
"svg_outline_width_unit" ) )
1916 if ( properties.
contains(
"svg_outline_width_map_unit_scale" ) )
1920 if ( properties.
contains(
"outline_width_unit" ) )
1924 if ( properties.
contains(
"outline_width_map_unit_scale" ) )
1953 if ( static_cast< int >( size ) < 1.0 || 10000.0 < size )
1960 bool fitsInCache =
true;
1968 double hwRatio = 1.0;
1969 if ( patternPict.
width() > 0 )
1971 hwRatio =
static_cast< double >( patternPict.
height() ) / static_cast< double >( patternPict.
width() );
1973 mSvgPattern =
new QImage( static_cast< int >( size ), static_cast< int >( size * hwRatio ), QImage::Format_ARGB32_Premultiplied );
1999 applyPattern(
mBrush,
mSvgFilePath,
mPatternWidth,
mPatternWidthUnit,
mColor,
mSvgOutlineColor,
mSvgOutlineWidth,
mSvgOutlineWidthUnit, context,
mPatternWidthMapUnitScale,
mSvgOutlineWidthMapUnitScale );
2083 if ( !props.
value(
"uom",
"" ).isEmpty() )
2119 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
2145 Qt::PenStyle penStyle;
2146 double size, borderWidth;
2153 if ( graphicFillElem.
isNull() )
2157 if ( graphicElem.
isNull() )
2163 if ( mimeType !=
"image/svg+xml" )
2177 double d = angleFunc.
toDouble( &ok );
2190 if ( !strokeElem.
isNull() )
2262 void QgsSVGFillSymbolLayer::storeViewBox()
2278 void QgsSVGFillSymbolLayer::setDefaultSvgParams()
2285 bool hasFillParam, hasFillOpacityParam, hasOutlineParam, hasOutlineWidthParam, hasOutlineOpacityParam;
2286 bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultOutlineColor, hasDefaultOutlineWidth, hasDefaultOutlineOpacity;
2287 QColor defaultFillColor, defaultOutlineColor;
2288 double defaultOutlineWidth, defaultFillOpacity, defaultOutlineOpacity;
2290 hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2291 hasOutlineParam, hasDefaultOutlineColor, defaultOutlineColor,
2292 hasOutlineWidthParam, hasDefaultOutlineWidth, defaultOutlineWidth,
2293 hasOutlineOpacityParam, hasDefaultOutlineOpacity, defaultOutlineOpacity );
2295 double newFillOpacity = hasFillOpacityParam ?
mColor.
alphaF() : 1.0;
2298 if ( hasDefaultFillColor )
2300 mColor = defaultFillColor;
2303 if ( hasDefaultFillOpacity )
2307 if ( hasDefaultOutlineColor )
2312 if ( hasDefaultOutlineOpacity )
2316 if ( hasDefaultOutlineWidth )
2329 , mLineAngle( 45.0 )
2332 , mFillLineSymbol( nullptr )
2352 return mFillLineSymbol ? mFillLineSymbol->
color() :
mColor;
2357 delete mFillLineSymbol;
2372 delete mFillLineSymbol;
2373 mFillLineSymbol = lineSymbol;
2384 return mFillLineSymbol;
2390 if ( mFillLineSymbol )
2448 if ( properties.
contains(
"lineangle" ) )
2451 lineAngle = properties[
"lineangle"].toDouble();
2453 else if ( properties.
contains(
"angle" ) )
2455 lineAngle = properties[
"angle"].toDouble();
2459 if ( properties.
contains(
"distance" ) )
2461 distance = properties[
"distance"].toDouble();
2465 if ( properties.
contains(
"linewidth" ) )
2468 lineWidth = properties[
"linewidth"].toDouble();
2470 else if ( properties.
contains(
"outline_width" ) )
2472 lineWidth = properties[
"outline_width"].toDouble();
2474 else if ( properties.
contains(
"line_width" ) )
2476 lineWidth = properties[
"line_width"].toDouble();
2480 if ( properties.
contains(
"color" ) )
2484 else if ( properties.
contains(
"outline_color" ) )
2488 else if ( properties.
contains(
"line_color" ) )
2494 if ( properties.
contains(
"offset" ) )
2496 offset = properties[
"offset"].toDouble();
2501 if ( properties.
contains(
"distance_unit" ) )
2505 if ( properties.
contains(
"distance_map_unit_scale" ) )
2509 if ( properties.
contains(
"line_width_unit" ) )
2513 else if ( properties.
contains(
"outline_width_unit" ) )
2517 if ( properties.
contains(
"line_width_map_unit_scale" ) )
2521 if ( properties.
contains(
"offset_unit" ) )
2525 if ( properties.
contains(
"offset_map_unit_scale" ) )
2529 if ( properties.
contains(
"outline_width_unit" ) )
2533 if ( properties.
contains(
"outline_width_map_unit_scale" ) )
2540 return patternLayer;
2545 return "LinePatternFill";
2556 if ( !mFillLineSymbol )
2562 if ( !fillLineSymbol )
2574 double outputPixelBleed = 0;
2575 double outputPixelInterval = 0;
2587 outputPixelBleed = qMax( outputPixelBleed, outputPixelLayerBleed );
2590 if ( markerLineLayer )
2599 outputPixelInterval = qMax( outputPixelInterval, outputPixelLayerInterval );
2603 if ( outputPixelInterval > 0 )
2607 double intervalScale = qRound( outputPixelInterval ) / outputPixelInterval;
2608 outputPixelInterval = qRound( outputPixelInterval );
2615 if ( markerLineLayer )
2626 height = outputPixelDist;
2627 width = outputPixelInterval > 0 ? outputPixelInterval : height;
2631 width = outputPixelDist;
2632 height = outputPixelInterval > 0 ? outputPixelInterval : width;
2640 lineAngle = 180 * atan2( static_cast< double >( height ), static_cast< double >( width ) ) /
M_PI;
2646 height = qAbs( height );
2647 width = qAbs( width );
2653 int offsetHeight = qRound( qAbs( outputPixelOffset / cos(
lineAngle *
M_PI / 180 ) ) );
2654 outputPixelOffset = offsetHeight * cos(
lineAngle *
M_PI / 180 );
2663 int bufferMulti = qMax( qCeil( outputPixelBleed / width ), qCeil( outputPixelBleed / width ) );
2667 bufferMulti = qMax( bufferMulti, 1 );
2669 int xBuffer = width * bufferMulti;
2670 int yBuffer = height * bufferMulti;
2671 int innerWidth = width;
2672 int innerHeight = height;
2673 width += 2 * xBuffer;
2674 height += 2 * yBuffer;
2676 if ( width > 10000 || height > 10000 )
2681 QImage patternImage( width, height, QImage::Format_ARGB32 );
2682 patternImage.
fill( 0 );
2684 QPointF p1, p2, p3, p4, p5, p6;
2688 p2 =
QPointF( width, yBuffer );
2689 p3 =
QPointF( 0, yBuffer + innerHeight );
2690 p4 =
QPointF( width, yBuffer + innerHeight );
2694 p1 =
QPointF( xBuffer, height );
2696 p3 =
QPointF( xBuffer + innerWidth, height );
2697 p4 =
QPointF( xBuffer + innerWidth, 0 );
2701 dx = outputPixelDist * cos(( 90 -
lineAngle ) *
M_PI / 180.0 );
2702 dy = outputPixelDist * sin(( 90 -
lineAngle ) *
M_PI / 180.0 );
2705 p3 =
QPointF( -dx, height - dy );
2706 p4 =
QPointF( width - dx, -dy );
2707 p5 =
QPointF( dx, height + dy );
2708 p6 =
QPointF( width + dx, dy );
2712 dx = outputPixelDist * cos(( 90 -
lineAngle ) *
M_PI / 180.0 );
2713 dy = outputPixelDist * sin(( 90 -
lineAngle ) *
M_PI / 180.0 );
2716 p3 =
QPointF( width - dx, -dy );
2717 p4 =
QPointF( -dx, height - dy );
2718 p5 =
QPointF( width + dx, dy );
2719 p6 =
QPointF( dx, height + dy );
2723 dy = outputPixelDist * cos(( 180 -
lineAngle ) *
M_PI / 180 );
2724 dx = outputPixelDist * sin(( 180 -
lineAngle ) *
M_PI / 180 );
2726 p2 =
QPointF( width, height );
2728 p6 =
QPointF( width + dx, height - dy );
2730 p4 =
QPointF( width - dx, height + dy );
2734 dy = outputPixelDist * cos(( 180 -
lineAngle ) *
M_PI / 180 );
2735 dx = outputPixelDist * sin(( 180 -
lineAngle ) *
M_PI / 180 );
2736 p1 =
QPointF( width, height );
2738 p5 =
QPointF( width + dx, height - dy );
2740 p3 =
QPointF( width - dx, height + dy );
2767 p.setRenderHint( QPainter::Antialiasing,
false );
2776 p.drawPolygon( polygon );
2778 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 );
2779 p.drawPolygon( polygon );
2785 p.setRenderHint( QPainter::Antialiasing,
true );
2807 Q_FOREACH (
const QPolygonF& polygon, polygons )
2812 fillLineSymbol->
stopRender( lineRenderContext );
2816 patternImage = patternImage.
copy( xBuffer, yBuffer, patternImage.
width() - 2 * xBuffer, patternImage.
height() - 2 * yBuffer );
2821 QImage transparentImage = patternImage.
copy();
2834 delete fillLineSymbol;
2841 if ( mFillLineSymbol )
2851 if ( mFillLineSymbol )
2880 if ( mFillLineSymbol )
2891 if ( !props.
value(
"uom",
"" ).isEmpty() )
2909 double lineWidth = mFillLineSymbol ? mFillLineSymbol->
width() : 0.0;
2917 double angle = props.
value(
"angle",
"0" ).toDouble( &ok );
2937 featureStyle.
append(
"Brush(" );
2939 featureStyle.
append(
QString(
",bc:%1" ).arg(
"#00000000" ) );
2940 featureStyle.
append(
",id:\"ogr-brush-2\"" );
2943 featureStyle.
append(
",dx:0mm" );
2945 featureStyle.
append(
')' );
2946 return featureStyle;
2985 applyPattern( context,
mBrush, lineAngle, distance, lineWidth, color );
2995 Qt::PenStyle lineStyle;
3002 if ( graphicFillElem.
isNull() )
3006 if ( graphicElem.
isNull() )
3012 if ( name !=
"horline" )
3020 double d = angleFunc.
toDouble( &ok );
3029 offset = sqrt( pow( vectOffset.
x(), 2 ) + pow( vectOffset.
y(), 2 ) );
3046 if ( !strokeElem.
isNull() )
3065 , mMarkerSymbol( nullptr )
3070 , mDisplacementX( 0 )
3072 , mDisplacementY( 0 )
3136 if ( properties.
contains(
"distance_x" ) )
3138 layer->
setDistanceX( properties[
"distance_x"].toDouble() );
3140 if ( properties.
contains(
"distance_y" ) )
3142 layer->
setDistanceY( properties[
"distance_y"].toDouble() );
3144 if ( properties.
contains(
"displacement_x" ) )
3148 if ( properties.
contains(
"displacement_y" ) )
3153 if ( properties.
contains(
"distance_x_unit" ) )
3157 if ( properties.
contains(
"distance_x_map_unit_scale" ) )
3161 if ( properties.
contains(
"distance_y_unit" ) )
3165 if ( properties.
contains(
"distance_y_map_unit_scale" ) )
3169 if ( properties.
contains(
"displacement_x_unit" ) )
3173 if ( properties.
contains(
"displacement_x_map_unit_scale" ) )
3177 if ( properties.
contains(
"displacement_y_unit" ) )
3181 if ( properties.
contains(
"displacement_y_map_unit_scale" ) )
3185 if ( properties.
contains(
"outline_width_unit" ) )
3189 if ( properties.
contains(
"outline_width_map_unit_scale" ) )
3201 return "PointPatternFill";
3212 if ( width > 10000 || height > 10000 )
3219 QImage patternImage( width, height, QImage::Format_ARGB32 );
3220 patternImage.
fill( 0 );
3259 QImage transparentImage = patternImage.
copy();
3328 if ( !props.
value(
"uom",
"" ).isEmpty() )
3364 Q_UNUSED( element );
3417 applyPattern( context,
mBrush, distanceX, distanceY, displacementX, displacementY );
3451 : mMarker( nullptr )
3452 , mPointOnSurface( false )
3453 , mPointOnAllParts( true )
3454 , mCurrentFeatureId( -1 )
3455 , mBiggestPartIndex( -1 )
3469 if ( properties.
contains(
"point_on_surface" ) )
3471 if ( properties.
contains(
"point_on_all_parts" ) )
3479 return "CentroidFill";
3527 double areaBiggest = 0;
3531 if ( area > areaBiggest )
3665 , mImageFilePath( imageFilePath )
3689 if ( properties.
contains(
"imageFile" ) )
3691 imagePath = properties[
"imageFile"];
3693 if ( properties.
contains(
"coordinate_mode" ) )
3697 if ( properties.
contains(
"alpha" ) )
3699 alpha = properties[
"alpha"].toDouble();
3701 if ( properties.
contains(
"offset" ) )
3705 if ( properties.
contains(
"angle" ) )
3707 angle = properties[
"angle"].toDouble();
3709 if ( properties.
contains(
"width" ) )
3711 width = properties[
"width"].toDouble();
3719 if ( properties.
contains(
"offset_unit" ) )
3723 if ( properties.
contains(
"offset_map_unit_scale" ) )
3727 if ( properties.
contains(
"width_unit" ) )
3731 if ( properties.
contains(
"width_map_unit_scale" ) )
3749 return "RasterFill";
3789 Q_UNUSED( context );
3857 if ( !hasWidthExpression && !hasAngleExpression && !hasAlphaExpression && !hasFileExpression )
3863 if ( hasAngleExpression )
3871 if ( !hasWidthExpression && !hasAlphaExpression && !hasFileExpression )
3877 if ( hasWidthExpression )
3883 if ( hasAlphaExpression )
3889 if ( hasFileExpression )
3894 applyPattern(
mBrush, file, width, alpha, context );
3899 QImage image( imageFilePath );
3916 pixelWidth = image.
width();
3925 QColor alphaColor( 0, 0, 0 );
3934 image = image.
scaledToWidth( pixelWidth, Qt::SmoothTransformation );
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale mSvgOutlineWidthMapUnitScale
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
static double mapUnitScaleFactor(double scaleDenominator, QgsSymbolV2::OutputUnit symbolUnits, QGis::UnitType mapUnits, double mapUnitsPerPixel=1.0)
Returns scale factor for conversion to map units.
static const QString EXPR_DISTANCE_Y
void setBorderWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mapUnitScale() const override
QgsSymbolV2 * subSymbol() override
ShapeburstColorType mColorType
QgsFeatureId mCurrentFeatureId
void setForceVectorOutput(bool force)
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary...
QgsImageFillSymbolLayer()
static void createRotationElement(QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
#define DEFAULT_SIMPLEFILL_BORDERCOLOR
QString layerType() const override
Returns a string that represents this layer type.
static const QString EXPR_DISPLACEMENT_Y
void setDistance(double d)
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
double rendererScale() const
virtual QSet< QString > usedAttributes() const override
Returns the set of attributes referenced by the layer.
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
const QgsFields * fields() const
Fields of the layer.
QgsSymbolV2::OutputUnit mSvgOutlineWidthUnit
void setStyle(Qt::PenStyle style)
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
void startRender(QgsSymbolV2RenderContext &context) override
void setSvgOutlineWidth(double w)
QString & append(QChar ch)
static void multiplyImageOpacity(QImage *image, qreal alpha)
Multiplies opacity of image pixel values with a (global) transparency value.
OutputUnit
The unit of the output.
QImage scaledToWidth(int width, Qt::TransformationMode mode) const
QString svgFilePath() const
QColor dxfColor(QgsSymbolV2RenderContext &context) const override
get color
QgsSymbolV2::OutputUnit mOffsetUnit
static Qt::BrushStyle decodeBrushStyle(const QString &str)
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
FillCoordinateMode mCoordinateMode
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)
QgsSymbolV2::OutputUnit mLineWidthUnit
QByteArray getImageData(const QString &path) const
Get image data.
virtual QString type() const =0
Returns a string representing the color ramp type.
QSet< QString > usedAttributes() const override
Returns the set of attributes referenced by the layer.
bool contains(const Key &key) const
static Q_DECL_DEPRECATED bool wellKnownMarkerFromSld(QDomElement &element, QString &name, QColor &color, QColor &borderColor, double &borderWidth, double &size)
static const QString EXPR_BORDER_COLOR
void fillRect(const QRectF &rectangle, const QBrush &brush)
void setCompositionMode(CompositionMode mode)
QgsRasterFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QgsLineSymbolV2 * clone() const override
QgsMapUnitScale mLineWidthMapUnitScale
const uchar * constScanLine(int i) const
void setSvgFillColor(const QColor &c)
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
bool mReferencePoint1IsCentroid
void setRenderHint(RenderHint hint, bool on)
void startRender(QgsSymbolV2RenderContext &context) override
QDomNode appendChild(const QDomNode &newChild)
void setColor(const QColor &c) override
The fill color.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setDistanceYUnit(QgsSymbolV2::OutputUnit unit)
void stopRender(QgsSymbolV2RenderContext &context) override
void append(const T &value)
QString imageFilePath() const
The path to the raster image used for the fill.
static double rescaleUom(double size, QgsSymbolV2::OutputUnit 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.
static QDomElement createVendorOptionElement(QDomDocument &doc, const QString &name, const QString &value)
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
static const QString EXPR_USE_WHOLE_SHAPE
double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const override
get line width
const QPicture & svgAsPicture(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput=false)
Get SVG as QPicture&.
static const QString EXPR_REFERENCE2_Y
static void createGeometryElement(QDomDocument &doc, QDomElement &element, const QString &geomFunc)
QMap< Key, T > & unite(const QMap< Key, T > &other)
void setOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
QString attribute(const QString &name, const QString &defValue) const
double dxfAngle(QgsSymbolV2RenderContext &context) const override
get angle
virtual QSet< QString > usedAttributes() const
Returns the set of attributes referenced by the layer.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsPointPatternFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient.
QgsLinePatternFillSymbolLayer()
void setMatrix(const QMatrix &matrix)
GradientType gradientType() const
Type of gradient, eg linear or radial.
static double sizeInPixelsFromSldUom(const QString &uom, double size)
Returns the size scaled in pixels according to the uom attribute.
bool setSubSymbol(QgsSymbolV2 *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
void setColorAt(qreal position, const QColor &color)
static QString encodeColor(const QColor &color)
Base class for polygon renderers generating texture images.
QgsMapUnitScale mOffsetMapUnitScale
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QgsMapUnitScale mPatternWidthMapUnitScale
static const QString EXPR_DISPLACEMENT_X
GradientCoordinateMode mCoordinateMode
void stopRender(QgsSymbolV2RenderContext &context) override
void setPointOnSurface(bool pointOnSurface)
static const QString EXPR_WIDTH
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
static void externalGraphicToSld(QDomDocument &doc, QDomElement &element, const QString &path, const QString &mime, const QColor &color, double size=-1)
void scale(qreal sx, qreal sy)
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
The output shall be in pixels.
void setRendererScale(double scale)
void stopRender(QgsSymbolV2RenderContext &context) override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
void setTextureImage(const QImage &image)
QPointF offset() const
Returns the offset for the shapeburst fill.
static QString ogrFeatureStyleBrush(const QColor &fillColr)
Create ogr feature style string for brush.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
void stopRender(QgsSymbolV2RenderContext &context) override
QString layerType() const override
Returns a string that represents this layer type.
virtual bool hasDataDefinedProperties() const
Checks whether the layer has any associated data defined properties.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
bool hasAlphaChannel() const
QString layerType() const override
Returns a string that represents this layer type.
QgsMapUnitScale mOutlineWidthMapUnitScale
Qt::BrushStyle dxfBrushStyle() const override
get brush/fill style
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.
QgsSymbolV2::OutputUnit outputUnit() const override
static const QString EXPR_BLUR_RADIUS
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context) override
static bool externalGraphicFromSld(QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
A geometry is the spatial representation of a feature.
void setJoinStyle(Qt::PenJoinStyle style)
QgsShapeburstFillSymbolLayerV2(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, const QColor &color2=Qt::white, ShapeburstColorType colorType=SimpleTwoColor, int blurRadius=0, bool useWholeShape=true, double maxDistance=5)
virtual QgsStringMap properties() const =0
Returns a string map containing all the color ramp's properties.
GradientType mGradientType
static const QString EXPR_COORDINATE_MODE
QgsSymbolV2::OutputUnit mWidthUnit
static QPointF decodePoint(const QString &str)
QgsSymbolV2::OutputUnit mDisplacementXUnit
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void stopRender(QgsSymbolV2RenderContext &context) override
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static const QString EXPR_COLOR2
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasOutlineParam, QColor &defaultOutlineColor, bool &hasOutlineWidthParam, double &defaultOutlineWidth) const
Tests if an svg file contains parameters for fill, outline color, outline width.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
static const bool selectionIsOpaque
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
const QgsFeature * feature() const
Current feature being rendered - may be null.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context) override
QGis::UnitType mapUnits() const
Retrieve map units.
void applyDataDefinedSettings(QgsSymbolV2RenderContext &context) override
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context) override
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
virtual bool setSubSymbol(QgsSymbolV2 *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
QPointF referencePoint2() const
double mDistance
Distance (in mm or map units) between lines.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setSvgOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features...
QImage copy(const QRect &rectangle) const
QgsMapUnitScale mOffsetMapUnitScale
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
static void createDisplacementElement(QDomDocument &doc, QDomElement &element, QPointF offset)
double mLineAngle
Vector line angle in degrees (0 = horizontal, counterclockwise)
bool setSubSymbol(QgsSymbolV2 *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
GradientSpread mGradientSpread
double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setMapUnitScale(const QgsMapUnitScale &scale) override
double toDouble(bool *ok) const
QColor color() const override
The fill color.
QgsMapUnitScale mDistanceYMapUnitScale
void setStyle(Qt::BrushStyle style)
QgsVectorColorRampV2 * mGradientRamp
QString layerType() const override
Returns a string that represents this layer type.
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
QString tr(const char *sourceText, const char *disambiguation, int n)
void setColorRamp(QgsVectorColorRampV2 *ramp)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
virtual QColor color() const override
The fill color.
QgsSymbolV2::OutputUnit svgOutlineWidthUnit() const
static double pixelSizeScaleFactor(const QgsRenderContext &c, QgsSymbolV2::OutputUnit u, const QgsMapUnitScale &scale=QgsMapUnitScale())
Returns scale factor painter units -> pixel dimensions.
void setWidth(double width)
virtual Q_DECL_DEPRECATED QVariant evaluateDataDefinedProperty(const QString &property, const QgsFeature *feature, const QVariant &defaultVal=QVariant(), bool *ok=nullptr) const
Evaluates the matching data defined property and returns the calculated value.
void setMapUnitScale(const QgsMapUnitScale &scale)
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsMapUnitScale mapUnitScale() const override
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the SLD element following the SLD v1.1 specs.
QgsSymbolV2::OutputUnit outputUnit() const override
void setSvgOutlineColor(const QColor &c)
double symbologyScaleDenominator() const
Retrieve reference scale for output.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setInterval(double interval)
The interval between individual markers.
static const QString EXPR_JOIN_STYLE
void setDistanceUnit(QgsSymbolV2::OutputUnit unit)
QgsMapUnitScale mDisplacementYMapUnitScale
static QgsSymbolV2::OutputUnit decodeOutputUnit(const QString &str)
static bool displacementFromSldElement(QDomElement &element, QPointF &offset)
QColor dxfColor(QgsSymbolV2RenderContext &context) const override
get color
static const QString EXPR_FILL_STYLE
static QgsSvgCache * instance()
static const QString EXPR_REFERENCE1_Y
static QString encodePenStyle(Qt::PenStyle style)
static QPointF pointOnLineWithDistance(QPointF startPoint, QPointF directionPoint, double distance)
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setCapStyle(Qt::PenCapStyle style)
const QImage & svgAsImage(const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool &fitsInCache)
Get SVG as QImage.
QString mImageFilePath
Path to the image file.
QgsSymbolV2::OutputUnit mDisplacementYUnit
Perform transforms between map coordinates and device coordinates.
static const QString EXPR_BORDER_STYLE
void setColor(const QColor &color)
static const QString EXPR_REFERENCE2_X
static const QString EXPR_REFERENCE2_ISCENTROID
static QString symbolPathToName(QString path)
Get symbols's name from its path.
virtual double estimateMaxBleed() const
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
GradientSpread gradientSpread() const
Gradient spread mode.
Mixed units in symbol layers.
void setLineAngle(double a)
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
static const QString EXPR_LINEWIDTH
QgsLinePatternFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolV2::OutputUnit outputUnit() const override
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
static QgsSymbolLayerV2 * createMarkerLayerFromSld(QDomElement &element)
The output shall be in millimeters.
#define DEFAULT_SIMPLEFILL_BORDERSTYLE
void stopRender(QgsSymbolV2RenderContext &context) override
QString number(int n, int base)
A class for filling symbols with a repeated raster image.
bool mReferencePoint2IsCentroid
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
QByteArray mSvgData
SVG data.
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
void append(const T &value)
void setOutlineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsLineSymbolV2 * mOutline
Custom outline.
static const QString EXPR_SPREAD
#define DEFAULT_SIMPLEFILL_STYLE
virtual ~QgsImageFillSymbolLayer()
QgsMapUnitScale mDistanceXMapUnitScale
void startRender(QgsSymbolV2RenderContext &context) override
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
void setScaleFactor(double factor)
QgsGradientFillSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual QColor fillColor() const
Get fill color.
QgsSymbolV2::OutputUnit patternWidthUnit() const
QString layerType() const override
Returns a string that represents this layer type.
void startRender(QgsRenderContext &context, const QgsFields *fields=nullptr)
static const QString EXPR_LINEANGLE
int toInt(bool *ok) const
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
void startRender(QgsSymbolV2RenderContext &context) override
void applyDataDefinedSettings(QgsSymbolV2RenderContext &context) override
double mOffset
Offset perpendicular to line direction.
void fill(uint pixelValue)
QgsMapUnitScale mDistanceMapUnitScale
static QString encodePoint(QPointF point)
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
const QgsMapUnitScale & intervalMapUnitScale() const
static double convertToPainterUnits(const QgsRenderContext &c, double size, QgsSymbolV2::OutputUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale())
Converts a size from the specied units to painter units.
double interval() const
The interval between individual markers.
static const QString EXPR_ALPHA
QColor color() const override
The fill color.
QgsSymbolV2::OutputUnit outputUnit() const override
double dxfWidth(const QgsDxfExport &e, QgsSymbolV2RenderContext &context) const override
get line width
QgsVectorColorRampV2 * mTwoColorGradientRamp
void setPen(const QColor &color)
void setLineWidthUnit(QgsSymbolV2::OutputUnit unit)
QgsSymbolV2::OutputUnit outputUnit() const override
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
void setAttribute(const QString &name, const QString &value)
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
virtual QgsVectorColorRampV2 * clone() const =0
Creates a clone of the color ramp.
virtual QSet< QString > usedAttributes() const override
Returns the set of attributes referenced by the layer.
~QgsCentroidFillSymbolLayerV2()
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
bool setSubSymbol(QgsSymbolV2 *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
virtual double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setAngle(qreal angle)
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
QgsMarkerSymbolV2 * mMarker
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width.
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mapUnitScale() const override
void setAngle(double angle)
double displacementX() const
virtual double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
void startRender(QgsSymbolV2RenderContext &context) override
QgsSVGFillSymbolLayer(const QString &svgFilePath="", double width=20, double rotation=0.0)
~QgsLinePatternFillSymbolLayer()
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenStyle mBorderStyle
QColor selectionColor() const
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
void setWidthF(qreal width)
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
double alpha() const
The opacity for the raster image used in the fill.
QgsMapUnitScale mOffsetMapUnitScale
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
QgsSymbolV2::OutputUnit mOffsetUnit
void setBrush(const QBrush &brush)
QgsCentroidFillSymbolLayerV2()
void setPainter(QPainter *p)
QgsSymbolV2::OutputUnit outputUnit() const override
static const bool selectFillStyle
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context) override
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
const QgsMapUnitScale & svgOutlineWidthMapUnitScale() const
void setDisplacementXUnit(QgsSymbolV2::OutputUnit unit)
void setCoordinateMode(const FillCoordinateMode mode)
Set the coordinate mode for fill.
bool hasDataDefinedProperties() const
Returns whether the symbol utilises any data defined properties.
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual bool setSubSymbol(QgsSymbolV2 *symbol) override
set layer's subsymbol. takes ownership of the passed symbol
QgsMapUnitScale mOffsetMapUnitScale
QString layerType() const override
Returns a string that represents this layer type.
QgsShapeburstFillSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSymbolV2::OutputUnit mOffsetUnit
void setColor(const QColor &color)
virtual Q_DECL_DEPRECATED void prepareExpressions(const QgsFields *fields, double scale=-1.0)
Prepares all data defined property expressions for evaluation.
QgsMapUnitScale mapUnitScale() const
double mapUnitsPerPixel() const
Return current map units per pixel.
virtual QColor color() const
The fill color.
void startRender(QgsSymbolV2RenderContext &context) override
QgsMapUnitScale mDisplacementXMapUnitScale
void setBorderWidthUnit(QgsSymbolV2::OutputUnit unit)
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
static void lineToSld(QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, double width=-1, const Qt::PenJoinStyle *penJoinStyle=nullptr, const Qt::PenCapStyle *penCapStyle=nullptr, const QVector< qreal > *customDashPattern=nullptr, double dashOffset=0.0)
static const QString EXPR_FILE
void setCoordinateMode(CoordinateMode mode)
void setLineWidthMapUnitScale(const QgsMapUnitScale &scale)
QSet< QString > usedAttributes() const override
Returns the set of attributes referenced by the layer.
QString layerType() const override
Returns a string that represents this layer type.
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
QgsMapUnitScale mOffsetMapUnitScale
QgsSymbolV2::OutputUnit mOffsetUnit
void setOffset(QPointF offset)
Sets the offset for the fill.
static Qt::PenStyle decodePenStyle(const QString &str)
void startRender(QgsSymbolV2RenderContext &context) override
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
int geometryPartCount() const
Part count of current geometry.
QString mSvgFilePath
Path to the svg file (or empty if constructed directly from data)
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
QgsSymbolV2::OutputUnit mOffsetUnit
static const QString EXPR_DISTANCE
QgsSymbolV2::OutputUnit mOutlineWidthUnit
QByteArray fromHex(const QByteArray &hexEncoded)
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
void copyDataDefinedProperties(QgsSymbolLayerV2 *destLayer) const
Copies all data defined properties of this layer to another symbol layer.
double mOutlineWidth
Outline width.
QgsFeatureId id() const
Get the feature ID for this feature.
void setDistanceXUnit(QgsSymbolV2::OutputUnit unit)
void saveDataDefinedProperties(QgsStringMap &stringMap) const
Saves all data defined properties to a string map.
double mLineWidth
Line width (in mm or map units)
QgsVectorColorRampV2 * mGradientRamp
static const QString EXPR_COLOR
static const QString EXPR_WIDTH_BORDER
QgsMapUnitScale mapUnitScale() const override
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
static QgsSymbolLayerV2 * createLineLayerFromSld(QDomElement &element)
QgsMapUnitScale mapUnitScale() const override
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
static const QString EXPR_SVG_FILE
static const QString EXPR_ANGLE
void setOffset(QPointF offset)
Offset for gradient fill.
virtual QString layerType() const =0
Returns a string that represents this layer type.
void applyDataDefinedSettings(QgsSymbolV2RenderContext &context) override
virtual ~QgsShapeburstFillSymbolLayerV2()
void setDisplacementY(double d)
QgsExpressionContext & expressionContext()
Gets the expression context.
double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Sets the units used for the offset for the shapeburst fill.
QgsSymbolV2::OutputUnit mDistanceYUnit
static const QString EXPR_DISTANCE_X
QgsSymbolV2::OutputUnit intervalUnit() const
QString layerType() const override
Returns a string that represents this layer type.
static const QString EXPR_REFERENCE1_X
double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
static QgsVectorColorRampV2 * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsVectorColorRampV2 from a map of properties.
void setOffset(QPointF offset)
static const QString EXPR_GRADIENT_TYPE
QgsRasterFillSymbolLayer(const QString &imageFilePath=QString())
void setLineWidth(double w)
QgsSymbolV2::OutputUnit outputUnit() const
Qt::PenJoinStyle mPenJoinStyle
double svgOutlineWidth() const
QgsMapUnitScale mWidthMapUnitScale
void copyPaintEffect(QgsSymbolLayerV2 *destLayer) const
Copies paint effect of this layer to another symbol layer.
A class for svg fill patterns.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsMapUnitScale mapUnitScale() const override
Contains information about the context of a rendering operation.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
static const QString EXPR_SVG_FILL_COLOR
Qt::BrushStyle mBrushStyle
QColor borderColor() const
QRectF boundingRect() const
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
const QgsMapToPixel & mapToPixel() const
void stopRender(QgsRenderContext &context)
QgsMapUnitScale mBorderWidthMapUnitScale
static QString encodeBrushStyle(Qt::BrushStyle style)
static void fillToSld(QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, const QColor &color=QColor())
QSet< T > & unite(const QSet< T > &other)
GradientColorType mGradientColorType
QgsPointPatternFillSymbolLayer()
QColor svgFillColor() const
virtual void writeSldMarker(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const
Writes the symbol layer definition as a SLD XML element.
void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props) const override
Writes the SLD element following the SLD v1.1 specs.
Struct for storing maximum and minimum scales for measurements in map units.
QgsSymbolV2::OutputUnit mDistanceXUnit
QgsMapUnitScale mDistanceMapUnitScale
virtual bool hasDataDefinedProperty(const QString &property) const
Checks whether the layer has a matching data defined property and if that property is currently activ...
void setDisplacementYUnit(QgsSymbolV2::OutputUnit unit)
static const QString EXPR_SVG_OUTLINE_COLOR
const QgsMapUnitScale & patternWidthMapUnitScale() const
QgsSymbolV2::OutputUnit outputUnit() const override
void setSvgFilePath(const QString &svgPath)
QString ogrFeatureStyleWidth(double widthScaleFactor) const
QgsStringMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
QgsRenderContext & renderContext()
double borderWidth() const
QDomElement firstChildElement(const QString &tagName) const
QgsSymbolV2::OutputUnit mBorderWidthUnit
int geometryPartNum() const
Part number of current geometry.
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
static const QString EXPR_IGNORE_RINGS
virtual ~QgsGradientFillSymbolLayerV2()
void setColorRamp(QgsVectorColorRampV2 *ramp)
Sets the color ramp used to draw the shapeburst fill.
void setMapToPixel(const QgsMapToPixel &mtp)
static const QString EXPR_COLOR_BORDER
QString ogrFeatureStyle(double mmScaleFactor, double mapUnitScaleFactor) const override
QgsSymbolV2::OutputUnit mDistanceUnit
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context) override
double patternWidth() const
void setDistanceY(double d)
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
QgsMarkerSymbolV2 * mMarkerSymbol
void renderPoint(QPointF point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void translate(const QPointF &offset)
static const QString EXPR_REFERENCE1_ISCENTROID
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
void setAlpha(const double alpha)
Sets the opacity for the raster image used in the fill.
QgsMapUnitScale mapUnitScale() const override
QgsSymbolV2::OutputUnit outputUnit() const override
void startRender(QgsSymbolV2RenderContext &context) override
~QgsRasterFillSymbolLayer()
QgsGradientFillSymbolLayerV2(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, const QColor &color2=Qt::white, GradientColorType gradientColorType=SimpleTwoColor, GradientType gradientType=Linear, GradientCoordinateMode coordinateMode=Feature, GradientSpread gradientSpread=Pad)
QgsSymbolV2 * subSymbol() override
void setAlphaF(qreal alpha)
static bool rotationFromSldElement(QDomElement &element, QString &rotationFunc)
double estimateMaxBleed() const override
Returns the estimated maximum distance which the layer style will bleed outside the drawn shape...
QgsCentroidFillSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
double toDouble(bool *ok) const
static QColor decodeColor(const QString &str)
void setDistanceX(double d)
iterator insert(const Key &key, const T &value)
Abstract base class for marker symbol layers.
void setMapUnitScale(const QgsMapUnitScale &scale) override
static QPointF polygonCentroid(const QPolygonF &points)
Calculate the centroid point of a QPolygonF.
void setRasterScaleFactor(double factor)
Qt::PenStyle dxfPenStyle() const override
get pen style
QgsSymbolV2::OutputUnit mDistanceUnit
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setColor(const QColor &c) override
The fill color.
void drawPicture(const QPointF &point, const QPicture &picture)
~QgsPointPatternFillSymbolLayer()
static const QString EXPR_SVG_OUTLINE_WIDTH
void restoreDataDefinedProperties(const QgsStringMap &stringMap)
Restores all data defined properties from string map.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QgsSymbolLayerV2 * symbolLayer(int layer)
Returns a specific symbol layers contained in the symbol.
double rasterScaleFactor() const
const_iterator constEnd() const
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
static QgsSymbolLayerV2 * createFromSld(QDomElement &element)
QDomElement createElement(const QString &tagName)
const_iterator constBegin() const
QSet< QString > usedAttributes() const
Return a list of attributes required to render this feature.
void setOffset(double offset)
void setWidthUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the image's width.
void setPatternWidthUnit(QgsSymbolV2::OutputUnit unit)
Draw map such that there are no problems between adjacent tiles.
QgsSymbolV2::OutputUnit mPatternWidthUnit
static QPointF polygonPointOnSurface(const QPolygonF &points)
Calculate a point within of a QPolygonF.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void _renderPolygon(QPainter *p, const QPolygonF &points, const QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context)
Default method to render polygon.
void setOutputUnit(QgsSymbolV2::OutputUnit unit) override
void addStopsToGradient(QGradient *gradient, double alpha=1)
Copy color ramp stops to a QGradient.
static const bool selectFillBorder
QColor dxfBrushColor(QgsSymbolV2RenderContext &context) const override
get brush/fill color
void setColor(const QColor &color) override
The fill color.
Qt::PenStyle borderStyle() const
QColor svgOutlineColor() const
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
double scaleFactor() const
bool begin(QPaintDevice *device)
double displacementY() const
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
Abstract base class for color ramps.
static const QString EXPR_MAX_DISTANCE
void setColor(const QColor &color)
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
QgsSymbolV2::SymbolType type() const
#define DEFAULT_SIMPLEFILL_JOINSTYLE
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QgsSimpleFillSymbolLayerV2 * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setDisplacementX(double d)
double width() const
Returns the width used for scaling the image used in the fill.
void setSpread(Spread method)
void setMapUnitScale(const QgsMapUnitScale &scale) override
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
QgsSimpleFillSymbolLayerV2(const QColor &color=DEFAULT_SIMPLEFILL_COLOR, Qt::BrushStyle style=DEFAULT_SIMPLEFILL_STYLE, const QColor &borderColor=DEFAULT_SIMPLEFILL_BORDERCOLOR, Qt::PenStyle borderStyle=DEFAULT_SIMPLEFILL_BORDERSTYLE, double borderWidth=DEFAULT_SIMPLEFILL_BORDERWIDTH, Qt::PenJoinStyle penJoinStyle=DEFAULT_SIMPLEFILL_JOINSTYLE)
static void blurImageInPlace(QImage &image, QRect rect, int radius, bool alphaOnly)
Blurs an image in place, e.g.
void applyDataDefinedSettings(QgsSymbolV2RenderContext &context) override
void setOutputUnit(QgsSymbolV2::OutputUnit u)
QgsSVGFillSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qt::PenJoinStyle penJoinStyle() const
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
virtual double area() const
Returns the area of the geometry.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsMapUnitScale mapUnitScale() const override
QColor fillColor() const override
Get fill color.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
void setOffsetUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units for the fill's offset.
void stopRender(QgsSymbolV2RenderContext &context) override
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenStyle dxfPenStyle() const override
get pen style
#define DEFAULT_SIMPLEFILL_BORDERWIDTH
virtual void applyDataDefinedSettings(QgsSymbolV2RenderContext &context)
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
virtual QgsMarkerSymbolV2 * clone() const override
static void premultiplyColor(QColor &rgb, int alpha)
Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value.
void setOffsetUnit(QgsSymbolV2::OutputUnit unit)
Units for gradient fill offset.
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolV2RenderContext &context) override
QRectF mSvgViewBox
SVG view box (to keep the aspect ratio.
QImage * mSvgPattern
SVG pattern image.
void setSvgOutlineWidthMapUnitScale(const QgsMapUnitScale &scale)
const T value(const Key &key) const
QPointF offset() const
Returns the offset for the fill.
void stopRender(QgsSymbolV2RenderContext &context) override
double mPatternWidth
Width of the pattern (in output units)
static Q_DECL_DEPRECATED void wellKnownMarkerToSld(QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &borderColor=QColor(), double borderWidth=-1, double size=-1)
QPointF referencePoint1() const
#define DEFAULT_SIMPLEFILL_COLOR