38 connect(
mMinMaxWidget, SIGNAL( load(
int,
double,
double,
int ) ),
39 this, SLOT(
loadMinMax(
int,
double,
double,
int ) ) );
41 connect( mRedBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
43 connect( mGreenBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
45 connect( mBlueBandComboBox, SIGNAL( currentIndexChanged(
int ) ),
49 mRedBandComboBox->addItem(
tr(
"Not set" ), -1 );
50 mGreenBandComboBox->addItem(
tr(
"Not set" ), -1 );
51 mBlueBandComboBox->addItem(
tr(
"Not set" ), -1 );
54 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"No enhancement" ), 0 );
55 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Stretch to MinMax" ), 1 );
56 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Stretch and clip to MinMax" ), 2 );
57 mContrastEnhancementAlgorithmComboBox->addItem(
tr(
"Clip to MinMax" ), 3 );
60 for (
int i = 1; i <= nBands; ++i )
63 mRedBandComboBox->addItem( bandName, i );
64 mGreenBandComboBox->addItem( bandName, i );
65 mBlueBandComboBox->addItem( bandName, i );
89 int redBand = mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt();
90 int greenBand = mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt();
91 int blueBand = mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt();
100 mRedMinLineEdit->setValidator(
new QDoubleValidator( mRedMinLineEdit ) );
101 mRedMaxLineEdit->setValidator(
new QDoubleValidator( mRedMinLineEdit ) );
102 mGreenMinLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
103 mGreenMaxLineEdit->setValidator(
new QDoubleValidator( mGreenMinLineEdit ) );
104 mBlueMinLineEdit->setValidator(
new QDoubleValidator( mBlueMinLineEdit ) );
105 mBlueMaxLineEdit->setValidator(
new QDoubleValidator( mBlueMinLineEdit ) );
110 int redBand,
int greenBand,
int blueBand )
112 if ( !r || !provider )
117 if ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ==
130 bool redMinOk, redMaxOk;
131 double redMin = mRedMinLineEdit->text().toDouble( &redMinOk );
132 double redMax = mRedMaxLineEdit->text().toDouble( &redMaxOk );
133 if ( redMinOk && redMaxOk && redBand != -1 )
141 bool greenMinOk, greenMaxOk;
142 double greenMin = mGreenMinLineEdit->text().toDouble( &greenMinOk );
143 double greenMax = mGreenMaxLineEdit->text().toDouble( &greenMaxOk );
144 if ( greenMinOk && greenMaxOk && greenBand != -1 )
147 provider->
dataType( greenBand ) ) );
152 bool blueMinOk, blueMaxOk;
153 double blueMin = mBlueMinLineEdit->text().toDouble( &blueMinOk );
154 double blueMax = mBlueMaxLineEdit->text().toDouble( &blueMaxOk );
155 if ( blueMinOk && blueMaxOk && blueBand != -1 )
163 if ( redEnhancement )
166 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
168 if ( greenEnhancement )
171 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
173 if ( blueEnhancement )
176 ( mContrastEnhancementAlgorithmComboBox->itemData( mContrastEnhancementAlgorithmComboBox->currentIndex() ).toInt() ) );
188 myBands.append( mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt() );
189 myBands.append( mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt() );
190 myBands.append( mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt() );
196 Q_UNUSED( theOrigin );
197 QgsDebugMsg( QString(
"theBandNo = %1 theMin = %2 theMax = %3" ).arg( theBandNo ).arg( theMin ).arg( theMax ) );
199 QLineEdit *myMinLineEdit, *myMaxLineEdit;
201 if ( mRedBandComboBox->itemData( mRedBandComboBox->currentIndex() ).toInt() == theBandNo )
203 myMinLineEdit = mRedMinLineEdit;
204 myMaxLineEdit = mRedMaxLineEdit;
206 else if ( mGreenBandComboBox->itemData( mGreenBandComboBox->currentIndex() ).toInt() == theBandNo )
208 myMinLineEdit = mGreenMinLineEdit;
209 myMaxLineEdit = mGreenMaxLineEdit;
211 else if ( mBlueBandComboBox->itemData( mBlueBandComboBox->currentIndex() ).toInt() == theBandNo )
213 myMinLineEdit = mBlueMinLineEdit;
214 myMaxLineEdit = mBlueMaxLineEdit;
222 if ( qIsNaN( theMin ) )
224 myMinLineEdit->clear();
228 myMinLineEdit->setText( QString::number( theMin ) );
231 if ( qIsNaN( theMax ) )
233 myMaxLineEdit->clear();
237 myMaxLineEdit->setText( QString::number( theMax ) );
243 if ( !minEdit || !maxEdit )
255 minEdit->setText( QString::number( ce->
minimumValue() ) );
256 maxEdit->setText( QString::number( ce->
maximumValue() ) );
260 mContrastEnhancementAlgorithmComboBox->setCurrentIndex( mContrastEnhancementAlgorithmComboBox->findData(
269 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findData( mbcr->
redBand() ) );
270 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findData( mbcr->
greenBand() ) );
271 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findData( mbcr->
blueBand() ) );
279 mRedBandComboBox->setCurrentIndex( mRedBandComboBox->findText(
tr(
"Red" ) ) );
280 mGreenBandComboBox->setCurrentIndex( mGreenBandComboBox->findText(
tr(
"Green" ) ) );
281 mBlueBandComboBox->setCurrentIndex( mBlueBandComboBox->findText(
tr(
"Blue" ) ) );
290 return mRedMinLineEdit->text();
293 return mGreenMinLineEdit->text();
296 return mBlueMinLineEdit->text();
309 return mRedMaxLineEdit->text();
312 return mGreenMaxLineEdit->text();
315 return mBlueMaxLineEdit->text();
328 mRedMinLineEdit->setText( value );
331 mGreenMinLineEdit->setText( value );
334 mBlueMinLineEdit->setText( value );
346 mRedMaxLineEdit->setText( value );
349 mGreenMaxLineEdit->setText( value );
352 mBlueMaxLineEdit->setText( value );
364 return mRedBandComboBox->currentIndex();
367 return mGreenBandComboBox->currentIndex();
370 return mBlueBandComboBox->currentIndex();
virtual int bandCount() const =0
Get number of bands.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm, bool generateTable=true)
Set the contrast enhancement algorithm.
A rectangle specified with double values.
const QgsContrastEnhancement * greenContrastEnhancement() const
ContrastEnhancementAlgorithm contrastEnhancementAlgorithm() const
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
const QgsContrastEnhancement * redContrastEnhancement() const
void setGreenContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
void setRedContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
QgsRasterRenderer * renderer() const
void setMinimumValue(double, bool generateTable=true)
Return the minimum value for the contrast enhancement range.
virtual QGis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
double minimumValue() const
Return the minimum value for the contrast enhancement range.
const QgsContrastEnhancement * blueContrastEnhancement() const
ContrastEnhancementAlgorithm
This enumerator describes the types of contrast enhancement algorithms that can be used...
double maximumValue() const
Return the maximum value for the contrast enhancement range.
DataType
Raster data types.
void setBlueContrastEnhancement(QgsContrastEnhancement *ce)
Takes ownership.
Renderer for multiband images with the color components.
Manipulates raster pixel values so that they enhanceContrast or clip into a specified numerical range...
QgsRasterDataProvider * dataProvider()
Returns the data provider.
Raster renderer pipe that applies colors to a raster.
void setMaximumValue(double, bool generateTable=true)
Set the maximum value for the contrast enhancement range.
Base class for raster data providers.