QGIS API Documentation  2.99.0-Master (7d4f81d)
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 
24 class QgsRasterLayer;
26 class QgsRasterFormatOptionsWidget;
27 
31 class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRasterLayerSaveAsDialogBase
32 {
33  Q_OBJECT
34  public:
35  enum Mode
36  {
38  RenderedImageMode
39  };
40  enum CrsState
41  {
44  UserCrs
45  };
47  {
49  UserResolution
50  };
51 
53  QgsRasterDataProvider *sourceProvider,
54  const QgsRectangle &currentExtent,
55  const QgsCoordinateReferenceSystem &layerCrs,
56  const QgsCoordinateReferenceSystem &currentCrs,
57  QWidget *parent SIP_TRANSFERTHIS = nullptr,
58  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  bool addToCanvas() const;
69  QString outputFileName() const;
70  QString outputFormat() const;
71  QgsCoordinateReferenceSystem outputCrs();
72  QStringList createOptions() const;
73  QgsRectangle outputRectangle() const;
74  QgsRasterRangeList noData() const;
75 
76  QList< int > pyramidsList() const;
77  QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
78  QString pyramidsResamplingMethod() const { return mPyramidsOptionsWidget->resamplingMethod(); }
79  QgsRaster::RasterPyramidsFormat pyramidsFormat() const { return mPyramidsOptionsWidget->pyramidsFormat(); }
80  QStringList pyramidsConfigOptions() const { return mPyramidsOptionsWidget->configOptions(); }
81 
82  void hideFormat();
83  void hideOutput();
84 
85  public slots:
86  virtual void accept() override { if ( validate() ) return QDialog::accept(); }
87 
88  private slots:
89  void on_mRawModeRadioButton_toggled( bool );
90  void on_mBrowseButton_clicked();
91  void on_mSaveAsLineEdit_textChanged( const QString &text );
92  void on_mFormatComboBox_currentIndexChanged( const QString &text );
93  void on_mResolutionRadioButton_toggled( bool ) { toggleResolutionSize(); }
94  void on_mOriginalResolutionPushButton_clicked() { setOriginalResolution(); }
95  void on_mXResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
96  void on_mYResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
97 
98  void on_mOriginalSizePushButton_clicked() { setOriginalSize(); }
99  void on_mColumnsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
100  void on_mRowsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
101 
102  void on_mAddNoDataManuallyToolButton_clicked();
103  void on_mLoadTransparentNoDataToolButton_clicked();
104  void on_mRemoveSelectedNoDataToolButton_clicked();
105  void on_mRemoveAllNoDataToolButton_clicked();
106  void noDataCellTextEdited( const QString &text );
107  void on_mTileModeCheckBox_toggled( bool toggled );
108  void on_mPyramidsGroupBox_toggled( bool toggled );
109  void populatePyramidsLevels();
110  void extentChanged();
111 
112  private:
113  QgsRasterLayer *mRasterLayer = nullptr;
114  QgsRasterDataProvider *mDataProvider = nullptr;
115  QgsRectangle mCurrentExtent;
116  QgsCoordinateReferenceSystem mLayerCrs; // may differ from provider CRS
117  QgsCoordinateReferenceSystem mCurrentCrs;
118  QgsCoordinateReferenceSystem mPreviousCrs;
119  ResolutionState mResolutionState;
120  QVector<bool> mNoDataToEdited;
121 
122  void setValidators();
123  void toggleResolutionSize();
124  void setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem &srcCrs );
125  void setOriginalResolution();
126  void setOriginalSize();
127  void recalcSize();
128  void recalcResolution();
129  void updateResolutionStateMsg();
130  void recalcResolutionSize();
131 
132  void addNoDataRow( double min, double max );
133  void setNoDataToEdited( int row );
134  double noDataCellValue( int row, int column ) const;
135  void adjustNoDataCellWidth( int row, int column );
136  bool validate() const;
137 
138  private slots:
139  void crsChanged();
140 };
141 
142 
143 #endif // QGSRASTERLAYERSAVEASDIALOG_H
144 
A rectangle specified with double values.
Definition: qgsrectangle.h:38
#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
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:452
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
Definition: MathUtils.cc:437
QList< QgsRasterRange > QgsRasterRangeList
This class represents a coordinate reference system (CRS).
RasterBuildPyramids
Definition: qgsraster.h:73
RasterPyramidsFormat
Definition: qgsraster.h:80
Base class for raster data providers.