Skip to content
Permalink
Browse files
-Moved invert color controls back onto main tab
-Changed default load behavior so two band images show up on initial load, closes ticket #1157
-Moved to using generic band names (i.e., Band 1, Band 2) rather than names stored in the raster file itself
-Updated set default contrast enhancement behavior so that it not applied until the ok or apply button is clicked
-Added a default band combination setting that will be persistant between QGIS sessions.

git-svn-id: http://svn.osgeo.org/qgis/trunk@8819 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts committed Jul 21, 2008
1 parent 2cd989a commit c9c90bdb926eb8c50796d3ffedf7b5f161d0a6f7
@@ -284,13 +284,13 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
QPixmap myPyramidPixmap(myThemePath + "/mIconPyramid.png");
QPixmap myNoPyramidPixmap(myThemePath + "/mIconNoPyramid.png");

pbnAddValuesManually->setIcon(QIcon(QPixmap(myThemePath + "/mActionNewAttribute.png")));
pbnAddValuesFromDisplay->setIcon(QIcon(QPixmap(myThemePath + "/mActionContextHelp.png")));
pbnRemoveSelectedRow->setIcon(QIcon(QPixmap(myThemePath + "/mActionDeleteAttribute.png")));
pbnDefaultValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionCopySelected.png")));
pbnImportTransparentPixelValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileOpen.png")));
pbnExportTransparentPixelValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileSave.png")));
pbtnMakeContrastEnhancementAlgorithmDefault->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileSave.png")));
pbnAddValuesManually->setIcon(QIcon(myThemePath + "/mActionNewAttribute.png"));
pbnAddValuesFromDisplay->setIcon(QIcon(myThemePath + "/mActionContextHelp.png"));
pbnRemoveSelectedRow->setIcon(QIcon(myThemePath + "/mActionDeleteAttribute.png"));
pbnDefaultValues->setIcon(QIcon(myThemePath + "/mActionCopySelected.png"));
pbnImportTransparentPixelValues->setIcon(QIcon(myThemePath + "/mActionFileOpen.png"));
pbnExportTransparentPixelValues->setIcon(QIcon(myThemePath + "/mActionFileSave.png"));
pbtnMakeContrastEnhancementAlgorithmDefault->setIcon(QIcon(myThemePath + "/mActionFileSave.png"));

// Only do pyramids if dealing directly with GDAL.
if (mRasterLayerIsGdal)
@@ -729,20 +729,25 @@ void QgsRasterLayerProperties::sync()

//Display the current default contrast enhancement algorithm
QSettings myQSettings;
QString myDefaultAlgorithm = myQSettings.value("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH").toString();
if(myDefaultAlgorithm == "NO_STRETCH")
mDefaultRedBand = myQSettings.value("/Raster/defaultRedBand", 1).toInt();
mDefaultGreenBand = myQSettings.value("/Raster/defaultGreenBand", 2).toInt();
mDefaultBlueBand = myQSettings.value("/Raster/defaultBlueBand", 3).toInt();
labelDefaultBandCombination->setText(QString(tr("Default") + " R:%1 G:%2 B:%3") .arg(mDefaultRedBand) .arg(mDefaultGreenBand) .arg(mDefaultBlueBand));

mDefaultContrastEnhancementAlgorithm = myQSettings.value("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH").toString();
if(mDefaultContrastEnhancementAlgorithm == "NO_STRETCH")
{
labelDefaultContrastEnhancementAlgorithm->setText(tr("No Stretch"));
}
if(myDefaultAlgorithm == "STRETCH_TO_MINMAX")
if(mDefaultContrastEnhancementAlgorithm == "STRETCH_TO_MINMAX")
{
labelDefaultContrastEnhancementAlgorithm->setText(tr("Stretch To MinMax"));
}
else if(myDefaultAlgorithm == "STRETCH_AND_CLIP_TO_MINMAX")
else if(mDefaultContrastEnhancementAlgorithm == "STRETCH_AND_CLIP_TO_MINMAX")
{
labelDefaultContrastEnhancementAlgorithm->setText(tr("Stretch And Clip To MinMax"));
}
else if(myDefaultAlgorithm == "CLIP_TO_MINMAX")
else if(mDefaultContrastEnhancementAlgorithm == "CLIP_TO_MINMAX")
{
labelDefaultContrastEnhancementAlgorithm->setText(tr("Clip To MinMax"));
}
@@ -1196,6 +1201,13 @@ void QgsRasterLayerProperties::apply()
}
}

QSettings myQSettings;
myQSettings.setValue("/Raster/defaultRedBand", mDefaultRedBand);
myQSettings.setValue("/Raster/defaultGreenBand", mDefaultGreenBand);
myQSettings.setValue("/Raster/defaultBlueBand", mDefaultBlueBand);

myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", mDefaultContrastEnhancementAlgorithm);

#ifdef QGISDEBUG
QgsDebugMsg("QgsRasterLayerProperties::apply processing transparency tab");
#endif
@@ -1857,29 +1869,6 @@ void QgsRasterLayerProperties::on_pbnHistRefresh_clicked()
std::cout << "QgsRasterLayerProperties::on_pbnHistRefresh_clicked" << std::endl;
#endif
int myBandCountInt = mRasterLayer->getBandCount();
//
// Find out how many bands are selected and short circuit out clearing the image
// if needed
int mySelectionCount=0;
for (int myIteratorInt = 1;
myIteratorInt <= myBandCountInt;
++myIteratorInt)
{
QgsRasterBandStats myRasterBandStats = mRasterLayer->getRasterBandStats(myIteratorInt);
QListWidgetItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
if ( myItem->isSelected() )
{
mySelectionCount++;
}
}
if (mySelectionCount==0)
{
int myImageWidth = pixHistogram->width();
int myImageHeight = pixHistogram->height();
QPixmap myPixmap(myImageWidth,myImageHeight);
myPixmap.fill(Qt::white);
pixHistogram->setPixmap(myPixmap);
}

// Explanation:
// We use the gdal histogram creation routine is called for each selected
@@ -2766,32 +2755,36 @@ void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
}
}

void QgsRasterLayerProperties::on_pbtnMakeBandCombinationDefault_clicked()
{
mDefaultRedBand = cboRed->currentIndex() + 1;
mDefaultGreenBand = cboGreen->currentIndex() + 1;
mDefaultBlueBand = cboBlue->currentIndex() + 1;
labelDefaultBandCombination->setText(QString(tr("Default") + " R:%1 G:%2 B:%3") .arg(mDefaultRedBand) .arg(mDefaultGreenBand) .arg(mDefaultBlueBand));
}

void QgsRasterLayerProperties::on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked()
{
//Like some of the other functionality in the raster properties GUI this deviated a little from the
//best practice of GUI design as this pressing cancel will not undo setting the default
//contrast enhancement algorithm
if(cboxContrastEnhancementAlgorithm->currentText() != tr("User Defined"))
{
QSettings myQSettings;
if(cboxContrastEnhancementAlgorithm->currentText() == tr("No Stretch"))
{
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH");
mDefaultContrastEnhancementAlgorithm = "NO_STRETCH";
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
}
else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Stretch To MinMax"))
{
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "STRETCH_TO_MINMAX");
mDefaultContrastEnhancementAlgorithm = "STRETCH_TO_MINMAX";
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
}
else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Stretch And Clip To MinMax"))
{
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "STRETCH_AND_CLIP_TO_MINMAX");
mDefaultContrastEnhancementAlgorithm = "STRETCH_AND_CLIP_TO_MINMAX";
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
}
else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Clip To MinMax"))
{
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "CLIP_TO_MINMAX");
mDefaultContrastEnhancementAlgorithm = "CLIP_TO_MINMAX";
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
}
else
@@ -108,9 +108,11 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
void handleColormapTreeWidgetDoubleClick(QTreeWidgetItem* item, int column);
/**This slot loads the minimum and maximum values from the raster band and updates the gui*/
void on_pbtnLoadMinMax_clicked();
/**This slot save the current contrast enhancement algorithm as the default algorithm */
/**This slot sets the default band combination varaible to current band combination */
void on_pbtnMakeBandCombinationDefault_clicked();
/**This slot sets the default contrast enhancement varaible to current contrast enhancement algorithm */
void on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked();
/** Load the default style when appriate button is pressed. */
void on_pbnLoadDefaultStyle_clicked();
/** Save the default style when appriate button is pressed. */
@@ -133,6 +135,14 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
/** Id for context help */
static const int context_id = 394441851;

/** \brief Default contrast enhancement algorithm */
QString mDefaultContrastEnhancementAlgorithm;

/** \brief Default band combination */
int mDefaultRedBand;
int mDefaultGreenBand;
int mDefaultBlueBand;

/** \brief Internal flag used to short circuit signal loop between min max field and stdDev spin box */
bool ignoreSpinBoxEvent;

@@ -36,8 +36,6 @@
class CORE_EXPORT QgsRasterBandStats
{
public:
//This constructor was added because values were being used un initalized
//TODO: This should not be in the header file.
QgsRasterBandStats() {
bandName = "";
statsGatheredFlag = false;

0 comments on commit c9c90bd

Please sign in to comment.