Skip to content

Commit

Permalink
Fix transparency restoration on project load
Browse files Browse the repository at this point in the history
  • Loading branch information
timlinux authored and mhugent committed Feb 10, 2012
1 parent 884de68 commit ae2899a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsmaplayer.h
Expand Up @@ -201,7 +201,7 @@ class CORE_EXPORT QgsMapLayer : public QObject
unsigned int getTransparency();

/** Mutator for transparency level. Should be between 0 and 255 */
void setTransparency( unsigned int );
virtual void setTransparency( unsigned int );

/**
* If an operation returns 0 (e.g. draw()), this function
Expand Down
15 changes: 13 additions & 2 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -3151,7 +3151,8 @@ bool QgsRasterLayer::readSymbology( const QDomNode& layer_node, QString& errorMe
{
QgsColorRampShader* myColorRampShader = ( QgsColorRampShader* ) mRasterShader->rasterShaderFunction();

//TODO: Remove the customColorRampType check and following if() in v2.0, added for compatibility with older ( bugged ) project files
//TODO: Remove the customColorRampType check and following if() in v2.0,
//added for compatibility with older ( bugged ) project files
QDomNode customColorRampTypeNode = customColorRampNode.namedItem( "customColorRampType" );
QDomNode colorRampTypeNode = customColorRampNode.namedItem( "colorRampType" );
QString myRampType = "";
Expand Down Expand Up @@ -3760,7 +3761,8 @@ QString QgsRasterLayer::generateBandName( int theBandNumber )
*/
bool QgsRasterLayer::hasBand( QString const & theBandName )
{
//TODO: This function is no longer really needed and about be removed -- it is only used to see if "Palette" exists which is not the correct way to see if a band is paletted or not
//TODO: This function is no longer really needed and about be removed
//-- it is only used to see if "Palette" exists which is not the correct way to see if a band is paletted or not
QgsDebugMsg( "Looking for band : " + theBandName );

for ( int i = 1; i <= mDataProvider->bandCount(); i++ )
Expand Down Expand Up @@ -3984,3 +3986,12 @@ bool QgsRasterLayer::readColorTable( int theBandNumber, QList<QgsColorRampShader
return true;
}


void QgsRasterLayer::setTransparency( unsigned int theInt )
{
mTransparencyLevel = theInt;
if ( mRenderer )
{
mRenderer->setOpacity( mTransparencyLevel / 255.0 );
}
}
3 changes: 3 additions & 0 deletions src/core/raster/qgsrasterlayer.h
Expand Up @@ -694,6 +694,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** \brief receive progress signal from provider */
void onProgress( int, double, QString );

/** \brief Overload the setTransparency method from QgsMapLayer */
void setTransparency( unsigned int theInt );

signals:
/** \brief Signal for notifying listeners of long running processes */
void progressUpdate( int theValue );
Expand Down

0 comments on commit ae2899a

Please sign in to comment.