Skip to content
Permalink
Browse files

apply brightness/contrast changes to all selected layers (fix #8176)

  • Loading branch information
alexbruy committed Mar 24, 2014
1 parent 4ecdc6b commit dcda258dd296d045fd0e961d9c352623e7e07572
Showing with 27 additions and 26 deletions.
  1. +27 −26 src/app/qgisapp.cpp
@@ -7050,37 +7050,38 @@ void QgisApp::decreaseContrast()

void QgisApp::adjustBrightnessContrast( int delta, bool updateBrightness )
{
QgsMapLayer * myLayer = mMapLegend->currentLayer();

if ( !myLayer )
foreach ( QgsMapLayer * layer, mMapLegend->selectedLayers() )
{
messageBar()->pushMessage( tr( "No Layer Selected" ),
tr( "To change brightness or contrast, you need to have a raster layer selected." ),
QgsMessageBar::INFO, messageTimeout() );
return;
}
if ( !layer )
{
messageBar()->pushMessage( tr( "No Layer Selected" ),
tr( "To change brightness or contrast, you need to have a raster layer selected." ),
QgsMessageBar::INFO, messageTimeout() );
return;
}

QgsRasterLayer* myRasterLayer = qobject_cast<QgsRasterLayer *>( myLayer );
if ( !myRasterLayer )
{
messageBar()->pushMessage( tr( "No Layer Selected" ),
tr( "To change brightness or contrast, you need to have a raster layer selected." ),
QgsMessageBar::INFO, messageTimeout() );
return;
}
QgsRasterLayer* rasterLayer = qobject_cast<QgsRasterLayer *>( layer );
if ( !rasterLayer )
{
messageBar()->pushMessage( tr( "No Layer Selected" ),
tr( "To change brightness or contrast, you need to have a raster layer selected." ),
QgsMessageBar::INFO, messageTimeout() );
return;
}

QgsBrightnessContrastFilter* brightnessFilter = myRasterLayer->brightnessFilter();
QgsBrightnessContrastFilter* brightnessFilter = rasterLayer->brightnessFilter();

if ( updateBrightness )
{
brightnessFilter->setBrightness( brightnessFilter->brightness() + delta );
}
else
{
brightnessFilter->setContrast( brightnessFilter->contrast() + delta );
}
if ( updateBrightness )
{
brightnessFilter->setBrightness( brightnessFilter->brightness() + delta );
}
else
{
brightnessFilter->setContrast( brightnessFilter->contrast() + delta );
}

myRasterLayer->triggerRepaint();
rasterLayer->triggerRepaint();
}
}

void QgisApp::helpContents()

0 comments on commit dcda258

Please sign in to comment.
You can’t perform that action at this time.