Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
merged raster-providers branch r15390
git-svn-id: http://svn.osgeo.org/qgis/trunk@15392 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Mar 8, 2011
1 parent 5bae2ab commit 3109508
Show file tree
Hide file tree
Showing 27 changed files with 4,593 additions and 2,404 deletions.
6 changes: 3 additions & 3 deletions python/core/qgscoordinatetransform.sip
Expand Up @@ -64,7 +64,7 @@ class QgsCoordinateTransform : QObject
* Set the source (layer) QgsCoordinateReferenceSystem
* @param theCRS QgsCoordinateReferenceSystem representation of the layer's coordinate system
*/
void setSourceCrs(const QgsCoordinateReferenceSystem& theCRS);
void setSourceCrs( const QgsCoordinateReferenceSystem& theCRS );

/*!
* Mutator for dest QgsCoordinateReferenceSystem
Expand All @@ -76,13 +76,13 @@ class QgsCoordinateTransform : QObject
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
*/
QgsCoordinateReferenceSystem& sourceCrs();
const QgsCoordinateReferenceSystem& sourceCrs();

/*!
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
* @return QgsCoordinateReferenceSystem of the map canvas coordinate system
*/
QgsCoordinateReferenceSystem& destCRS();
const QgsCoordinateReferenceSystem& destCRS();

/*! Transform the point from Source Coordinate System to Destination Coordinate System
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
Expand Down
29 changes: 19 additions & 10 deletions python/core/qgsrasterviewport.sip
Expand Up @@ -7,36 +7,36 @@ struct QgsRasterViewPort

/** \brief The offset from the left hand edge of the raster for the rectangle that will be drawn to screen.
* TODO Check this explanation is correc!*/
int rectXOffset;
float rectXOffsetFloat;
//int rectXOffset;
//float rectXOffsetFloat;
/** \brief The offset from the bottom edge of the raster for the rectangle that will be drawn to screen.
* TODO Check this explanation is correc!*/
int rectYOffset;
float rectYOffsetFloat;
//int rectYOffset;
//float rectYOffsetFloat;
/** \brief Lower left X dimension of clipped raster image in raster pixel space.
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
* whatever the screen coordinates are (e.g. a 600x800 display window) */
double clippedXMin;
//double clippedXMin;
/** \brief Top Right X dimension of clipped raster image in raster pixel space.
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
* whatever the screen coordinates are (e.g. a 600x800 display window) */
double clippedXMax;
//double clippedXMax;
/** \brief Lower left Y dimension of clipped raster image in raster pixel space.
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
* whatever the screen coordinates are (e.g. a 600x800 display window) */
double clippedYMin;
//double clippedYMin;
/** \brief Top Right X dimension of clipped raster image in raster pixel space.
* RasterIO will do the scaling for us, so for example, if the user is zoomed in a long way, there may only
* be e.g. 5x5 pixels retrieved from the raw raster data, but rasterio will seamlessly scale the up to
* whatever the screen coordinates are (e.g. a 600x800 display window) */
double clippedYMax;
//double clippedYMax;
/** \brief Distance in pixels from clippedXMin to clippedXMax. */
int clippedWidth;
//int clippedWidth;
/** \brief Distance in pixels from clippedYMin to clippedYMax */
int clippedHeight;
//int clippedHeight;
/** \brief Coordinate (in geographic coordinate system) of top left corner of the part of the raster that
* is to be rendered.*/
QgsPoint topLeftPoint;
Expand All @@ -49,5 +49,14 @@ struct QgsRasterViewPort
/** \brief Distance in map units from bottom edge to top edge for the part of the raster that
* is to be rendered.*/
int drawableAreaYDim;

// intersection of current map extent and layer extent
QgsRectangle mDrawnExtent;

// Source coordinate system
QgsCoordinateReferenceSystem mSrcCRS;

// Target coordinate system
QgsCoordinateReferenceSystem mDestCRS;
};

138 changes: 75 additions & 63 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -71,8 +71,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
mGrayMinimumMaximumEstimated = true;
mRGBMinimumMaximumEstimated = true;

mRasterLayerIsInternal = mRasterLayer->dataProvider() == 0;

setupUi( this );
connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) );
Expand Down Expand Up @@ -218,7 +216,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv


// 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;
Expand Down Expand Up @@ -518,19 +516,25 @@ void QgsRasterLayerProperties::sync()
break;
}

if ( !mRasterLayerIsInternal )
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
{
delete tabPageSymbology;
delete tabPageColormap;
delete tabPagePyramids;
delete tabPageHistogram;

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 )
{
Expand Down Expand Up @@ -558,35 +562,38 @@ void QgsRasterLayerProperties::sync()
//
// 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 )
{
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" ) ) );
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 )
{
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::UserDefinedShader )
else
{
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "User Defined" ) ) );
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Grayscale" ) ) );
}
}
else if ( mRasterLayerIsInternal )
{
cboxColorMap->setCurrentIndex( cboxColorMap->findText( tr( "Grayscale" ) ) );
}

if ( mRasterLayerIsInternal )
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
{
if ( rbtnThreeBand->isChecked() )
{
Expand Down Expand Up @@ -774,10 +781,24 @@ void QgsRasterLayerProperties::sync()
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() ) );
Expand All @@ -787,13 +808,6 @@ void QgsRasterLayerProperties::sync()
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() );
Expand Down Expand Up @@ -824,12 +838,12 @@ void QgsRasterLayerProperties::sync()
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;
}
Expand Down Expand Up @@ -921,7 +935,7 @@ bool QgsRasterLayerProperties::validUserDefinedMinMax()
*/
void QgsRasterLayerProperties::apply()
{
if ( mRasterLayerIsInternal )
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
{
QgsDebugMsg( "apply processing symbology tab" );
/*
Expand Down Expand Up @@ -1411,7 +1425,7 @@ void QgsRasterLayerProperties::apply()
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() )
{
Expand Down Expand Up @@ -1581,7 +1595,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()

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 ) ) );
Expand All @@ -1590,7 +1604,7 @@ void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged( const QString& th

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 ) ) );
Expand All @@ -1599,7 +1613,7 @@ void QgsRasterLayerProperties::on_cboGray_currentIndexChanged( const QString& th

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 ) ) );
Expand All @@ -1608,7 +1622,7 @@ void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged( const QString& t

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 ) ) );
Expand Down Expand Up @@ -1654,8 +1668,10 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()

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" ) )
{
Expand Down Expand Up @@ -2570,10 +2586,9 @@ void QgsRasterLayerProperties::on_pbtnLoadColorMapFromFile_clicked()

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];
Expand Down Expand Up @@ -2994,16 +3009,13 @@ void QgsPixelSelectorTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
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();
}
}
2 changes: 1 addition & 1 deletion src/app/qgsrasterlayerproperties.h
Expand Up @@ -185,7 +185,7 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
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>& );
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -76,6 +76,7 @@ SET(QGIS_CORE_SRCS
qgsproviderextentcalcevent.cpp
qgsprovidermetadata.cpp
qgsproviderregistry.cpp
qgsrasterprojector.cpp
qgsrasterdataprovider.cpp
qgsrendercontext.cpp
qgsrectangle.cpp
Expand Down Expand Up @@ -408,6 +409,7 @@ SET(QGIS_CORE_HDRS
qgsproviderextentcalcevent.h
qgsprovidermetadata.h
qgsproviderregistry.h
qgsrasterprojector.h
qgsrasterdataprovider.h
qgsrectangle.h
qgsrendercontext.h
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscoordinatetransform.h
Expand Up @@ -111,13 +111,13 @@ class CORE_EXPORT QgsCoordinateTransform: public QObject
* Get the QgsCoordinateReferenceSystem representation of the layer's coordinate system
* @return QgsCoordinateReferenceSystem of the layer's coordinate system
*/
QgsCoordinateReferenceSystem& sourceCrs() { return mSourceCRS; }
const QgsCoordinateReferenceSystem& sourceCrs() const { return mSourceCRS; }

/*!
* Get the QgsCoordinateReferenceSystem representation of the map canvas coordinate system
* @return QgsCoordinateReferenceSystem of the map canvas coordinate system
*/
QgsCoordinateReferenceSystem& destCRS() { return mDestCRS; }
const QgsCoordinateReferenceSystem& destCRS() const { return mDestCRS; }

/*! Transform the point from Source Coordinate System to Destination Coordinate System
* If the direction is ForwardTransform then coordinates are transformed from layer CS --> map canvas CS,
Expand Down

0 comments on commit 3109508

Please sign in to comment.