mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Added progress reporting
This commit is contained in:
parent
d6d2f1a374
commit
515de2879b
@ -73,6 +73,22 @@ class QgsAlignRaster
|
||||
};
|
||||
typedef QList<QgsAlignRaster::Item> List;
|
||||
|
||||
//! Helper struct to be sub-classed for progress reporting
|
||||
struct ProgressHandler
|
||||
{
|
||||
//! Method to be overridden for progress reporting.
|
||||
//! @param complete Overall progress of the alignment operation
|
||||
//! @return false if the execution should be cancelled, true otherwise
|
||||
virtual bool progress( double complete ) = 0;
|
||||
|
||||
virtual ~ProgressHandler();
|
||||
};
|
||||
|
||||
//! Assign a progress handler instance. Does not take ownership. NULL can be passed.
|
||||
void setProgressHandler( ProgressHandler* progressHandler );
|
||||
//! Get associated progress handler. May be NULL (default)
|
||||
ProgressHandler* progressHandler() const;
|
||||
|
||||
//! Set list of rasters that will be aligned
|
||||
void setRasters( const List& list );
|
||||
//! Get list of rasters that will be aligned
|
||||
@ -88,6 +104,11 @@ class QgsAlignRaster
|
||||
//! Get output cell size
|
||||
QSizeF cellSize() const;
|
||||
|
||||
//! Set the output CRS in WKT format
|
||||
void setDestinationCRS( const QString& crsWkt );
|
||||
//! Get the output CRS in WKT format
|
||||
QString destinationCRS() const;
|
||||
|
||||
// TODO: first need to run determineTransformAndSize() before this
|
||||
//QSize rasterSize() const { return QSize(mXSize, mYSize); }
|
||||
// TODO: add method for access to final extent
|
||||
|
@ -56,13 +56,13 @@ static QgsRectangle transform_to_extent( const double* geotransform, double xSiz
|
||||
|
||||
static int CPL_STDCALL _progress( double dfComplete, const char* pszMessage, void* pProgressArg )
|
||||
{
|
||||
QgsAlignRaster* align = ( QgsAlignRaster* ) pProgressArg;
|
||||
Q_UNUSED( align );
|
||||
Q_UNUSED( pszMessage );
|
||||
|
||||
// TODO: report the progress somehow
|
||||
qDebug( "progress %f", dfComplete * 100 );
|
||||
return 1; // 1 = all is well, 0 = user terminated
|
||||
QgsAlignRaster::ProgressHandler* handler = (( QgsAlignRaster* ) pProgressArg )->progressHandler();
|
||||
if ( handler )
|
||||
return handler->progress( dfComplete );
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -110,6 +110,7 @@ static CPLErr rescalePostWarpChunkProcessor( void* pKern, void* pArg )
|
||||
|
||||
|
||||
QgsAlignRaster::QgsAlignRaster()
|
||||
: mProgressHandler( 0 )
|
||||
{
|
||||
mCellSizeX = mCellSizeY = 0;
|
||||
mGridOffsetX = mGridOffsetY = 0;
|
||||
@ -126,7 +127,7 @@ void QgsAlignRaster::setClipExtent( double xmin, double ymin, double xmax, doubl
|
||||
mClipExtent[3] = ymax;
|
||||
}
|
||||
|
||||
void QgsAlignRaster::setClipExtent(const QgsRectangle& extent)
|
||||
void QgsAlignRaster::setClipExtent( const QgsRectangle& extent )
|
||||
{
|
||||
setClipExtent( extent.xMinimum(), extent.yMinimum(),
|
||||
extent.xMaximum(), extent.yMaximum() );
|
||||
@ -332,7 +333,7 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
|
||||
psWarpOptions->eResampleAlg = ( GDALResampleAlg ) raster.resampleMethod;
|
||||
|
||||
// our progress function
|
||||
psWarpOptions->pfnProgress = _progress; //GDALTermProgress;
|
||||
psWarpOptions->pfnProgress = _progress;
|
||||
psWarpOptions->pProgressArg = this;
|
||||
|
||||
// Establish reprojection transformer.
|
||||
|
@ -119,6 +119,22 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
};
|
||||
typedef QList<Item> List;
|
||||
|
||||
//! Helper struct to be sub-classed for progress reporting
|
||||
struct ProgressHandler
|
||||
{
|
||||
//! Method to be overridden for progress reporting.
|
||||
//! @param complete Overall progress of the alignment operation
|
||||
//! @return false if the execution should be cancelled, true otherwise
|
||||
virtual bool progress( double complete ) = 0;
|
||||
|
||||
virtual ~ProgressHandler() {}
|
||||
};
|
||||
|
||||
//! Assign a progress handler instance. Does not take ownership. NULL can be passed.
|
||||
void setProgressHandler( ProgressHandler* progressHandler ) { mProgressHandler = progressHandler; }
|
||||
//! Get associated progress handler. May be NULL (default)
|
||||
ProgressHandler* progressHandler() const { return mProgressHandler; }
|
||||
|
||||
//! Set list of rasters that will be aligned
|
||||
void setRasters( const List& list ) { mRasters = list; }
|
||||
//! Get list of rasters that will be aligned
|
||||
@ -134,6 +150,11 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
//! Get output cell size
|
||||
QSizeF cellSize() const { return QSizeF( mCellSizeX, mCellSizeY ); }
|
||||
|
||||
//! Set the output CRS in WKT format
|
||||
void setDestinationCRS( const QString& crsWkt ) { mCrsWkt = crsWkt.toAscii(); }
|
||||
//! Get the output CRS in WKT format
|
||||
QString destinationCRS() const { return mCrsWkt; }
|
||||
|
||||
// TODO: first need to run determineTransformAndSize() before this
|
||||
//QSize rasterSize() const { return QSize(mXSize, mYSize); }
|
||||
// TODO: add method for access to final extent
|
||||
@ -172,6 +193,9 @@ class ANALYSIS_EXPORT QgsAlignRaster
|
||||
|
||||
// set by the client
|
||||
|
||||
//! Object that facilitates reporting of progress / cancellation
|
||||
ProgressHandler* mProgressHandler;
|
||||
|
||||
//! List of rasters to be aligned (with their output files and other options)
|
||||
List mRasters;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user