QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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  ~QgsRasterLayerSaveAsDialog() override;
63 
64  Mode mode() const;
65  int nColumns() const;
66  int nRows() const;
67  double xResolution() const;
68  double yResolution() const;
69  int maximumTileSizeX() const;
70  int maximumTileSizeY() const;
71  bool tileMode() const;
72 
78  bool addToCanvas() const;
79 
86  void setAddToCanvas( bool checked );
87 
88  QString outputFileName() const;
89 
94  QString outputLayerName() const;
95  QString outputFormat() const;
97  QStringList createOptions() const;
98  QgsRectangle outputRectangle() const;
99  QgsRasterRangeList noData() const;
100 
101  QList< int > pyramidsList() const;
102  QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
103  QString pyramidsResamplingMethod() const { return mPyramidsOptionsWidget->resamplingMethod(); }
104  QgsRaster::RasterPyramidsFormat pyramidsFormat() const { return mPyramidsOptionsWidget->pyramidsFormat(); }
105  QStringList pyramidsConfigOptions() const { return mPyramidsOptionsWidget->configOptions(); }
106 
107  void hideFormat();
108  void hideOutput();
109 
110  public slots:
111  void accept() override;
112 
113  private slots:
114  void mRawModeRadioButton_toggled( bool );
115  void mFormatComboBox_currentIndexChanged( const QString &text );
116  void mResolutionRadioButton_toggled( bool ) { toggleResolutionSize(); }
117  void mOriginalResolutionPushButton_clicked() { setOriginalResolution(); }
118  void mXResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
119  void mYResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
120 
121  void mOriginalSizePushButton_clicked() { setOriginalSize(); }
122  void mColumnsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
123  void mRowsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
124 
125  void mAddNoDataManuallyToolButton_clicked();
126  void mLoadTransparentNoDataToolButton_clicked();
127  void mRemoveSelectedNoDataToolButton_clicked();
128  void mRemoveAllNoDataToolButton_clicked();
129  void noDataCellTextEdited( const QString &text );
130  void mTileModeCheckBox_toggled( bool toggled );
131  void mPyramidsGroupBox_toggled( bool toggled );
132  void populatePyramidsLevels();
133  void extentChanged();
134  void crsChanged();
135  void showHelp();
136 
137  private:
138  QgsRasterLayer *mRasterLayer = nullptr;
139  QgsRasterDataProvider *mDataProvider = nullptr;
140  QgsRectangle mCurrentExtent;
141  QgsCoordinateReferenceSystem mLayerCrs; // may differ from provider CRS
142  QgsCoordinateReferenceSystem mCurrentCrs;
143  QgsCoordinateReferenceSystem mPreviousCrs;
144  ResolutionState mResolutionState;
145  QVector<bool> mNoDataToEdited;
146 
147  void setValidators();
148  void toggleResolutionSize();
149  void setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem &srcCrs );
150  void setOriginalResolution();
151  void setOriginalSize();
152  void recalcSize();
153  void recalcResolution();
154  void updateResolutionStateMsg();
155  void recalcResolutionSize();
156 
157  void addNoDataRow( double min, double max );
158  void setNoDataToEdited( int row );
159  double noDataCellValue( int row, int column ) const;
160  void adjustNoDataCellWidth( int row, int column );
161  bool validate() const;
162  // Returns true if the output layer already exists.
163  bool outputLayerExists() const;
164 
165  void insertAvailableOutputFormats();
166 
167  friend class TestQgsRasterLayerSaveAsDialog;
168 };
169 
170 
171 #endif // QGSRASTERLAYERSAVEASDIALOG_H
172 
A rectangle specified with double values.
Definition: qgsrectangle.h:41
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QgsRaster::RasterPyramidsFormat pyramidsFormat() const
QList< QgsRasterRange > QgsRasterRangeList
This class represents a coordinate reference system (CRS).
const QgsCoordinateReferenceSystem & outputCrs
RasterBuildPyramids
Definition: qgsraster.h:74
RasterPyramidsFormat
Definition: qgsraster.h:81
Base class for raster data providers.