@@ -232,20 +232,20 @@ QString QgsSimpleFillSymbolLayer::layerType() const
232
232
void QgsSimpleFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
233
233
{
234
234
QColor fillColor = mColor ;
235
- fillColor.setAlphaF ( context.alpha () * mColor .alphaF () );
235
+ fillColor.setAlphaF ( context.opacity () * mColor .alphaF () );
236
236
mBrush = QBrush ( fillColor, mBrushStyle );
237
237
238
238
QColor selColor = context.renderContext ().selectionColor ();
239
239
QColor selPenColor = selColor == mColor ? selColor : mStrokeColor ;
240
- if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.alpha () );
240
+ if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.opacity () );
241
241
mSelBrush = QBrush ( selColor );
242
242
// N.B. unless a "selection line color" is implemented in addition to the "selection color" option
243
243
// this would mean symbols with "no fill" look the same whether or not they are selected
244
244
if ( SELECT_FILL_STYLE )
245
245
mSelBrush .setStyle ( mBrushStyle );
246
246
247
247
QColor strokeColor = mStrokeColor ;
248
- strokeColor.setAlphaF ( context.alpha () * mStrokeColor .alphaF () );
248
+ strokeColor.setAlphaF ( context.opacity () * mStrokeColor .alphaF () );
249
249
mPen = QPen ( strokeColor );
250
250
mSelPen = QPen ( selPenColor );
251
251
mPen .setStyle ( mStrokeStyle );
@@ -767,9 +767,9 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
767
767
{
768
768
// update alpha of gradient colors
769
769
QColor fillColor = color;
770
- fillColor.setAlphaF ( context.alpha () * fillColor.alphaF () );
770
+ fillColor.setAlphaF ( context.opacity () * fillColor.alphaF () );
771
771
QColor fillColor2 = color2;
772
- fillColor2.setAlphaF ( context.alpha () * fillColor2.alphaF () );
772
+ fillColor2.setAlphaF ( context.opacity () * fillColor2.alphaF () );
773
773
774
774
// rotate reference points
775
775
QPointF rotatedReferencePoint1 = !qgsDoubleNear ( angle, 0.0 ) ? rotateReferencePoint ( referencePoint1, angle ) : referencePoint1;
@@ -817,7 +817,7 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
817
817
{
818
818
// color ramp gradient
819
819
QgsGradientColorRamp *gradRamp = static_cast <QgsGradientColorRamp *>( gradientRamp );
820
- gradRamp->addStopsToGradient ( &gradient, context.alpha () );
820
+ gradRamp->addStopsToGradient ( &gradient, context.opacity () );
821
821
}
822
822
else
823
823
{
@@ -833,7 +833,8 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
833
833
void QgsGradientFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
834
834
{
835
835
QColor selColor = context.renderContext ().selectionColor ();
836
- if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.alpha () );
836
+ if ( ! SELECTION_IS_OPAQUE )
837
+ selColor.setAlphaF ( context.opacity () );
837
838
mSelBrush = QBrush ( selColor );
838
839
}
839
840
@@ -1125,7 +1126,8 @@ void QgsShapeburstFillSymbolLayer::startRender( QgsSymbolRenderContext &context
1125
1126
{
1126
1127
// TODO - check this
1127
1128
QColor selColor = context.renderContext ().selectionColor ();
1128
- if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.alpha () );
1129
+ if ( ! SELECTION_IS_OPAQUE )
1130
+ selColor.setAlphaF ( context.opacity () );
1129
1131
mSelBrush = QBrush ( selColor );
1130
1132
}
1131
1133
@@ -1237,7 +1239,7 @@ void QgsShapeburstFillSymbolLayer::renderPolygon( const QPolygonF &points, QList
1237
1239
1238
1240
// copy distance transform values back to QImage, shading by appropriate color ramp
1239
1241
dtArrayToQImage ( dtArray, fillImage, mColorType == QgsShapeburstFillSymbolLayer::SimpleTwoColor ? mTwoColorGradientRamp : mGradientRamp ,
1240
- context.alpha (), useWholeShape, outputPixelMaxDist );
1242
+ context.opacity (), useWholeShape, outputPixelMaxDist );
1241
1243
1242
1244
// clean up some variables
1243
1245
delete [] dtArray;
@@ -1962,10 +1964,10 @@ void QgsSVGFillSymbolLayer::applyPattern( QBrush &brush, const QString &svgFileP
1962
1964
}
1963
1965
1964
1966
QTransform brushTransform;
1965
- if ( !qgsDoubleNear ( context.alpha (), 1.0 ) )
1967
+ if ( !qgsDoubleNear ( context.opacity (), 1.0 ) )
1966
1968
{
1967
1969
QImage transparentImage = fitsInCache ? patternImage.copy () : mSvgPattern ->copy ();
1968
- QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.alpha () );
1970
+ QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.opacity () );
1969
1971
brush.setTextureImage ( transparentImage );
1970
1972
}
1971
1973
else
@@ -2771,10 +2773,10 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &
2771
2773
patternImage = patternImage.copy ( xBuffer, yBuffer, patternImage.width () - 2 * xBuffer, patternImage.height () - 2 * yBuffer );
2772
2774
2773
2775
// set image to mBrush
2774
- if ( !qgsDoubleNear ( context.alpha (), 1.0 ) )
2776
+ if ( !qgsDoubleNear ( context.opacity (), 1.0 ) )
2775
2777
{
2776
2778
QImage transparentImage = patternImage.copy ();
2777
- QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.alpha () );
2779
+ QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.opacity () );
2778
2780
brush.setTextureImage ( transparentImage );
2779
2781
}
2780
2782
else
@@ -3185,10 +3187,10 @@ void QgsPointPatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext
3185
3187
mMarkerSymbol ->stopRender ( pointRenderContext );
3186
3188
}
3187
3189
3188
- if ( !qgsDoubleNear ( context.alpha (), 1.0 ) )
3190
+ if ( !qgsDoubleNear ( context.opacity (), 1.0 ) )
3189
3191
{
3190
3192
QImage transparentImage = patternImage.copy ();
3191
- QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.alpha () );
3193
+ QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.opacity () );
3192
3194
brush.setTextureImage ( transparentImage );
3193
3195
}
3194
3196
else
@@ -3418,7 +3420,7 @@ QColor QgsCentroidFillSymbolLayer::color() const
3418
3420
3419
3421
void QgsCentroidFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
3420
3422
{
3421
- mMarker ->setAlpha ( context.alpha () );
3423
+ mMarker ->setOpacity ( context.opacity () );
3422
3424
mMarker ->startRender ( context.renderContext (), context.fields () );
3423
3425
3424
3426
mCurrentFeatureId = -1 ;
@@ -3590,7 +3592,6 @@ QgsRasterFillSymbolLayer::QgsRasterFillSymbolLayer( const QString &imageFilePath
3590
3592
: QgsImageFillSymbolLayer()
3591
3593
, mImageFilePath( imageFilePath )
3592
3594
, mCoordinateMode( QgsRasterFillSymbolLayer::Feature )
3593
- , mAlpha( 1.0 )
3594
3595
, mOffsetUnit( QgsUnitTypes::RenderMillimeters )
3595
3596
, mWidth( 0.0 )
3596
3597
, mWidthUnit( QgsUnitTypes::RenderPixels )
@@ -3633,7 +3634,7 @@ QgsSymbolLayer *QgsRasterFillSymbolLayer::create( const QgsStringMap &properties
3633
3634
}
3634
3635
QgsRasterFillSymbolLayer *symbolLayer = new QgsRasterFillSymbolLayer ( imagePath );
3635
3636
symbolLayer->setCoordinateMode ( mode );
3636
- symbolLayer->setAlpha ( alpha );
3637
+ symbolLayer->setOpacity ( alpha );
3637
3638
symbolLayer->setOffset ( offset );
3638
3639
symbolLayer->setAngle ( angle );
3639
3640
symbolLayer->setWidth ( width );
@@ -3701,7 +3702,7 @@ void QgsRasterFillSymbolLayer::renderPolygon( const QPolygonF &points, QList<QPo
3701
3702
3702
3703
void QgsRasterFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
3703
3704
{
3704
- applyPattern ( mBrush , mImageFilePath , mWidth , mAlpha , context );
3705
+ applyPattern ( mBrush , mImageFilePath , mWidth , mOpacity , context );
3705
3706
}
3706
3707
3707
3708
void QgsRasterFillSymbolLayer::stopRender ( QgsSymbolRenderContext &context )
@@ -3714,7 +3715,7 @@ QgsStringMap QgsRasterFillSymbolLayer::properties() const
3714
3715
QgsStringMap map;
3715
3716
map[QStringLiteral ( " imageFile" )] = mImageFilePath ;
3716
3717
map[QStringLiteral ( " coordinate_mode" )] = QString::number ( mCoordinateMode );
3717
- map[QStringLiteral ( " alpha" )] = QString::number ( mAlpha );
3718
+ map[QStringLiteral ( " alpha" )] = QString::number ( mOpacity );
3718
3719
map[QStringLiteral ( " offset" )] = QgsSymbolLayerUtils::encodePoint ( mOffset );
3719
3720
map[QStringLiteral ( " offset_unit" )] = QgsUnitTypes::encodeUnit ( mOffsetUnit );
3720
3721
map[QStringLiteral ( " offset_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale ( mOffsetMapUnitScale );
@@ -3729,7 +3730,7 @@ QgsRasterFillSymbolLayer *QgsRasterFillSymbolLayer::clone() const
3729
3730
{
3730
3731
QgsRasterFillSymbolLayer *sl = new QgsRasterFillSymbolLayer ( mImageFilePath );
3731
3732
sl->setCoordinateMode ( mCoordinateMode );
3732
- sl->setAlpha ( mAlpha );
3733
+ sl->setOpacity ( mOpacity );
3733
3734
sl->setOffset ( mOffset );
3734
3735
sl->setOffsetUnit ( mOffsetUnit );
3735
3736
sl->setOffsetMapUnitScale ( mOffsetMapUnitScale );
@@ -3757,9 +3758,9 @@ void QgsRasterFillSymbolLayer::setCoordinateMode( const QgsRasterFillSymbolLayer
3757
3758
mCoordinateMode = mode;
3758
3759
}
3759
3760
3760
- void QgsRasterFillSymbolLayer::setAlpha ( const double alpha )
3761
+ void QgsRasterFillSymbolLayer::setOpacity ( const double opacity )
3761
3762
{
3762
- mAlpha = alpha ;
3763
+ mOpacity = opacity ;
3763
3764
}
3764
3765
3765
3766
void QgsRasterFillSymbolLayer::applyDataDefinedSettings ( QgsSymbolRenderContext &context )
@@ -3769,10 +3770,10 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
3769
3770
3770
3771
bool hasWidthExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyWidth );
3771
3772
bool hasFileExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyFile );
3772
- bool hasAlphaExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyAlpha );
3773
+ bool hasOpacityExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyOpacity );
3773
3774
bool hasAngleExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyAngle );
3774
3775
3775
- if ( !hasWidthExpression && !hasAngleExpression && !hasAlphaExpression && !hasFileExpression )
3776
+ if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
3776
3777
{
3777
3778
return ; // no data defined settings
3778
3779
}
@@ -3786,7 +3787,7 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
3786
3787
mNextAngle = nextAngle;
3787
3788
}
3788
3789
3789
- if ( !hasWidthExpression && !hasAlphaExpression && !hasFileExpression )
3790
+ if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
3790
3791
{
3791
3792
return ; // nothing further to do
3792
3793
}
@@ -3797,19 +3798,19 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
3797
3798
context.setOriginalValueVariable ( mWidth );
3798
3799
width = mDataDefinedProperties .valueAsDouble ( QgsSymbolLayer::PropertyWidth, context.renderContext ().expressionContext (), width );
3799
3800
}
3800
- double alpha = mAlpha ;
3801
- if ( hasAlphaExpression )
3801
+ double opacity = mOpacity ;
3802
+ if ( hasOpacityExpression )
3802
3803
{
3803
- context.setOriginalValueVariable ( mAlpha );
3804
- alpha = mDataDefinedProperties .valueAsDouble ( QgsSymbolLayer::PropertyAlpha , context.renderContext ().expressionContext (), alpha ) ;
3804
+ context.setOriginalValueVariable ( mOpacity );
3805
+ opacity = mDataDefinedProperties .valueAsDouble ( QgsSymbolLayer::PropertyOpacity , context.renderContext ().expressionContext (), opacity * 100 ) / 100.0 ;
3805
3806
}
3806
3807
QString file = mImageFilePath ;
3807
3808
if ( hasFileExpression )
3808
3809
{
3809
3810
context.setOriginalValueVariable ( mImageFilePath );
3810
3811
file = mDataDefinedProperties .valueAsString ( QgsSymbolLayer::PropertyFile, context.renderContext ().expressionContext (), file );
3811
3812
}
3812
- applyPattern ( mBrush , file, width, alpha , context );
3813
+ applyPattern ( mBrush , file, width, opacity , context );
3813
3814
}
3814
3815
3815
3816
void QgsRasterFillSymbolLayer::applyPattern ( QBrush &brush, const QString &imageFilePath, const double width, const double alpha, const QgsSymbolRenderContext &context )
0 commit comments