2 changes: 2 additions & 0 deletions src/core/raster/qgscontrastenhancement.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class CORE_EXPORT QgsContrastEnhancement

ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const { return mContrastEnhancementAlgorithm; }

static QString contrastEnhancementAlgorithmString( ContrastEnhancementAlgorithm algorithm );

static ContrastEnhancementAlgorithm contrastEnhancementAlgorithmFromString( const QString& contrastEnhancementString );

/*
Expand Down
1,275 changes: 74 additions & 1,201 deletions src/core/raster/qgsrasterlayer.cpp

Large diffs are not rendered by default.

381 changes: 24 additions & 357 deletions src/core/raster/qgsrasterlayer.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/core/raster/qgsrasterpipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

#include <typeinfo>

#include "qgsrasterpipe.h"
#include "qgslogger.h"

#include <QByteArray>

#include "qgslogger.h"
#include "qgsrasterpipe.h"

QgsRasterPipe::QgsRasterPipe()
{
}
Expand Down
13 changes: 5 additions & 8 deletions src/core/raster/qgsrasterpipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
#ifndef QGSRASTERPIPE_H
#define QGSRASTERPIPE_H

#include <QObject>
#include <QImage>
#include <QObject>

#include "qgsrectangle.h"
#include "qgsrasterinterface.h"
#include "qgsrasterresamplefilter.h"
#include "qgsbrightnesscontrastfilter.h"
#include "qgshuesaturationfilter.h"
#include "qgsrasterdataprovider.h"
#include "qgsrasterinterface.h"
#include "qgsrasternuller.h"
#include "qgsrasterrenderer.h"
#include "qgsrasterprojector.h"
#include "qgsrasterrenderer.h"
#include "qgsrasterresamplefilter.h"
#include "qgsrectangle.h"

#if defined(Q_OS_WIN)
#undef interface
Expand Down Expand Up @@ -101,9 +101,6 @@ class CORE_EXPORT QgsRasterPipe
QgsRasterProjector * projector() const;
QgsRasterNuller * nuller() const;

/** Set on/off collection of statistics */
//void setStatsOn( bool on ) { if ( last() ) last()->setStatsOn( on ); }

private:
/** Get known parent type_info of interface parent */
Role interfaceRole( QgsRasterInterface * iface ) const;
Expand Down
21 changes: 12 additions & 9 deletions src/gui/raster/qgspalettedrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,19 @@ void QgsPalettedRendererWidget::setFromRenderer( const QgsRasterRenderer* r )
else
{
//read default palette settings from layer
QList<QgsColorRampShader::ColorRampItem> itemList =
mRasterLayer->colorTable( mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt() );
QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin();
int index = 0;
for ( ; itemIt != itemList.constEnd(); ++itemIt )
QgsRasterDataProvider *provider = mRasterLayer->dataProvider();
if ( provider )
{
QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget );
item->setText( 0, QString::number( index ) );
item->setBackground( 1, QBrush( itemIt->color ) );
++index;
QList<QgsColorRampShader::ColorRampItem> itemList = provider->colorTable( mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt() );
QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin();
int index = 0;
for ( ; itemIt != itemList.constEnd(); ++itemIt )
{
QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget );
item->setText( 0, QString::number( index ) );
item->setBackground( 1, QBrush( itemIt->color ) );
++index;
}
}
}
}
9 changes: 5 additions & 4 deletions src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,22 +365,23 @@ void QgsSingleBandPseudoColorRendererWidget::populateColormapTreeWidget( const Q

void QgsSingleBandPseudoColorRendererWidget::on_mLoadFromBandButton_clicked()
{
if ( !mRasterLayer )
if ( !mRasterLayer || !mRasterLayer->dataProvider() )
{
return;
}

QList<QgsColorRampShader::ColorRampItem> colorRampList;
int bandIndex = mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt();

if ( mRasterLayer->readColorTable( bandIndex, &colorRampList ) )

QList<QgsColorRampShader::ColorRampItem> colorRampList = mRasterLayer->dataProvider()->colorTable( bandIndex );
if ( colorRampList.size() > 0 )
{
populateColormapTreeWidget( colorRampList );
mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findText( tr( "Linear" ) ) );
}
else
{
QMessageBox::warning( this, tr( "Load Color Map" ), tr( "The color map for band %1 failed to load" ).arg( bandIndex ) );
QMessageBox::warning( this, tr( "Load Color Map" ), tr( "The color map for band %1 has no entries" ).arg( bandIndex ) );
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/georeferencer/qgsgeorefplugingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,16 @@ void QgsGeorefPluginGui::showGeorefConfigDialog()
// Histogram stretch slots
void QgsGeorefPluginGui::fullHistogramStretch()
{
mLayer->setContrastEnhancementAlgorithm( "StretchToMinimumMaximum" );
mLayer->setMinimumMaximumUsingDataset();
mLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum );
mLayer->setCacheImage( NULL );
mCanvas->refresh();
}

void QgsGeorefPluginGui::localHistogramStretch()
{
mLayer->setContrastEnhancementAlgorithm( "StretchToMinimumMaximum" );
mLayer->setMinimumMaximumUsingLastExtent();
QgsRectangle rectangle = mIface->mapCanvas()->mapRenderer()->outputExtentToLayerExtent( mLayer, mIface->mapCanvas()->extent() );

mLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum, QgsRasterLayer::ContrastEnhancementMinMax, rectangle );
mLayer->setCacheImage( NULL );
mCanvas->refresh();
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void TestQgsRasterLayer::cleanupTestCase()
void TestQgsRasterLayer::isValid()
{
QVERIFY( mpRasterLayer->isValid() );
mpRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum, false );
mpRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum, QgsRasterLayer::ContrastEnhancementMinMax );
mpMapRenderer->setExtent( mpRasterLayer->extent() );
QVERIFY( render( "raster" ) );
}
Expand Down Expand Up @@ -289,7 +289,7 @@ void TestQgsRasterLayer::colorRamp4()

void TestQgsRasterLayer::landsatBasic()
{
mpLandsatRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum, false );
mpLandsatRasterLayer->setContrastEnhancementAlgorithm( QgsContrastEnhancement::StretchToMinimumMaximum, QgsRasterLayer::ContrastEnhancementMinMax );
QStringList myLayers;
myLayers << mpLandsatRasterLayer->id();
mpMapRenderer->setLayerSet( myLayers );
Expand Down