QGIS API Documentation  master-6227475
src/gui/qgsrasterlayersaveasdialog.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     qgsrasterlayersaveasdialog.h
00003     ---------------------
00004     begin                : May 2012
00005     copyright            : (C) 2012 by Marco Hugentobler
00006     email                : marco dot hugentobler at sourcepole dot ch
00007  ***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 #ifndef QGSRASTERLAYERSAVEASDIALOG_H
00016 #define QGSRASTERLAYERSAVEASDIALOG_H
00017 
00018 #include "ui_qgsrasterlayersaveasdialogbase.h"
00019 #include "qgsrectangle.h"
00020 #include "qgscoordinatereferencesystem.h"
00021 #include "qgsrasterrange.h"
00022 
00023 class QgsRasterLayer;
00024 class QgsRasterDataProvider;
00025 class QgsRasterFormatOptionsWidget;
00026 
00027 class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRasterLayerSaveAsDialogBase
00028 {
00029     Q_OBJECT
00030   public:
00031     enum Mode
00032     {
00033       RawDataMode,
00034       RenderedImageMode
00035     };
00036     enum CrsState
00037     {
00038       OriginalCrs,
00039       CurrentCrs,
00040       UserCrs
00041     };
00042     enum ExtentState
00043     {
00044       OriginalExtent,
00045       CurrentExtent,
00046       UserExtent,
00047     };
00048     enum ResolutionState
00049     {
00050       OriginalResolution,
00051       UserResolution
00052     };
00053 
00054     QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLayer,
00055                                 QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
00056                                 const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs,
00057                                 QWidget* parent = 0, Qt::WindowFlags f = 0 );
00058     ~QgsRasterLayerSaveAsDialog();
00059 
00060     Mode mode() const;
00061     int nColumns() const;
00062     int nRows() const;
00063     double xResolution() const;
00064     double yResolution() const;
00065     int maximumTileSizeX() const;
00066     int maximumTileSizeY() const;
00067     bool tileMode() const;
00068     QString outputFileName() const;
00069     QString outputFormat() const;
00070     QgsCoordinateReferenceSystem outputCrs();
00071     QStringList createOptions() const;
00072     QgsRectangle outputRectangle() const;
00073     QgsRasterRangeList noData() const;
00074 
00075     QList< int > pyramidsList() const;
00076     QgsRaster::RasterBuildPyramids buildPyramidsFlag() const;
00077     QString pyramidsResamplingMethod() const { return mPyramidsOptionsWidget->resamplingMethod(); }
00078     QgsRaster::RasterPyramidsFormat pyramidsFormat() const
00079     { return mPyramidsOptionsWidget->pyramidsFormat(); }
00080     QStringList pyramidsConfigOptions() const
00081     { return mPyramidsOptionsWidget->configOptions(); }
00082 
00083     void hideFormat();
00084     void hideOutput();
00085 
00086   public slots:
00087     virtual void accept() { if ( validate() ) return QDialog::accept(); }
00088 
00089   private slots:
00090     void on_mRawModeRadioButton_toggled( bool );
00091     void on_mBrowseButton_clicked();
00092     void on_mSaveAsLineEdit_textChanged( const QString& text );
00093     void on_mCurrentExtentButton_clicked();
00094     void on_mOriginalExtentButton_clicked();
00095     void on_mFormatComboBox_currentIndexChanged( const QString& text );
00096     void on_mResolutionRadioButton_toggled( bool ) { toggleResolutionSize(); }
00097     void on_mOriginalResolutionPushButton_clicked() { setOriginalResolution(); }
00098     void on_mXResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
00099     void on_mYResolutionLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcSize(); }
00100 
00101     void on_mOriginalSizePushButton_clicked() { setOriginalSize(); }
00102     void on_mColumnsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
00103     void on_mRowsLineEdit_textEdited( const QString & ) { mResolutionState = UserResolution; recalcResolution(); }
00104 
00105     void on_mXMinLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
00106     void on_mXMaxLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
00107     void on_mYMinLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
00108     void on_mYMaxLineEdit_textEdited( const QString & ) { mExtentState = UserExtent; extentChanged(); }
00109 
00110     void on_mChangeCrsPushButton_clicked();
00111 
00112     void on_mCrsComboBox_currentIndexChanged( int ) { crsChanged(); }
00113 
00114     void on_mAddNoDataManuallyToolButton_clicked();
00115     void on_mLoadTransparentNoDataToolButton_clicked();
00116     void on_mRemoveSelectedNoDataToolButton_clicked();
00117     void on_mRemoveAllNoDataToolButton_clicked();
00118     void noDataCellTextEdited( const QString & text );
00119     void on_mTileModeCheckBox_toggled( bool toggled );
00120     void on_mPyramidsGroupBox_toggled( bool toggled );
00121     void populatePyramidsLevels();
00122 
00123   private:
00124     QgsRasterLayer* mRasterLayer;
00125     QgsRasterDataProvider* mDataProvider;
00126     QgsRectangle mCurrentExtent;
00127     QgsCoordinateReferenceSystem mLayerCrs; // may differ from provider CRS
00128     QgsCoordinateReferenceSystem mCurrentCrs;
00129     QgsCoordinateReferenceSystem mUserCrs;
00130     QgsCoordinateReferenceSystem mPreviousCrs;
00131     ExtentState mExtentState;
00132     ResolutionState mResolutionState;
00133     QVector<bool> mNoDataToEdited;
00134 
00135     void setValidators();
00136     void setOutputExtent( const QgsRectangle& r, const QgsCoordinateReferenceSystem& srcCrs, ExtentState state );
00137     void extentChanged();
00138     void updateExtentStateMsg();
00139     void toggleResolutionSize();
00140     void setResolution( double xRes, double yRes, const QgsCoordinateReferenceSystem& srcCrs );
00141     void setOriginalResolution();
00142     void setOriginalSize();
00143     void recalcSize();
00144     void recalcResolution();
00145     void updateResolutionStateMsg();
00146     void recalcResolutionSize();
00147     void crsChanged();
00148     void updateCrsGroup();
00149 
00150     void addNoDataRow( double min, double max );
00151     void setNoDataToEdited( int row );
00152     double noDataCellValue( int row, int column ) const;
00153     void adjustNoDataCellWidth( int row, int column );
00154     bool validate() const;
00155 };
00156 
00157 
00158 #endif // QGSRASTERLAYERSAVEASDIALOG_H
00159 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines