[QGIS Commit] r15231 - in branches/raster-providers/src: app core
core/raster providers/gdal providers/grass providers/wms
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Feb 21 07:15:38 EST 2011
Author: rblazek
Date: 2011-02-21 04:15:38 -0800 (Mon, 21 Feb 2011)
New Revision: 15231
Modified:
branches/raster-providers/src/app/qgsrasterlayerproperties.cpp
branches/raster-providers/src/app/qgsrasterlayerproperties.h
branches/raster-providers/src/core/qgsrasterdataprovider.cpp
branches/raster-providers/src/core/qgsrasterdataprovider.h
branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp
branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp
branches/raster-providers/src/providers/wms/qgswmsprovider.cpp
Log:
properties based on capabilities
Modified: branches/raster-providers/src/app/qgsrasterlayerproperties.cpp
===================================================================
--- branches/raster-providers/src/app/qgsrasterlayerproperties.cpp 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/app/qgsrasterlayerproperties.cpp 2011-02-21 12:15:38 UTC (rev 15231)
@@ -71,10 +71,6 @@
mGrayMinimumMaximumEstimated = true;
mRGBMinimumMaximumEstimated = true;
- // TODO: use providers capabilietes
- //mRasterLayerIsInternal = mRasterLayer->dataProvider() == 0;
- mRasterLayerIsInternal = true;
-
setupUi( this );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
@@ -220,7 +216,7 @@
// Only do pyramids if dealing directly with GDAL.
- if ( mRasterLayerIsInternal )
+ if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids )
{
QgsRasterLayer::RasterPyramidList myPyramidList = mRasterLayer->buildPyramidList();
QgsRasterLayer::RasterPyramidList::iterator myRasterPyramidIterator;
@@ -520,20 +516,25 @@
break;
}
- if ( !mRasterLayerIsInternal )
+ if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
{
- // TODO: add providers capabilities
- //delete tabPageSymbology;
- //delete tabPageColormap;
- //delete tabPagePyramids;
- //delete tabPageHistogram;
-
+ delete tabPageSymbology;
+ delete tabPageColormap;
gboxNoDataValue->setEnabled( false );
gboxCustomTransparency->setEnabled( false );
-
tabBar->setCurrentWidget( tabPageMetadata );
}
+ if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
+ {
+ delete tabPagePyramids;
+ }
+
+ if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
+ {
+ delete tabPageHistogram;
+ }
+
#if 0
if ( mRasterLayer->rasterType() == QgsRasterLayer::Multiband )
{
@@ -561,35 +562,38 @@
//
// Populate the various controls on the form
//
- QgsDebugMsg( "colorShadingAlgorithm = " + QString::number( mRasterLayer->colorShadingAlgorithm() ) );
- if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandPseudoColor ||
- mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedColor ||
- mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedSingleBandPseudoColor ||
- mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandPseudoColor )
- {
- if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::PseudoColorShader )
+ if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
+ {
+ QgsDebugMsg( "colorShadingAlgorithm = " + QString::number( mRasterLayer->colorShadingAlgorithm() ) );
+ if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandPseudoColor ||
+ mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedColor ||
+ mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedSingleBandPseudoColor ||
+ mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandPseudoColor )
{
- cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Pseudocolor" ) ) );
+ if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::PseudoColorShader )
+ {
+ cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Pseudocolor" ) ) );
+ }
+ else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::FreakOutShader )
+ {
+ cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Freak Out" ) ) );
+ }
+ else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::ColorRampShader )
+ {
+ cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Colormap" ) ) );
+ }
+ else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::UserDefinedShader )
+ {
+ cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "User Defined" ) ) );
+ }
}
- else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::FreakOutShader )
+ else
{
- cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Freak Out" ) ) );
+ cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Grayscale" ) ) );
}
- else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::ColorRampShader )
- {
- cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Colormap" ) ) );
- }
- else if ( mRasterLayer->colorShadingAlgorithm() == QgsRasterLayer::UserDefinedShader )
- {
- cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "User Defined" ) ) );
- }
}
- else if ( mRasterLayerIsInternal )
- {
- cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Grayscale" ) ) );
- }
- if ( mRasterLayerIsInternal )
+ if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
{
if ( rbtnThreeBand->isChecked() )
{
@@ -769,10 +773,24 @@
leDisplayName->setText( mRasterLayer->name() );
//display the raster dimensions and no data value
- if ( mRasterLayerIsInternal )
- {
+ if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
+ {
lblColumns->setText( tr( "Columns: %1" ).arg( mRasterLayer->width() ) );
lblRows->setText( tr( "Rows: %1" ).arg( mRasterLayer->height() ) );
+ }
+ else
+ {
+ // TODO: Account for fixedWidth and fixedHeight WMS layers
+ lblColumns->setText( tr( "Columns: " ) + tr( "n/a" ) );
+ lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
+ }
+
+ if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
+ {
+ lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
+ }
+ else
+ {
if ( mRasterLayer->isNoDataValueValid() )
{
lblNoData->setText( tr( "No-Data Value: %1" ).arg( mRasterLayer->noDataValue() ) );
@@ -782,13 +800,6 @@
lblNoData->setText( tr( "No-Data Value: Not Set" ) );
}
}
- else
- {
- // TODO: Account for fixedWidth and fixedHeight WMS layers
- lblColumns->setText( tr( "Columns: " ) + tr( "n/a" ) );
- lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
- lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
- }
//get the thumbnail for the layer
QPixmap myQPixmap = QPixmap( pixmapThumbnail->width(), pixmapThumbnail->height() );
@@ -819,12 +830,12 @@
void QgsRasterLayerProperties::syncColormapTab()
{
QgsDebugMsg( "populate color ramp tab" );
- if ( !mRasterLayerIsInternal )
+ if ( !mRasterLayer || !mRasterLayer->dataProvider() )
{
return;
}
- if ( !mRasterLayer )
+ if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
{
return;
}
@@ -916,7 +927,7 @@
*/
void QgsRasterLayerProperties::apply()
{
- if ( mRasterLayerIsInternal )
+ if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
{
QgsDebugMsg( "apply processing symbology tab" );
/*
@@ -1406,7 +1417,7 @@
mRasterLayer->triggerRepaint();
//Because Min Max values can be set during the redraw if a strech is requested we need to resync after apply
- if ( mRasterLayerIsInternal )
+ if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
{
if ( QgsContrastEnhancement::NoEnhancement != mRasterLayer->contrastEnhancementAlgorithm() )
{
@@ -1576,7 +1587,7 @@
void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged( const QString& theText )
{
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
+ if ( TRSTRING_NOT_SET != theText )
{
leBlueMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
leBlueMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1585,7 +1596,7 @@
void QgsRasterLayerProperties::on_cboGray_currentIndexChanged( const QString& theText )
{
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
+ if ( TRSTRING_NOT_SET != theText )
{
leGrayMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
leGrayMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1594,7 +1605,7 @@
void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged( const QString& theText )
{
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
+ if ( TRSTRING_NOT_SET != theText )
{
leGreenMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
leGreenMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1603,7 +1614,7 @@
void QgsRasterLayerProperties::on_cboRed_currentIndexChanged( const QString& theText )
{
- if ( mRasterLayerIsInternal && TRSTRING_NOT_SET != theText )
+ if ( TRSTRING_NOT_SET != theText )
{
leRedMin->setText( QString::number( mRasterLayer->minimumValue( theText ) ) );
leRedMax->setText( QString::number( mRasterLayer->maximumValue( theText ) ) );
@@ -1649,8 +1660,10 @@
void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged( const QString& theText )
{
- if ( !mRasterLayerIsInternal )
+ if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
+ {
return;
+ }
if ( theText == tr( "Pseudocolor" ) || theText == tr( "Freak Out" ) )
{
@@ -2564,10 +2577,9 @@
void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
{
- if ( mRasterLayerIsInternal &&
- ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
+ if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
- || mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor ) )
+ || mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
{
QgsRasterBandStats myRasterBandStats;
double myMinimumMaximum[2];
@@ -2988,16 +3000,13 @@
void QgsRasterLayerProperties::on_btnResetNull_clicked( )
{
//If reset NoDataValue is checked do this first, will ignore what ever is in the LineEdit
- if ( mRasterLayerIsInternal )
+ mRasterLayer->resetNoDataValue();
+ if ( mRasterLayer->isNoDataValueValid() )
{
- mRasterLayer->resetNoDataValue();
- if ( mRasterLayer->isNoDataValueValid() )
- {
- leNoDataValue->setText( QString::number( mRasterLayer->noDataValue(), 'f' ) );
- }
- else
- {
- leNoDataValue->clear();
- }
+ leNoDataValue->setText( QString::number( mRasterLayer->noDataValue(), 'f' ) );
}
+ else
+ {
+ leNoDataValue->clear();
+ }
}
Modified: branches/raster-providers/src/app/qgsrasterlayerproperties.h
===================================================================
--- branches/raster-providers/src/app/qgsrasterlayerproperties.h 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/app/qgsrasterlayerproperties.h 2011-02-21 12:15:38 UTC (rev 15231)
@@ -185,7 +185,7 @@
This variable is used to determine if various parts of the Properties UI are
included or not
*/
- bool mRasterLayerIsInternal;
+ //bool mRasterLayerIsInternal;
/** \brief Clear current color map table and population with values from new list */
void populateColorMapTable( const QList<QgsColorRampShader::ColorRampItem>& );
Modified: branches/raster-providers/src/core/qgsrasterdataprovider.cpp
===================================================================
--- branches/raster-providers/src/core/qgsrasterdataprovider.cpp 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/core/qgsrasterdataprovider.cpp 2011-02-21 12:15:38 UTC (rev 15231)
@@ -147,16 +147,11 @@
abilitiesList += tr( "Identify" );
}
- if ( abilities & QgsRasterDataProvider::Draw )
+ if ( abilities & QgsRasterDataProvider::BuildPyramids )
{
- abilitiesList += tr( "Draw" );
+ abilitiesList += tr( "Build Pyramids" );
}
- if ( abilities & QgsRasterDataProvider::Data )
- {
- abilitiesList += tr( "Data" );
- }
-
QgsDebugMsg( "Capability: " + abilitiesList.join( ", " ) );
return abilitiesList.join( ", " );
Modified: branches/raster-providers/src/core/qgsrasterdataprovider.h
===================================================================
--- branches/raster-providers/src/core/qgsrasterdataprovider.h 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/core/qgsrasterdataprovider.h 2011-02-21 12:15:38 UTC (rev 15231)
@@ -55,15 +55,13 @@
//! If you add to this, please also add to capabilitiesString()
enum Capability
{
- NoCapabilities = 0,
- Identify = 1,
- // Draw: the provider is capable to render data on QImage, e.g. WMS, GRASS
- Draw = 1 << 1,
- // Data: the provider is capable to return data values, so that
- // QgsRasterLayer can render them using selected rendering mode, e.g. GDAL, GRASS
- Data = 1 << 2,
- ExactMinimumMaximum = 1 << 3,
- EstimatedMinimumMaximum = 1 << 4,
+ NoCapabilities = 0,
+ Identify = 1,
+ ExactMinimumMaximum = 1 << 1,
+ EstimatedMinimumMaximum = 1 << 2,
+ BuildPyramids = 1 << 3,
+ Histogram = 1 << 4,
+ Size = 1 << 5 // has fixed source type
};
// This is modified copy of GDALDataType
Modified: branches/raster-providers/src/core/raster/qgsrasterlayer.cpp
===================================================================
--- branches/raster-providers/src/core/raster/qgsrasterlayer.cpp 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/core/raster/qgsrasterlayer.cpp 2011-02-21 12:15:38 UTC (rev 15231)
@@ -1001,7 +1001,8 @@
QgsDebugMsg( "Checking for provider capability." );
// Some providers were returning QImage directly, not they are passing ARGB data - ARGBDataType
- if ( mDataProvider->capabilities() & QgsRasterDataProvider::Draw )
+ //if ( mDataProvider->capabilities() & QgsRasterDataProvider::Draw )
+ if ( false )
{
// Currently not used
/*
@@ -1100,7 +1101,8 @@
}
*/
}
- else if ( mDataProvider->capabilities() & QgsRasterDataProvider::Data )
+ //else if ( mDataProvider->capabilities() & QgsRasterDataProvider::Data )
+ else
{
// (Otherwise use the old-fashioned GDAL direct-drawing style
// TODO: Move into its own GDAL provider.)
@@ -2388,13 +2390,14 @@
QLibrary* QgsRasterLayer::loadProviderLibrary( QString theProviderKey )
{
- QgsDebugMsg( "Entered" );
+ QgsDebugMsg( "theProviderKey = " + theProviderKey );
// load the plugin
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
- QString ogrlib = pReg->library( theProviderKey );
+ QString myLibPath = pReg->library( theProviderKey );
+ QgsDebugMsg( "myLibPath = " + myLibPath );
#ifdef TESTPROVIDERLIB
- const char *cOgrLib = ( const char * ) ogrlib;
+ const char *cOgrLib = ( const char * ) myLibPath;
// test code to help debug provider loading problems
// void *handle = dlopen(cOgrLib, RTLD_LAZY);
void *handle = dlopen( cOgrLib, RTLD_LAZY | RTLD_GLOBAL );
@@ -2411,7 +2414,7 @@
#endif
// load the data provider
- QLibrary* myLib = new QLibrary( ogrlib );
+ QLibrary* myLib = new QLibrary( myLibPath );
QgsDebugMsg( "Library name is " + myLib->fileName() );
bool loaded = myLib->load();
@@ -4372,7 +4375,7 @@
myGrayVal = 255 - myGrayVal;
}
- QgsDebugMsg( QString( "i = %1 myGrayValue = %2 myGrayVal = %3 myAlphaValue = %4").arg(i).arg( myGrayValue ).arg(myGrayVal).arg(myAlphaValue) );
+ //QgsDebugMsg( QString( "i = %1 myGrayValue = %2 myGrayVal = %3 myAlphaValue = %4").arg(i).arg( myGrayValue ).arg(myGrayVal).arg(myAlphaValue) );
imageScanLine[ i ] = qRgba( myGrayVal, myGrayVal, myGrayVal, myAlphaValue );
}
}
Modified: branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp
===================================================================
--- branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/providers/gdal/qgsgdalprovider.cpp 2011-02-21 12:15:38 UTC (rev 15231)
@@ -918,8 +918,10 @@
int QgsGdalProvider::capabilities() const
{
int capability = QgsRasterDataProvider::Identify
- | QgsRasterDataProvider::Data
- | QgsRasterDataProvider::EstimatedMinimumMaximum;
+ | QgsRasterDataProvider::EstimatedMinimumMaximum
+ | QgsRasterDataProvider::BuildPyramids
+ | QgsRasterDataProvider::Histogram
+ | QgsRasterDataProvider::Size;
return capability;
}
Modified: branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp
===================================================================
--- branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/providers/grass/qgsgrassrasterprovider.cpp 2011-02-21 12:15:38 UTC (rev 15231)
@@ -335,11 +335,16 @@
int QgsGrassRasterProvider::capabilities() const
{
int capability = QgsRasterDataProvider::Identify
- | QgsRasterDataProvider::Data
- | QgsRasterDataProvider::ExactMinimumMaximum;
+ | QgsRasterDataProvider::ExactMinimumMaximum
+ | QgsRasterDataProvider::Size;
return capability;
}
+int QgsGrassRasterProvider::dataType( int bandNo ) const
+{
+ return srcDataType( bandNo );
+}
+
int QgsGrassRasterProvider::srcDataType( int bandNo ) const
{
switch ( mGrassDataType ) {
Modified: branches/raster-providers/src/providers/wms/qgswmsprovider.cpp
===================================================================
--- branches/raster-providers/src/providers/wms/qgswmsprovider.cpp 2011-02-21 10:06:36 UTC (rev 15230)
+++ branches/raster-providers/src/providers/wms/qgswmsprovider.cpp 2011-02-21 12:15:38 UTC (rev 15231)
@@ -996,6 +996,10 @@
mCapabilitiesReply = 0;
}
+int QgsWmsProvider::dataType( int bandNo ) const
+{
+ return srcDataType( bandNo );
+}
int QgsWmsProvider::srcDataType( int bandNo ) const
{
return QgsRasterDataProvider::ARGBDataType;
@@ -2169,8 +2173,7 @@
int QgsWmsProvider::capabilities() const
{
- //int capability = QgsRasterDataProvider::Draw;
- int capability = QgsRasterDataProvider::Data;
+ int capability = NoCapabilities;
bool canIdentify = false;
QgsDebugMsg( "entering." );
More information about the QGIS-commit
mailing list