66 changes: 47 additions & 19 deletions src/gui/qgsrasterformatsaveoptionswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 & ) ),
Expand Down Expand Up @@ -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 )
Expand All @@ -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 );
}
}

Expand Down Expand Up @@ -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();
}

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

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

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

Expand Down Expand Up @@ -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 )
Expand Down
5 changes: 3 additions & 2 deletions src/gui/qgsrasterformatsaveoptionswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -53,6 +54,7 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget,
void apply();
void helpOptions();
bool validateOptions( bool gui = true );
void updateProfiles();

private slots:

Expand Down Expand Up @@ -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 );

};
Expand Down
137 changes: 19 additions & 118 deletions src/gui/qgsrasterlayersaveasdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,119 +10,15 @@
#include <QFileDialog>
#include <QSettings>

// this widget class will go into its separate file

// #include <QMouseEvent>
// #include <QStyleOptionGroupBox>
// #include <QStylePainter>

GroupBox::GroupBox( QWidget *parent )
: QGroupBox( parent ), m_collapsed( false )
{
connect( this, SIGNAL( toggled ( bool ) ), this, SLOT( setToggled( bool ) ) );
//setToggled( isChecked() );
}

GroupBox::GroupBox( const QString &title, QWidget *parent )
: QGroupBox(title, parent ), m_collapsed( false )
{}

bool GroupBox::isCollapsed() { return m_collapsed; }

// void GroupBox::mousePressEvent( QMouseEvent *e )
// {
// QgsDebugMsg("press event");
// if( e->button() == Qt::LeftButton )
// {
// QgsDebugMsg("left but");
// QStyleOptionGroupBox option;
// initStyleOption( &option );
// QRect buttonArea( 0, 0, 16, 16 );
// buttonArea.moveTopRight( option.rect.adjusted( 0, 0, -10, 0
// ).topRight() );
// if( buttonArea.contains( e->pos() ) )
// {
// clickPos = e->pos();
// return;
// }
// }
// QGroupBox::mousePressEvent( e );
// }

// void GroupBox::mouseReleaseEvent( QMouseEvent *e )
// {
// QgsDebugMsg("release");
// if( e->button() == Qt::LeftButton && clickPos == e->pos() )
// setCollapse( !isCollapsed() );
// }

// void GroupBox::paintEvent( QPaintEvent * )
// {
// QgsDebugMsg("paint event");

// QStylePainter paint( this );
// QStyleOptionGroupBox option;
// initStyleOption( &option );
// paint.drawComplexControl( QStyle::CC_GroupBox, option );
// paint.drawItemPixmap(
// option.rect.adjusted( 0, 0, -10, 0 ),
// Qt::AlignTop | Qt::AlignRight,
// QPixmap( m_collapsed ?
// ":/images/images/navigate_down2_16x16.png" :
// ":/images/images/navigate_up2_16x16.png" ) );
// }

void GroupBox::showEvent( QShowEvent * event )
{
// QgsDebugMsg(QString("%1 showEvent %2 %3").arg(objectName()).arg(isChecked()).arg(isCollapsed()));
QGroupBox::showEvent( event );
if ( ! isChecked() && ! isCollapsed() )
setCollapsed( true );
}

void GroupBox::setCollapsed( bool collapse )
{
if ( ! isVisible() )
return;
// QgsDebugMsg(QString("%1 setcollapse %2").arg(objectName()).arg(collapse));

// minimize layout margins, restore later
if ( collapse )
{
if ( layout() )
{
margins = layout()->contentsMargins();
layout()->setContentsMargins(1,1,1,1);
}
}
else
{
if ( layout() )
{
layout()->setContentsMargins( margins );
}
}
m_collapsed = collapse;
foreach( QWidget *widget, findChildren<QWidget*>() )
widget->setHidden( collapse );

if ( m_collapsed )
emit collapsed( this );
else
emit expanded( this );
}

QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLayer, QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
const QgsCoordinateReferenceSystem& layerCrs,
const QgsCoordinateReferenceSystem& currentCrs,
QWidget* parent, Qt::WindowFlags f ):
QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLayer,
QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs,
QWidget* parent, Qt::WindowFlags f ) :
QDialog( parent, f )
, mRasterLayer( rasterLayer )
, mDataProvider( sourceProvider )
, mCurrentExtent( currentExtent )
, mLayerCrs( layerCrs )
, mCurrentCrs( currentCrs )
, mExtentState( OriginalExtent )
, mRasterLayer( rasterLayer ), mDataProvider( sourceProvider )
, mCurrentExtent( currentExtent ), mLayerCrs( layerCrs )
, mCurrentCrs( currentCrs ), mExtentState( OriginalExtent )
, mResolutionState( OriginalResolution )
{
setupUi( this );
Expand Down Expand Up @@ -175,12 +71,14 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
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();
Expand All @@ -191,9 +89,10 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
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* ) ),
connect( mCreateOptionsGroupBox, SIGNAL( expanded( QWidget* ) ),
this, SLOT( groupBoxExpanded( QWidget* ) ) );

}
Expand Down Expand Up @@ -263,8 +162,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();
}
}

Expand Down Expand Up @@ -315,7 +214,7 @@ QString QgsRasterLayerSaveAsDialog::outputFormat() const

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

QgsRectangle QgsRasterLayerSaveAsDialog::outputRectangle() const
Expand Down Expand Up @@ -690,6 +589,8 @@ void QgsRasterLayerSaveAsDialog::addNoDataRow( double min, double max )

void QgsRasterLayerSaveAsDialog::noDataCellTextEdited( const QString & text )
{
Q_UNUSED( text );

QLineEdit *lineEdit = dynamic_cast<QLineEdit *>( sender() );
if ( !lineEdit ) return;
int row = -1;
Expand Down
43 changes: 4 additions & 39 deletions src/gui/qgsrasterlayersaveasdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRast
UserResolution
};

QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLayer, QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent, const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs, QWidget* parent = 0, Qt::WindowFlags f = 0 );
QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLayer,
QgsRasterDataProvider* sourceProvider, const QgsRectangle& currentExtent,
const QgsCoordinateReferenceSystem& layerCrs, const QgsCoordinateReferenceSystem& currentCrs,
QWidget* parent = 0, Qt::WindowFlags f = 0 );
~QgsRasterLayerSaveAsDialog();

Mode mode() const;
Expand Down Expand Up @@ -125,41 +128,3 @@ class GUI_EXPORT QgsRasterLayerSaveAsDialog: public QDialog, private Ui::QgsRast

#endif // QGSRASTERLAYERSAVEASDIALOG_H


// this widget class will go into its separate file
#ifndef GROUPBOX_H
#define GROUPBOX_H

#include <QGroupBox>

class GroupBox : public QGroupBox
{
Q_OBJECT

public:
GroupBox( QWidget *parent = 0 );
GroupBox( const QString &title, QWidget *parent = 0 );

bool isCollapsed();

signals:
void collapsed( QWidget* );
void expanded( QWidget* );

public slots:
void setToggled( bool toggled ) { setCollapsed( ! toggled ); }
void setCollapsed( bool collapsed );

protected:
/* void mousePressEvent( QMouseEvent *e ); */
/* void mouseReleaseEvent( QMouseEvent *e ); */
/* void paintEvent( QPaintEvent * ); */
void showEvent( QShowEvent * event );

private:
QPoint clickPos;
bool m_collapsed;
QMargins margins;
};

#endif
153 changes: 153 additions & 0 deletions src/gui/qgsrasterpyramidsoptionswidget.cpp
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 );
}
}
63 changes: 63 additions & 0 deletions src/gui/qgsrasterpyramidsoptionswidget.h
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
12 changes: 6 additions & 6 deletions src/ui/qgsrasterformatsaveoptionswidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>1</number>
</property>
<item row="0" column="1">
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="1">
Expand Down Expand Up @@ -95,12 +98,6 @@
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>30</number>
</attribute>
<column>
<property name="text">
<string>Name</string>
Expand Down Expand Up @@ -188,6 +185,9 @@
</property>
<item>
<widget class="QLineEdit" name="mOptionsLineEdit">
<property name="toolTip">
<string>Insert KEY=VALUE pairs seperated by spaces</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
Expand Down
200 changes: 117 additions & 83 deletions src/ui/qgsrasterlayersaveasdialogbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-239</y>
<width>514</width>
<height>686</height>
<height>784</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
Expand Down Expand Up @@ -190,7 +190,7 @@
</layout>
</item>
<item>
<widget class="GroupBox" name="mExtentGroupBox">
<widget class="QgsCollapsibleGroupBox" name="mExtentGroupBox">
<property name="title">
<string>Extent</string>
</property>
Expand Down Expand Up @@ -336,7 +336,7 @@
</widget>
</item>
<item>
<widget class="GroupBox" name="mResolutionGroupBox">
<widget class="QgsCollapsibleGroupBox" name="mResolutionGroupBox">
<property name="title">
<string>Resolution</string>
</property>
Expand Down Expand Up @@ -412,7 +412,103 @@
</widget>
</item>
<item>
<widget class="GroupBox" name="mNoDataGroupBox">
<widget class="QgsCollapsibleGroupBox" name="mCreateOptionsGroupBox">
<property name="title">
<string>Create Options</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="margin">
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QgsRasterFormatSaveOptionsWidget" name="mCreateOptionsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mTilesGroupBox">
<property name="title">
<string>Tiles</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="mMaximumSizeXLabel">
<property name="toolTip">
<string>Maximum number of columns in one tile.</string>
</property>
<property name="text">
<string>Max columns</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mMaximumSizeXLineEdit">
<property name="toolTip">
<string>Maximum number of columns in one tile.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mMaximumSizeYLabel">
<property name="toolTip">
<string>Maximum number of rows in one tile.</string>
</property>
<property name="text">
<string>Max rows</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mMaximumSizeYLineEdit">
<property name="toolTip">
<string>Maximum number of rows in one tile.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mTileModeCheckBox">
<property name="text">
<string>Create VRT</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mNoDataGroupBox">
<property name="enabled">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -506,101 +602,33 @@
</widget>
</item>
<item>
<widget class="GroupBox" name="mCreateOptionsGroupBox">
<property name="title">
<string>Create Options</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QgsRasterFormatSaveOptionsWidget" name="mOptionsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="GroupBox" name="mTilesGroupBox">
<widget class="QgsCollapsibleGroupBox" name="mPyramidsGroupBox">
<property name="title">
<string>Tiles</string>
<string>Pyramids (not yet implemented)</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QLabel" name="mMaximumSizeXLabel">
<property name="toolTip">
<string>Maximum number of columns in one tile.</string>
</property>
<property name="text">
<string>Max columns</string>
</property>
</widget>
</item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLineEdit" name="mMaximumSizeXLineEdit">
<property name="toolTip">
<string>Maximum number of columns in one tile.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mMaximumSizeYLabel">
<property name="toolTip">
<string>Maximum number of rows in one tile.</string>
<widget class="QCheckBox" name="cbxPyramidsBuild">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Max rows</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mMaximumSizeYLineEdit">
<property name="toolTip">
<string>Maximum number of rows in one tile.</string>
<string>Build pyramids</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mTileModeCheckBox">
<property name="text">
<string>Create VRT</string>
</property>
</widget>
<widget class="QgsRasterPyramidsOptionsWidget" name="mPyramidsOptionsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
Expand All @@ -625,9 +653,15 @@
<container>1</container>
</customwidget>
<customwidget>
<class>GroupBox</class>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgsrasterlayersaveasdialog.h</header>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsRasterPyramidsOptionsWidget</class>
<extends>QWidget</extends>
<header>qgsrasterpyramidsoptionswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
Expand Down
162 changes: 162 additions & 0 deletions src/ui/qgsrasterpyramidsoptionswidgetbase.ui
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>
7 changes: 7 additions & 0 deletions tests/src/core/testqgscomposerhtml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void TestQgsComposerHtml::table()
{
QgsComposerHtml* htmlItem = new QgsComposerHtml( mComposition, false );
QgsComposerFrame* htmlFrame = new QgsComposerFrame( mComposition, htmlItem, 0, 0, 100, 200 );
htmlFrame->setFrame( true );
htmlItem->addFrame( htmlFrame );
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
QgsCompositionChecker checker( "Composer html table", mComposition, QString( QString( TEST_DATA_DIR ) + QDir::separator() +
Expand All @@ -77,6 +78,12 @@ void TestQgsComposerHtml::tableMultiFrame()
QgsComposerFrame* htmlFrame = new QgsComposerFrame( mComposition, htmlItem, 10, 10, 100, 50 );
htmlItem->addFrame( htmlFrame );
htmlItem->setResizeMode( QgsComposerMultiFrame::RepeatUntilFinished );
int nFrames = htmlItem->nFrames();
for ( int i = 0; i < nFrames; ++i )
{
htmlItem->frame( i )->setFrame( true );
}

bool result = true;
//page1
htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "html_table.html" ) ) );
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void TestQgsComposerMap::initTestCase()
mComposition = new QgsComposition( mMapRenderer );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
mComposerMap->setFrame( true );
mComposition->addComposerMap( mComposerMap );
}

Expand Down Expand Up @@ -121,6 +122,7 @@ void TestQgsComposerMap::grid()
void TestQgsComposerMap::overviewMap()
{
QgsComposerMap* overviewMap = new QgsComposerMap( mComposition, 20, 130, 70, 70 );
overviewMap->setFrame( true );
mComposition->addComposerMap( overviewMap );
mComposerMap->setNewExtent( QgsRectangle( 785462.375, 3341423.125, 789262.375, 3343323.125 ) ); //zoom in
overviewMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3350923.125 ) );
Expand Down
95 changes: 93 additions & 2 deletions tests/src/python/test_qgsgeometry.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import unittest

from qgis.core import (QgsGeometry,
QgsVectorLayer,
QgsFeature,
QgsPoint,
QGis)

# Convenience instances in case you may need them
# not used in this test
#from utilities import getQgisTestApp
#QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()
from utilities import getQgisTestApp
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()

class TestQgsGeometry(unittest.TestCase):

Expand Down Expand Up @@ -55,6 +57,95 @@ def testFromMultiPolygon(self):
(QGis.WKBMultiPolygon, myMultiPolygon.type()))
assert myMultiPolygon.wkbType() == QGis.WKBMultiPolygon, myMessage

def testIntersection(self):
myLine = QgsGeometry.fromPolyline([QgsPoint(0, 0),QgsPoint(1, 1),QgsPoint(2, 2)])
myPoint = QgsGeometry.fromPoint(QgsPoint(1, 1))
intersectionGeom = QgsGeometry.intersection(myLine, myPoint)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
(QGis.Point, intersectionGeom.type()))
assert intersectionGeom.wkbType() == QGis.WKBPoint, myMessage

layer = QgsVectorLayer("Point", "intersection", "memory")
assert layer.isValid(), "Failed to create valid point memory layer"

provider = layer.dataProvider()

ft = QgsFeature()
ft.setGeometry(intersectionGeom)
provider.addFeatures([ft])

myMessage = ('Expected:\n%s\nGot:\n%s\n' %
(1, layer.featureCount()))
assert layer.featureCount() == 1, myMessage

def testBuffer(self):
myPoint = QgsGeometry.fromPoint(QgsPoint(1, 1))
bufferGeom = myPoint.buffer(10, 5)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
(QGis.Polygon, bufferGeom.type()))
assert bufferGeom.wkbType() == QGis.WKBPolygon, myMessage

layer = QgsVectorLayer("Polygon", "buffer", "memory")
assert layer.isValid(), "Failed to create valid polygon memory layer"

provider = layer.dataProvider()

ft = QgsFeature()
ft.setGeometry(bufferGeom)
provider.addFeatures([ft])

myMessage = ('Expected:\n%s\nGot:\n%s\n' %
(1, layer.featureCount()))
assert layer.featureCount() == 1, myMessage

def testContains(self):
myPoly = QgsGeometry.fromPolygon([[QgsPoint(0, 0),QgsPoint(2, 0),QgsPoint(2, 2),QgsPoint(0, 2), QgsPoint(0, 0)]])
myPoint = QgsGeometry.fromPoint(QgsPoint(1, 1))
containsGeom = QgsGeometry.contains(myPoly, myPoint)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
("True", containsGeom))
assert containsGeom == True, myMessage

def testTouches(self):
myLine = QgsGeometry.fromPolyline([QgsPoint(0, 0),QgsPoint(1, 1),QgsPoint(2, 2)])
myPoly = QgsGeometry.fromPolygon([[QgsPoint(0, 0),QgsPoint(1, 1),QgsPoint(2, 0),QgsPoint(0, 0)]])
touchesGeom = QgsGeometry.touches(myLine, myPoly)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
("True", touchesGeom))
assert touchesGeom == True, myMessage

def testOverlaps(self):
myPolyA = QgsGeometry.fromPolygon([[QgsPoint(0, 0),QgsPoint(1, 3),QgsPoint(2, 0),QgsPoint(0, 0)]])
myPolyB = QgsGeometry.fromPolygon([[QgsPoint(0, 0),QgsPoint(2, 0),QgsPoint(2, 2),QgsPoint(0, 2), QgsPoint(0, 0)]])
overlapsGeom = QgsGeometry.overlaps(myPolyA, myPolyB)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
("True", overlapsGeom))
assert overlapsGeom == True, myMessage

def testWithin(self):
myLine = QgsGeometry.fromPolyline([QgsPoint(0.5, 0.5),QgsPoint(1, 1),QgsPoint(1.5, 1.5)])
myPoly = QgsGeometry.fromPolygon([[QgsPoint(0, 0),QgsPoint(2, 0),QgsPoint(2, 2),QgsPoint(0, 2), QgsPoint(0, 0)]])
withinGeom = QgsGeometry.within(myLine, myPoly)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
("True", withinGeom))
assert withinGeom == True, myMessage

def testEquals(self):
myPointA = QgsGeometry.fromPoint(QgsPoint(1, 1))
myPointB = QgsGeometry.fromPoint(QgsPoint(1, 1))
equalsGeom = QgsGeometry.equals(myPointA, myPointB)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
("True", equalsGeom))
assert equalsGeom == True, myMessage

def testCrosses(self):
myLine = QgsGeometry.fromPolyline([QgsPoint(0, 0),QgsPoint(1, 1),QgsPoint(3, 3)])
myPoly = QgsGeometry.fromPolygon([[QgsPoint(1, 0),QgsPoint(2, 0),QgsPoint(2, 2),QgsPoint(1, 2), QgsPoint(1, 0)]])
crossesGeom = QgsGeometry.crosses(myLine, myPoly)
myMessage = ('Expected:\n%s\nGot:\n%s\n' %
("True", crossesGeom))
assert crossesGeom == True, myMessage


if __name__ == '__main__':
unittest.main()
Expand Down