~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/plugins/interpolation/qgsinterpolationdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/***************************************************************************
 
3
                              qgsinterpolationdialog.cpp
 
4
                              --------------------------
 
5
  begin                : Marco 10, 2008
 
6
  copyright            : (C) 2008 by Marco Hugentobler
 
7
  email                : marco dot hugentobler at karto dot baug dot ethz dot ch
 
8
 ***************************************************************************/
 
9
 
 
10
/***************************************************************************
 
11
 *                                                                         *
 
12
 *   This program is free software; you can redistribute it and/or modify  *
 
13
 *   it under the terms of the GNU General Public License as published by  *
 
14
 *   the Free Software Foundation; either version 2 of the License, or     *
 
15
 *   (at your option) any later version.                                   *
 
16
 *                                                                         *
 
17
 ***************************************************************************/
 
18
 
 
19
#include "qgsinterpolationdialog.h"
 
20
#include "qgsinterpolatordialog.h"
 
21
#include "qgsfield.h"
 
22
#include "qgsgridfilewriter.h"
 
23
#include "qgsidwinterpolatordialog.h"
 
24
#include "qgstininterpolatordialog.h"
 
25
#include "qgsmapcanvas.h"
 
26
#include "qgsmaplayerregistry.h"
 
27
#include "qgsvectordataprovider.h"
 
28
#include "qgsvectorlayer.h"
 
29
#include <QComboBox>
 
30
#include <QFileDialog>
 
31
#include <QMessageBox>
 
32
#include <QSettings>
 
33
 
 
34
 
 
35
QgsInterpolationDialog::QgsInterpolationDialog( QWidget* parent, QgisInterface* iface ): QDialog( parent ), mIface( iface ), mInterpolatorDialog( 0 )
 
36
{
 
37
  setupUi( this );
 
38
 
 
39
  //enter available layers into the combo box
 
40
  QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
 
41
  QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();
 
42
 
 
43
  for ( ; layer_it != mapLayers.end(); ++layer_it )
 
44
  {
 
45
    QgsVectorLayer* vl = qobject_cast<QgsVectorLayer *>( layer_it.value() );
 
46
    if ( vl )
 
47
    {
 
48
      mInputLayerComboBox->insertItem( 0, vl->name() );
 
49
    }
 
50
  }
 
51
 
 
52
  //default resolution 300 * 300
 
53
  mNumberOfColumnsSpinBox->setValue( 300 );
 
54
  mNumberOfRowsSpinBox->setValue( 300 );
 
55
 
 
56
  //only inverse distance weighting available for now
 
57
  mInterpolationMethodComboBox->insertItem( 0, tr( "Triangular interpolation (TIN)" ) );
 
58
  mInterpolationMethodComboBox->insertItem( 1, tr( "Inverse Distance Weighting (IDW)" ) );
 
59
 
 
60
  enableOrDisableOkButton();
 
61
}
 
62
 
 
63
QgsInterpolationDialog::~QgsInterpolationDialog()
 
64
{
 
65
 
 
66
}
 
67
 
 
68
void QgsInterpolationDialog::enableOrDisableOkButton()
 
69
{
 
70
  bool enabled = true;
 
71
 
 
72
  //no input data
 
73
  if ( mLayersTreeWidget->topLevelItemCount() < 1 )
 
74
  {
 
75
    enabled = false;
 
76
  }
 
77
  else
 
78
  {
 
79
    QString fileName = mOutputFileLineEdit->text();
 
80
    QFileInfo theFileInfo( fileName );
 
81
    if ( fileName.isEmpty() || !theFileInfo.dir().exists() )
 
82
    {
 
83
      enabled = false;
 
84
    }
 
85
  }
 
86
 
 
87
  buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
 
88
}
 
89
 
 
90
void QgsInterpolationDialog::on_buttonBox_accepted()
 
91
{
 
92
  if ( !mInterpolatorDialog )
 
93
  {
 
94
    return;
 
95
  }
 
96
 
 
97
  QgsRectangle outputBBox = currentBoundingBox();
 
98
  if ( outputBBox.isEmpty() )
 
99
  {
 
100
    return;
 
101
  }
 
102
 
 
103
  //warn the user if there isn't any input layer
 
104
  if ( mLayersTreeWidget->topLevelItemCount() < 1 )
 
105
  {
 
106
    QMessageBox::information( 0, tr( "No input data for interpolation" ), tr( "Please add one or more input layers" ) );
 
107
    return;
 
108
  }
 
109
 
 
110
  //read file name
 
111
  QString fileName = mOutputFileLineEdit->text();
 
112
  QFileInfo theFileInfo( fileName );
 
113
  if ( fileName.isEmpty() || !theFileInfo.dir().exists() )
 
114
  {
 
115
    QMessageBox::information( 0, tr( "Output file name invalid" ), tr( "Please enter a valid output file name" ) );
 
116
    return;
 
117
  }
 
118
 
 
119
  //add .asc suffix if the user did not provider it already
 
120
  QString suffix = theFileInfo.suffix();
 
121
  if ( suffix.isEmpty() )
 
122
  {
 
123
    fileName.append( ".asc" );
 
124
  }
 
125
 
 
126
  int nLayers = mLayersTreeWidget->topLevelItemCount();
 
127
  QList< QgsInterpolator::LayerData > inputLayerList;
 
128
 
 
129
  for ( int i = 0; i < nLayers; ++i )
 
130
  {
 
131
    QString layerName = mLayersTreeWidget->topLevelItem( i )->text( 0 );
 
132
    QgsVectorLayer* theVectorLayer = vectorLayerFromName( layerName );
 
133
    if ( !theVectorLayer )
 
134
    {
 
135
      continue;
 
136
    }
 
137
 
 
138
    QgsVectorDataProvider* theProvider = theVectorLayer->dataProvider();
 
139
    if ( !theProvider )
 
140
    {
 
141
      continue;
 
142
    }
 
143
 
 
144
    QgsInterpolator::LayerData currentLayerData;
 
145
    currentLayerData.vectorLayer = theVectorLayer;
 
146
 
 
147
    QString interpolationAttString = mLayersTreeWidget->topLevelItem( i )->text( 1 );
 
148
    if ( interpolationAttString == "Z_COORD" )
 
149
    {
 
150
      currentLayerData.zCoordInterpolation = true;
 
151
      currentLayerData.interpolationAttribute = -1;
 
152
    }
 
153
    else
 
154
    {
 
155
      currentLayerData.zCoordInterpolation = false;
 
156
      int attributeIndex = theProvider->fieldNameIndex( interpolationAttString );
 
157
      currentLayerData.interpolationAttribute = attributeIndex;
 
158
    }
 
159
 
 
160
    //type (point/structure line/ breakline)
 
161
    QComboBox* itemCombo = qobject_cast<QComboBox *>( mLayersTreeWidget->itemWidget( mLayersTreeWidget->topLevelItem( i ), 2 ) );
 
162
    if ( itemCombo )
 
163
    {
 
164
      QString typeString = itemCombo->currentText();
 
165
      if ( typeString == tr( "Break lines" ) )
 
166
      {
 
167
        currentLayerData.mInputType = QgsInterpolator::BREAK_LINES;
 
168
      }
 
169
      else if ( typeString == tr( "Structure lines" ) )
 
170
      {
 
171
        currentLayerData.mInputType = QgsInterpolator::STRUCTURE_LINES;
 
172
      }
 
173
      else //Points
 
174
      {
 
175
        currentLayerData.mInputType = QgsInterpolator::POINTS;
 
176
      }
 
177
    }
 
178
    else
 
179
    {
 
180
      currentLayerData.mInputType = QgsInterpolator::POINTS;
 
181
    }
 
182
    inputLayerList.push_back( currentLayerData );
 
183
  }
 
184
 
 
185
  mInterpolatorDialog->setInputData( inputLayerList );
 
186
  QgsInterpolator* theInterpolator = mInterpolatorDialog->createInterpolator();
 
187
 
 
188
  if ( !theInterpolator )
 
189
  {
 
190
    return;
 
191
  }
 
192
 
 
193
  //create grid file writer
 
194
  QgsGridFileWriter theWriter( theInterpolator, fileName, outputBBox, mNumberOfColumnsSpinBox->value(), \
 
195
                               mNumberOfRowsSpinBox->value(), mCellsizeXSpinBox->value(), mCellSizeYSpinBox->value() );
 
196
  if ( theWriter.writeFile( true ) == 0 )
 
197
  {
 
198
    mIface->addRasterLayer( fileName, "Interpolation" );
 
199
    accept();
 
200
  }
 
201
 
 
202
  delete theInterpolator;
 
203
}
 
204
 
 
205
void QgsInterpolationDialog::on_mInputLayerComboBox_currentIndexChanged( const QString& text )
 
206
{
 
207
  mInterpolationAttributeComboBox->clear();
 
208
  mUseZCoordCheckBox->setEnabled( false );
 
209
 
 
210
  //get current vector layer
 
211
  QString currentComboText = mInputLayerComboBox->currentText();
 
212
  QgsVectorLayer* theVectorLayer = vectorLayerFromName( currentComboText );
 
213
 
 
214
  if ( !theVectorLayer )
 
215
  {
 
216
    return;
 
217
  }
 
218
 
 
219
  QgsVectorDataProvider* provider = theVectorLayer->dataProvider();
 
220
  if ( !provider )
 
221
  {
 
222
    return;
 
223
  }
 
224
 
 
225
  //find out if the layer has 25D type
 
226
  QGis::WkbType geomType = provider->geometryType();
 
227
  if ( geomType == QGis::WKBPoint25D ||
 
228
       geomType == QGis::WKBLineString25D ||
 
229
       geomType == QGis::WKBPolygon25D ||
 
230
       geomType == QGis::WKBMultiPoint25D ||
 
231
       geomType == QGis::WKBMultiLineString25D ||
 
232
       geomType == QGis::WKBMultiPolygon25D )
 
233
  {
 
234
    mUseZCoordCheckBox->setEnabled( true );
 
235
  }
 
236
 
 
237
  //insert numeric attributes of layer into mInterpolationAttributesComboBox
 
238
  const QgsFieldMap& fields = provider->fields();
 
239
  QgsFieldMap::const_iterator field_it = fields.constBegin();
 
240
  for ( ; field_it != fields.constEnd(); ++field_it )
 
241
  {
 
242
    QgsField currentField = field_it.value();
 
243
    QVariant::Type currentType = currentField.type();
 
244
    if ( currentType == QVariant::Int || currentType == QVariant::Double )
 
245
    {
 
246
      mInterpolationAttributeComboBox->insertItem( 0, currentField.name() );
 
247
    }
 
248
  }
 
249
}
 
250
 
 
251
void QgsInterpolationDialog::on_mAddPushButton_clicked()
 
252
{
 
253
  //read active layer in mInputLayerComboBox
 
254
  QString inputLayer = mInputLayerComboBox->currentText();
 
255
 
 
256
  //read attribute / z-coordinate interpolation
 
257
  QString interpolationAttribute;
 
258
  if ( mUseZCoordCheckBox->checkState() == Qt::Checked )
 
259
  {
 
260
    interpolationAttribute = "Z_COORD";
 
261
  }
 
262
  else
 
263
  {
 
264
    interpolationAttribute = mInterpolationAttributeComboBox->currentText();
 
265
  }
 
266
 
 
267
  QTreeWidgetItem* newLayerItem = new QTreeWidgetItem();
 
268
  newLayerItem->setText( 0, inputLayer );
 
269
  newLayerItem->setText( 1, interpolationAttribute );
 
270
 
 
271
  mLayersTreeWidget->addTopLevelItem( newLayerItem );
 
272
  QComboBox* typeComboBox = new QComboBox();
 
273
  typeComboBox->addItem( tr( "Points" ) );
 
274
  typeComboBox->addItem( tr( "Structure lines" ) );
 
275
  typeComboBox->addItem( tr( "Break lines" ) );
 
276
  typeComboBox->setCurrentIndex( 0 );
 
277
  mLayersTreeWidget->setItemWidget( newLayerItem, 2, typeComboBox );
 
278
 
 
279
  //keep bounding box up to date
 
280
  setLayersBoundingBox();
 
281
 
 
282
  enableOrDisableOkButton();
 
283
}
 
284
 
 
285
void QgsInterpolationDialog::on_mRemovePushButton_clicked()
 
286
{
 
287
  QTreeWidgetItem* currentItem = mLayersTreeWidget->currentItem();
 
288
  if ( !currentItem )
 
289
  {
 
290
    return;
 
291
  }
 
292
  delete currentItem;
 
293
  enableOrDisableOkButton();
 
294
}
 
295
 
 
296
 
 
297
void QgsInterpolationDialog::on_mOutputFileButton_clicked()
 
298
{
 
299
  //get last output file dir
 
300
  QSettings s;
 
301
  QString lastOutputDir = s.value( "/Interpolation/lastOutputDir", "" ).toString();
 
302
 
 
303
  QString rasterFileName = QFileDialog::getSaveFileName( 0, tr( "Save interpolated raster as..." ), lastOutputDir );
 
304
  if ( !rasterFileName.isEmpty() )
 
305
  {
 
306
    mOutputFileLineEdit->setText( rasterFileName );
 
307
    QFileInfo rasterFileInfo( rasterFileName );
 
308
    QDir fileDir = rasterFileInfo.absoluteDir();
 
309
    if ( fileDir.exists() )
 
310
    {
 
311
      s.setValue( "/Interpolation/lastOutputDir", rasterFileInfo.absolutePath() );
 
312
    }
 
313
  }
 
314
  enableOrDisableOkButton();
 
315
}
 
316
 
 
317
void QgsInterpolationDialog::on_mOutputFileLineEdit_textChanged()
 
318
{
 
319
  if ( mOutputFileLineEdit->text().endsWith( ".asc" ) )
 
320
  {
 
321
    enableOrDisableOkButton();
 
322
  }
 
323
}
 
324
 
 
325
void QgsInterpolationDialog::on_mConfigureInterpolationButton_clicked()
 
326
{
 
327
  if ( mInterpolatorDialog )
 
328
  {
 
329
    mInterpolatorDialog->exec();
 
330
  }
 
331
}
 
332
 
 
333
QgsVectorLayer* QgsInterpolationDialog::vectorLayerFromName( const QString& name )
 
334
{
 
335
  QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
 
336
  QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();
 
337
 
 
338
  for ( ; layer_it != mapLayers.end(); ++layer_it )
 
339
  {
 
340
    if ( layer_it.value()->name() == name )
 
341
    {
 
342
      return qobject_cast<QgsVectorLayer *>( layer_it.value() );
 
343
      break;
 
344
    }
 
345
  }
 
346
 
 
347
  return 0;
 
348
}
 
349
 
 
350
void QgsInterpolationDialog::on_mInterpolationMethodComboBox_currentIndexChanged( const QString &text )
 
351
{
 
352
  delete mInterpolatorDialog;
 
353
  if ( text == tr( "Inverse Distance Weighting (IDW)" ) )
 
354
  {
 
355
    mInterpolatorDialog = new QgsIDWInterpolatorDialog( 0, mIface );
 
356
  }
 
357
  else if ( text == tr( "Triangular interpolation (TIN)" ) )
 
358
  {
 
359
    mInterpolatorDialog = new QgsTINInterpolatorDialog( 0, mIface );
 
360
  }
 
361
}
 
362
 
 
363
void QgsInterpolationDialog::on_mNumberOfColumnsSpinBox_valueChanged( int value )
 
364
{
 
365
  setNewCellsizeXOnNColumnsChange();
 
366
}
 
367
 
 
368
void QgsInterpolationDialog::on_mNumberOfRowsSpinBox_valueChanged( int value )
 
369
{
 
370
  setNewCellsizeYOnNRowschange();
 
371
}
 
372
 
 
373
void QgsInterpolationDialog::on_mCellsizeXSpinBox_valueChanged( double value )
 
374
{
 
375
  setNColsOnCellsizeXChange();
 
376
}
 
377
 
 
378
void QgsInterpolationDialog::on_mCellSizeYSpinBox_valueChanged( double value )
 
379
{
 
380
  setNRowsOnCellsizeYChange();
 
381
}
 
382
 
 
383
void QgsInterpolationDialog::on_mXMinLineEdit_textEdited( const QString& text )
 
384
{
 
385
  setNewCellsizeOnBoundingBoxChange();
 
386
}
 
387
 
 
388
void QgsInterpolationDialog::on_mXMaxLineEdit_textEdited( const QString& text )
 
389
{
 
390
  setNewCellsizeOnBoundingBoxChange();
 
391
}
 
392
 
 
393
void QgsInterpolationDialog::on_mYMinLineEdit_textEdited( const QString& text )
 
394
{
 
395
  setNewCellsizeOnBoundingBoxChange();
 
396
}
 
397
 
 
398
void QgsInterpolationDialog::on_mYMaxLineEdit_textEdited( const QString& text )
 
399
{
 
400
  setNewCellsizeOnBoundingBoxChange();
 
401
}
 
402
 
 
403
void QgsInterpolationDialog::on_mBBoxToCurrentExtent_clicked()
 
404
{
 
405
  if ( mIface )
 
406
  {
 
407
    QgsMapCanvas* canvas = mIface->mapCanvas();
 
408
    if ( canvas )
 
409
    {
 
410
      QgsRectangle extent = canvas->extent();
 
411
      mXMinLineEdit->setText( QString::number( extent.xMinimum() ) );
 
412
      mXMaxLineEdit->setText( QString::number( extent.xMaximum() ) );
 
413
      mYMinLineEdit->setText( QString::number( extent.yMinimum() ) );
 
414
      mYMaxLineEdit->setText( QString::number( extent.yMaximum() ) );
 
415
      setNewCellsizeOnBoundingBoxChange();
 
416
    }
 
417
  }
 
418
}
 
419
 
 
420
QgsRectangle QgsInterpolationDialog::boundingBoxOfLayers()
 
421
{
 
422
  int nLayers = mLayersTreeWidget->topLevelItemCount();
 
423
  QList< QgsInterpolator::LayerData > inputLayerList;
 
424
  QgsRectangle combinedLayerExtent;
 
425
 
 
426
  for ( int i = 0; i < nLayers; ++i )
 
427
  {
 
428
    QString layerName = mLayersTreeWidget->topLevelItem( i )->text( 0 );
 
429
    QgsVectorLayer* theVectorLayer = vectorLayerFromName( layerName );
 
430
    if ( !theVectorLayer )
 
431
    {
 
432
      continue;
 
433
    }
 
434
 
 
435
    QgsVectorDataProvider* theProvider = theVectorLayer->dataProvider();
 
436
    if ( !theProvider )
 
437
    {
 
438
      continue;
 
439
    }
 
440
 
 
441
    //update extent
 
442
    QgsRectangle currentLayerExtent = theVectorLayer->extent();
 
443
    if ( combinedLayerExtent.isEmpty() )
 
444
    {
 
445
      combinedLayerExtent = currentLayerExtent;
 
446
    }
 
447
    else
 
448
    {
 
449
      combinedLayerExtent.combineExtentWith( &currentLayerExtent );
 
450
    }
 
451
  }
 
452
  return combinedLayerExtent;
 
453
}
 
454
 
 
455
void QgsInterpolationDialog::setLayersBoundingBox()
 
456
{
 
457
  QgsRectangle layersBoundingBox = boundingBoxOfLayers();
 
458
  mXMinLineEdit->setText( QString::number( layersBoundingBox.xMinimum() ) );
 
459
  mXMaxLineEdit->setText( QString::number( layersBoundingBox.xMaximum() ) );
 
460
  mYMinLineEdit->setText( QString::number( layersBoundingBox.yMinimum() ) );
 
461
  mYMaxLineEdit->setText( QString::number( layersBoundingBox.yMaximum() ) );
 
462
  setNewCellsizeOnBoundingBoxChange();
 
463
}
 
464
 
 
465
void QgsInterpolationDialog::setNewCellsizeOnBoundingBoxChange()
 
466
{
 
467
  QgsRectangle currentBbox = currentBoundingBox();
 
468
  if ( currentBbox.isEmpty() )
 
469
  {
 
470
    return;
 
471
  }
 
472
 
 
473
  if ( currentBbox.width() > 0 && mNumberOfColumnsSpinBox->value() > 0 )
 
474
  {
 
475
    mCellsizeXSpinBox->blockSignals( true );
 
476
    mCellsizeXSpinBox->setValue( currentBbox.width() / mNumberOfColumnsSpinBox->value() );
 
477
    mCellsizeXSpinBox->blockSignals( false );
 
478
  }
 
479
  if ( currentBbox.height() > 0 && mNumberOfRowsSpinBox->value() > 0 )
 
480
  {
 
481
    mCellSizeYSpinBox->blockSignals( true );
 
482
    mCellSizeYSpinBox->setValue( currentBbox.height() / mNumberOfRowsSpinBox->value() );
 
483
    mCellSizeYSpinBox->blockSignals( false );
 
484
  }
 
485
}
 
486
 
 
487
void QgsInterpolationDialog::setNewCellsizeXOnNColumnsChange()
 
488
{
 
489
  QgsRectangle currentBBox = currentBoundingBox();
 
490
  if ( !currentBBox.isEmpty() && mNumberOfColumnsSpinBox->value() > 0 )
 
491
  {
 
492
    mCellsizeXSpinBox->blockSignals( true );
 
493
    mCellsizeXSpinBox->setValue( currentBBox.width() / mNumberOfColumnsSpinBox->value() );
 
494
    mCellsizeXSpinBox->blockSignals( false );
 
495
  }
 
496
}
 
497
 
 
498
void QgsInterpolationDialog::setNewCellsizeYOnNRowschange()
 
499
{
 
500
  QgsRectangle currentBBox = currentBoundingBox();
 
501
  if ( !currentBBox.isEmpty() && mNumberOfRowsSpinBox->value() > 0 )
 
502
  {
 
503
    mCellSizeYSpinBox->blockSignals( true );
 
504
    mCellSizeYSpinBox->setValue( currentBBox.height() / mNumberOfRowsSpinBox->value() );
 
505
    mCellSizeYSpinBox->blockSignals( false );
 
506
  }
 
507
}
 
508
 
 
509
void QgsInterpolationDialog::setNColsOnCellsizeXChange()
 
510
{
 
511
  QgsRectangle currentBBox = currentBoundingBox();
 
512
  int newSize;
 
513
 
 
514
  if ( mCellsizeXSpinBox->value() <= 0 )
 
515
  {
 
516
    return;
 
517
  }
 
518
 
 
519
  if ( currentBBox.width() <= 0 )
 
520
  {
 
521
    newSize = 0;
 
522
  }
 
523
  else
 
524
  {
 
525
    newSize = ( int )( currentBBox.width() / mCellsizeXSpinBox->value() );
 
526
  }
 
527
 
 
528
  mNumberOfColumnsSpinBox->blockSignals( true );
 
529
  mNumberOfColumnsSpinBox->setValue( newSize );
 
530
  mNumberOfColumnsSpinBox->blockSignals( false );
 
531
}
 
532
 
 
533
void QgsInterpolationDialog::setNRowsOnCellsizeYChange()
 
534
{
 
535
  QgsRectangle currentBBox = currentBoundingBox();
 
536
  int newSize;
 
537
 
 
538
  if ( mCellSizeYSpinBox->value() <= 0 )
 
539
  {
 
540
    return;
 
541
  }
 
542
 
 
543
  if ( currentBBox.height() <= 0 )
 
544
  {
 
545
    newSize = 0;
 
546
  }
 
547
  else
 
548
  {
 
549
    newSize = ( int )( currentBBox.height() / mCellSizeYSpinBox->value() );
 
550
  }
 
551
 
 
552
  mNumberOfRowsSpinBox->blockSignals( true );
 
553
  mNumberOfRowsSpinBox->setValue( newSize );
 
554
  mNumberOfRowsSpinBox->blockSignals( false );
 
555
}
 
556
 
 
557
QgsRectangle QgsInterpolationDialog::currentBoundingBox()
 
558
{
 
559
  QString xMinString = mXMinLineEdit->text();
 
560
  QString xMaxString = mXMaxLineEdit->text();
 
561
  QString yMinString = mYMinLineEdit->text();
 
562
  QString yMaxString = mYMaxLineEdit->text();
 
563
 
 
564
  bool xMinOk, xMaxOk, yMinOk, yMaxOk;
 
565
  double xMin = xMinString.toDouble( &xMinOk );
 
566
  double xMax = xMaxString.toDouble( &xMaxOk );
 
567
  double yMin = yMinString.toDouble( &yMinOk );
 
568
  double yMax = yMaxString.toDouble( &yMaxOk );
 
569
 
 
570
  if ( !xMinOk || !xMaxOk || !yMinOk || !yMaxOk )
 
571
  {
 
572
    QgsRectangle emptyBbox;
 
573
    return emptyBbox; //error, return empty bounding box
 
574
  }
 
575
 
 
576
  return QgsRectangle( xMin, yMin, xMax, yMax );
 
577
}