Skip to content
Permalink
Browse files

implement UI for pyramids in raster save dialog, ui tweaks and bugfixes

  • Loading branch information
etiennesky committed Aug 24, 2012
1 parent fe6923b commit 9d96e76291d1758e2b5eeb8c92585ab6dd58a645
@@ -27,6 +27,7 @@
#include "qgsproject.h"

#include "qgsrasterformatsaveoptionswidget.h"
#include "qgsrasterpyramidsoptionswidget.h"
#include "qgsdialog.h"

#include <QInputDialog>
@@ -1118,15 +1119,26 @@ void QgsOptions::editGdalDriver( const QString& driverName )
QLabel *label = new QLabel( title, &dlg );
label->setAlignment( Qt::AlignHCenter );
layout->addWidget( label );
QgsRasterFormatSaveOptionsWidget* optionsWidget =
new QgsRasterFormatSaveOptionsWidget( &dlg, driverName,
QgsRasterFormatSaveOptionsWidget::Full, "gdal" );
layout->addWidget( optionsWidget );

if ( dlg.exec() == QDialog::Accepted )
if ( driverName == "_pyramids" )
{
optionsWidget->apply();
QgsRasterPyramidsOptionsWidget* optionsWidget =
new QgsRasterPyramidsOptionsWidget( &dlg, "gdal" );
layout->addWidget( optionsWidget );
dlg.resize( 400, 400 );
if ( dlg.exec() == QDialog::Accepted )
optionsWidget->apply();
}
else
{
QgsRasterFormatSaveOptionsWidget* optionsWidget =
new QgsRasterFormatSaveOptionsWidget( &dlg, driverName,
QgsRasterFormatSaveOptionsWidget::Full, "gdal" );
layout->addWidget( optionsWidget );
if ( dlg.exec() == QDialog::Accepted )
optionsWidget->apply();
}

}

// Return state of the visibility flag for newly added layers. If
@@ -83,6 +83,7 @@ qgsprojectionselector.cpp
qgsquickprint.cpp
qgsrasterlayersaveasdialog.cpp
qgsrasterformatsaveoptionswidget.cpp
qgsrasterpyramidsoptionswidget.cpp
qgsrubberband.cpp
qgsscalecombobox.cpp
qgstextannotationitem.cpp
@@ -169,6 +170,7 @@ qgsprojectionselector.h
qgsquickprint.h
qgsrasterlayersaveasdialog.h
qgsrasterformatsaveoptionswidget.h
qgsrasterpyramidsoptionswidget.h
qgsludialog.h
qgsprojectbadlayerguihandler.h
qgslonglongvalidator.h
@@ -76,6 +76,8 @@ void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
if ( ! isVisible() )
return;

mCollapsed = collapse;

// minimize layout margins and save for subsequent restore
if ( collapse )
{
@@ -93,10 +95,30 @@ void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
}
}

mCollapsed = collapse;
// if we are collapsing, save hidden widgets in a list
if ( collapse )
{
mHiddenWidgets.clear();
foreach ( QWidget *widget, findChildren<QWidget*>() )
{
if ( widget->isHidden() )
mHiddenWidgets << widget;
}
}

// show/hide widgets
foreach ( QWidget *widget, findChildren<QWidget*>() )
widget->setHidden( collapse );

// if we are expanding, re-hide saved hidden widgets
if ( ! collapse )
{
foreach ( QWidget *widget, mHiddenWidgets )
{
widget->setHidden( true );
}
}

if ( mCollapsed )
emit collapsed( this );
else
@@ -52,6 +52,7 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
private:
bool mCollapsed;
QMargins mMargins;
QList< QWidget* > mHiddenWidgets;
};

#endif
@@ -59,17 +59,38 @@ QgsRasterFormatSaveOptionsWidget::QgsRasterFormatSaveOptionsWidget( QWidget* par
{
// key=profileKey values=format,profileName,options
mBuiltinProfiles[ "z_adefault" ] = ( QStringList() << "" << tr( "Default" ) << "" );

// these GTiff profiles are based on Tim's benchmarks at
// http://linfiniti.com/2011/05/gdal-efficiency-of-various-compression-algorithms/
// big: no compression | medium: reasonable size/speed tradeoff | small: smallest size
mBuiltinProfiles[ "z_gtiff_1big" ] = ( QStringList() << "GTiff" << tr( "No compression" )
<< "COMPRESS=NONE BIGTIFF=IF_NEEDED" );
mBuiltinProfiles[ "z_gtiff_2medium" ] = ( QStringList() << "GTiff" << tr( "Low compression" )
<< "COMPRESS=PACKBITS" );
mBuiltinProfiles[ "z_gtiff_3small" ] = ( QStringList() << "GTiff" << tr( "High compression" )
<< "COMPRESS=DEFLATE PREDICTOR=2 ZLEVEL=9" );
mBuiltinProfiles[ "z_gtiff_4jpeg" ] = ( QStringList() << "GTiff" << tr( "Lossy compression" )
<< "COMPRESS=JPEG" );
mBuiltinProfiles[ "z_gtiff_1big" ] =
( QStringList() << "GTiff" << tr( "No compression" )
<< "COMPRESS=NONE BIGTIFF=IF_NEEDED" );
mBuiltinProfiles[ "z_gtiff_2medium" ] =
( QStringList() << "GTiff" << tr( "Low compression" )
<< "COMPRESS=PACKBITS" );
mBuiltinProfiles[ "z_gtiff_3small" ] =
( QStringList() << "GTiff" << tr( "High compression" )
<< "COMPRESS=DEFLATE PREDICTOR=2 ZLEVEL=9" );
mBuiltinProfiles[ "z_gtiff_4jpeg" ] =
( QStringList() << "GTiff" << tr( "Lossy compression" )
<< "COMPRESS=JPEG" );

// overview compression schemes for GTiff format, see
// http://www.gdal.org/gdaladdo.html and http://www.gdal.org/frmt_gtiff.html
// TODO - should we offer GDAL_TIFF_OVR_BLOCKSIZE option here or in QgsRasterPyramidsOptionsWidget ?
mBuiltinProfiles[ "z__pyramids_gtiff_1big" ] =
( QStringList() << "_pyramids" << tr( "No compression" )
<< "COMPRESS_OVERVIEW=NONE BIGTIFF_OVERVIEW=IF_NEEDED" );
mBuiltinProfiles[ "z__pyramids_gtiff_2medium" ] =
( QStringList() << "_pyramids" << tr( "Low compression" )
<< "COMPRESS_OVERVIEW=PACKBITS" );
mBuiltinProfiles[ "z__pyramids_gtiff_3small" ] =
( QStringList() << "_pyramids" << tr( "High compression" )
<< "COMPRESS_OVERVIEW=DEFLATE PREDICTOR_OVERVIEW=2 ZLEVEL=9" ); // how to set zlevel?
mBuiltinProfiles[ "z__pyramids_gtiff_4jpeg" ] =
( QStringList() << "_pyramids" << tr( "Lossy compression" )
<< "COMPRESS_OVERVIEW=JPEG PHOTOMETRIC_OVERVIEW=YCBCR INTERLEAVE_OVERVIEW=PIXEL" );
}

connect( mProfileComboBox, SIGNAL( currentIndexChanged( const QString & ) ),
@@ -109,15 +130,12 @@ void QgsRasterFormatSaveOptionsWidget::setType( QgsRasterFormatSaveOptionsWidget
{
// hide all controls, except stacked widget
foreach ( QWidget* widget, widgets )
{
widget->setVisible( false );
}
mOptionsStackedWidget->setVisible( true );
foreach ( QWidget* widget, mOptionsStackedWidget->findChildren<QWidget *>() )
{
widget->setVisible( true );
}
// show page relevant page

// show elevant page
if ( type == Table )
swapOptionsUI( 0 );
else if ( type == LineEdit )
@@ -127,13 +145,13 @@ void QgsRasterFormatSaveOptionsWidget::setType( QgsRasterFormatSaveOptionsWidget
{
// show all widgets, except profile buttons (unless Full)
foreach ( QWidget* widget, widgets )
{
widget->setVisible( true );
}
if ( type != Full )
{
mProfileButtons->setVisible( false );
}

// show elevant page
if ( type == ProfileLineEdit )
swapOptionsUI( 1 );
}
}

@@ -179,7 +197,11 @@ void QgsRasterFormatSaveOptionsWidget::updateProfiles()

// update UI
mProfileComboBox->blockSignals( false );
mProfileComboBox->setCurrentIndex( 0 );
// mProfileComboBox->setCurrentIndex( 0 );
QSettings mySettings;
mProfileComboBox->setCurrentIndex( mProfileComboBox->findData( mySettings.value(
mProvider + "/driverOptions/" + mFormat.toLower() + "/defaultProfile",
"z_adefault" ) ) );
updateOptions();
}

@@ -205,6 +227,7 @@ void QgsRasterFormatSaveOptionsWidget::updateOptions()
else
{
mOptionsLineEdit->setText( myOptions );
mOptionsLineEdit->setCursorPosition( 0 );
}
}

@@ -293,6 +316,7 @@ void QgsRasterFormatSaveOptionsWidget::optionsTableChanged()
options = options.trimmed();
mOptionsMap[ currentProfileKey()] = options;
mOptionsLineEdit->setText( options );
mOptionsLineEdit->setCursorPosition( 0 );
}

void QgsRasterFormatSaveOptionsWidget::on_mOptionsLineEdit_editingFinished()
@@ -335,6 +359,7 @@ void QgsRasterFormatSaveOptionsWidget::on_mProfileResetButton_clicked()
mOptionsMap[ profileKey ] = "";
}
mOptionsLineEdit->setText( mOptionsMap.value( currentProfileKey() ) );
mOptionsLineEdit->setCursorPosition( 0 );
updateOptions();
}

@@ -408,7 +433,10 @@ void QgsRasterFormatSaveOptionsWidget::setCreateOptions()
myProfiles += i.key() + QString( " " );
++i;
}
mySettings.setValue( mProvider + "/driverOptions/" + mFormat.toLower() + "/profiles", myProfiles.trimmed() );
mySettings.setValue( mProvider + "/driverOptions/" + mFormat.toLower() + "/profiles",
myProfiles.trimmed() );
mySettings.setValue( mProvider + "/driverOptions/" + mFormat.toLower() + "/defaultProfile",
currentProfileKey().trimmed() );
}

void QgsRasterFormatSaveOptionsWidget::setCreateOptions( QString profileName, QString options )
@@ -35,7 +35,8 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget,
Default, // everything except profile buttons (save as dlg)
Full, // everything (options dlg)
Table, // just table
LineEdit // just the line edit
LineEdit, // just the line edit
ProfileLineEdit // Profile + LineEdit
};

QgsRasterFormatSaveOptionsWidget( QWidget* parent = 0, QString format = "GTiff",
@@ -53,6 +54,7 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget,
void apply();
void helpOptions();
bool validateOptions( bool gui = true );
void updateProfiles();

private slots:

@@ -82,7 +84,6 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget,
void setCreateOptions( QString profile, QString options );
void setCreateOptions( QString profile, QStringList list );
QStringList profiles() const;
void updateProfiles();
bool eventFilter( QObject *obj, QEvent *event );

};
@@ -67,12 +67,14 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterDataProvider* s
mMaximumSizeYLineEdit->setText( QString::number( 2000 ) );
}

mOptionsWidget->setProvider( mDataProvider->name() );
mCreateOptionsWidget->setProvider( mDataProvider->name() );
if ( mDataProvider->name() == "gdal" )
{
mOptionsWidget->setFormat( myFormats[0] );
mCreateOptionsWidget->setFormat( myFormats[0] );
}
mOptionsWidget->update();
mCreateOptionsWidget->update();

mPyramidsOptionsWidget->createOptionsWidget()->setType( QgsRasterFormatSaveOptionsWidget::ProfileLineEdit );

}
updateCrsGroup();
@@ -83,6 +85,7 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterDataProvider* s
okButton->setEnabled( false );
}


// this should scroll down to make widget visible, but it's not happening
// (at least part of it is visible)...
connect( mCreateOptionsGroupBox, SIGNAL( expanded( QWidget* ) ),
@@ -155,8 +158,8 @@ void QgsRasterLayerSaveAsDialog::on_mFormatComboBox_currentIndexChanged( const Q
//gdal-specific
if ( mDataProvider && mDataProvider->name() == "gdal" )
{
mOptionsWidget->setFormat( text );
mOptionsWidget->update();
mCreateOptionsWidget->setFormat( text );
mCreateOptionsWidget->update();
}
}

@@ -207,7 +210,7 @@ QString QgsRasterLayerSaveAsDialog::outputFormat() const

QStringList QgsRasterLayerSaveAsDialog::createOptions() const
{
return mOptionsWidget ? mOptionsWidget->options() : QStringList();
return mCreateOptionsWidget ? mCreateOptionsWidget->options() : QStringList();
}

QgsRectangle QgsRasterLayerSaveAsDialog::outputRectangle() const

0 comments on commit 9d96e76

Please sign in to comment.
You can’t perform that action at this time.