QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrasterlayersaveasdialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterlayersaveasdialog.h
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 #ifndef QGSRASTERLAYERSAVEASDIALOG_H
16 #define QGSRASTERLAYERSAVEASDIALOG_H
17 
18 #include "ui_qgsrasterlayersaveasdialogbase.h"
19 #include "qgsrectangle.h"
21 #include "qgsrasterrange.h"
22 
23 class QgsRasterLayer;
25 class QgsRasterFormatOptionsWidget;
26 
27 class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRasterLayerSaveAsDialogBase
28 {
29  Q_OBJECT
30  public:
31  enum Mode
32  {
34  RenderedImageMode
35  };
36  enum CrsState
37  {
40  UserCrs
41  };
43  {
45  UserResolution
46  };
47 
49  QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
50  const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs,
51  QWidget* parent = 0, Qt::WindowFlags f = 0 );
53 
54  Mode mode() const;
55  int nColumns() const;
56  int nRows() const;
57  double xResolution() const;
58  double yResolution() const;
59  int maximumTileSizeX() const;
60  int maximumTileSizeY() const;
61  bool tileMode() const;
62  QString outputFileName() const;
63  QString outputFormat() const;
64  QgsCoordinateReferenceSystem outputCrs();
65  QStringList createOptions() const;
66  QgsRectangle outputRectangle() const;
67  QgsRasterRangeList noData() const;
68 
69  QList< int > pyramidsList() const;
70  QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
71  QString pyramidsResamplingMethod() const { return mPyramidsOptionsWidget->resamplingMethod(); }
72  QgsRaster::RasterPyramidsFormat pyramidsFormat() const { return mPyramidsOptionsWidget->pyramidsFormat(); }
73  QStringList pyramidsConfigOptions() const { return mPyramidsOptionsWidget->configOptions(); }
74 
75  void hideFormat();
76  void hideOutput();
77 
78  public slots:
79  virtual void accept() override { if ( validate() ) return QDialog::accept(); }
80 
81  private slots:
82  void on_mRawModeRadioButton_toggled( bool );
83  void on_mBrowseButton_clicked();
84  void on_mSaveAsLineEdit_textChanged( const QString& text );
85  void on_mFormatComboBox_currentIndexChanged( const QString& text );
86  void on_mResolutionRadioButton_toggled( bool ) { toggleResolutionSize(); }
87  void on_mOriginalResolutionPushButton_clicked() { setOriginalResolution(); }
88  void on_mXResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
89  void on_mYResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
90 
91  void on_mOriginalSizePushButton_clicked() { setOriginalSize(); }
92  void on_mColumnsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
93  void on_mRowsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
94 
95  void on_mAddNoDataManuallyToolButton_clicked();
96  void on_mLoadTransparentNoDataToolButton_clicked();
97  void on_mRemoveSelectedNoDataToolButton_clicked();
98  void on_mRemoveAllNoDataToolButton_clicked();
99  void noDataCellTextEdited( const QString & text );
100  void on_mTileModeCheckBox_toggled( bool toggled );
101  void on_mPyramidsGroupBox_toggled( bool toggled );
102  void populatePyramidsLevels();
103  void extentChanged();
104 
105  private:
106  QgsRasterLayer* mRasterLayer;
107  QgsRasterDataProvider* mDataProvider;
108  QgsRectangle mCurrentExtent;
109  QgsCoordinateReferenceSystem mLayerCrs; // may differ from provider CRS
110  QgsCoordinateReferenceSystem mCurrentCrs;
111  QgsCoordinateReferenceSystem mPreviousCrs;
112  ResolutionState mResolutionState;
113  QVector<bool> mNoDataToEdited;
114 
115  void setValidators();
116  void toggleResolutionSize();
117  void setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem& srcCrs );
118  void setOriginalResolution();
119  void setOriginalSize();
120  void recalcSize();
121  void recalcResolution();
122  void updateResolutionStateMsg();
123  void recalcResolutionSize();
124 
125  void addNoDataRow( double min, double max );
126  void setNoDataToEdited( int row );
127  double noDataCellValue( int row, int column ) const;
128  void adjustNoDataCellWidth( int row, int column );
129  bool validate() const;
130 
131  private slots:
132  void crsChanged();
133 };
134 
135 
136 #endif // QGSRASTERLAYERSAVEASDIALOG_H
137