QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 #include "qgis_gui.h"
23 #include "qgshelp.h"
24 
25 class QgsRasterLayer;
27 class QgsRasterFormatOptionsWidget;
28 
33 class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRasterLayerSaveAsDialogBase
34 {
35  Q_OBJECT
36  public:
37  enum Mode
38  {
40  RenderedImageMode
41  };
42  enum CrsState
43  {
46  UserCrs
47  };
49  {
51  UserResolution
52  };
53 
56  QgsRasterDataProvider *sourceProvider,
57  const QgsRectangle &currentExtent,
58  const QgsCoordinateReferenceSystem &layerCrs,
59  const QgsCoordinateReferenceSystem &currentCrs,
60  QWidget *parent SIP_TRANSFERTHIS = nullptr,
61  Qt::WindowFlags f = nullptr );
62 
63  Mode mode() const;
64  int nColumns() const;
65  int nRows() const;
66  double xResolution() const;
67  double yResolution() const;
68  int maximumTileSizeX() const;
69  int maximumTileSizeY() const;
70  bool tileMode() const;
71 
77  bool addToCanvas() const;
78 
85  void setAddToCanvas( bool checked );
86 
87  QString outputFileName() const;
88 
93  QString outputLayerName() const;
94  QString outputFormat() const;
96  QStringList createOptions() const;
97  QgsRectangle outputRectangle() const;
98  QgsRasterRangeList noData() const;
99 
100  QList< int > pyramidsList() const;
101  QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
102  QString pyramidsResamplingMethod() const { return mPyramidsOptionsWidget->resamplingMethod(); }
103  QgsRaster::RasterPyramidsFormat pyramidsFormat() const { return mPyramidsOptionsWidget->pyramidsFormat(); }
104  QStringList pyramidsConfigOptions() const { return mPyramidsOptionsWidget->configOptions(); }
105 
106  void hideFormat();
107  void hideOutput();
108 
109  public slots:
110  void accept() override;
111 
112  private slots:
113  void mRawModeRadioButton_toggled( bool );
114  void mFormatComboBox_currentIndexChanged( const QString &text );
115  void mResolutionRadioButton_toggled( bool ) { toggleResolutionSize(); }
116  void mOriginalResolutionPushButton_clicked() { setOriginalResolution(); }
117  void mXResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
118  void mYResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
119 
120  void mOriginalSizePushButton_clicked() { setOriginalSize(); }
121  void mColumnsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
122  void mRowsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
123 
124  void mAddNoDataManuallyToolButton_clicked();
125  void mLoadTransparentNoDataToolButton_clicked();
126  void mRemoveSelectedNoDataToolButton_clicked();
127  void mRemoveAllNoDataToolButton_clicked();
128  void noDataCellTextEdited( const QString &text );
129  void mTileModeCheckBox_toggled( bool toggled );
130  void mPyramidsGroupBox_toggled( bool toggled );
131  void populatePyramidsLevels();
132  void extentChanged();
133  void crsChanged();
134  void showHelp();
135 
136  private:
137  QgsRasterLayer *mRasterLayer = nullptr;
138  QgsRasterDataProvider *mDataProvider = nullptr;
139  QgsRectangle mCurrentExtent;
140  QgsCoordinateReferenceSystem mLayerCrs; // may differ from provider CRS
141  QgsCoordinateReferenceSystem mCurrentCrs;
142  QgsCoordinateReferenceSystem mPreviousCrs;
143  ResolutionState mResolutionState;
144  QVector<bool> mNoDataToEdited;
145 
146  void setValidators();
147  void toggleResolutionSize();
148  void setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem &srcCrs );
149  void setOriginalResolution();
150  void setOriginalSize();
151  void recalcSize();
152  void recalcResolution();
153  void updateResolutionStateMsg();
154  void recalcResolutionSize();
155 
156  void addNoDataRow( double min, double max );
157  void setNoDataToEdited( int row );
158  double noDataCellValue( int row, int column ) const;
159  void adjustNoDataCellWidth( int row, int column );
160  bool validate() const;
161  // Returns true if the output layer already exists.
162  bool outputLayerExists() const;
163 
164  void insertAvailableOutputFormats();
165 
166  friend class TestQgsRasterLayerSaveAsDialog;
167 };
168 
169 
170 #endif // QGSRASTERLAYERSAVEASDIALOG_H
171 
QgsRasterLayerSaveAsDialog::ResolutionState
ResolutionState
Definition: qgsrasterlayersaveasdialog.h:48
outputCrs
const QgsCoordinateReferenceSystem & outputCrs
Definition: qgswfsgetfeature.cpp:115
QgsRasterLayerSaveAsDialog::CurrentCrs
@ CurrentCrs
Definition: qgsrasterlayersaveasdialog.h:45
QgsRasterLayerSaveAsDialog::pyramidsConfigOptions
QStringList pyramidsConfigOptions() const
Definition: qgsrasterlayersaveasdialog.h:104
QgsRasterLayerSaveAsDialog::pyramidsResamplingMethod
QString pyramidsResamplingMethod() const
Definition: qgsrasterlayersaveasdialog.h:102
qgsrectangle.h
QgsRasterLayerSaveAsDialog::CrsState
CrsState
Definition: qgsrasterlayersaveasdialog.h:42
QgsRaster::RasterPyramidsFormat
RasterPyramidsFormat
Definition: qgsraster.h:94
QgsRasterLayerSaveAsDialog::pyramidsFormat
QgsRaster::RasterPyramidsFormat pyramidsFormat() const
Definition: qgsrasterlayersaveasdialog.h:103
QgsRectangle
Definition: qgsrectangle.h:41
QgsRasterLayerSaveAsDialog
Definition: qgsrasterlayersaveasdialog.h:33
QgsRaster::RasterBuildPyramids
RasterBuildPyramids
Definition: qgsraster.h:87
QgsRasterLayerSaveAsDialog::Mode
Mode
Definition: qgsrasterlayersaveasdialog.h:37
QgsRasterLayerSaveAsDialog::OriginalCrs
@ OriginalCrs
Definition: qgsrasterlayersaveasdialog.h:44
QgsRasterRangeList
QList< QgsRasterRange > QgsRasterRangeList
Definition: qgsrasterrange.h:26
QgsRasterLayer
Definition: qgsrasterlayer.h:72
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsRasterLayerSaveAsDialog::OriginalResolution
@ OriginalResolution
Definition: qgsrasterlayersaveasdialog.h:50
qgsrasterrange.h
QgsRasterLayerSaveAsDialog::RawDataMode
@ RawDataMode
Definition: qgsrasterlayersaveasdialog.h:39
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
qgscoordinatereferencesystem.h
qgshelp.h
QgsRasterDataProvider
Definition: qgsrasterdataprovider.h:88