QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 = Qt::WindowFlags() );
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 
This class represents a coordinate reference system (CRS).
Base class for raster data providers.
QgsRaster::RasterPyramidsFormat pyramidsFormat() const
Represents a raster layer.
RasterPyramidsFormat
Definition: qgsraster.h:82
RasterBuildPyramids
Definition: qgsraster.h:75
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QList< QgsRasterRange > QgsRasterRangeList
const QgsCoordinateReferenceSystem & outputCrs