Skip to content
Permalink
Browse files
Added local histogram stretch icon to the new raster toolbar and wire…
…d it up so it works

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15192 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Feb 18, 2011
1 parent 26d7b8b commit 44b9e73abc66fd9fb525b76bcd7e9d9d524ce0a2
Showing with 64 additions and 0 deletions.
  1. +1 −0 images/images.qrc
  2. BIN images/themes/default/mActionLocalHistogramStretch.png
  3. +57 −0 src/app/qgisapp.cpp
  4. +6 −0 src/app/qgisapp.h
@@ -3,6 +3,7 @@
<file>north_arrows/gpsarrow.svg</file>
<file>north_arrows/gpsarrow2.svg</file>
<file>themes/default/mActionAddArrow.png</file>
<file>themes/default/mActionLocalHistogramStretch.png</file>
<file>themes/newgis/mActionAddGPSLayer.png</file>
<file>themes/newgis/mActionAddImage.png</file>
<file>themes/newgis/mActionAddIsland.png</file>
Binary file not shown.
@@ -1209,6 +1209,12 @@ void QgisApp::createActions()
mWindowActions = new QActionGroup( this );
#endif

// Raster toolbar items
mActionLocalHistogramStretch = new QAction( getThemeIcon( "mActionmRasterLocalHistogramStretch.png" ), tr( "Local Histogram Stretch" ), this );
mActionLocalHistogramStretch->setStatusTip( tr( "Stretch histogram of active raster to view extents" ) );
connect( mActionLocalHistogramStretch, SIGNAL( triggered() ), this, SLOT( localHistogramStretch() ) );


// Help Menu Items

mActionHelpContents = new QAction( getThemeIcon( "mActionHelpContents.png" ), tr( "Help Contents" ), this );
@@ -1864,6 +1870,14 @@ void QgisApp::createToolBars()
mHelpToolBar->addAction( mActionHelpContents );
mHelpToolBar->addAction( QWhatsThis::createAction() );
mToolbarMenu->addAction( mHelpToolBar->toggleViewAction() );

//
// Raster Toolbar
mRasterToolBar = addToolBar( tr( "Raster" ) );
mRasterToolBar->setObjectName( "Raster" );
mRasterToolBar->addAction( mActionLocalHistogramStretch );
mToolbarMenu->addAction( mRasterToolBar->toggleViewAction() );


//Label Toolbar
mLabelToolBar = addToolBar( tr( "Label" ) );
@@ -2070,6 +2084,7 @@ void QgisApp::setTheme( QString theThemeName )
mActionOptions->setIcon( getThemeIcon( "/mActionOptions.png" ) );
mActionConfigureShortcuts->setIcon( getThemeIcon( "/mActionOptions.png" ) );
mActionHelpContents->setIcon( getThemeIcon( "/mActionHelpContents.png" ) );
mActionLocalHistogramStretch->setIcon( getThemeIcon( "/mActionLocalHistogramStretch.png" ) );
mActionQgisHomePage->setIcon( getThemeIcon( "/mActionQgisHomePage.png" ) );
mActionAbout->setIcon( getThemeIcon( "/mActionHelpAbout.png" ) );
mActionDraw->setIcon( getThemeIcon( "/mActionDraw.png" ) );
@@ -5459,6 +5474,48 @@ void QgisApp::options()
delete optionsDialog;
}

void QgisApp::localHistogramStretch()
{
QgsMapLayer * layer = mMapLegend->currentLayer();

if ( !layer )
{
QMessageBox::information( this,
tr( "No Layer Selected" ),
tr( "To perform a local histogram stretch, you need to have a raster layer selected." ) );
return;
}

QgsRasterLayer* rlayer = qobject_cast<QgsRasterLayer *>( layer );
if ( !rlayer )
{
QMessageBox::information( this,
tr( "No Raster Layer Selected" ),
tr( "To perform a local histogram stretch, you need to have a raster layer selected." ) );
return;
}
if ( rlayer->drawingStyle() == QgsRasterLayer::SingleBandGray ||
rlayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
)
{
rlayer->setContrastEnhancementAlgorithm( "StretchToMinimumMaximum" );
rlayer->setMinimumMaximumUsingLastExtent();
rlayer->setCacheImage(NULL);
//refreshLayerSymbology( rlayer->getLayerID() );
mMapCanvas->refresh();
return;
}
else
{
QMessageBox::information( this,
tr( "No Valid Raster Layer Selected" ),
tr( "To perform a local histogram stretch, you need to have a grayscale "
"(multiband single layer, or singleband grayscale) raster layer "
"selected." ) );
return;
}
}

void QgisApp::helpContents()
{
openURL( "index.html" );
@@ -361,6 +361,7 @@ class QgisApp : public QMainWindow
QToolBar *attributesToolBar() { return mAttributesToolBar; }
QToolBar *pluginToolBar() { return mPluginToolBar; }
QToolBar *helpToolBar() { return mHelpToolBar; }
QToolBar *rasterToolBar() { return mRasterToolBar; }

//! run python
void runPythonString( const QString &expr );
@@ -498,6 +499,8 @@ class QgisApp : public QMainWindow
void zoomToLayerExtent();
//! zoom to actual size of raster layer
void zoomActualSize();
//! perform a local histogram stretch on the active raster layer (stretch based on pixel values in view extent)
void localHistogramStretch();
//! plugin manager
void showPluginManager();
//! load python support if possible
@@ -876,6 +879,7 @@ class QgisApp : public QMainWindow
QToolBar *mAttributesToolBar;
QToolBar *mPluginToolBar;
QToolBar *mHelpToolBar;
QToolBar *mRasterToolBar;
QToolBar *mLabelToolBar;

// actions for menus and toolbars -----------------
@@ -1013,6 +1017,8 @@ class QgisApp : public QMainWindow
QAction *mActionHelpSeparator2;
QAction *mActionAbout;

QAction *mActionLocalHistogramStretch;

QAction *mActionMoveLabel;
QAction *mActionRotateLabel;
QAction *mActionChangeLabelProperties;

0 comments on commit 44b9e73

Please sign in to comment.