Skip to content

Commit

Permalink
QgsRasterBlock::DataType moved to QGis::DataType
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Dec 17, 2012
1 parent e2f9fcd commit d435bfc
Show file tree
Hide file tree
Showing 45 changed files with 338 additions and 337 deletions.
23 changes: 23 additions & 0 deletions python/core/qgis.sip
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ class QGis
//! description strings for feature types
// static const char *qgisFeatureTypes[];

/** Raster data types.
* This is modified and extended copy of GDALDataType.
*/
enum DataType
{
/*! Unknown or unspecified type */ UnknownDataType = 0,
/*! Eight bit unsigned integer (quint8) */ Byte = 1,
/*! Sixteen bit unsigned integer (quint16) */ UInt16 = 2,
/*! Sixteen bit signed integer (qint16) */ Int16 = 3,
/*! Thirty two bit unsigned integer (quint32) */ UInt32 = 4,
/*! Thirty two bit signed integer (qint32) */ Int32 = 5,
/*! Thirty two bit floating point (float) */ Float32 = 6,
/*! Sixty four bit floating point (double) */ Float64 = 7,
/*! Complex Int16 */ CInt16 = 8,
/*! Complex Int32 */ CInt32 = 9,
/*! Complex Float32 */ CFloat32 = 10,
/*! Complex Float64 */ CFloat64 = 11,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32 */ ARGB32 = 12,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32_Premultiplied */ ARGB32_Premultiplied = 13
};

/** Map units that qgis supports
* @note that QGIS < 1.4 api had only Meters, Feet, Degrees and UnknownUnit
* @note and QGIS >1.8 returns to that
Expand Down
39 changes: 8 additions & 31 deletions python/core/raster/qgsrasterblock.sip
Original file line number Diff line number Diff line change
@@ -1,34 +1,11 @@
class QgsRasterBlock
{
%TypeHeaderCode
#include <qgis.h>
#include <qgsrasterblock.h>
%End

public:

/** Data types.
* This is modified and extended copy of GDALDataType.
*/
enum DataType
{
/*! Unknown or unspecified type */ UnknownDataType = 0,
/*! Eight bit unsigned integer */ Byte = 1,
/*! Sixteen bit unsigned integer */ UInt16 = 2,
/*! Sixteen bit signed integer */ Int16 = 3,
/*! Thirty two bit unsigned integer */ UInt32 = 4,
/*! Thirty two bit signed integer */ Int32 = 5,
/*! Thirty two bit floating point */ Float32 = 6,
/*! Sixty four bit floating point */ Float64 = 7,
/*! Complex Int16 */ CInt16 = 8,
/*! Complex Int32 */ CInt32 = 9,
/*! Complex Float32 */ CFloat32 = 10,
/*! Complex Float64 */ CFloat64 = 11,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32 */ ARGB32 = 12,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32_Premultiplied */ ARGB32_Premultiplied = 13
};

struct Range
{
double min;
Expand All @@ -38,11 +15,11 @@ class QgsRasterBlock

QgsRasterBlock();

QgsRasterBlock( DataType theDataType, int theWidth, int theHeight, double theNoDataValue );
QgsRasterBlock( QGis::DataType theDataType, int theWidth, int theHeight, double theNoDataValue );

virtual ~QgsRasterBlock();

bool reset( DataType theDataType, int theWidth, int theHeight, double theNoDataValue );
bool reset( QGis::DataType theDataType, int theWidth, int theHeight, double theNoDataValue );

bool isEmpty() const;

Expand All @@ -51,16 +28,16 @@ class QgsRasterBlock
int dataTypeSize( int bandNo ) const;

/** Returns true if data type is numeric */
bool typeIsNumeric( QgsRasterBlock::DataType type ) const;
bool typeIsNumeric( QGis::DataType type ) const;

/** Returns true if data type is color */
bool typeIsColor( QgsRasterBlock::DataType type ) const;
bool typeIsColor( QGis::DataType type ) const;

/** Returns data type for the band specified by number */
virtual QgsRasterBlock::DataType dataType() const;
virtual QGis::DataType dataType() const;

/** For given data type returns wider type and sets no data value */
static QgsRasterBlock::DataType typeWithNoDataValue( DataType dataType, double *noDataValue );
static QGis::DataType typeWithNoDataValue( QGis::DataType dataType, double *noDataValue );

double noDataValue( ) const;

Expand All @@ -85,7 +62,7 @@ class QgsRasterBlock
//char * bits( size_t index );
static QString printValue( double value );

bool convert( QgsRasterBlock::DataType destDataType );
bool convert( QGis::DataType destDataType );
QImage image() const;
bool setImage( const QImage * image );

Expand Down
6 changes: 3 additions & 3 deletions python/core/raster/qgsrasterdataprovider.sip
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
// TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box

/** Returns data type for the band specified by number */
virtual QgsRasterBlock::DataType dataType( int bandNo ) const = 0;
virtual QGis::DataType dataType( int bandNo ) const = 0;

/** Returns source data type for the band specified by number,
* source data type may be shorter than dataType
*/
virtual QgsRasterBlock::DataType srcDataType( int bandNo ) const = 0;
virtual QGis::DataType srcDataType( int bandNo ) const = 0;

/** Returns data type for the band specified by number */
virtual int colorInterpretation( int theBandNo ) const;
Expand Down Expand Up @@ -350,7 +350,7 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
/** Creates a new dataset with mDataSourceURI
@return true in case of success*/
virtual bool create( const QString& format, int nBands,
QgsRasterBlock::DataType type,
QGis::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions = QStringList() /*e.v. color table*/ );
Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgsrasterinterface.sip
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class QgsRasterInterface
virtual QgsRasterInterface *clone() const = 0 /Factory/;

/** Returns data type for the band specified by number */
virtual QgsRasterBlock::DataType dataType( int bandNo ) const = 0;
virtual QGis::DataType dataType( int bandNo ) const = 0;

int dataTypeSize ( int bandNo );

Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgsrasternuller.sip
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class QgsRasterNuller : QgsRasterInterface

int bandCount() const;

QgsRasterBlock::DataType dataType( int bandNo ) const;
QGis::DataType dataType( int bandNo ) const;

QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) / Factory /;

Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgsrasterrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QgsRasterRenderer : QgsRasterInterface

virtual int bandCount() const;

virtual QgsRasterBlock::DataType dataType( int bandNo ) const;
virtual QGis::DataType dataType( int bandNo ) const;

virtual QString type() const;

Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgsrasterresamplefilter.sip
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class QgsRasterResampleFilter : QgsRasterInterface

int bandCount() const;

QgsRasterBlock::DataType dataType( int bandNo ) const;
QGis::DataType dataType( int bandNo ) const;

bool setInput( QgsRasterInterface* input );

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7355,8 +7355,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
else if ( layer->type() == QgsMapLayer::RasterLayer )
{
const QgsRasterLayer *rlayer = qobject_cast<const QgsRasterLayer *>( layer );
if ( rlayer->dataProvider()->dataType( 1 ) != QgsRasterBlock::ARGB32
&& rlayer->dataProvider()->dataType( 1 ) != QgsRasterBlock::ARGB32_Premultiplied )
if ( rlayer->dataProvider()->dataType( 1 ) != QGis::ARGB32
&& rlayer->dataProvider()->dataType( 1 ) != QGis::ARGB32_Premultiplied )
{
if ( rlayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
{
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ void QgsRasterLayerProperties::sync()
{
QSettings myQSettings;

if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterBlock::ARGB32
|| mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterBlock::ARGB32_Premultiplied )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QGis::ARGB32
|| mRasterLayer->dataProvider()->dataType( 1 ) == QGis::ARGB32_Premultiplied )
{
gboxNoDataValue->setEnabled( false );
gboxCustomTransparency->setEnabled( false );
Expand Down Expand Up @@ -606,8 +606,8 @@ void QgsRasterLayerProperties::sync()
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
}

if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterBlock::ARGB32
|| mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterBlock::ARGB32_Premultiplied )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QGis::ARGB32
|| mRasterLayer->dataProvider()->dataType( 1 ) == QGis::ARGB32_Premultiplied )
{
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
}
Expand Down Expand Up @@ -1060,8 +1060,8 @@ void QgsRasterLayerProperties::setTransparencyCell( int row, int column, double
QString valueString;
switch ( provider->srcDataType( 1 ) )
{
case QgsRasterBlock::Float32:
case QgsRasterBlock::Float64:
case QGis::Float32:
case QGis::Float64:
lineEdit->setValidator( new QDoubleValidator( 0 ) );
if ( !qIsNaN( value ) )
{
Expand Down
24 changes: 24 additions & 0 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ class CORE_EXPORT QGis
//! @note not available in python bindings
static const char *qgisFeatureTypes[];

/** Raster data types.
* This is modified and extended copy of GDALDataType.
*/
enum DataType
{
/*! Unknown or unspecified type */ UnknownDataType = 0,
/*! Eight bit unsigned integer (quint8) */ Byte = 1,
/*! Sixteen bit unsigned integer (quint16) */ UInt16 = 2,
/*! Sixteen bit signed integer (qint16) */ Int16 = 3,
/*! Thirty two bit unsigned integer (quint32) */ UInt32 = 4,
/*! Thirty two bit signed integer (qint32) */ Int32 = 5,
/*! Thirty two bit floating point (float) */ Float32 = 6,
/*! Sixty four bit floating point (double) */ Float64 = 7,
/*! Complex Int16 */ CInt16 = 8,
/*! Complex Int32 */ CInt32 = 9,
/*! Complex Float32 */ CFloat32 = 10,
/*! Complex Float64 */ CFloat64 = 11,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32 */ ARGB32 = 12,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32_Premultiplied */ ARGB32_Premultiplied = 13
};


/** Map units that qgis supports
* @note that QGIS < 1.4 api had only Meters, Feet, Degrees and UnknownUnit
* @note and QGIS >1.8 returns to that
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsmultibandcolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ QgsRasterBlock* QgsMultiBandColorRenderer::block( int bandNo, QgsRectangle cons
alphaBlock = bandBlocks[mAlphaBand];
}

if ( !outputBlock->reset( QgsRasterBlock::ARGB32_Premultiplied, width, height ) )
if ( !outputBlock->reset( QGis::ARGB32_Premultiplied, width, height ) )
{
for ( int i = 0; i < bandBlocks.size(); i++ )
{
Expand Down
8 changes: 4 additions & 4 deletions src/core/raster/qgspalettedrasterrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
}
QRgb myDefaultColor = NODATA_COLOR;

//QgsRasterBlock::DataType transparencyType = QgsRasterBlock::UnknownDataType;
//QGis::DataType transparencyType = QGis::UnknownDataType;
//if ( mAlphaBand > 0 )
//{
// transparencyType = ( QgsRasterBlock::DataType )mInput->dataType( mAlphaBand );
// transparencyType = ( QGis::DataType )mInput->dataType( mAlphaBand );
//}

//QgsRasterBlock::DataType rasterType = ( QgsRasterBlock::DataType )mInput->dataType( mBand );
//QGis::DataType rasterType = ( QGis::DataType )mInput->dataType( mBand );
//void* rasterData = mInput->block( bandNo, extent, width, height );
QgsRasterBlock *inputBlock = mInput->block( bandNo, extent, width, height );

Expand Down Expand Up @@ -164,7 +164,7 @@ QgsRasterBlock * QgsPalettedRasterRenderer::block( int bandNo, QgsRectangle con
alphaBlock = inputBlock;
}

if ( !outputBlock->reset( QgsRasterBlock::ARGB32_Premultiplied, width, height ) )
if ( !outputBlock->reset( QGis::ARGB32_Premultiplied, width, height ) )
{
delete inputBlock;
delete alphaBlock;
Expand Down
Loading

0 comments on commit d435bfc

Please sign in to comment.