QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrasterlayersaveasdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterlayersaveasdialog.cpp
3  ---------------------
4  begin : May 2012
5  copyright : (C) 2012 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "qgsapplication.h"
16 #include "qgslogger.h"
17 #include "qgscoordinatetransform.h"
18 #include "qgsrasterlayer.h"
20 #include "qgsrasterdataprovider.h"
23 
24 #include <QFileDialog>
25 #include <QMessageBox>
26 #include <QSettings>
27 
29  QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
30  const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs,
31  QWidget* parent, Qt::WindowFlags f ) :
32  QDialog( parent, f )
33  , mRasterLayer( rasterLayer ), mDataProvider( sourceProvider )
34  , mCurrentExtent( currentExtent ), mLayerCrs( layerCrs )
35  , mCurrentCrs( currentCrs ), mExtentState( OriginalExtent )
36  , mResolutionState( OriginalResolution )
37 {
38  setupUi( this );
39  mAddNoDataManuallyToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionNewAttribute.png" ) );
40  mLoadTransparentNoDataToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionCopySelected.png" ) );
41  mRemoveSelectedNoDataToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionDeleteAttribute.png" ) );
42  mRemoveAllNoDataToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionRemove.png" ) );
43 
44  mNoDataTableWidget->setColumnCount( 2 );
45  mNoDataTableWidget->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "From" ) ) );
46  mNoDataTableWidget->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "To" ) ) );
47 
49 
50  setValidators();
51  // Translated labels + EPSG are updated later
52  mCrsComboBox->addItem( "Layer", OriginalCrs );
53  mCrsComboBox->addItem( "Project", CurrentCrs );
54  mCrsComboBox->addItem( "Selected", UserCrs );
55 
57  mUserCrs.createFromOgcWmsCrs( "EPSG:4326" );
58 
59  //only one hardcoded format at the moment
60  QStringList myFormats;
61  myFormats << "GTiff";
62  foreach ( QString myFormat, myFormats )
63  {
64  mFormatComboBox->addItem( myFormat );
65  }
66 
67  //fill reasonable default values depending on the provider
68  if ( mDataProvider )
69  {
70  //extent
72 
74  {
76  int xSize = mDataProvider->xSize();
77  int ySize = mDataProvider->ySize();
78  mMaximumSizeXLineEdit->setText( QString::number( xSize ) );
79  mMaximumSizeYLineEdit->setText( QString::number( ySize ) );
80  }
81  else //wms, sometimes wcs
82  {
83  mTileModeCheckBox->setChecked( true );
84  mMaximumSizeXLineEdit->setText( QString::number( 2000 ) );
85  mMaximumSizeYLineEdit->setText( QString::number( 2000 ) );
86  }
87 
88  // setup creation option widget
89  mCreateOptionsWidget->setProvider( mDataProvider->name() );
90  if ( mDataProvider->name() == "gdal" )
91  {
92  mCreateOptionsWidget->setFormat( myFormats[0] );
93  }
94  mCreateOptionsWidget->setRasterLayer( mRasterLayer );
95  mCreateOptionsWidget->update();
96  }
97 
98  // Only do pyramids if dealing directly with GDAL.
100  {
101  // setup pyramids option widget
102  // mPyramidsOptionsWidget->createOptionsWidget()->setType( QgsRasterFormatSaveOptionsWidget::ProfileLineEdit );
103  mPyramidsOptionsWidget->createOptionsWidget()->setRasterLayer( mRasterLayer );
104 
105  // TODO enable "use existing", has no effect for now, because using Create() in gdal provider
106  // if ( ! mDataProvider->hasPyramids() )
107  // mPyramidsButtonGroup->button( QgsRaster::PyramidsCopyExisting )->setEnabled( false );
108  mPyramidsUseExistingCheckBox->setEnabled( false );
109  mPyramidsUseExistingCheckBox->setVisible( false );
110 
112  connect( mPyramidsOptionsWidget, SIGNAL( overviewListChanged() ),
113  this, SLOT( populatePyramidsLevels() ) );
114  }
115  else
116  {
117  mPyramidsGroupBox->setEnabled( false );
118  }
119 
120  // restore checked state for most groupboxes (default is to restore collapsed state)
121  // create options and pyramids will be preset, if user has selected defaults in the gdal options dlg
122  mCreateOptionsGroupBox->setSaveCheckedState( true );
123  //mTilesGroupBox->setSaveCheckedState( true );
124  // don't restore nodata, it needs user input
125  // pyramids are not necessarily built every time
126 
127  mTilesGroupBox->hide();
128 
129  updateCrsGroup();
130 
131  QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );
132  if ( okButton )
133  {
134  okButton->setEnabled( false );
135  }
136 }
137 
139 {
140  mXResolutionLineEdit->setValidator( new QDoubleValidator( this ) );
141  mYResolutionLineEdit->setValidator( new QDoubleValidator( this ) );
142  mColumnsLineEdit->setValidator( new QIntValidator( this ) );
143  mRowsLineEdit->setValidator( new QIntValidator( this ) );
144  mMaximumSizeXLineEdit->setValidator( new QIntValidator( this ) );
145  mMaximumSizeYLineEdit->setValidator( new QIntValidator( this ) );
146  mXMinLineEdit->setValidator( new QDoubleValidator( this ) );
147  mXMaxLineEdit->setValidator( new QDoubleValidator( this ) );
148  mYMinLineEdit->setValidator( new QDoubleValidator( this ) );
149  mYMaxLineEdit->setValidator( new QDoubleValidator( this ) );
150 }
151 
153 {
154 }
155 
157 {
158  QString fileName;
159  if ( mTileModeCheckBox->isChecked() )
160  {
161  while ( true )
162  {
163  // TODO: would not it be better to select .vrt file instead of directory?
164  fileName = QFileDialog::getExistingDirectory( this, tr( "Select output directory" ) );
165  //fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ), QString(), tr( "VRT" ) + " (*.vrt *.VRT)" );
166 
167  if ( fileName.isEmpty() ) break; // canceled
168 
169  // Check if directory is empty
170  QDir dir( fileName );
171  QString baseName = QFileInfo( fileName ).baseName();
172  QStringList filters;
173  filters << QString( "%1.*" ).arg( baseName );
174  QStringList files = dir.entryList( filters );
175  if ( !files.isEmpty() )
176  {
177  QMessageBox::StandardButton button = QMessageBox::warning( this, tr( "Warning" ),
178  tr( "The directory %1 contains files which will be overwritten: %2" ).arg( dir.absolutePath() ).arg( files.join( ", " ) ),
179  QMessageBox::Ok | QMessageBox::Cancel );
180 
181  if ( button == QMessageBox::Ok )
182  {
183  break;
184  }
185  else
186  {
187  fileName = "";
188  }
189  }
190  else
191  {
192  break;
193  }
194  }
195  }
196  else
197  {
198  fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ), QString(), tr( "GeoTIFF" ) + " (*.tif *.tiff *.TIF *.TIFF)" );
199  }
200 
201  if ( !fileName.isEmpty() )
202  {
203  mSaveAsLineEdit->setText( fileName );
204  }
205 }
206 
208 {
209  QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );
210  if ( !okButton )
211  {
212  return;
213  }
214 
215  okButton->setEnabled( QFileInfo( text ).absoluteDir().exists() );
216 }
217 
219 {
221 }
222 
224 {
225  if ( mDataProvider )
226  {
228  }
229 }
230 
232 {
233  //gdal-specific
234  if ( mDataProvider && mDataProvider->name() == "gdal" )
235  {
236  mCreateOptionsWidget->setFormat( text );
237  mCreateOptionsWidget->update();
238  }
239 }
240 
242 {
243  return mColumnsLineEdit->text().toInt();
244 }
245 
247 {
248  return mRowsLineEdit->text().toInt();
249 }
250 
252 {
253  return mXResolutionLineEdit->text().toDouble();
254 }
255 
257 {
258  return mYResolutionLineEdit->text().toDouble();
259 }
260 
262 {
263  return mMaximumSizeXLineEdit->text().toInt();
264 }
265 
267 {
268  return mMaximumSizeYLineEdit->text().toInt();
269 }
270 
272 {
273  return mTileModeCheckBox->isChecked();
274 }
275 
277 {
278  return mSaveAsLineEdit->text();
279 }
280 
282 {
283  return mFormatComboBox->currentText();
284 }
285 
287 {
288  return mCreateOptionsGroupBox->isChecked() ? mCreateOptionsWidget->options() : QStringList();
289 }
290 
292 {
293  return QgsRectangle( mXMinLineEdit->text().toDouble(), mYMinLineEdit->text().toDouble(), mXMaxLineEdit->text().toDouble(), mYMaxLineEdit->text().toDouble() );
294 }
295 
297 {
298  QgsRectangle extent;
299  if ( outputCrs() == srcCrs )
300  {
301  extent = r;
302  }
303  else
304  {
305  QgsCoordinateTransform ct( srcCrs, outputCrs() );
306  extent = ct.transformBoundingBox( r );
307  }
308 
309  mXMinLineEdit->setText( QgsRasterBlock::printValue( extent.xMinimum() ) );
310  mXMaxLineEdit->setText( QgsRasterBlock::printValue( extent.xMaximum() ) );
311  mYMinLineEdit->setText( QgsRasterBlock::printValue( extent.yMinimum() ) );
312  mYMaxLineEdit->setText( QgsRasterBlock::printValue( extent.yMaximum() ) );
313 
314  mExtentState = state;
315  extentChanged();
316 }
317 
319 {
320  mFormatLabel->hide();
321  mFormatComboBox->hide();
322 }
323 
325 {
326  mSaveAsLabel->hide();
327  mSaveAsLineEdit->hide();
328  mBrowseButton->hide();
329  QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );
330  if ( okButton )
331  {
332  okButton->setEnabled( true );
333  }
334 }
335 
337 {
339 
340  bool on = mResolutionRadioButton->isChecked();
341  mXResolutionLineEdit->setEnabled( on );
342  mYResolutionLineEdit->setEnabled( on );
343  mOriginalResolutionPushButton->setEnabled( on && hasResolution );
344  mColumnsLineEdit->setEnabled( !on );
345  mRowsLineEdit->setEnabled( !on );
346  mOriginalSizePushButton->setEnabled( !on && hasResolution );
347 }
348 
350 {
351  double xRes, yRes;
352 
354  {
355  xRes = mDataProvider->extent().width() / mDataProvider->xSize();
356  yRes = mDataProvider->extent().height() / mDataProvider->ySize();
357  }
358  else
359  {
360  // Init to something if no original resolution is available
361  xRes = yRes = mDataProvider->extent().width() / 100;
362  }
363  setResolution( xRes, yRes, mLayerCrs );
365  recalcSize();
366 }
367 
368 void QgsRasterLayerSaveAsDialog::setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem& srcCrs )
369 {
370  if ( srcCrs != outputCrs() )
371  {
372  // We reproject pixel rectangle from center of selected extent, of course, it gives
373  // bigger xRes,yRes than reprojected edges (envelope), it may also be that
374  // close to margins are higher resolutions (even very, too high)
375  // TODO: consider more precise resolution calculation
376 
377  QgsPoint center = outputRectangle().center();
378  QgsCoordinateTransform ct( srcCrs, outputCrs() );
380 
381  QgsRectangle srcExtent( srsCenter.x() - xRes / 2, srsCenter.y() - yRes / 2, srsCenter.x() + xRes / 2, srsCenter.y() + yRes / 2 );
382 
383  QgsRectangle extent = ct.transform( srcExtent );
384  xRes = extent.width();
385  yRes = extent.height();
386  }
387  mXResolutionLineEdit->setText( QString::number( xRes ) );
388  mYResolutionLineEdit->setText( QString::number( yRes ) );
389 }
390 
392 {
393  QgsDebugMsg( "Entered" );
394  QgsRectangle extent = outputRectangle();
395  int xSize = xResolution() != 0 ? static_cast<int>( qRound( extent.width() / xResolution() ) ) : 0;
396  int ySize = yResolution() != 0 ? static_cast<int>( qRound( extent.height() / yResolution() ) ) : 0;
397  mColumnsLineEdit->setText( QString::number( xSize ) );
398  mRowsLineEdit->setText( QString::number( ySize ) );
400 }
401 
403 {
404  mColumnsLineEdit->setText( QString::number( mDataProvider->xSize() ) );
405  mRowsLineEdit->setText( QString::number( mDataProvider->ySize() ) );
407 }
408 
410 {
411  QgsDebugMsg( "Entered" );
412  QgsRectangle extent = outputRectangle();
413  double xRes = nColumns() != 0 ? extent.width() / nColumns() : 0;
414  double yRes = nRows() != 0 ? extent.height() / nRows() : 0;
415  mXResolutionLineEdit->setText( QString::number( xRes ) );
416  mYResolutionLineEdit->setText( QString::number( yRes ) );
418 }
419 
421 {
422  QgsDebugMsg( "Entered" );
423  if ( mResolutionRadioButton->isChecked() )
424  {
425  recalcSize();
426  }
427  else
428  {
431  }
432 }
433 
435 {
436  QString msg;
437  switch ( mResolutionState )
438  {
439  case OriginalResolution:
440  msg = tr( "layer" );
441  break;
442  case UserResolution:
443  msg = tr( "user defined" );
444  break;
445  default:
446  break;
447  }
448  msg = tr( "Resolution (current: %1)" ).arg( msg );
449  mResolutionGroupBox->setTitle( msg );
450 }
451 
453 {
455  // Whenever extent changes with fixed size, original resolution is lost
456  if ( mSizeRadioButton->isChecked() )
457  {
459  }
461 }
462 
464 {
465  QString msg;
466  switch ( mExtentState )
467  {
468  case OriginalExtent:
469  msg = tr( "layer" );
470  break;
471  case CurrentExtent:
472  msg = tr( "map view" );
473  break;
474  case UserExtent:
475  msg = tr( "user defined" );
476  break;
477  default:
478  break;
479  }
480  msg = tr( "Extent (current: %1)" ).arg( msg );
481  mExtentGroupBox->setTitle( msg );
482 }
483 
485 {
487  selector->setMessage();
488  selector->setSelectedCrsId( mUserCrs.srsid() );
489  if ( selector->exec() )
490  {
492  mCrsComboBox->setCurrentIndex( mCrsComboBox->findData( UserCrs ) );
493  }
494  delete selector;
495  crsChanged();
496 }
497 
499 {
500  QgsDebugMsg( "Entered" );
501  if ( outputCrs() != mPreviousCrs )
502  {
503  // Reset extent
504  QgsRectangle previousExtent;
505  QgsCoordinateReferenceSystem previousCrs;
506  // We could reproject previous but that would add additional space also if
507  // it is was not necessary or at leas it could decrease accuracy
508  if ( mExtentState == OriginalExtent )
509  {
510  previousExtent = mDataProvider->extent();
511  previousCrs = mLayerCrs;
512  }
513  else if ( mExtentState == CurrentExtent )
514  {
515  previousExtent = mCurrentExtent;
516  previousCrs = mCurrentCrs;
517  }
518  else
519  {
520  previousExtent = outputRectangle();
521  previousCrs = mPreviousCrs;
522  }
523  setOutputExtent( previousExtent, previousCrs, mExtentState );
524 
525  // Reset resolution
526  if ( mResolutionRadioButton->isChecked() )
527  {
529  {
531  }
532  else
533  {
534  // reset from present resolution and present crs
536  }
537  }
538  else
539  {
540  // Size does not change, we just recalc resolution from new extent
542  }
543  }
545  updateCrsGroup();
546 }
547 
549 {
550  QgsDebugMsg( "Entered" );
551 
552  mCrsComboBox->setItemText( mCrsComboBox->findData( OriginalCrs ),
553  tr( "Layer (%1, %2)" ).arg( mLayerCrs.description() ).arg( mLayerCrs.authid() ) );
554 
555  mCrsComboBox->setItemText( mCrsComboBox->findData( CurrentCrs ),
556  tr( "Project (%1, %2)" ).arg( mCurrentCrs.description() ).arg( mCurrentCrs.authid() ) );
557 
558  mCrsComboBox->setItemText( mCrsComboBox->findData( UserCrs ),
559  tr( "Selected (%1, %2)" ).arg( mUserCrs.description() ).arg( mUserCrs.authid() ) );
560 }
561 
563 {
564  int state = mCrsComboBox->itemData( mCrsComboBox->currentIndex() ).toInt();
565  if ( state == OriginalCrs )
566  {
567  return mLayerCrs;
568  }
569  else if ( state == CurrentCrs )
570  {
571  return mCurrentCrs;
572  }
573  return mUserCrs;
574 }
575 
577 {
578  if ( mRenderedModeRadioButton->isChecked() ) return RenderedImageMode;
579  return RawDataMode;
580 }
581 
583 {
584  mNoDataGroupBox->setEnabled( checked && mDataProvider->bandCount() == 1 );
585 }
586 
588 {
589  addNoDataRow( std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN() );
590 }
591 
593 {
594  if ( !mRasterLayer->renderer() ) return;
595  const QgsRasterTransparency* rasterTransparency = mRasterLayer->renderer()->rasterTransparency();
596  if ( !rasterTransparency ) return;
597 
598  foreach ( QgsRasterTransparency::TransparentSingleValuePixel transparencyPixel, rasterTransparency->transparentSingleValuePixelList() )
599  {
600  if ( transparencyPixel.percentTransparent == 100 )
601  {
602  addNoDataRow( transparencyPixel.min, transparencyPixel.max );
603  if ( transparencyPixel.min != transparencyPixel.max )
604  {
605  setNoDataToEdited( mNoDataTableWidget->rowCount() - 1 );
606  }
607  }
608  }
609 }
610 
612 {
613  mNoDataTableWidget->removeRow( mNoDataTableWidget->currentRow() );
614 }
615 
617 {
618  while ( mNoDataTableWidget->rowCount() > 0 )
619  {
620  mNoDataTableWidget->removeRow( 0 );
621  }
622 }
623 
625 {
626  mNoDataTableWidget->insertRow( mNoDataTableWidget->rowCount() );
627  for ( int i = 0; i < 2; i++ )
628  {
629  double value = i == 0 ? min : max;
630  QLineEdit *lineEdit = new QLineEdit();
631  lineEdit->setFrame( false );
632  lineEdit->setContentsMargins( 1, 1, 1, 1 );
633  QString valueString;
634  switch ( mRasterLayer->dataProvider()->srcDataType( 1 ) )
635  {
636  case QGis::Float32:
637  case QGis::Float64:
638  lineEdit->setValidator( new QDoubleValidator( 0 ) );
639  if ( !qIsNaN( value ) )
640  {
641  valueString = QgsRasterBlock::printValue( value );
642  }
643  break;
644  default:
645  lineEdit->setValidator( new QIntValidator( 0 ) );
646  if ( !qIsNaN( value ) )
647  {
648  valueString = QString::number( static_cast<int>( value ) );
649  }
650  break;
651  }
652  lineEdit->setText( valueString );
653  mNoDataTableWidget->setCellWidget( mNoDataTableWidget->rowCount() - 1, i, lineEdit );
654 
655  adjustNoDataCellWidth( mNoDataTableWidget->rowCount() - 1, i );
656 
657  connect( lineEdit, SIGNAL( textEdited( const QString & ) ), this, SLOT( noDataCellTextEdited( const QString & ) ) );
658  }
659  mNoDataTableWidget->resizeColumnsToContents();
660  mNoDataTableWidget->resizeRowsToContents();
661 }
662 
664 {
665  Q_UNUSED( text );
666 
667  QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( sender() );
668  if ( !lineEdit ) return;
669  int row = -1;
670  int column = -1;
671  for ( int r = 0 ; r < mNoDataTableWidget->rowCount(); r++ )
672  {
673  for ( int c = 0 ; c < mNoDataTableWidget->columnCount(); c++ )
674  {
675  if ( mNoDataTableWidget->cellWidget( r, c ) == sender() )
676  {
677  row = r;
678  column = c;
679  break;
680  }
681  }
682  if ( row != -1 ) break;
683  }
684  QgsDebugMsg( QString( "row = %1 column =%2" ).arg( row ).arg( column ) );
685 
686  if ( column == 0 )
687  {
688  QLineEdit *toLineEdit = dynamic_cast<QLineEdit *>( mNoDataTableWidget->cellWidget( row, 1 ) );
689  if ( !toLineEdit ) return;
690  bool toChanged = mNoDataToEdited.value( row );
691  QgsDebugMsg( QString( "toChanged = %1" ).arg( toChanged ) );
692  if ( !toChanged )
693  {
694  toLineEdit->setText( lineEdit->text() );
695  }
696  }
697  else if ( column == 1 )
698  {
699  setNoDataToEdited( row );
700  }
701 }
702 
704 {
705  if ( toggled )
706  {
707  // enable pyramids
708 
709  // Disabled (Radim), auto enabling of pyramids was making impression that
710  // we (programmers) know better what you (user) want to do,
711  // certainly auto expaning was bad experience
712 
713  //if ( ! mPyramidsGroupBox->isChecked() )
714  // mPyramidsGroupBox->setChecked( true );
715 
716  // Auto expanding mPyramidsGroupBox is bad - it auto crolls content of dialog
717  //if ( mPyramidsGroupBox->isCollapsed() )
718  // mPyramidsGroupBox->setCollapsed( false );
719  //mPyramidsOptionsWidget->checkAllLevels( true );
720 
721  // Show / hide tile options
722  mTilesGroupBox->show();
723  }
724  else
725  {
726  mTilesGroupBox->hide();
727  }
728 }
729 
731 {
732  Q_UNUSED( toggled );
734 }
735 
737 {
738  QString text;
739 
740  if ( mPyramidsGroupBox->isChecked() )
741  {
742  QList<QgsRasterPyramid> myPyramidList;
743  // if use existing, get pyramids from actual layer
744  // but that's not available yet
745  if ( mPyramidsUseExistingCheckBox->isChecked() )
746  {
747  myPyramidList = mDataProvider->buildPyramidList();
748  }
749  else
750  {
751  if ( ! mPyramidsOptionsWidget->overviewList().isEmpty() )
752  myPyramidList = mDataProvider->buildPyramidList( mPyramidsOptionsWidget->overviewList() );
753  }
754  QList<QgsRasterPyramid>::iterator myRasterPyramidIterator;
755  for ( myRasterPyramidIterator = myPyramidList.begin();
756  myRasterPyramidIterator != myPyramidList.end();
757  ++myRasterPyramidIterator )
758  {
759  if ( ! mPyramidsUseExistingCheckBox->isChecked() || myRasterPyramidIterator->exists )
760  {
761  text += QString::number( myRasterPyramidIterator->xDim ) + QString( "x" ) +
762  QString::number( myRasterPyramidIterator->yDim ) + " ";
763  }
764  }
765  }
766 
767  mPyramidResolutionsLineEdit->setText( text.trimmed() );
768 }
769 
771 {
772  if ( row >= mNoDataToEdited.size() )
773  {
774  mNoDataToEdited.resize( row + 1 );
775  }
776  mNoDataToEdited[row] = true;
777 }
778 
779 double QgsRasterLayerSaveAsDialog::noDataCellValue( int row, int column ) const
780 {
781  QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( mNoDataTableWidget->cellWidget( row, column ) );
782  if ( !lineEdit || lineEdit->text().isEmpty() )
783  {
784  std::numeric_limits<double>::quiet_NaN();
785  }
786  return lineEdit->text().toDouble();
787 }
788 
790 {
791  QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( mNoDataTableWidget->cellWidget( row, column ) );
792  if ( !lineEdit ) return;
793 
794  int width = qMax( lineEdit->fontMetrics().width( lineEdit->text() ) + 10, 100 );
795  width = qMax( width, mNoDataTableWidget->columnWidth( column ) );
796 
797  lineEdit->setFixedWidth( width );
798 }
799 
801 {
802  QgsRasterRangeList noDataList;
803  if ( ! mNoDataGroupBox->isChecked() )
804  return noDataList;
805 
806  for ( int r = 0 ; r < mNoDataTableWidget->rowCount(); r++ )
807  {
809  noDataList.append( noData );
810 
811  }
812  return noDataList;
813 }
814 
816 {
817  return mPyramidsGroupBox->isChecked() ? mPyramidsOptionsWidget->overviewList() : QList<int>();
818 }
819 
821 {
822  if ( ! mPyramidsGroupBox->isChecked() )
824  else if ( mPyramidsUseExistingCheckBox->isChecked() )
826  else
828 }
829 
831 {
832  if ( mCreateOptionsGroupBox->isChecked() )
833  {
834  QString message = mCreateOptionsWidget->validateOptions( true, false );
835  if ( !message.isNull() )
836  return false;
837  }
838  if ( mPyramidsGroupBox->isChecked() )
839  {
840  QString message = mPyramidsOptionsWidget->createOptionsWidget()->validateOptions( true, false );
841  if ( !message.isNull() )
842  return false;
843  }
844  return true;
845 }
846