QGIS API Documentation  2.2.0-Valmiera
 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 { return mPyramidsOptionsWidget->pyramidsFormat(); }
79  QStringList pyramidsConfigOptions() const { return mPyramidsOptionsWidget->configOptions(); }
80 
81  void hideFormat();
82  void hideOutput();
83 
84  public slots:
85  virtual void accept() { if ( validate() ) return QDialog::accept(); }
86 
87  private slots:
88  void on_mRawModeRadioButton_toggled( bool );
89  void on_mBrowseButton_clicked();
90  void on_mSaveAsLineEdit_textChanged( const QString& text );
91  void on_mCurrentExtentButton_clicked();
92  void on_mOriginalExtentButton_clicked();
93  void on_mFormatComboBox_currentIndexChanged( const QString& text );
94  void on_mResolutionRadioButton_toggled( bool ) { toggleResolutionSize(); }
95  void on_mOriginalResolutionPushButton_clicked() { setOriginalResolution(); }
96  void on_mXResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
97  void on_mYResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
98 
99  void on_mOriginalSizePushButton_clicked() { setOriginalSize(); }
100  void on_mColumnsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
101  void on_mRowsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
102 
103  void on_mXMinLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
104  void on_mXMaxLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
105  void on_mYMinLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
106  void on_mYMaxLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
107 
108  void on_mChangeCrsPushButton_clicked();
109 
110  void on_mCrsComboBox_currentIndexChanged( int ) { crsChanged(); }
111 
112  void on_mAddNoDataManuallyToolButton_clicked();
113  void on_mLoadTransparentNoDataToolButton_clicked();
114  void on_mRemoveSelectedNoDataToolButton_clicked();
115  void on_mRemoveAllNoDataToolButton_clicked();
116  void noDataCellTextEdited( const QString & text );
117  void on_mTileModeCheckBox_toggled( bool toggled );
118  void on_mPyramidsGroupBox_toggled( bool toggled );
119  void populatePyramidsLevels();
120 
121  private:
125  QgsCoordinateReferenceSystem mLayerCrs; // may differ from provider CRS
131  QVector<bool> mNoDataToEdited;
132 
133  void setValidators();
134  void setOutputExtent( const QgsRectangle& r, const QgsCoordinateReferenceSystem& srcCrs, ExtentState state );
135  void extentChanged();
136  void updateExtentStateMsg();
137  void toggleResolutionSize();
138  void setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem& srcCrs );
139  void setOriginalResolution();
140  void setOriginalSize();
141  void recalcSize();
142  void recalcResolution();
143  void updateResolutionStateMsg();
144  void recalcResolutionSize();
145  void crsChanged();
146  void updateCrsGroup();
147 
148  void addNoDataRow( double min, double max );
149  void setNoDataToEdited( int row );
150  double noDataCellValue( int row, int column ) const;
151  void adjustNoDataCellWidth( int row, int column );
152  bool validate() const;
153 };
154 
155 
156 #endif // QGSRASTERLAYERSAVEASDIALOG_H
157