Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
-updated enums and respective functions to have undefined be initial …
…value

-replaced some QT3 calls with QT4 calls in raster layer properties
-updated python bindings 

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8026 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts committed Jan 22, 2008
1 parent b751ccd commit bac4fc8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 66 deletions.
2 changes: 2 additions & 0 deletions python/core/qgsrasterlayer.sip
Expand Up @@ -286,6 +286,7 @@ public:
/** \brief This enumerator describes the types of shading that can be used. */
enum COLOR_SHADING_ALGORITHM
{
UNDEFINED_SHADING_ALGORITHM,
PSEUDO_COLOR,
FREAK_OUT, //it will scare your granny!
COLOR_RAMP,
Expand Down Expand Up @@ -315,6 +316,7 @@ public:
/** \brief This enumerator describes the different kinds of drawing we can do. */
enum DRAWING_STYLE
{
UNDEFINED_DRAWING_STYLE,
SINGLE_BAND_GRAY, // a "Gray" or "Undefined" layer drawn as a range of gray colors
SINGLE_BAND_PSEUDO_COLOR,// a "Gray" or "Undefined" layer drawn using a pseudocolor algorithm
PALETTED_COLOR, //a "Palette" image drawn using color table
Expand Down
97 changes: 49 additions & 48 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -95,16 +95,16 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
spinMaximumScale->setValue((int)lyr->maxScale());

// build GUI components
cboxColorMap->insertItem(tr("Grayscale"));
cboxColorMap->insertItem(tr("Pseudocolor"));
cboxColorMap->insertItem(tr("Freak Out"));
cboxColorMap->insertItem(tr("Custom Colormap"));
cboxColorMap->addItem(tr("Grayscale"));
cboxColorMap->addItem(tr("Pseudocolor"));
cboxColorMap->addItem(tr("Freak Out"));
cboxColorMap->addItem(tr("Custom Colormap"));

//add items to the color stretch combo box
cboxContrastEnhancementAlgorithm->insertItem(tr("No Stretch"));
cboxContrastEnhancementAlgorithm->insertItem(tr("Stretch To MinMax"));
cboxContrastEnhancementAlgorithm->insertItem(tr("Stretch And Clip To MinMax"));
cboxContrastEnhancementAlgorithm->insertItem(tr("Clip To MinMax"));
cboxContrastEnhancementAlgorithm->addItem(tr("No Stretch"));
cboxContrastEnhancementAlgorithm->addItem(tr("Stretch To MinMax"));
cboxContrastEnhancementAlgorithm->addItem(tr("Stretch And Clip To MinMax"));
cboxContrastEnhancementAlgorithm->addItem(tr("Clip To MinMax"));

//set initial states of all Min Max and StdDev fields and labels to disabled
sboxThreeBandStdDev->setEnabled(false);
Expand All @@ -129,10 +129,10 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
pbtnLoadMinMax->setEnabled(false);

//setup custom colormap tab
cboxColorInterpolation->insertItem(-1, tr("Discrete"));
cboxColorInterpolation->insertItem(-1, tr("Linearly"));
cboxClassificationMode->insertItem(-1, tr("Equal interval"));
cboxClassificationMode->insertItem(-1, tr("Quantiles"));
cboxColorInterpolation->addItem(tr("Discrete"));
cboxColorInterpolation->addItem(tr("Linearly"));
cboxClassificationMode->addItem(tr("Equal interval"));
cboxClassificationMode->addItem(tr("Quantiles"));

QStringList headerLabels;
headerLabels << "Value";
Expand All @@ -150,26 +150,26 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
if (mRasterLayer->getRasterLayerType()
== QgsRasterLayer::PALETTE) //paletted layers have hard coded color entries
{
cboRed->insertItem("Red");
cboGreen->insertItem("Red");
cboBlue->insertItem("Red");
cboRed->addItem("Red");
cboGreen->addItem("Red");
cboBlue->addItem("Red");

cboRed->insertItem("Green");
cboGreen->insertItem("Green");
cboBlue->insertItem("Green");
cboRed->addItem("Green");
cboGreen->addItem("Green");
cboBlue->addItem("Green");

cboRed->insertItem("Blue");
cboGreen->insertItem("Blue");
cboBlue->insertItem("Blue");
cboRed->addItem("Blue");
cboGreen->addItem("Blue");
cboBlue->addItem("Blue");

cboRed->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboGreen->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboBlue->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboRed->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboGreen->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboBlue->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));

cboGray->insertItem("Red");
cboGray->insertItem("Green");
cboGray->insertItem("Blue");
cboGray->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboGray->addItem("Red");
cboGray->addItem("Green");
cboGray->addItem("Blue");
cboGray->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));

lstHistogramLabels->insertItem(tr("Palette"));
}
Expand Down Expand Up @@ -263,41 +263,41 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
std::cout << "Inserting : " << myQString.toLocal8Bit().data() << std::endl;
#endif

cboGray->insertItem(myQString);
cboRed->insertItem(myQString);
cboGreen->insertItem(myQString);
cboBlue->insertItem(myQString);
cboGray->addItem(myQString);
cboRed->addItem(myQString);
cboGreen->addItem(myQString);
cboBlue->addItem(myQString);
}
//TODO: Need to handle situations where a band is set to Not Set, currently if you set a band to this it will segfault.
cboRed->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboGreen->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboBlue->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboRed->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboGreen->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboBlue->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
if (cboGray->count() != 1)
cboGray->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboGray->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
}

cboxTransparencyBand->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboxTransparencyLayer->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboxTransparencyBand->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboxTransparencyLayer->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
QMap<QString, QgsMapLayer *> myLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer *>::iterator it;
for(it = myLayers.begin(); it != myLayers.end(); it++)
{
if(QgsMapLayer::RASTER == it.value()->type())
{
cboxTransparencyLayer->insertItem(it.value()->name());
cboxTransparencyLayer->addItem(it.value()->name());
}
}

QString myThemePath = QgsApplication::themePath();
QPixmap myPyramidPixmap(myThemePath + "/mIconPyramid.png");
QPixmap myNoPyramidPixmap(myThemePath + "/mIconNoPyramid.png");

pbnAddValuesManually->setIconSet(QIcon(QPixmap(myThemePath + "/mActionNewAttribute.png")));
pbnAddValuesFromDisplay->setIconSet(QIcon(QPixmap(myThemePath + "/mActionContextHelp.png")));
pbnRemoveSelectedRow->setIconSet(QIcon(QPixmap(myThemePath + "/mActionDeleteAttribute.png")));
pbnDefaultValues->setIconSet(QIcon(QPixmap(myThemePath + "/mActionCopySelected.png")));
pbnImportTransparentPixelValues->setIconSet(QIcon(QPixmap(myThemePath + "/mActionFileOpen.png")));
pbnExportTransparentPixelValues->setIconSet(QIcon(QPixmap(myThemePath + "/mActionFileSave.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")));

// Only do pyramids if dealing directly with GDAL.
if (mRasterLayerIsGdal)
Expand Down Expand Up @@ -542,6 +542,7 @@ void QgsRasterLayerProperties::sync()
if(mRasterLayerIsWms)
{
tabBar->setCurrentIndex(tabBar->indexOf(tabPageMetadata));
tabBar->removeTab(tabBar->indexOf(tabPageColormap));
tabBar->removeTab(tabBar->indexOf(tabPageSymbology));
tabBar->removeTab(tabBar->indexOf(tabPageTransparency));
tabBar->removeTab(tabBar->indexOf(tabPageHistogram));
Expand Down Expand Up @@ -1717,7 +1718,7 @@ void QgsRasterLayerProperties::on_cboxTransparencyLayer_currentIndexChanged(cons
if(theText == tr(QgsRasterLayer::QSTRING_NOT_SET))
{
cboxTransparencyBand->clear();
cboxTransparencyBand->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboxTransparencyBand->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
}
else
{
Expand All @@ -1730,10 +1731,10 @@ void QgsRasterLayerProperties::on_cboxTransparencyLayer_currentIndexChanged(cons
QgsRasterLayer* myRasterLayer = (QgsRasterLayer*)it.value();
int myBandCount = myRasterLayer->getBandCount();
cboxTransparencyBand->clear();
cboxTransparencyBand->insertItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
cboxTransparencyBand->addItem(tr(QgsRasterLayer::QSTRING_NOT_SET));
for(int bandRunner = 1; bandRunner <= myBandCount; bandRunner++)
{
cboxTransparencyBand->insertItem(myRasterLayer->getRasterBandName(bandRunner));
cboxTransparencyBand->addItem(myRasterLayer->getRasterBandName(bandRunner));
}
break;
}
Expand Down
34 changes: 16 additions & 18 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -816,7 +816,7 @@ QString QgsRasterLayer::getDrawingStyleAsQString()
break;
}

return QString("INVALID_DRAWING_STYLE"); // XXX I hope this is ok to return
return QString("UNDEFINED_DRAWING_STYLE");

}

Expand All @@ -825,42 +825,38 @@ void QgsRasterLayer::setDrawingStyle(QString const & theDrawingStyleQString)
if (theDrawingStyleQString == "SINGLE_BAND_GRAY")//no need to tr() this its not shown in ui
{
drawingStyle = SINGLE_BAND_GRAY;
return;
}
if (theDrawingStyleQString == "SINGLE_BAND_PSEUDO_COLOR")//no need to tr() this its not shown in ui
else if (theDrawingStyleQString == "SINGLE_BAND_PSEUDO_COLOR")//no need to tr() this its not shown in ui
{
drawingStyle = SINGLE_BAND_PSEUDO_COLOR;
return;
}
if (theDrawingStyleQString == "PALETTED_SINGLE_BAND_GRAY")//no need to tr() this its not shown in ui
else if (theDrawingStyleQString == "PALETTED_SINGLE_BAND_GRAY")//no need to tr() this its not shown in ui
{
drawingStyle = PALETTED_SINGLE_BAND_GRAY;
return;
}
if (theDrawingStyleQString == "PALETTED_SINGLE_BAND_PSEUDO_COLOR")//no need to tr() this its not shown in ui
else if (theDrawingStyleQString == "PALETTED_SINGLE_BAND_PSEUDO_COLOR")//no need to tr() this its not shown in ui
{
drawingStyle = PALETTED_SINGLE_BAND_PSEUDO_COLOR;
return;
}
if (theDrawingStyleQString == "PALETTED_MULTI_BAND_COLOR")//no need to tr() this its not shown in ui
else if (theDrawingStyleQString == "PALETTED_MULTI_BAND_COLOR")//no need to tr() this its not shown in ui
{
drawingStyle = PALETTED_MULTI_BAND_COLOR;
return;
}
if (theDrawingStyleQString == "MULTI_BAND_SINGLE_BAND_GRAY")//no need to tr() this its not shown in ui
else if (theDrawingStyleQString == "MULTI_BAND_SINGLE_BAND_GRAY")//no need to tr() this its not shown in ui
{
drawingStyle = MULTI_BAND_SINGLE_BAND_GRAY;
return;
}
if (theDrawingStyleQString == "MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR")//no need to tr() this its not shown in ui
else if (theDrawingStyleQString == "MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR")//no need to tr() this its not shown in ui
{
drawingStyle = MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR;
return;
}
if (theDrawingStyleQString == "MULTI_BAND_COLOR")//no need to tr() this its not shown in ui
else if (theDrawingStyleQString == "MULTI_BAND_COLOR")//no need to tr() this its not shown in ui
{
drawingStyle = MULTI_BAND_COLOR;
return;
}
else
{
drawingStyle = UNDEFINED_DRAWING_STYLE;
}
}

Expand Down Expand Up @@ -5309,7 +5305,7 @@ QString QgsRasterLayer::getColorShadingAlgorithmAsQString()
break;
}

return QString("UNKNOWN");
return QString("UNDEFINED_SHADING_ALGORITHM");
}

void QgsRasterLayer::setColorShadingAlgorithm(QString theShaderAlgorithm)
Expand All @@ -5326,6 +5322,8 @@ void QgsRasterLayer::setColorShadingAlgorithm(QString theShaderAlgorithm)
setColorShadingAlgorithm(COLOR_RAMP);
else if(theShaderAlgorithm == "USER_DEFINED")
setColorShadingAlgorithm(USER_DEFINED);
else
setColorShadingAlgorithm(UNDEFINED_SHADING_ALGORITHM);
}

QString QgsRasterLayer::getContrastEnhancementAlgorithmAsQString()
Expand All @@ -5349,7 +5347,7 @@ QString QgsRasterLayer::getContrastEnhancementAlgorithmAsQString()
break;
}

return QString("UNKNOWN");
return QString("NO_STRETCH");
}

void QgsRasterLayer::setContrastEnhancementAlgorithm(QString theAlgorithm, bool theGenerateLookupTableFlag)
Expand Down
2 changes: 2 additions & 0 deletions src/core/raster/qgsrasterlayer.h
Expand Up @@ -580,6 +580,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** \brief This enumerator describes the types of shading that can be used. */
enum COLOR_SHADING_ALGORITHM
{
UNDEFINED_SHADING_ALGORITHM,
PSEUDO_COLOR,
FREAK_OUT, //it will scare your granny!
COLOR_RAMP,
Expand Down Expand Up @@ -629,6 +630,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** \brief This enumerator describes the different kinds of drawing we can do. */
enum DRAWING_STYLE
{
UNDEFINED_DRAWING_STYLE,
SINGLE_BAND_GRAY, // a "Gray" or "Undefined" layer drawn as a range of gray colors
SINGLE_BAND_PSEUDO_COLOR,// a "Gray" or "Undefined" layer drawn using a pseudocolor algorithm
PALETTED_COLOR, //a "Palette" image drawn using color table
Expand Down

0 comments on commit bac4fc8

Please sign in to comment.