@@ -3728,18 +3728,18 @@ QString QgsRasterLayer::buildPyramids(RasterPyramidList const & theRasterPyramid
3728
3728
if (theResamplingMethod==tr (" Average Magphase" ))
3729
3729
{
3730
3730
myError = GDALBuildOverviews ( mGdalDataset , " MODE" , 1 , myOverviewLevelsArray, 0 , NULL ,
3731
- GDALDummyProgress, NULL );
3731
+ progressCallback, this ); // this is the arg for the gdal progress callback
3732
3732
}
3733
3733
else if (theResamplingMethod==tr (" Average" ))
3734
3734
3735
3735
{
3736
3736
myError = GDALBuildOverviews ( mGdalDataset , " AVERAGE" , 1 , myOverviewLevelsArray, 0 , NULL ,
3737
- GDALDummyProgress, NULL );
3737
+ progressCallback, this ); // this is the arg for the gdal progress callback
3738
3738
}
3739
3739
else // fall back to nearest neighbor
3740
3740
{
3741
3741
myError = GDALBuildOverviews ( mGdalDataset , " NEAREST" , 1 , myOverviewLevelsArray, 0 , NULL ,
3742
- GDALDummyProgress, NULL );
3742
+ progressCallback, this ); // this is the arg for the gdal progress callback
3743
3743
}
3744
3744
if (myError == CE_Failure || CPLGetLastErrorNo ()==CPLE_NotSupported )
3745
3745
{
@@ -4749,7 +4749,10 @@ void QgsRasterLayer::populateHistogram(int theBandNo, int theBinCount,bool theIg
4749
4749
* )
4750
4750
*/
4751
4751
double myerval = (myRasterBandStats.maxVal -myRasterBandStats.minVal )/theBinCount;
4752
- GDALGetRasterHistogram ( myGdalBand, myRasterBandStats.minVal -0.1 *myerval, myRasterBandStats.maxVal +0.1 *myerval, theBinCount, myHistogramArray ,theIgnoreOutOfRangeFlag ,theHistogramEstimatedFlag , GDALDummyProgress, NULL );
4752
+ GDALGetRasterHistogram ( myGdalBand, myRasterBandStats.minVal -0.1 *myerval,
4753
+ myRasterBandStats.maxVal +0.1 *myerval, theBinCount, myHistogramArray
4754
+ ,theIgnoreOutOfRangeFlag ,theHistogramEstimatedFlag , progressCallback,
4755
+ this ); // this is the arg for our custome gdal progress callback
4753
4756
4754
4757
for (int myBin = 0 ; myBin <theBinCount; myBin++)
4755
4758
{
@@ -5219,3 +5222,53 @@ void QgsRasterLayer::setContrastEnhancementAlgorithm(QString theAlgorithm, bool
5219
5222
setContrastEnhancementAlgorithm (QgsContrastEnhancement::NO_STRETCH, theGenerateLookupTableFlag);
5220
5223
}
5221
5224
}
5225
+
5226
+ void QgsRasterLayer::showProgress (int theValue)
5227
+ {
5228
+ emit progressUpdate (theValue);
5229
+ }
5230
+ //
5231
+ // global callback function
5232
+ //
5233
+ int CPL_STDCALL progressCallback ( double dfComplete,
5234
+ const char * pszMessage,
5235
+ void * pProgressArg)
5236
+ {
5237
+ static double dfLastComplete = -1.0 ;
5238
+
5239
+ QgsRasterLayer * mypLayer = (QgsRasterLayer *) pProgressArg;
5240
+
5241
+ if ( dfLastComplete > dfComplete )
5242
+ {
5243
+ if ( dfLastComplete >= 1.0 )
5244
+ dfLastComplete = -1.0 ;
5245
+ else
5246
+ dfLastComplete = dfComplete;
5247
+ }
5248
+
5249
+ if ( floor (dfLastComplete*10 ) != floor (dfComplete*10 ) )
5250
+ {
5251
+ int nPercent = (int ) floor (dfComplete*100 );
5252
+
5253
+ if ( nPercent == 0 && pszMessage != NULL )
5254
+ {
5255
+ // fprintf( stdout, "%s:", pszMessage );
5256
+ }
5257
+
5258
+ if ( nPercent == 100 )
5259
+ {
5260
+ // fprintf( stdout, "%d - done.\n", (int) floor(dfComplete*100) );
5261
+ mypLayer->showProgress (100 );
5262
+ }
5263
+ else
5264
+ {
5265
+ int myProgress = (int ) floor (dfComplete*100 );
5266
+ // fprintf( stdout, "%d.", myProgress);
5267
+ mypLayer->showProgress (myProgress);
5268
+ // fflush( stdout );
5269
+ }
5270
+ }
5271
+ dfLastComplete = dfComplete;
5272
+
5273
+ return TRUE ;
5274
+ }
0 commit comments