| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| /*************************************************************************** | ||
| qgsrasterpyramidsoptionswidget.cpp | ||
| ------------------- | ||
| begin : July 2012 | ||
| copyright : (C) 2012 by Etienne Tourigny | ||
| email : etourigny dot dev at gmail dot com | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #include "qgsrasterpyramidsoptionswidget.h" | ||
| #include "qgslogger.h" | ||
| #include "qgsdialog.h" | ||
|
|
||
| #include "gdal.h" | ||
| #include "cpl_string.h" | ||
| #include "cpl_conv.h" | ||
| #include "cpl_minixml.h" | ||
|
|
||
| #include <QSettings> | ||
| #include <QInputDialog> | ||
| #include <QMessageBox> | ||
| #include <QTextEdit> | ||
| #include <QMouseEvent> | ||
| #include <QMenu> | ||
| #include <QCheckBox> | ||
|
|
||
|
|
||
| QgsRasterPyramidsOptionsWidget::QgsRasterPyramidsOptionsWidget( QWidget* parent, QString provider ) | ||
| : QWidget( parent ), mProvider( provider ) | ||
| { | ||
| setupUi( this ); | ||
|
|
||
| mPyramidsOptionsWidget->setProvider( provider ); | ||
| mPyramidsOptionsWidget->setFormat( "_pyramids" ); | ||
| // mPyramidsOptionsWidget->swapOptionsUI( 1 ); | ||
|
|
||
| updateUi(); | ||
| } | ||
|
|
||
| QgsRasterPyramidsOptionsWidget::~QgsRasterPyramidsOptionsWidget() | ||
| { | ||
| } | ||
|
|
||
|
|
||
| void QgsRasterPyramidsOptionsWidget::updateUi() | ||
| { | ||
| QSettings mySettings; | ||
| QString prefix = mProvider + "/driverOptions/_pyramids/"; | ||
| QString tmpStr; | ||
|
|
||
| // cbxPyramidsInternal->setChecked( mySettings.value( prefix + "internal", false ).toBool() ); | ||
| tmpStr = mySettings.value( prefix + "format", "gtiff" ).toString(); | ||
| if ( tmpStr == "internal" ) | ||
| cboPyramidsFormat->setCurrentIndex( 0 ); | ||
| else if ( tmpStr == "erdas" ) | ||
| cboPyramidsFormat->setCurrentIndex( 2 ); | ||
| else | ||
| cboPyramidsFormat->setCurrentIndex( 1 ); | ||
| cboResamplingMethod->setCurrentIndex( cboResamplingMethod->findText( | ||
| mySettings.value( prefix + "resampling", "Average" ).toString() ) ); | ||
| lePyramidsLevels->setText( mySettings.value( prefix + "overviewStr", "bla" ).toString() ); | ||
|
|
||
| // overview list | ||
| if ( mOverviewCheckBoxes.isEmpty() ) | ||
| { | ||
| QList<int> overviewList; | ||
| overviewList << 2 << 4 << 8 << 16 << 32 << 64; | ||
| mOverviewCheckBoxes.clear(); | ||
| foreach( int i, overviewList ) | ||
| { | ||
| mOverviewCheckBoxes[ i ] = new QCheckBox( QString::number( i ), this ); | ||
| layoutPyramidLevels->addWidget( mOverviewCheckBoxes[ i ] ); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| foreach( int i, mOverviewCheckBoxes.keys() ) | ||
| mOverviewCheckBoxes[ i ]->setChecked( false ); | ||
| } | ||
| tmpStr = mySettings.value( prefix + "overviewList", "" ).toString(); | ||
| foreach( QString lev, tmpStr.split( " ", QString::SkipEmptyParts ) ) | ||
| { | ||
| if( mOverviewCheckBoxes.contains( lev.toInt() ) ) | ||
| mOverviewCheckBoxes[ lev.toInt() ]->setChecked( true ); | ||
| } | ||
| on_lePyramidsLevels_editingFinished(); | ||
|
|
||
| mPyramidsOptionsWidget->updateProfiles(); | ||
| } | ||
|
|
||
| void QgsRasterPyramidsOptionsWidget::apply() | ||
| { | ||
| QSettings mySettings; | ||
| QString prefix = mProvider + "/driverOptions/_pyramids/"; | ||
| QString tmpStr; | ||
|
|
||
| // mySettings.setValue( prefix + "internal", cbxPyramidsInternal->isChecked() ); | ||
| if ( cboPyramidsFormat->currentIndex() == 0 ) | ||
| tmpStr = "internal"; | ||
| else if ( cboPyramidsFormat->currentIndex() == 2 ) | ||
| tmpStr = "erdas"; | ||
| else | ||
| tmpStr = "tiff"; | ||
| mySettings.setValue( prefix + "format", tmpStr ); | ||
| mySettings.setValue( prefix + "resampling", cboResamplingMethod->currentText().trimmed() ); | ||
| mySettings.setValue( prefix + "overviewStr", lePyramidsLevels->text().trimmed() ); | ||
|
|
||
| // overview list | ||
| tmpStr = ""; | ||
| foreach( int i, mOverviewCheckBoxes.keys() ) | ||
| { | ||
| if ( mOverviewCheckBoxes[ i ]->isChecked() ) | ||
| tmpStr += QString::number( i ) + " "; | ||
| } | ||
| mySettings.setValue( prefix + "overviewList", tmpStr.trimmed() ); | ||
|
|
||
| mPyramidsOptionsWidget->apply(); | ||
| } | ||
|
|
||
| void QgsRasterPyramidsOptionsWidget::on_lePyramidsLevels_editingFinished() | ||
| { | ||
| // validate string, only space-separated positive integers are allowed | ||
| // should we also validate that numbers are increasing? | ||
| QString tmpStr; | ||
| int tmpInt; | ||
| foreach( QString lev, lePyramidsLevels->text().trimmed().split( " ", QString::SkipEmptyParts ) ) | ||
| { | ||
| tmpInt = lev.toInt(); | ||
| if ( tmpInt > 0 ) | ||
| tmpStr += QString::number( tmpInt ) + " "; | ||
| } | ||
| lePyramidsLevels->setText( tmpStr.trimmed() ); | ||
|
|
||
| // if text is non-empty, disable checkboxes | ||
| if ( lePyramidsLevels->text() == "" ) | ||
| { | ||
| foreach( int i, mOverviewCheckBoxes.keys() ) | ||
| mOverviewCheckBoxes[ i ]->setEnabled( true ); | ||
| } | ||
| else | ||
| { | ||
| foreach( int i, mOverviewCheckBoxes.keys() ) | ||
| mOverviewCheckBoxes[ i ]->setEnabled( false ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /*************************************************************************** | ||
| qgsrasterpyramidsoptionswidget.h | ||
| ------------------- | ||
| begin : July 2012 | ||
| copyright : (C) 2012 by Etienne Tourigny | ||
| email : etourigny dot dev at gmail dot com | ||
| ***************************************************************************/ | ||
|
|
||
| /*************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| ***************************************************************************/ | ||
|
|
||
| #ifndef QGSRASTERPYRAMIDSOPTIONSWIDGET_H | ||
| #define QGSRASTERPYRAMIDSOPTIONSWIDGET_H | ||
|
|
||
| #include "ui_qgsrasterpyramidsoptionswidgetbase.h" | ||
|
|
||
| class QCheckBox; | ||
|
|
||
| /** \ingroup gui | ||
| * A widget to select format-specific raster saving options | ||
| */ | ||
| class GUI_EXPORT QgsRasterPyramidsOptionsWidget: public QWidget, | ||
| private Ui::QgsRasterPyramidsOptionsWidgetBase | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
|
|
||
| QgsRasterPyramidsOptionsWidget( QWidget* parent = 0, QString provider = "gdal" ); | ||
| ~QgsRasterPyramidsOptionsWidget(); | ||
|
|
||
| void setProvider( QString provider ); | ||
| QStringList createOptions() const { return mPyramidsOptionsWidget->options(); } | ||
| QgsRasterFormatSaveOptionsWidget* createOptionsWidget() { return mPyramidsOptionsWidget; } | ||
|
|
||
| public slots: | ||
|
|
||
| void apply(); | ||
|
|
||
| private slots: | ||
|
|
||
| void on_lePyramidsLevels_editingFinished(); | ||
| void on_cboPyramidsFormat_currentIndexChanged( int index ) | ||
| { mPyramidsOptionsWidget->setEnabled( index != 2 ); } | ||
|
|
||
| private: | ||
|
|
||
| void updateUi(); | ||
|
|
||
| QString mProvider; | ||
| bool mInternal; | ||
| QString mResamplingMethod; | ||
| QList<int> mOverviewList; | ||
| QMap< int, QCheckBox* > mOverviewCheckBoxes; | ||
| }; | ||
|
|
||
| #endif // QGSRASTERLAYERSAVEASDIALOG_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>QgsRasterPyramidsOptionsWidgetBase</class> | ||
| <widget class="QWidget" name="QgsRasterPyramidsOptionsWidgetBase"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>351</width> | ||
| <height>195</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Form</string> | ||
| </property> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <property name="margin"> | ||
| <number>1</number> | ||
| </property> | ||
| <item row="3" column="2"> | ||
| <widget class="QLineEdit" name="lePyramidsLevels"> | ||
| <property name="toolTip"> | ||
| <string>Insert positive integer values separated by spaces</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="7" column="0" colspan="3"> | ||
| <widget class="QLabel" name="label_4"> | ||
| <property name="text"> | ||
| <string>Create Options</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="8" column="0" colspan="3"> | ||
| <widget class="QgsRasterFormatSaveOptionsWidget" name="mPyramidsOptionsWidget" native="true"/> | ||
| </item> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="label_2"> | ||
| <property name="text"> | ||
| <string>Overview format</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="1"> | ||
| <spacer name="horizontalSpacer"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Horizontal</enum> | ||
| </property> | ||
| <property name="sizeType"> | ||
| <enum>QSizePolicy::Fixed</enum> | ||
| </property> | ||
| <property name="sizeHint" stdset="0"> | ||
| <size> | ||
| <width>10</width> | ||
| <height>20</height> | ||
| </size> | ||
| </property> | ||
| </spacer> | ||
| </item> | ||
| <item row="0" column="2"> | ||
| <widget class="QComboBox" name="cboPyramidsFormat"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Internal (if possible)</string> | ||
| </property> | ||
| </item> | ||
| <item> | ||
| <property name="text"> | ||
| <string>External (GTiff)</string> | ||
| </property> | ||
| </item> | ||
| <item> | ||
| <property name="text"> | ||
| <string>External (Erdas Imagine)</string> | ||
| </property> | ||
| </item> | ||
| </widget> | ||
| </item> | ||
| <item row="4" column="2"> | ||
| <widget class="QLineEdit" name="lePyramidResolutions"> | ||
| <property name="toolTip"> | ||
| <string>Pyramid resolutions correspnoding to levels given</string> | ||
| </property> | ||
| <property name="text"> | ||
| <string>to be done</string> | ||
| </property> | ||
| <property name="readOnly"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="6" column="0" colspan="3"> | ||
| <widget class="Line" name="line"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Horizontal</enum> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="0"> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>Custom levels</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="4" column="0"> | ||
| <widget class="QLabel" name="label_3"> | ||
| <property name="text"> | ||
| <string>Resolutions</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="0"> | ||
| <widget class="QLabel" name="textLabel4_2"> | ||
| <property name="text"> | ||
| <string>Resampling method</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="2"> | ||
| <widget class="QComboBox" name="cboResamplingMethod"> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Average</string> | ||
| </property> | ||
| </item> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Nearest Neighbour</string> | ||
| </property> | ||
| </item> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="0"> | ||
| <widget class="QLabel" name="label_5"> | ||
| <property name="text"> | ||
| <string>Levels</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="2"> | ||
| <layout class="QHBoxLayout" name="layoutPyramidLevels"/> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <customwidgets> | ||
| <customwidget> | ||
| <class>QgsRasterFormatSaveOptionsWidget</class> | ||
| <extends>QWidget</extends> | ||
| <header>qgsrasterformatsaveoptionswidget.h</header> | ||
| <container>1</container> | ||
| </customwidget> | ||
| </customwidgets> | ||
| <resources/> | ||
| <connections/> | ||
| </ui> |