@@ -1315,44 +1315,42 @@ void QgsRasterLayerProperties::on_pbnRemoveSelectedRow_clicked()
1315
1315
1316
1316
void QgsRasterLayerProperties::pixelSelected ( const QgsPoint& canvasPoint )
1317
1317
{
1318
- #if 0 //needs to be fixed
1319
- //PixelSelectorTool has registered a mouse click on the canvas, so bring the dialog back to the front
1318
+ QgsRasterRenderer* renderer = mRendererWidget ->renderer ();
1319
+ if ( !renderer )
1320
+ {
1321
+ return ;
1322
+ }
1323
+
1320
1324
raise ();
1321
1325
setModal ( true );
1322
1326
activateWindow ();
1323
1327
1324
1328
// Get the pixel values and add a new entry to the transparency table
1325
1329
if ( mMapCanvas && mPixelSelectorTool )
1326
1330
{
1327
- QMap< QString , QString > myPixelMap;
1331
+ QMap< int , QString > myPixelMap;
1328
1332
mMapCanvas ->unsetMapTool ( mPixelSelectorTool );
1329
1333
mRasterLayer ->identify ( mMapCanvas ->mapRenderer ()->mapToLayerCoordinates ( mRasterLayer , canvasPoint ), myPixelMap );
1330
- if ( tableTransparency->columnCount() == 2 )
1331
- {
1332
- QString myValue = myPixelMap[ mRasterLayer->grayBandName()];
1333
- if ( myValue != tr( "out of extent" ) )
1334
- {
1335
- tableTransparency->insertRow( tableTransparency->rowCount() );
1336
- tableTransparency->setItem( tableTransparency->rowCount() - 1, tableTransparency->columnCount() - 1, new QTableWidgetItem( "100.0" ) );
1337
- tableTransparency->setItem( tableTransparency->rowCount() - 1, 0, new QTableWidgetItem( myValue ) );
1338
- }
1339
- }
1340
- else
1334
+
1335
+ QList<int > bands = renderer->usesBands ();
1336
+ tableTransparency->insertRow ( tableTransparency->rowCount () );
1337
+ tableTransparency->setItem ( tableTransparency->rowCount () - 1 , tableTransparency->columnCount () - 1 , new QTableWidgetItem ( " 100.0" ) );
1338
+
1339
+ for ( int i = 0 ; i < bands.size (); ++i )
1341
1340
{
1342
- QString myValue = myPixelMap[ mRasterLayer->redBandName()] ;
1343
- if ( myValue != tr( "out of extent" ) )
1341
+ QMap< int , QString >::const_iterator pixelResult = myPixelMap. find ( bands. at ( i ) ) ;
1342
+ if ( pixelResult != myPixelMap. constEnd ( ) )
1344
1343
{
1345
- tableTransparency->insertRow( tableTransparency->rowCount() );
1346
- tableTransparency->setItem( tableTransparency->rowCount() - 1, tableTransparency->columnCount() - 1, new QTableWidgetItem( "100.0" ) );
1347
- tableTransparency->setItem( tableTransparency->rowCount() - 1, 0, new QTableWidgetItem( myValue ) );
1348
- tableTransparency->setItem( tableTransparency->rowCount() - 1, 1 , new QTableWidgetItem( myPixelMap[ mRasterLayer->greenBandName()] ) );
1349
- tableTransparency->setItem( tableTransparency->rowCount() - 1, 2, new QTableWidgetItem( myPixelMap[ mRasterLayer->blueBandName()] ) );
1344
+ QString value = pixelResult. value ( );
1345
+ if ( value != tr ( " out of extent " ) )
1346
+ {
1347
+ tableTransparency->setItem ( tableTransparency->rowCount () - 1 , i , new QTableWidgetItem ( value ) );
1348
+ }
1350
1349
}
1351
1350
}
1352
1351
}
1353
- #else
1354
- Q_UNUSED ( canvasPoint );
1355
- #endif // 0
1352
+
1353
+ delete renderer;
1356
1354
}
1357
1355
1358
1356
void QgsRasterLayerProperties::sliderTransparency_valueChanged ( int theValue )
0 commit comments