QGIS API Documentation  2.0.1-Dufour
 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  {
47  };
49  {
51  UserResolution
52  };
53 
55  QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
56  const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs,
57  QWidget* parent = 0, Qt::WindowFlags f = 0 );
59 
60  Mode mode() const;
61  int nColumns() const;
62  int nRows() const;
63  double xResolution() const;
64  double yResolution() const;
65  int maximumTileSizeX() const;
66  int maximumTileSizeY() const;
67  bool tileMode() const;
68  QString outputFileName() const;
69  QString outputFormat() const;
70  QgsCoordinateReferenceSystem outputCrs();
71  QStringList createOptions() const;
72  QgsRectangle outputRectangle() const;
73  QgsRasterRangeList noData() const;
74 
75  QList< int > pyramidsList() const;
76  QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
77  QString pyramidsResamplingMethod() const { return mPyramidsOptionsWidget->resamplingMethod(); }
78  QgsRaster::RasterPyramidsFormat pyramidsFormat() const
79  { return mPyramidsOptionsWidget->pyramidsFormat(); }
80  QStringList pyramidsConfigOptions() const
81  { return mPyramidsOptionsWidget->configOptions(); }
82 
83  void hideFormat();
84  void hideOutput();
85 
86  public slots:
87  virtual void accept() { if ( validate() ) return QDialog::accept(); }
88 
89  private slots:
90  void on_mRawModeRadioButton_toggled( bool );
91  void on_mBrowseButton_clicked();
92  void on_mSaveAsLineEdit_textChanged( const QString& text );
93  void on_mCurrentExtentButton_clicked();
94  void on_mOriginalExtentButton_clicked();
95  void on_mFormatComboBox_currentIndexChanged( const QString& text );
96  void on_mResolutionRadioButton_toggled( bool ) { toggleResolutionSize(); }
97  void on_mOriginalResolutionPushButton_clicked() { setOriginalResolution(); }
98  void on_mXResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
99  void on_mYResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
100 
101  void on_mOriginalSizePushButton_clicked() { setOriginalSize(); }
102  void on_mColumnsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
103  void on_mRowsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
104 
105  void on_mXMinLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
106  void on_mXMaxLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
107  void on_mYMinLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
108  void on_mYMaxLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
109 
110  void on_mChangeCrsPushButton_clicked();
111 
112  void on_mCrsComboBox_currentIndexChanged( int ) { crsChanged(); }
113 
114  void on_mAddNoDataManuallyToolButton_clicked();
115  void on_mLoadTransparentNoDataToolButton_clicked();
116  void on_mRemoveSelectedNoDataToolButton_clicked();
117  void on_mRemoveAllNoDataToolButton_clicked();
118  void noDataCellTextEdited( const QString & text );
119  void on_mTileModeCheckBox_toggled( bool toggled );
120  void on_mPyramidsGroupBox_toggled( bool toggled );
121  void populatePyramidsLevels();
122 
123  private:
127  QgsCoordinateReferenceSystem mLayerCrs; // may differ from provider CRS
133  QVector<bool> mNoDataToEdited;
134 
135  void setValidators();
136  void setOutputExtent( const QgsRectangle& r, const QgsCoordinateReferenceSystem& srcCrs, ExtentState state );
137  void extentChanged();
138  void updateExtentStateMsg();
139  void toggleResolutionSize();
140  void setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem& srcCrs );
141  void setOriginalResolution();
142  void setOriginalSize();
143  void recalcSize();
144  void recalcResolution();
145  void updateResolutionStateMsg();
146  void recalcResolutionSize();
147  void crsChanged();
148  void updateCrsGroup();
149 
150  void addNoDataRow( double min, double max );
151  void setNoDataToEdited( int row );
152  double noDataCellValue( int row, int column ) const;
153  void adjustNoDataCellWidth( int row, int column );
154  bool validate() const;
155 };
156 
157 
158 #endif // QGSRASTERLAYERSAVEASDIALOG_H
159