Skip to content
Permalink
Browse files

adapted gui to support data input

  • Loading branch information
mbernasocchi authored and pka committed Jul 5, 2011
1 parent 0d2cdd8 commit 7bf8489b61e22be809dbca7401229ec0762eee53
@@ -31,6 +31,9 @@
#include <QString>
#include <QStringList>
#include <QVariant>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>

#include <osg/DisplaySettings>

@@ -51,14 +54,44 @@ QgsGlobePluginDialog::~QgsGlobePluginDialog()

QString QgsGlobePluginDialog::openFile()
{
//see http://www.gdal.org/formats_list.html
const char* filter = "GDAL files (*.dem *.tif *.tiff *.jpg *.jpeg *.asc);;DEM files (*.dem);;All files (*.*)";
QString path = QFileDialog::getOpenFileName( this,
tr( "Open earth file" ),
earthFile,
tr( "Earth files (*.earth)" ) );
tr( "Open raster file" ),
QDir::homePath (),
tr( filter ) );

return path;
}

bool QgsGlobePluginDialog::validateNetworkResource(QString uri)
{
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(QUrl(uri));
QNetworkReply *reply = manager->get(request);

//wait for response syncronously
QEventLoop eLoop;
connect( manager, SIGNAL( finished( QNetworkReply * ) ),
&eLoop, SLOT( quit() ) );
eLoop.exec(QEventLoop::ExcludeUserInputEvents);

if (QNetworkReply::HostNotFoundError != reply->error())
//FIXME:should be the following line but reply->error() always give "unknown error"
//if (QNetworkReply::NoError == reply->error())
{
QByteArray data = reply->readAll();
QString req(data);
return true;
}
else
{
showMessageBox( tr("Invalid URL: ") + reply->errorString() );
return false;
}
}

void QgsGlobePluginDialog::showMessageBox( QString text )
{
QMessageBox msgBox;
@@ -81,102 +114,42 @@ void QgsGlobePluginDialog::on_buttonBox_accepted()
{
setStereoConfig();
saveStereoConfig();
/*
*
// Validate input settings
QString srcUrl( inputSrcDataset->text() );
QString srcLayer( comboSrcLayer->currentText() );
if ( srcUrl.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Input OGR dataset is missing!" ) );
return;
}

if ( srcLayer.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Input OGR layer name is missing!" ) );
return;
}
// Validate output settings
QString dstFormat( comboDstFormats->currentText() );
QString dstUrl( inputDstDataset->text() );
QString dstLayer( inputDstLayer->text() );
if ( dstLayer.isEmpty() )
dstLayer = srcLayer;
if ( dstFormat.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Target OGR format not selected!" ) );
return;
}
if ( dstUrl.isEmpty() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Output OGR dataset is missing!" ) );
return;
}
if ( dstLayer.isEmpty() )
if ( globeRunning() )
{
QMessageBox::warning( this,
tr( "OGR Layer Converter" ),
tr( "Output OGR layer name is missing!" ) );
return;
restartGlobe();
}
accept();
}

// TODO: SRS transformation support
//QString srcSrs("EPSG:");
//QString dstSrs("EPSG:");
//srcSrs += inputSrcSrs->text();
//dstSrs += inputDstSrs->text();
// Execute layer translation
bool success = false;
// TODO: Use try-catch to display more meaningful error messages from Translator
Translator worker( srcUrl, dstUrl, dstFormat );
worker.setSourceLayer( srcLayer );
worker.setTargetLayer( dstLayer );
success = worker.translate();
void QgsGlobePluginDialog::on_buttonBox_rejected()
{
loadStereoConfig();
setStereoConfig();
reject();
}

if ( success )
//ELEVATION
void QgsGlobePluginDialog::on_elevationCombo_currentIndexChanged(QString type)
{
if("Raster" == type)
{
QMessageBox::information( this,
tr( "OGR Layer Converter" ),
tr( "Successfully translated layer '%1'" ).arg( srcLayer ) );
elevationActions->setCurrentIndex(0);
}
else
{
QMessageBox::information( this,
tr( "OGR Layer Converter" ),
tr( "Failed to translate layer '%1'" ).arg( srcLayer ) );
elevationActions->setCurrentIndex(1);
}
}

// Close dialog box
*/

if ( globeRunning() )
{
restartGlobe();
}
accept();
void QgsGlobePluginDialog::on_elevationBrowse_clicked()
{
elevationPath->setText( openFile() );
}

void QgsGlobePluginDialog::on_buttonBox_rejected()
void QgsGlobePluginDialog::on_elevationTest_clicked()
{
loadStereoConfig();
setStereoConfig();
reject();
validateNetworkResource( elevationPath->text() );
}

void QgsGlobePluginDialog::on_resetStereoDefaults_clicked()
@@ -32,12 +32,12 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
~QgsGlobePluginDialog();

private:
QString earthFile;
QString openFile();
QSettings settings;
QString openFile();
void updateStereoDialog();
void restartGlobe();
bool globeRunning();
bool validateNetworkResource( QString uri);
void showMessageBox( QString text);
//! Set osg/DisplaySettings
void setStereoConfig();
@@ -52,6 +52,7 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
void on_buttonBox_accepted();
void on_buttonBox_rejected();

//STEREO
void on_comboStereoMode_currentIndexChanged(QString value);
void on_eyeSeparation_valueChanged(double value);
void on_screenDistance_valueChanged(double value);
@@ -62,6 +63,11 @@ class QgsGlobePluginDialog:public QDialog, private Ui::QgsGlobePluginDialogGuiBa
void on_splitStereoHorizontalEyeMapping_currentIndexChanged(int value);
void on_splitStereoVerticalEyeMapping_currentIndexChanged(int value);
void on_resetStereoDefaults_clicked();

//ELEVATION
void on_elevationCombo_currentIndexChanged(QString value);
void on_elevationBrowse_clicked();
void on_elevationTest_clicked();
};

#endif // QGIS_GLOBE_PLUGIN_DIALOG_H

0 comments on commit 7bf8489

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