22
22
#include " qgsrasterlayer.h"
23
23
#include " qgsrastermatrix.h"
24
24
#include " qgsrasterprojector.h"
25
+ #include " qgsfeedback.h"
25
26
26
- #include < QProgressDialog>
27
27
#include < QFile>
28
28
29
29
#include < cpl_string.h>
@@ -56,7 +56,7 @@ QgsRasterCalculator::QgsRasterCalculator( const QString &formulaString, const QS
56
56
{
57
57
}
58
58
59
- int QgsRasterCalculator::processCalculation ( QProgressDialog *p )
59
+ int QgsRasterCalculator::processCalculation ( QgsFeedback *feedback )
60
60
{
61
61
// prepare search string / tree
62
62
QString errorString;
@@ -117,23 +117,18 @@ int QgsRasterCalculator::processCalculation( QProgressDialog *p )
117
117
float outputNodataValue = -FLT_MAX;
118
118
GDALSetRasterNoDataValue ( outputRasterBand, outputNodataValue );
119
119
120
- if ( p )
121
- {
122
- p->setMaximum ( mNumOutputRows );
123
- }
124
-
125
120
QgsRasterMatrix resultMatrix;
126
121
resultMatrix.setNodataValue ( outputNodataValue );
127
122
128
123
// read / write line by line
129
124
for ( int i = 0 ; i < mNumOutputRows ; ++i )
130
125
{
131
- if ( p )
126
+ if ( feedback )
132
127
{
133
- p-> setValue ( i );
128
+ feedback-> setProgress ( 100.0 * static_cast < double >( i ) / mNumOutputRows );
134
129
}
135
130
136
- if ( p && p-> wasCanceled () )
131
+ if ( feedback && feedback-> isCanceled () )
137
132
{
138
133
break ;
139
134
}
@@ -159,17 +154,17 @@ int QgsRasterCalculator::processCalculation( QProgressDialog *p )
159
154
160
155
}
161
156
162
- if ( p )
157
+ if ( feedback )
163
158
{
164
- p-> setValue ( mNumOutputRows );
159
+ feedback-> setProgress ( 100.0 );
165
160
}
166
161
167
162
// close datasets and release memory
168
163
delete calcNode;
169
164
qDeleteAll ( inputBlocks );
170
165
inputBlocks.clear ();
171
166
172
- if ( p && p-> wasCanceled () )
167
+ if ( feedback && feedback-> isCanceled () )
173
168
{
174
169
// delete the dataset without closing (because it is faster)
175
170
GDALDeleteDataset ( outputDriver, mOutputFile .toUtf8 ().constData () );
0 commit comments