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