Skip to content
Permalink
Browse files

Show actual pixel values on x axis of raster histogram

git-svn-id: http://svn.osgeo.org/qgis/trunk@14381 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Oct 15, 2010
1 parent 4f4a212 commit ebda009178abfad182f45a7ba53a5a8ced907642
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/app/qgsrasterlayerproperties.cpp
@@ -1872,8 +1872,8 @@ void QgsRasterLayerProperties::refreshHistogram()
// Set axis titles
mpPlot->setAxisTitle( QwtPlot::xBottom, QObject::tr("Pixel Value") );
mpPlot->setAxisTitle( QwtPlot::yLeft, QObject::tr("Frequency") );
mpPlot->setAxisAutoScale( QwtPlot::xBottom );
mpPlot->setAxisAutoScale( QwtPlot::yLeft );
// x axis scale only set after computing global min/max across bands (see below)
// add a grid
QwtPlotGrid * myGrid = new QwtPlotGrid();
myGrid->attach(mpPlot);
@@ -1905,6 +1905,9 @@ void QgsRasterLayerProperties::refreshHistogram()
//
// scan through to get counts from layers' histograms
//
float myGlobalMin = 0;
float myGlobalMax = 0;
bool myFirstIteration = true;
for ( int myIteratorInt = 1;
myIteratorInt <= myBandCountInt;
++myIteratorInt )
@@ -1924,7 +1927,22 @@ void QgsRasterLayerProperties::refreshHistogram()
}
mypCurve->setData(myX2Data,myY2Data);
mypCurve->attach(mpPlot);
if ( myFirstIteration || myGlobalMin < myRasterBandStats.minimumValue )
{
myGlobalMin = myRasterBandStats.minimumValue;
}
if ( myFirstIteration || myGlobalMax < myRasterBandStats.maximumValue )
{
myGlobalMax = myRasterBandStats.maximumValue;
}
myFirstIteration = false;
}
// for x axis use band pixel values rather than gdal hist. bin values
// subtract -0.5 to prevent rounding errors
// see http://www.gdal.org/classGDALRasterBand.html#3f8889607d3b2294f7e0f11181c201c8
mpPlot->setAxisScale ( QwtPlot::xBottom,
myGlobalMin - 0.5,
myGlobalMax + 0.5 );
mpPlot->replot();
disconnect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
mHistogramProgress->hide();

0 comments on commit ebda009

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