[QGIS Commit] r8819 - in trunk/qgis/src: app core/raster ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Jul 20 21:30:07 EDT 2008
Author: ersts
Date: 2008-07-20 21:30:07 -0400 (Sun, 20 Jul 2008)
New Revision: 8819
Modified:
trunk/qgis/src/app/qgsrasterlayerproperties.cpp
trunk/qgis/src/app/qgsrasterlayerproperties.h
trunk/qgis/src/core/raster/qgsrasterbandstats.h
trunk/qgis/src/core/raster/qgsrasterlayer.cpp
trunk/qgis/src/core/raster/qgsrasterlayer.h
trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui
Log:
-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.
Modified: trunk/qgis/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.cpp 2008-07-19 18:07:50 UTC (rev 8818)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.cpp 2008-07-21 01:30:07 UTC (rev 8819)
@@ -284,13 +284,13 @@
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 @@
//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 @@
}
}
+ 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 @@
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_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
Modified: trunk/qgis/src/app/qgsrasterlayerproperties.h
===================================================================
--- trunk/qgis/src/app/qgsrasterlayerproperties.h 2008-07-19 18:07:50 UTC (rev 8818)
+++ trunk/qgis/src/app/qgsrasterlayerproperties.h 2008-07-21 01:30:07 UTC (rev 8819)
@@ -108,9 +108,11 @@
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 @@
/** 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;
Modified: trunk/qgis/src/core/raster/qgsrasterbandstats.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterbandstats.h 2008-07-19 18:07:50 UTC (rev 8818)
+++ trunk/qgis/src/core/raster/qgsrasterbandstats.h 2008-07-21 01:30:07 UTC (rev 8819)
@@ -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;
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2008-07-19 18:07:50 UTC (rev 8818)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.cpp 2008-07-21 01:30:07 UTC (rev 8819)
@@ -516,10 +516,9 @@
for (int i = 1; i <= GDALGetRasterCount(mGdalDataset); i++)
{
GDALRasterBandH myGdalBand = GDALGetRasterBand(mGdalDataset,i);
- QString myColorQString = GDALGetColorInterpretationName(GDALGetRasterColorInterpretation(myGdalBand));
QgsRasterBandStats myRasterBandStats;
//myRasterBandStats.bandName = myColorQString ;
- myRasterBandStats.bandName=QString::number(i) + " : " + myColorQString;
+ myRasterBandStats.bandName="Band " + QString::number(i);
myRasterBandStats.bandNo = i;
myRasterBandStats.statsGatheredFlag = false;
myRasterBandStats.histogramVector = new QgsRasterBandStats::HistogramVector();
@@ -567,16 +566,16 @@
else if (rasterLayerType == MULTIBAND)
{
//we know we have at least 2 layers...
- mRedBandName = getRasterBandName(1); // sensible default
- mGreenBandName = getRasterBandName(2); // sensible default
+ mRedBandName = getRasterBandName(myQSettings.value("/Raster/defaultRedBand", 1).toInt()); // sensible default
+ mGreenBandName = getRasterBandName(myQSettings.value("/Raster/defaultGreenBand", 2).toInt()); // sensible default
//for the third layer we cant be sure so..
if (GDALGetRasterCount(mGdalDataset) > 2)
{
- mBlueBandName = getRasterBandName(3); // sensible default
+ mBlueBandName = getRasterBandName(myQSettings.value("/Raster/defaultBlueBand", 3).toInt()); // sensible default
}
else
{
- mBlueBandName = TRSTRING_NOT_SET; // sensible default
+ mBlueBandName = getRasterBandName(myQSettings.value("/Raster/defaultBlueBand", 2).toInt()); // sensible default
}
mTransparencyBandName = TRSTRING_NOT_SET;
@@ -2220,11 +2219,7 @@
} //end of main draw method
-/** Return the statistics for a given band name.
- WARDNING::: THERE IS NO GUARANTEE THAT BAND NAMES ARE UNIQE
- THE FIRST MATCH WILL BE RETURNED!!!!!!!!!!!!
- */
-const QgsRasterBandStats QgsRasterLayer::getRasterBandStats(QString const & theBandNameQString)
+const QgsRasterBandStats QgsRasterLayer::getRasterBandStats(QString const & theBandName)
{
//we cant use a vector iterator because the iterator is astruct not a class
@@ -2232,38 +2227,33 @@
for (int i = 1; i <= GDALGetRasterCount(mGdalDataset); i++)
{
QgsRasterBandStats myRasterBandStats = getRasterBandStats(i);
- if (myRasterBandStats.bandName == theBandNameQString)
+ if (myRasterBandStats.bandName == theBandName)
{
return myRasterBandStats;
}
}
return QgsRasterBandStats(); // return a null one
- // XXX is this ok? IS there a "null" one?
}
-//get the number of a band given its name
-//note this should be the rewritten name set up in the constructor,
-//not the name retrieved directly from gdal!
-//if no matching band is found zero will be returned!
-int QgsRasterLayer::getRasterBandNumber(QString const & theBandNameQString)
+int QgsRasterLayer::getRasterBandNumber(QString const & theBandName)
{
for (int myIterator = 0; myIterator < mRasterStatsList.size(); ++myIterator)
{
//find out the name of this band
QgsRasterBandStats myRasterBandStats = mRasterStatsList[myIterator];
- QgsDebugMsg("myRasterBandStats.bandName: " + myRasterBandStats.bandName + " :: theBandNameQString: "\
- + theBandNameQString);
+ QgsDebugMsg("myRasterBandStats.bandName: " + myRasterBandStats.bandName + " :: theBandName: "\
+ + theBandName);
- if (myRasterBandStats.bandName == theBandNameQString)
+ if (myRasterBandStats.bandName == theBandName)
{
QgsDebugMsg("********** band " + QString::number(myRasterBandStats.bandNo) +\
- " was found in getRasterBandNumber " + theBandNameQString);
+ " was found in getRasterBandNumber " + theBandName);
return myRasterBandStats.bandNo;
}
}
- QgsDebugMsg("********** no band was found in getRasterBandNumber " + theBandNameQString);
+ QgsDebugMsg("********** no band was found in getRasterBandNumber " + theBandName);
return 0; //no band was found
}
@@ -2274,7 +2264,7 @@
const QString QgsRasterLayer::getRasterBandName(int theBandNo)
{
- if (theBandNo <= mRasterStatsList.size())
+ if (theBandNo <= mRasterStatsList.size() && theBandNo > 0)
{
//vector starts at base 0, band counts at base1 !
return mRasterStatsList[theBandNo - 1].bandName;
@@ -2290,7 +2280,7 @@
/** Check whether a given band number has stats associated with it */
bool QgsRasterLayer::hasStats(int theBandNo)
{
- if (theBandNo <= mRasterStatsList.size())
+ if (theBandNo <= mRasterStatsList.size() && theBandNo > 0)
{
//vector starts at base 0, band counts at base1 !
return mRasterStatsList[theBandNo - 1].statsGatheredFlag;
@@ -2643,180 +2633,88 @@
-
-//mutator for red band name (allows alternate mappings e.g. map blue as red colour)
-void QgsRasterLayer::setRedBandName(QString const & theBandNameQString)
+QString QgsRasterLayer::validateBandName(QString const & theBandName)
{
- QgsDebugMsg("setRedBandName : " + theBandNameQString);
+ QgsDebugMsg("validateBandName : Checking...");
//check if the band is unset
- if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET )
+ if (theBandName == TRSTRING_NOT_SET || theBandName == QSTRING_NOT_SET )
{
+ QgsDebugMsg("validateBandName : Band name is '" + QSTRING_NOT_SET + "'. Nothing to do.");
// Use translated name internally
- mRedBandName = TRSTRING_NOT_SET;
- return;
+ return TRSTRING_NOT_SET;
}
+
//check if the image is paletted
- if (rasterLayerType == PALETTE && (theBandNameQString == "Red" || theBandNameQString == "Green" || theBandNameQString == "Blue"))
+ if (rasterLayerType == PALETTE && (theBandName == "Red" || theBandName == "Green" || theBandName == "Blue"))
{
- mRedBandName = theBandNameQString;
- return;
+ QgsDebugMsg("validateBandName : Paletted image valid faux RGB band name");
+ return theBandName;
}
+
//check that a valid band name was passed
-
+ QgsDebugMsg("validateBandName : Looking through raster band stats for matching band name");
for (int myIterator = 0; myIterator < mRasterStatsList.size(); ++myIterator)
{
//find out the name of this band
- QgsRasterBandStats myRasterBandStats = mRasterStatsList[myIterator];
- if (myRasterBandStats.bandName == theBandNameQString)
+ if (mRasterStatsList[myIterator].bandName == theBandName)
{
- mRedBandName = theBandNameQString;
- return;
+ QgsDebugMsg("validateBandName : Matching band name found");
+ return theBandName;
}
}
-
- //if no matches were found default to not set
- mRedBandName = TRSTRING_NOT_SET;
- return;
-}
-
-
-
-//mutator for green band name
-void QgsRasterLayer::setGreenBandName(QString const & theBandNameQString)
-{
- //check if the band is unset
- if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET )
+ QgsDebugMsg("validateBandName : No matching band name found in raster band stats");
+
+ QgsDebugMsg("validateBandName : Testing older naming format");
+ //See of the band in an older format #:something.
+ //TODO Remove test in v2.0
+ if(theBandName.contains(':'))
{
- // Use translated name internally
- mGreenBandName = TRSTRING_NOT_SET;
- return;
- }
- //check if the image is paletted
- if (rasterLayerType == PALETTE && (theBandNameQString == "Red" || theBandNameQString == "Green" || theBandNameQString == "Blue"))
- {
- mGreenBandName = theBandNameQString;
- return;
- }
- //check that a valid band name was passed
-
- for (int myIterator = 0; myIterator < mRasterStatsList.size(); ++myIterator)
- {
- //find out the name of this band
- QgsRasterBandStats myRasterBandStats = mRasterStatsList[myIterator];
- if (myRasterBandStats.bandName == theBandNameQString)
+ QStringList myBandNameComponents = theBandName.split(":");
+ if(myBandNameComponents.size() == 2)
{
- mGreenBandName = theBandNameQString;
- return;
+ int myBandNumber = myBandNameComponents.at(0).toInt();
+ if(myBandNumber > 0)
+ {
+ QgsDebugMsg("validateBandName : Transformed older name format to current format");
+ return "Band " + QString::number(myBandNumber);
+ }
}
}
-
+
//if no matches were found default to not set
- mGreenBandName = TRSTRING_NOT_SET;
- return;
+ QgsDebugMsg("validateBandName : All checks failed, returning '" + QSTRING_NOT_SET + "'");
+ return TRSTRING_NOT_SET;
}
-//mutator for blue band name
-void QgsRasterLayer::setBlueBandName(QString const & theBandNameQString)
+//mutator for red band name (allows alternate mappings e.g. map blue as red colour)
+void QgsRasterLayer::setRedBandName(QString const & theBandName)
{
- //check if the band is unset
- if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET)
- {
- // Use translated name internally
- mBlueBandName = TRSTRING_NOT_SET;
- return;
- }
- //check if the image is paletted
- if (rasterLayerType == PALETTE && (theBandNameQString == "Red" || theBandNameQString == "Green" || theBandNameQString == "Blue"))
- {
- mBlueBandName = theBandNameQString;
- return;
- }
- //check that a valid band name was passed
+ QgsDebugMsg("setRedBandName : " + theBandName);
+ mRedBandName = validateBandName(theBandName);
+}
- for (int myIterator = 0; myIterator < mRasterStatsList.size(); ++myIterator)
- {
- //find out the name of this band
- QgsRasterBandStats myRasterBandStats = mRasterStatsList[myIterator];
- if (myRasterBandStats.bandName == theBandNameQString)
- {
- mBlueBandName = theBandNameQString;
- return;
- }
- }
+//mutator for green band name
+void QgsRasterLayer::setGreenBandName(QString const & theBandName)
+{
+ mGreenBandName = validateBandName(theBandName);
+}
- //if no matches were found default to not set
- mBlueBandName = TRSTRING_NOT_SET;
- return;
+//mutator for blue band name
+void QgsRasterLayer::setBlueBandName(QString const & theBandName)
+{
+ mBlueBandName = validateBandName(theBandName);
}
//mutator for transparent band name
-void QgsRasterLayer::setTransparentBandName(QString const & theBandNameQString)
+void QgsRasterLayer::setTransparentBandName(QString const & theBandName)
{
- //check if the band is unset
- if (theBandNameQString == TRSTRING_NOT_SET)
- {
- mTransparencyBandName = theBandNameQString;
- return;
- }
- //check if the image is paletted
- if (rasterLayerType == PALETTE && (theBandNameQString == "Red" || theBandNameQString == "Green" || theBandNameQString == "Blue"))
- {
- mTransparencyBandName = theBandNameQString;
- return;
- }
- //check that a valid band name was passed
-
- for (int myIterator = 0; myIterator < mRasterStatsList.size(); ++myIterator)
- {
- //find out the name of this band
- QgsRasterBandStats myRasterBandStats = mRasterStatsList[myIterator];
- if (myRasterBandStats.bandName == theBandNameQString)
- {
- mTransparencyBandName = theBandNameQString;
- return;
- }
- }
-
- //if no matches were found default to not set
- mTransparencyBandName = TRSTRING_NOT_SET;
- return;
+ mTransparencyBandName = validateBandName(theBandName);
}
-
//mutator for gray band name
-void QgsRasterLayer::setGrayBandName(QString const & theBandNameQString)
+void QgsRasterLayer::setGrayBandName(QString const & theBandName)
{
- //check if the band is unset
- if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET )
- {
- // Use translated name internally
- mGrayBandName = TRSTRING_NOT_SET;
- return;
- }
- //check if the image is paletted
- if (rasterLayerType == PALETTE && (theBandNameQString == mRedBandName || theBandNameQString == mGreenBandName || theBandNameQString == mBlueBandName))
- {
- mGrayBandName = theBandNameQString;
- return;
- }
- //otherwise check that a valid band name was passed
-
- for (int myIterator = 0; myIterator < mRasterStatsList.size(); ++myIterator)
- {
- //find out the name of this band
- QgsRasterBandStats myRasterBandStats = mRasterStatsList[myIterator];
- QgsDebugMsg("Checking if " + myRasterBandStats.bandName + " == "
- + mGrayBandName);
- if (myRasterBandStats.bandName == theBandNameQString)
- {
- mGrayBandName = theBandNameQString;
- return;
- }
- }
-
- //if no matches were found default to not set
- mGrayBandName = TRSTRING_NOT_SET;
- return;
+ mGrayBandName = validateBandName(theBandName);
}
/** Return a pixmap representing a legend image. This is an overloaded
Modified: trunk/qgis/src/core/raster/qgsrasterlayer.h
===================================================================
--- trunk/qgis/src/core/raster/qgsrasterlayer.h 2008-07-19 18:07:50 UTC (rev 8818)
+++ trunk/qgis/src/core/raster/qgsrasterlayer.h 2008-07-21 01:30:07 UTC (rev 8819)
@@ -367,7 +367,7 @@
/** \brief Get the number of a band given its name. Note this will be the rewritten name set
* up in the constructor, and will not necessarily be the same as the name retrieved directly from gdal!
* If no matching band is found zero will be returned! */
- int getRasterBandNumber (const QString & theBandNameQString);
+ int getRasterBandNumber (const QString & theBandName);
/** \brief Get the name of a band given its number. */
const QString getRasterBandName(int theBandNoInt);
/** \brief Find out whether a given band exists. */
@@ -380,7 +380,7 @@
return mRedBandName;
}
/** \brief Mutator for red band name (allows alternate mappings e.g. map blue as red color). */
- void setRedBandName(const QString & theBandNameQString);
+ void setRedBandName(const QString & theBandName);
//
// Accessor and mutator for green band name
//
@@ -390,7 +390,7 @@
return mGreenBandName;
}
/** \brief Mutator for green band name mapping. */
- void setGreenBandName(const QString & theBandNameQString);
+ void setGreenBandName(const QString & theBandName);
//
// Accessor and mutator for blue band name
//
@@ -400,7 +400,7 @@
return mBlueBandName;
}
/** \brief Mutator for blue band name mapping. */
- void setBlueBandName(const QString & theBandNameQString);
+ void setBlueBandName(const QString & theBandName);
//
// Accessor raster transparency object
@@ -417,7 +417,7 @@
return mTransparencyBandName;
}
/** \brief Mutator for transparent band name mapping. */
- void setTransparentBandName(const QString & theBandNameQString);
+ void setTransparentBandName(const QString & theBandName);
//
// Accessor and mutator for gray band name
@@ -428,7 +428,7 @@
return mGrayBandName;
}
/** \brief Mutator for gray band name mapping. */
- void setGrayBandName(const QString & theBandNameQString);
+ void setGrayBandName(const QString & theBandName);
//
// Accessor and mutator for mDebugOverlayFlag
//
@@ -1010,6 +1010,9 @@
/** \brief Update the layer if it is outdated */
bool update ();
+ /** \brief Verify and transform band name for internal consistency. Return 'Not Set' on any type of failure */
+ QString validateBandName(const QString & theBandName);
+
//
// Private member vars
//
Modified: trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui 2008-07-19 18:07:50 UTC (rev 8818)
+++ trunk/qgis/src/ui/qgsrasterlayerpropertiesbase.ui 2008-07-21 01:30:07 UTC (rev 8819)
@@ -37,21 +37,60 @@
<property name="title" >
<string>Render as</string>
</property>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
+ <layout class="QHBoxLayout" >
+ <item>
<widget class="QRadioButton" name="rbtnSingleBand" >
<property name="text" >
<string>Single band gray</string>
</property>
</widget>
</item>
- <item row="0" column="1" >
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QRadioButton" name="rbtnThreeBand" >
<property name="text" >
<string>Three band color</string>
</property>
</widget>
</item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="cboxInvertColorMap" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Invert color map</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -96,7 +135,7 @@
</property>
</widget>
</item>
- <item row="0" column="1" colspan="3" >
+ <item row="0" column="1" colspan="4" >
<widget class="QComboBox" name="cboRed" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
@@ -128,7 +167,7 @@
</property>
</widget>
</item>
- <item row="1" column="1" colspan="3" >
+ <item row="1" column="1" colspan="4" >
<widget class="QComboBox" name="cboGreen" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
@@ -160,7 +199,7 @@
</property>
</widget>
</item>
- <item row="2" column="1" colspan="3" >
+ <item row="2" column="1" colspan="4" >
<widget class="QComboBox" name="cboBlue" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
@@ -182,14 +221,47 @@
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2" >
+ <item row="3" column="3" colspan="2" >
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QLabel" name="labelDefaultBandCombination" >
+ <property name="text" >
+ <string>Default R:1 G:2 B:3</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pbtnMakeBandCombinationDefault" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Save current band combination as default. This setting will be persistent between QGIS sessions.</string>
+ </property>
+ <property name="whatsThis" >
+ <string>Save current band combination as a default. This setting will be persistent between QGIS sessions.</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../images/themes/default/mActionFileSave.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0" colspan="5" >
<widget class="QRadioButton" name="rbtnThreeBandMinMax" >
<property name="text" >
<string>Custom min / max values</string>
</property>
</widget>
</item>
- <item row="4" column="0" >
+ <item row="5" column="0" >
<widget class="QLabel" name="lblRedMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="MinimumExpanding" >
@@ -202,7 +274,7 @@
</property>
</widget>
</item>
- <item row="4" column="1" >
+ <item row="5" column="1" >
<widget class="QLineEdit" name="leRedMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
@@ -227,7 +299,20 @@
</property>
</widget>
</item>
- <item row="4" column="2" >
+ <item row="5" column="2" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>119</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="5" column="3" >
<widget class="QLabel" name="lblRedMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="MinimumExpanding" >
@@ -240,7 +325,7 @@
</property>
</widget>
</item>
- <item row="4" column="3" >
+ <item row="5" column="4" >
<widget class="QLineEdit" name="leRedMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
@@ -265,7 +350,7 @@
</property>
</widget>
</item>
- <item row="5" column="0" >
+ <item row="6" column="0" >
<widget class="QLabel" name="lblGreenMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="MinimumExpanding" >
@@ -278,7 +363,7 @@
</property>
</widget>
</item>
- <item row="5" column="1" >
+ <item row="6" column="1" >
<widget class="QLineEdit" name="leGreenMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
@@ -303,7 +388,7 @@
</property>
</widget>
</item>
- <item row="5" column="2" >
+ <item row="6" column="3" >
<widget class="QLabel" name="lblGreenMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="MinimumExpanding" >
@@ -316,7 +401,7 @@
</property>
</widget>
</item>
- <item row="5" column="3" >
+ <item row="6" column="4" >
<widget class="QLineEdit" name="leGreenMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
@@ -341,7 +426,7 @@
</property>
</widget>
</item>
- <item row="6" column="0" >
+ <item row="7" column="0" >
<widget class="QLabel" name="lblBlueMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="MinimumExpanding" >
@@ -354,7 +439,7 @@
</property>
</widget>
</item>
- <item row="6" column="1" >
+ <item row="7" column="1" >
<widget class="QLineEdit" name="leBlueMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
@@ -379,7 +464,7 @@
</property>
</widget>
</item>
- <item row="6" column="2" >
+ <item row="7" column="3" >
<widget class="QLabel" name="lblBlueMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="MinimumExpanding" >
@@ -392,7 +477,7 @@
</property>
</widget>
</item>
- <item row="6" column="3" >
+ <item row="7" column="4" >
<widget class="QLineEdit" name="leBlueMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Expanding" >
@@ -417,14 +502,14 @@
</property>
</widget>
</item>
- <item row="7" column="0" colspan="2" >
+ <item row="8" column="0" colspan="2" >
<widget class="QRadioButton" name="rbtnThreeBandStdDev" >
<property name="text" >
- <string>Std. deviation</string>
+ <string>Use standard deviation</string>
</property>
</widget>
</item>
- <item row="7" column="3" >
+ <item row="8" column="4" >
<widget class="QDoubleSpinBox" name="sboxThreeBandStdDev" >
<property name="maximum" >
<double>10.000000000000000</double>
@@ -514,27 +599,14 @@
</property>
</widget>
</item>
- <item row="2" column="1" colspan="5" >
- <widget class="QCheckBox" name="cboxInvertColorMap" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Invert color map</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0" colspan="2" >
+ <item row="4" column="0" colspan="2" >
<widget class="QRadioButton" name="rbtnSingleBandMinMax" >
<property name="text" >
<string>Custom min / max values</string>
</property>
</widget>
</item>
- <item row="3" column="2" >
+ <item row="4" column="2" >
<widget class="QLabel" name="lblGrayMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
@@ -547,7 +619,7 @@
</property>
</widget>
</item>
- <item row="3" column="3" >
+ <item row="4" column="3" >
<widget class="QLineEdit" name="leGrayMin" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
@@ -572,7 +644,7 @@
</property>
</widget>
</item>
- <item row="3" column="4" >
+ <item row="4" column="4" >
<widget class="QLabel" name="lblGrayMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
@@ -585,7 +657,7 @@
</property>
</widget>
</item>
- <item row="3" column="5" >
+ <item row="4" column="5" >
<widget class="QLineEdit" name="leGrayMax" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
@@ -610,14 +682,14 @@
</property>
</widget>
</item>
- <item row="4" column="0" colspan="2" >
+ <item row="5" column="0" colspan="2" >
<widget class="QRadioButton" name="rbtnSingleBandStdDev" >
<property name="text" >
<string>Use standard deviation</string>
</property>
</widget>
</item>
- <item row="4" column="3" >
+ <item row="5" column="3" >
<widget class="QDoubleSpinBox" name="sboxSingleBandStdDev" >
<property name="maximum" >
<double>10.000000000000000</double>
@@ -630,6 +702,19 @@
</property>
</widget>
</item>
+ <item row="2" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
@@ -2041,7 +2126,6 @@
<layoutdefault spacing="6" margin="11" />
<tabstops>
<tabstop>tabBar</tabstop>
- <tabstop>cboxInvertColorMap</tabstop>
<tabstop>cboRed</tabstop>
<tabstop>cboGreen</tabstop>
<tabstop>cboBlue</tabstop>
More information about the QGIS-commit
mailing list