Skip to content
Permalink
Browse files

Updated the transparency widget to fix bug #16649 (#5358)

  • Loading branch information
JamesShaeffer authored and nirvn committed Oct 13, 2017
1 parent 873b4b0 commit b740a89cba4d0bc37ce868989f5a5799b25614f0
Showing with 32 additions and 0 deletions.
  1. +32 −0 src/gui/raster/qgsrastertransparencywidget.cpp
@@ -53,6 +53,8 @@ QgsRasterTransparencyWidget::QgsRasterTransparencyWidget( QgsRasterLayer *layer,

connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsPanelWidget::widgetChanged );
connect( cboxTransparencyBand, &QgsRasterBandComboBox::bandChanged, this, &QgsPanelWidget::widgetChanged );
connect( mSrcNoDataValueCheckBox, &QCheckBox::stateChanged, this, &QgsPanelWidget::widgetChanged );
connect( leNoDataValue, &QLineEdit::textEdited, this, &QgsPanelWidget::widgetChanged );

mPixelSelectorTool = nullptr;
if ( mMapCanvas )
@@ -103,6 +105,17 @@ void QgsRasterTransparencyWidget::syncToLayer()
mSrcNoDataValueCheckBox->setEnabled( enableSrcNoData );
lblSrcNoDataValue->setEnabled( enableSrcNoData );

QgsRasterRangeList noDataRangeList = mRasterLayer->dataProvider()->userNoDataValues( 1 );
QgsDebugMsg( QString( "noDataRangeList.size = %1" ).arg( noDataRangeList.size() ) );
if ( !noDataRangeList.isEmpty() )
{
leNoDataValue->insert( QgsRasterBlock::printValue( noDataRangeList.value( 0 ).min() ) );
}
else
{
leNoDataValue->insert( QLatin1String( "" ) );

This comment has been minimized.

Copy link
@Gustry

Gustry Oct 13, 2017

Contributor

without double quotes?

}

populateTransparencyTable( mRasterLayer->renderer() );
}

@@ -366,6 +379,25 @@ bool QgsRasterTransparencyWidget::rasterIsMultiBandColor()

void QgsRasterTransparencyWidget::apply()
{
//set NoDataValue
QgsRasterRangeList myNoDataRangeList;

This comment has been minimized.

Copy link
@DelazJ

DelazJ Oct 13, 2017

Contributor

@nirvn I might mix things but aren't we supposed to avoid these my... naming?

if ( "" != leNoDataValue->text() )

This comment has been minimized.

Copy link
@Gustry

Gustry Oct 13, 2017

Contributor

! leNoDataValue->text().isEmpty() ?

I'm just trying to apply what I learn from @nyalldawson ;-)

{
bool myDoubleOk = false;
double myNoDataValue = leNoDataValue->text().toDouble( &myDoubleOk );
if ( myDoubleOk )
{
QgsRasterRange myNoDataRange( myNoDataValue, myNoDataValue );
myNoDataRangeList << myNoDataRange;
}
}
for ( int bandNo = 1; bandNo <= mRasterLayer->dataProvider()->bandCount(); bandNo++ )
{
mRasterLayer->dataProvider()->setUserNoDataValue( bandNo, myNoDataRangeList );
mRasterLayer->dataProvider()->setUseSourceNoDataValue( bandNo, mSrcNoDataValueCheckBox->isChecked() );
}

//transparency settings
QgsRasterRenderer *rasterRenderer = mRasterLayer->renderer();
if ( rasterRenderer )
{

0 comments on commit b740a89

Please sign in to comment.