@@ -795,6 +795,7 @@ QgsShapeburstFillSymbolLayerV2::QgsShapeburstFillSymbolLayerV2( QColor color, QC
795
795
mColor2( color2 ),
796
796
mGradientRamp( NULL ),
797
797
mTwoColorGradientRamp( 0 ),
798
+ mIgnoreRings( false ),
798
799
mOffsetUnit( QgsSymbolV2::MM )
799
800
{
800
801
mColor = color;
@@ -859,6 +860,10 @@ QgsSymbolLayerV2* QgsShapeburstFillSymbolLayerV2::create( const QgsStringMap& pr
859
860
{
860
861
sl->setDistanceUnit ( QgsSymbolLayerV2Utils::decodeOutputUnit ( props[" distance_unit" ] ) );
861
862
}
863
+ if ( props.contains ( " ignore_rings" ) )
864
+ {
865
+ sl->setIgnoreRings ( props[" ignore_rings" ].toInt () );
866
+ }
862
867
if ( gradientRamp )
863
868
{
864
869
sl->setColorRamp ( gradientRamp );
@@ -874,6 +879,8 @@ QgsSymbolLayerV2* QgsShapeburstFillSymbolLayerV2::create( const QgsStringMap& pr
874
879
sl->setDataDefinedProperty ( " use_whole_shape" , props[" use_whole_shape_expression" ] );
875
880
if ( props.contains ( " max_distance_expression" ) )
876
881
sl->setDataDefinedProperty ( " max_distance" , props[" max_distance_expression" ] );
882
+ if ( props.contains ( " ignore_rings_expression" ) )
883
+ sl->setDataDefinedProperty ( " ignore_rings" , props[" ignore_rings_expression" ] );
877
884
878
885
return sl;
879
886
}
@@ -890,7 +897,7 @@ void QgsShapeburstFillSymbolLayerV2::setColorRamp( QgsVectorColorRampV2* ramp )
890
897
}
891
898
892
899
void QgsShapeburstFillSymbolLayerV2::applyDataDefinedSymbology ( QgsSymbolV2RenderContext& context, QColor& color, QColor& color2, int & blurRadius, bool & useWholeShape,
893
- double & maxDistance )
900
+ double & maxDistance, bool & ignoreRings )
894
901
{
895
902
// first gradient color
896
903
QgsExpression* colorExpression = expression ( " color" );
@@ -922,6 +929,12 @@ void QgsShapeburstFillSymbolLayerV2::applyDataDefinedSymbology( QgsSymbolV2Rende
922
929
if ( maxDistanceExpression )
923
930
maxDistance = maxDistanceExpression->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toDouble ();
924
931
932
+ // ignore rings
933
+ QgsExpression* ignoreRingsExpression = expression ( " ignore_rings" );
934
+ ignoreRings = mIgnoreRings ;
935
+ if ( ignoreRingsExpression )
936
+ ignoreRings = ignoreRingsExpression->evaluate ( const_cast <QgsFeature*>( context.feature () ) ).toBool ();
937
+
925
938
}
926
939
927
940
void QgsShapeburstFillSymbolLayerV2::startRender ( QgsSymbolV2RenderContext& context )
@@ -970,8 +983,9 @@ void QgsShapeburstFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QLi
970
983
int blurRadius;
971
984
bool useWholeShape;
972
985
double maxDistance;
986
+ bool ignoreRings;
973
987
// calculate data defined symbology
974
- applyDataDefinedSymbology ( context, color1, color2, blurRadius, useWholeShape, maxDistance );
988
+ applyDataDefinedSymbology ( context, color1, color2, blurRadius, useWholeShape, maxDistance, ignoreRings );
975
989
976
990
// calculate max distance for shapeburst fill to extend from polygon boundary, in pixels
977
991
int outputPixelMaxDist = 0 ;
@@ -1022,7 +1036,21 @@ void QgsShapeburstFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QLi
1022
1036
// now that we have a render of the polygon in white, draw this onto the shapeburst fill image too
1023
1037
// (this avoids calling _renderPolygon twice, since that can be slow)
1024
1038
imgPainter.begin ( fillImage );
1025
- imgPainter.drawImage ( 0 , 0 , *alphaImage );
1039
+ if ( !ignoreRings )
1040
+ {
1041
+ imgPainter.drawImage ( 0 , 0 , *alphaImage );
1042
+ }
1043
+ else
1044
+ {
1045
+ // using ignore rings mode, so the alpha image can't be used
1046
+ // directly as the alpha channel contains polygon rings and we need
1047
+ // to draw now without any rings
1048
+ imgPainter.setBrush ( QBrush ( Qt::white ) );
1049
+ imgPainter.setPen ( QPen ( Qt::black ) );
1050
+ imgPainter.translate ( -points.boundingRect ().left () + sideBuffer, - points.boundingRect ().top () + sideBuffer );
1051
+ imgPainter.scale ( context.renderContext ().rasterScaleFactor (), context.renderContext ().rasterScaleFactor () );
1052
+ _renderPolygon ( &imgPainter, points, NULL , context );
1053
+ }
1026
1054
imgPainter.end ();
1027
1055
1028
1056
// apply distance transform to image, uses the current color ramp to calculate final pixel colours
@@ -1252,6 +1280,7 @@ QgsStringMap QgsShapeburstFillSymbolLayerV2::properties() const
1252
1280
map[" use_whole_shape" ] = QString::number ( mUseWholeShape );
1253
1281
map[" max_distance" ] = QString::number ( mMaxDistance );
1254
1282
map[" distance_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mDistanceUnit );
1283
+ map[" ignore_rings" ] = QString::number ( mIgnoreRings );
1255
1284
map[" offset" ] = QgsSymbolLayerV2Utils::encodePoint ( mOffset );
1256
1285
map[" offset_unit" ] = QgsSymbolLayerV2Utils::encodeOutputUnit ( mOffsetUnit );
1257
1286
@@ -1273,6 +1302,7 @@ QgsSymbolLayerV2* QgsShapeburstFillSymbolLayerV2::clone() const
1273
1302
sl->setColorRamp ( mGradientRamp ->clone () );
1274
1303
}
1275
1304
sl->setDistanceUnit ( mDistanceUnit );
1305
+ sl->setIgnoreRings ( mIgnoreRings );
1276
1306
sl->setOffset ( mOffset );
1277
1307
sl->setOffsetUnit ( mOffsetUnit );
1278
1308
copyDataDefinedProperties ( sl );
0 commit comments