@@ -232,20 +232,20 @@ QString QgsSimpleFillSymbolLayer::layerType() const
232232void QgsSimpleFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
233233{
234234 QColor fillColor = mColor ;
235- fillColor.setAlphaF ( context.alpha () * mColor .alphaF () );
235+ fillColor.setAlphaF ( context.opacity () * mColor .alphaF () );
236236 mBrush = QBrush ( fillColor, mBrushStyle );
237237
238238 QColor selColor = context.renderContext ().selectionColor ();
239239 QColor selPenColor = selColor == mColor ? selColor : mStrokeColor ;
240- if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.alpha () );
240+ if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.opacity () );
241241 mSelBrush = QBrush ( selColor );
242242 // N.B. unless a "selection line color" is implemented in addition to the "selection color" option
243243 // this would mean symbols with "no fill" look the same whether or not they are selected
244244 if ( SELECT_FILL_STYLE )
245245 mSelBrush .setStyle ( mBrushStyle );
246246
247247 QColor strokeColor = mStrokeColor ;
248- strokeColor.setAlphaF ( context.alpha () * mStrokeColor .alphaF () );
248+ strokeColor.setAlphaF ( context.opacity () * mStrokeColor .alphaF () );
249249 mPen = QPen ( strokeColor );
250250 mSelPen = QPen ( selPenColor );
251251 mPen .setStyle ( mStrokeStyle );
@@ -767,9 +767,9 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
767767{
768768 // update alpha of gradient colors
769769 QColor fillColor = color;
770- fillColor.setAlphaF ( context.alpha () * fillColor.alphaF () );
770+ fillColor.setAlphaF ( context.opacity () * fillColor.alphaF () );
771771 QColor fillColor2 = color2;
772- fillColor2.setAlphaF ( context.alpha () * fillColor2.alphaF () );
772+ fillColor2.setAlphaF ( context.opacity () * fillColor2.alphaF () );
773773
774774 // rotate reference points
775775 QPointF rotatedReferencePoint1 = !qgsDoubleNear ( angle, 0.0 ) ? rotateReferencePoint ( referencePoint1, angle ) : referencePoint1;
@@ -817,7 +817,7 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
817817 {
818818 // color ramp gradient
819819 QgsGradientColorRamp *gradRamp = static_cast <QgsGradientColorRamp *>( gradientRamp );
820- gradRamp->addStopsToGradient ( &gradient, context.alpha () );
820+ gradRamp->addStopsToGradient ( &gradient, context.opacity () );
821821 }
822822 else
823823 {
@@ -833,7 +833,8 @@ void QgsGradientFillSymbolLayer::applyGradient( const QgsSymbolRenderContext &co
833833void QgsGradientFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
834834{
835835 QColor selColor = context.renderContext ().selectionColor ();
836- if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.alpha () );
836+ if ( ! SELECTION_IS_OPAQUE )
837+ selColor.setAlphaF ( context.opacity () );
837838 mSelBrush = QBrush ( selColor );
838839}
839840
@@ -1125,7 +1126,8 @@ void QgsShapeburstFillSymbolLayer::startRender( QgsSymbolRenderContext &context
11251126{
11261127 // TODO - check this
11271128 QColor selColor = context.renderContext ().selectionColor ();
1128- if ( ! SELECTION_IS_OPAQUE ) selColor.setAlphaF ( context.alpha () );
1129+ if ( ! SELECTION_IS_OPAQUE )
1130+ selColor.setAlphaF ( context.opacity () );
11291131 mSelBrush = QBrush ( selColor );
11301132}
11311133
@@ -1237,7 +1239,7 @@ void QgsShapeburstFillSymbolLayer::renderPolygon( const QPolygonF &points, QList
12371239
12381240 // copy distance transform values back to QImage, shading by appropriate color ramp
12391241 dtArrayToQImage ( dtArray, fillImage, mColorType == QgsShapeburstFillSymbolLayer::SimpleTwoColor ? mTwoColorGradientRamp : mGradientRamp ,
1240- context.alpha (), useWholeShape, outputPixelMaxDist );
1242+ context.opacity (), useWholeShape, outputPixelMaxDist );
12411243
12421244 // clean up some variables
12431245 delete [] dtArray;
@@ -1962,10 +1964,10 @@ void QgsSVGFillSymbolLayer::applyPattern( QBrush &brush, const QString &svgFileP
19621964 }
19631965
19641966 QTransform brushTransform;
1965- if ( !qgsDoubleNear ( context.alpha (), 1.0 ) )
1967+ if ( !qgsDoubleNear ( context.opacity (), 1.0 ) )
19661968 {
19671969 QImage transparentImage = fitsInCache ? patternImage.copy () : mSvgPattern ->copy ();
1968- QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.alpha () );
1970+ QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.opacity () );
19691971 brush.setTextureImage ( transparentImage );
19701972 }
19711973 else
@@ -2771,10 +2773,10 @@ void QgsLinePatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext &
27712773 patternImage = patternImage.copy ( xBuffer, yBuffer, patternImage.width () - 2 * xBuffer, patternImage.height () - 2 * yBuffer );
27722774
27732775 // set image to mBrush
2774- if ( !qgsDoubleNear ( context.alpha (), 1.0 ) )
2776+ if ( !qgsDoubleNear ( context.opacity (), 1.0 ) )
27752777 {
27762778 QImage transparentImage = patternImage.copy ();
2777- QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.alpha () );
2779+ QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.opacity () );
27782780 brush.setTextureImage ( transparentImage );
27792781 }
27802782 else
@@ -3185,10 +3187,10 @@ void QgsPointPatternFillSymbolLayer::applyPattern( const QgsSymbolRenderContext
31853187 mMarkerSymbol ->stopRender ( pointRenderContext );
31863188 }
31873189
3188- if ( !qgsDoubleNear ( context.alpha (), 1.0 ) )
3190+ if ( !qgsDoubleNear ( context.opacity (), 1.0 ) )
31893191 {
31903192 QImage transparentImage = patternImage.copy ();
3191- QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.alpha () );
3193+ QgsSymbolLayerUtils::multiplyImageOpacity ( &transparentImage, context.opacity () );
31923194 brush.setTextureImage ( transparentImage );
31933195 }
31943196 else
@@ -3418,7 +3420,7 @@ QColor QgsCentroidFillSymbolLayer::color() const
34183420
34193421void QgsCentroidFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
34203422{
3421- mMarker ->setAlpha ( context.alpha () );
3423+ mMarker ->setOpacity ( context.opacity () );
34223424 mMarker ->startRender ( context.renderContext (), context.fields () );
34233425
34243426 mCurrentFeatureId = -1 ;
@@ -3590,7 +3592,6 @@ QgsRasterFillSymbolLayer::QgsRasterFillSymbolLayer( const QString &imageFilePath
35903592 : QgsImageFillSymbolLayer()
35913593 , mImageFilePath( imageFilePath )
35923594 , mCoordinateMode( QgsRasterFillSymbolLayer::Feature )
3593- , mAlpha( 1.0 )
35943595 , mOffsetUnit( QgsUnitTypes::RenderMillimeters )
35953596 , mWidth( 0.0 )
35963597 , mWidthUnit( QgsUnitTypes::RenderPixels )
@@ -3633,7 +3634,7 @@ QgsSymbolLayer *QgsRasterFillSymbolLayer::create( const QgsStringMap &properties
36333634 }
36343635 QgsRasterFillSymbolLayer *symbolLayer = new QgsRasterFillSymbolLayer ( imagePath );
36353636 symbolLayer->setCoordinateMode ( mode );
3636- symbolLayer->setAlpha ( alpha );
3637+ symbolLayer->setOpacity ( alpha );
36373638 symbolLayer->setOffset ( offset );
36383639 symbolLayer->setAngle ( angle );
36393640 symbolLayer->setWidth ( width );
@@ -3701,7 +3702,7 @@ void QgsRasterFillSymbolLayer::renderPolygon( const QPolygonF &points, QList<QPo
37013702
37023703void QgsRasterFillSymbolLayer::startRender ( QgsSymbolRenderContext &context )
37033704{
3704- applyPattern ( mBrush , mImageFilePath , mWidth , mAlpha , context );
3705+ applyPattern ( mBrush , mImageFilePath , mWidth , mOpacity , context );
37053706}
37063707
37073708void QgsRasterFillSymbolLayer::stopRender ( QgsSymbolRenderContext &context )
@@ -3714,7 +3715,7 @@ QgsStringMap QgsRasterFillSymbolLayer::properties() const
37143715 QgsStringMap map;
37153716 map[QStringLiteral ( " imageFile" )] = mImageFilePath ;
37163717 map[QStringLiteral ( " coordinate_mode" )] = QString::number ( mCoordinateMode );
3717- map[QStringLiteral ( " alpha" )] = QString::number ( mAlpha );
3718+ map[QStringLiteral ( " alpha" )] = QString::number ( mOpacity );
37183719 map[QStringLiteral ( " offset" )] = QgsSymbolLayerUtils::encodePoint ( mOffset );
37193720 map[QStringLiteral ( " offset_unit" )] = QgsUnitTypes::encodeUnit ( mOffsetUnit );
37203721 map[QStringLiteral ( " offset_map_unit_scale" )] = QgsSymbolLayerUtils::encodeMapUnitScale ( mOffsetMapUnitScale );
@@ -3729,7 +3730,7 @@ QgsRasterFillSymbolLayer *QgsRasterFillSymbolLayer::clone() const
37293730{
37303731 QgsRasterFillSymbolLayer *sl = new QgsRasterFillSymbolLayer ( mImageFilePath );
37313732 sl->setCoordinateMode ( mCoordinateMode );
3732- sl->setAlpha ( mAlpha );
3733+ sl->setOpacity ( mOpacity );
37333734 sl->setOffset ( mOffset );
37343735 sl->setOffsetUnit ( mOffsetUnit );
37353736 sl->setOffsetMapUnitScale ( mOffsetMapUnitScale );
@@ -3757,9 +3758,9 @@ void QgsRasterFillSymbolLayer::setCoordinateMode( const QgsRasterFillSymbolLayer
37573758 mCoordinateMode = mode;
37583759}
37593760
3760- void QgsRasterFillSymbolLayer::setAlpha ( const double alpha )
3761+ void QgsRasterFillSymbolLayer::setOpacity ( const double opacity )
37613762{
3762- mAlpha = alpha ;
3763+ mOpacity = opacity ;
37633764}
37643765
37653766void QgsRasterFillSymbolLayer::applyDataDefinedSettings ( QgsSymbolRenderContext &context )
@@ -3769,10 +3770,10 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
37693770
37703771 bool hasWidthExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyWidth );
37713772 bool hasFileExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyFile );
3772- bool hasAlphaExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyAlpha );
3773+ bool hasOpacityExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyOpacity );
37733774 bool hasAngleExpression = mDataDefinedProperties .isActive ( QgsSymbolLayer::PropertyAngle );
37743775
3775- if ( !hasWidthExpression && !hasAngleExpression && !hasAlphaExpression && !hasFileExpression )
3776+ if ( !hasWidthExpression && !hasAngleExpression && !hasOpacityExpression && !hasFileExpression )
37763777 {
37773778 return ; // no data defined settings
37783779 }
@@ -3786,7 +3787,7 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
37863787 mNextAngle = nextAngle;
37873788 }
37883789
3789- if ( !hasWidthExpression && !hasAlphaExpression && !hasFileExpression )
3790+ if ( !hasWidthExpression && !hasOpacityExpression && !hasFileExpression )
37903791 {
37913792 return ; // nothing further to do
37923793 }
@@ -3797,19 +3798,19 @@ void QgsRasterFillSymbolLayer::applyDataDefinedSettings( QgsSymbolRenderContext
37973798 context.setOriginalValueVariable ( mWidth );
37983799 width = mDataDefinedProperties .valueAsDouble ( QgsSymbolLayer::PropertyWidth, context.renderContext ().expressionContext (), width );
37993800 }
3800- double alpha = mAlpha ;
3801- if ( hasAlphaExpression )
3801+ double opacity = mOpacity ;
3802+ if ( hasOpacityExpression )
38023803 {
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 ;
38053806 }
38063807 QString file = mImageFilePath ;
38073808 if ( hasFileExpression )
38083809 {
38093810 context.setOriginalValueVariable ( mImageFilePath );
38103811 file = mDataDefinedProperties .valueAsString ( QgsSymbolLayer::PropertyFile, context.renderContext ().expressionContext (), file );
38113812 }
3812- applyPattern ( mBrush , file, width, alpha , context );
3813+ applyPattern ( mBrush , file, width, opacity , context );
38133814}
38143815
38153816void QgsRasterFillSymbolLayer::applyPattern ( QBrush &brush, const QString &imageFilePath, const double width, const double alpha, const QgsSymbolRenderContext &context )
0 commit comments