Skip to content

Commit c95c7f1

Browse files
author
ersts
committed
-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/qgis@8819 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 63956c3 commit c95c7f1

6 files changed

+248
-262
lines changed

src/app/qgsrasterlayerproperties.cpp

+36-43
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,13 @@ QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *pa
284284
QPixmap myPyramidPixmap(myThemePath + "/mIconPyramid.png");
285285
QPixmap myNoPyramidPixmap(myThemePath + "/mIconNoPyramid.png");
286286

287-
pbnAddValuesManually->setIcon(QIcon(QPixmap(myThemePath + "/mActionNewAttribute.png")));
288-
pbnAddValuesFromDisplay->setIcon(QIcon(QPixmap(myThemePath + "/mActionContextHelp.png")));
289-
pbnRemoveSelectedRow->setIcon(QIcon(QPixmap(myThemePath + "/mActionDeleteAttribute.png")));
290-
pbnDefaultValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionCopySelected.png")));
291-
pbnImportTransparentPixelValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileOpen.png")));
292-
pbnExportTransparentPixelValues->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileSave.png")));
293-
pbtnMakeContrastEnhancementAlgorithmDefault->setIcon(QIcon(QPixmap(myThemePath + "/mActionFileSave.png")));
287+
pbnAddValuesManually->setIcon(QIcon(myThemePath + "/mActionNewAttribute.png"));
288+
pbnAddValuesFromDisplay->setIcon(QIcon(myThemePath + "/mActionContextHelp.png"));
289+
pbnRemoveSelectedRow->setIcon(QIcon(myThemePath + "/mActionDeleteAttribute.png"));
290+
pbnDefaultValues->setIcon(QIcon(myThemePath + "/mActionCopySelected.png"));
291+
pbnImportTransparentPixelValues->setIcon(QIcon(myThemePath + "/mActionFileOpen.png"));
292+
pbnExportTransparentPixelValues->setIcon(QIcon(myThemePath + "/mActionFileSave.png"));
293+
pbtnMakeContrastEnhancementAlgorithmDefault->setIcon(QIcon(myThemePath + "/mActionFileSave.png"));
294294

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

730730
//Display the current default contrast enhancement algorithm
731731
QSettings myQSettings;
732-
QString myDefaultAlgorithm = myQSettings.value("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH").toString();
733-
if(myDefaultAlgorithm == "NO_STRETCH")
732+
mDefaultRedBand = myQSettings.value("/Raster/defaultRedBand", 1).toInt();
733+
mDefaultGreenBand = myQSettings.value("/Raster/defaultGreenBand", 2).toInt();
734+
mDefaultBlueBand = myQSettings.value("/Raster/defaultBlueBand", 3).toInt();
735+
labelDefaultBandCombination->setText(QString(tr("Default") + " R:%1 G:%2 B:%3") .arg(mDefaultRedBand) .arg(mDefaultGreenBand) .arg(mDefaultBlueBand));
736+
737+
mDefaultContrastEnhancementAlgorithm = myQSettings.value("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH").toString();
738+
if(mDefaultContrastEnhancementAlgorithm == "NO_STRETCH")
734739
{
735740
labelDefaultContrastEnhancementAlgorithm->setText(tr("No Stretch"));
736741
}
737-
if(myDefaultAlgorithm == "STRETCH_TO_MINMAX")
742+
if(mDefaultContrastEnhancementAlgorithm == "STRETCH_TO_MINMAX")
738743
{
739744
labelDefaultContrastEnhancementAlgorithm->setText(tr("Stretch To MinMax"));
740745
}
741-
else if(myDefaultAlgorithm == "STRETCH_AND_CLIP_TO_MINMAX")
746+
else if(mDefaultContrastEnhancementAlgorithm == "STRETCH_AND_CLIP_TO_MINMAX")
742747
{
743748
labelDefaultContrastEnhancementAlgorithm->setText(tr("Stretch And Clip To MinMax"));
744749
}
745-
else if(myDefaultAlgorithm == "CLIP_TO_MINMAX")
750+
else if(mDefaultContrastEnhancementAlgorithm == "CLIP_TO_MINMAX")
746751
{
747752
labelDefaultContrastEnhancementAlgorithm->setText(tr("Clip To MinMax"));
748753
}
@@ -1196,6 +1201,13 @@ void QgsRasterLayerProperties::apply()
11961201
}
11971202
}
11981203

1204+
QSettings myQSettings;
1205+
myQSettings.setValue("/Raster/defaultRedBand", mDefaultRedBand);
1206+
myQSettings.setValue("/Raster/defaultGreenBand", mDefaultGreenBand);
1207+
myQSettings.setValue("/Raster/defaultBlueBand", mDefaultBlueBand);
1208+
1209+
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", mDefaultContrastEnhancementAlgorithm);
1210+
11991211
#ifdef QGISDEBUG
12001212
QgsDebugMsg("QgsRasterLayerProperties::apply processing transparency tab");
12011213
#endif
@@ -1857,29 +1869,6 @@ void QgsRasterLayerProperties::on_pbnHistRefresh_clicked()
18571869
std::cout << "QgsRasterLayerProperties::on_pbnHistRefresh_clicked" << std::endl;
18581870
#endif
18591871
int myBandCountInt = mRasterLayer->getBandCount();
1860-
//
1861-
// Find out how many bands are selected and short circuit out clearing the image
1862-
// if needed
1863-
int mySelectionCount=0;
1864-
for (int myIteratorInt = 1;
1865-
myIteratorInt <= myBandCountInt;
1866-
++myIteratorInt)
1867-
{
1868-
QgsRasterBandStats myRasterBandStats = mRasterLayer->getRasterBandStats(myIteratorInt);
1869-
QListWidgetItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
1870-
if ( myItem->isSelected() )
1871-
{
1872-
mySelectionCount++;
1873-
}
1874-
}
1875-
if (mySelectionCount==0)
1876-
{
1877-
int myImageWidth = pixHistogram->width();
1878-
int myImageHeight = pixHistogram->height();
1879-
QPixmap myPixmap(myImageWidth,myImageHeight);
1880-
myPixmap.fill(Qt::white);
1881-
pixHistogram->setPixmap(myPixmap);
1882-
}
18831872

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

2758+
void QgsRasterLayerProperties::on_pbtnMakeBandCombinationDefault_clicked()
2759+
{
2760+
mDefaultRedBand = cboRed->currentIndex() + 1;
2761+
mDefaultGreenBand = cboGreen->currentIndex() + 1;
2762+
mDefaultBlueBand = cboBlue->currentIndex() + 1;
2763+
labelDefaultBandCombination->setText(QString(tr("Default") + " R:%1 G:%2 B:%3") .arg(mDefaultRedBand) .arg(mDefaultGreenBand) .arg(mDefaultBlueBand));
2764+
}
2765+
27692766
void QgsRasterLayerProperties::on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked()
27702767
{
2771-
//Like some of the other functionality in the raster properties GUI this deviated a little from the
2772-
//best practice of GUI design as this pressing cancel will not undo setting the default
2773-
//contrast enhancement algorithm
27742768
if(cboxContrastEnhancementAlgorithm->currentText() != tr("User Defined"))
27752769
{
2776-
QSettings myQSettings;
27772770
if(cboxContrastEnhancementAlgorithm->currentText() == tr("No Stretch"))
27782771
{
2779-
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "NO_STRETCH");
2772+
mDefaultContrastEnhancementAlgorithm = "NO_STRETCH";
27802773
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
27812774
}
27822775
else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Stretch To MinMax"))
27832776
{
2784-
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "STRETCH_TO_MINMAX");
2777+
mDefaultContrastEnhancementAlgorithm = "STRETCH_TO_MINMAX";
27852778
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
27862779
}
27872780
else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Stretch And Clip To MinMax"))
27882781
{
2789-
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "STRETCH_AND_CLIP_TO_MINMAX");
2782+
mDefaultContrastEnhancementAlgorithm = "STRETCH_AND_CLIP_TO_MINMAX";
27902783
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
27912784
}
27922785
else if(cboxContrastEnhancementAlgorithm->currentText() == tr("Clip To MinMax"))
27932786
{
2794-
myQSettings.setValue("/Raster/defaultContrastEnhancementAlgorithm", "CLIP_TO_MINMAX");
2787+
mDefaultContrastEnhancementAlgorithm = "CLIP_TO_MINMAX";
27952788
labelDefaultContrastEnhancementAlgorithm->setText(cboxContrastEnhancementAlgorithm->currentText());
27962789
}
27972790
else

src/app/qgsrasterlayerproperties.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
108108
void handleColormapTreeWidgetDoubleClick(QTreeWidgetItem* item, int column);
109109
/**This slot loads the minimum and maximum values from the raster band and updates the gui*/
110110
void on_pbtnLoadMinMax_clicked();
111-
/**This slot save the current contrast enhancement algorithm as the default algorithm */
111+
/**This slot sets the default band combination varaible to current band combination */
112+
void on_pbtnMakeBandCombinationDefault_clicked();
113+
/**This slot sets the default contrast enhancement varaible to current contrast enhancement algorithm */
112114
void on_pbtnMakeContrastEnhancementAlgorithmDefault_clicked();
113-
115+
114116
/** Load the default style when appriate button is pressed. */
115117
void on_pbnLoadDefaultStyle_clicked();
116118
/** Save the default style when appriate button is pressed. */
@@ -133,6 +135,14 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
133135
/** Id for context help */
134136
static const int context_id = 394441851;
135137

138+
/** \brief Default contrast enhancement algorithm */
139+
QString mDefaultContrastEnhancementAlgorithm;
140+
141+
/** \brief Default band combination */
142+
int mDefaultRedBand;
143+
int mDefaultGreenBand;
144+
int mDefaultBlueBand;
145+
136146
/** \brief Internal flag used to short circuit signal loop between min max field and stdDev spin box */
137147
bool ignoreSpinBoxEvent;
138148

src/core/raster/qgsrasterbandstats.h

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
class CORE_EXPORT QgsRasterBandStats
3737
{
3838
public:
39-
//This constructor was added because values were being used un initalized
40-
//TODO: This should not be in the header file.
4139
QgsRasterBandStats() {
4240
bandName = "";
4341
statsGatheredFlag = false;

0 commit comments

Comments
 (0)