Added ssihub test application

Improved ssihub dialog and tested authentication
p4#: 21768
This commit is contained in:
Magne Sjaastad
2013-05-30 15:33:12 +02:00
parent 73f1b4052b
commit 261301ad4a
9 changed files with 804 additions and 68 deletions

View File

@@ -98,7 +98,7 @@ RiuMainWindow::RiuMainWindow()
m_treeModelPdm = new RimUiTreeModelPdm(this);
m_ssihubInterface = NULL;
m_ssihubInterface = new ssihub::Interface;
createActions();
createMenus();
@@ -552,6 +552,10 @@ void RiuMainWindow::slotRefreshFileActions()
m_saveProjectAction->setEnabled(projectExists);
m_saveProjectAsAction->setEnabled(projectExists);
m_closeProjectAction->setEnabled(projectExists);
bool projectFileExists = QFile::exists(app->project()->fileName());
m_importWellPathsAction->setEnabled(projectFileExists);
}
@@ -1581,56 +1585,38 @@ void RiuMainWindow::selectedCases(std::vector<RimCase*>& cases)
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotImportWellPaths()
{
CVF_ASSERT(m_ssihubInterface);
RiaApplication* app = RiaApplication::instance();
if (!app->project())
{
return;
}
if (!m_ssihubInterface)
if (!QFile::exists(app->project()->fileName()))
{
m_ssihubInterface = new ssihub::Interface;
return;
}
// ssihub::Interface ssiInterface;
m_ssihubInterface->setWebServiceAddress(app->preferences()->ssihubAddress);
//m_ssihubInterface->setJsonDestinationFolder(dir);
//m_ssihubInterface->setRegion(int east, int west, int north, int south);
QStringList wellPaths = m_ssihubInterface->jsonWellPaths();
QString dir;
QString wellPathsFolderPath;
QString projectFileName = app->project()->fileName();
QFileInfo fileInfo(projectFileName);
dir = fileInfo.canonicalPath();
dir += "/" + fileInfo.completeBaseName() + "_wellpaths";
wellPathsFolderPath = fileInfo.canonicalPath();
QString wellPathFolderName = fileInfo.completeBaseName() + "_wellpaths";
QDir projFolder(wellPathsFolderPath);
projFolder.mkdir(wellPathFolderName);
QStringList wellPathFileNames;
for (int i = 0; i < wellPaths.size(); i++)
wellPathsFolderPath += "/" + wellPathFolderName;
m_ssihubInterface->setWebServiceAddress(app->preferences()->ssihubAddress);
m_ssihubInterface->setJsonDestinationFolder(wellPathsFolderPath);
//m_ssihubInterface->setRegion(int east, int west, int north, int south);
QStringList wellPaths = m_ssihubInterface->jsonWellPaths();
if (wellPaths.size() > 0)
{
QUuid guid = QUuid::createUuid();
QString filename = projectFileName + QString("/%1.json").arg(guid);
QFile file(filename);
if (file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream out(&file);
out << wellPaths[i];
wellPathFileNames.push_back(filename);
}
}
if (wellPathFileNames.size() > 0)
{
app->addWellPathsToModel(wellPathFileNames);
app->addWellPathsToModel(wellPaths);
if (app->project()) app->project()->createDisplayModelAndRedrawAllViews();
}
}

View File

@@ -7,6 +7,7 @@ set( QOBJECT_HEADERS
ssihubWebServiceInterface.h
ssihubDialog.h
httpwindow.h
)
set( QT_UI_FILES
@@ -20,6 +21,8 @@ endif()
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../FileInterface
)
@@ -29,6 +32,8 @@ add_library( ${PROJECT_NAME}
ssihubDialog.cpp
httpwindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../FileInterface/RifJsonEncodeDecode.cpp
${MOC_FILES_CPP}
${FORM_FILES_CPP}
)

View File

@@ -20,22 +20,559 @@
#include "ssihubDialog.h"
namespace ssihub {
#include <QtGui>
#include <QtNetwork>
#include "httpwindow.h"
#include "ui_authenticationdialog.h"
#include "RifJsonEncodeDecode.h"
namespace ssihub {
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
BasicAboutDialog::BasicAboutDialog(QWidget* parent)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
FetchWellPathsDialog::FetchWellPathsDialog(QWidget *parent)
: QDialog(parent)
{
urlSsiHubLineEdit = new QLineEdit;
urlSsiHubLabel = new QLabel(tr("SSIHUB address:"));
urlSsiHubLabel->setBuddy(urlSsiHubLineEdit);
urlLineEdit = new QLineEdit;
urlLabel = new QLabel(tr("SSIHUB complete request:"));
urlLabel->setBuddy(urlLineEdit);
statusLabel = new QLabel(tr("Status : idle"));
statusLabel->setWordWrap(true);
m_downloadFieldsButton = new QPushButton(tr("Get fields"));
connect(m_downloadFieldsButton, SIGNAL(clicked()), this, SLOT(downloadFields()));
// Fields data model and view
m_fieldListView = new QListView(this);
m_fieldModel = new QStringListModel;
m_fieldListView->setModel(m_fieldModel);
connect(m_fieldListView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection& )), this, SLOT(slotSelectionChanged(const QItemSelection&, const QItemSelection& )));
// Well paths data model and view
m_wellPathsListView = new QListView(this);
m_wellPathsModel = new QStringListModel;
m_wellPathsListView->setModel(m_wellPathsModel);
m_downloadWellPathsButton = new QPushButton(tr("Get well paths"));
m_downloadWellPathsButton->setDefault(true);
buttonBox = new QDialogButtonBox;
buttonBox->addButton(m_downloadFieldsButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(m_downloadWellPathsButton, QDialogButtonBox::ActionRole);
QDialogButtonBox* buttonBox1 = new QDialogButtonBox;
buttonBox1->addButton(QDialogButtonBox::Cancel);
buttonBox1->addButton("Import well paths", QDialogButtonBox::AcceptRole);
connect(buttonBox1, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox1, SIGNAL(rejected()), this, SLOT(reject()));
progressDialog = new QProgressDialog(this);
connect(urlLineEdit, SIGNAL(textChanged(QString)),
this, SLOT(refreshButtonStatus()));
connect(&qnam, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
#ifndef QT_NO_OPENSSL
connect(&qnam, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
#endif
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelDownload()));
connect(m_downloadWellPathsButton, SIGNAL(clicked()), this, SLOT(downloadWellPaths()));
QVBoxLayout *topLayout1 = new QVBoxLayout;
QVBoxLayout *topLayout2 = new QVBoxLayout;
topLayout1->addWidget(urlSsiHubLabel);
topLayout1->addWidget(urlSsiHubLineEdit);
topLayout2->addWidget(urlLabel);
topLayout2->addWidget(urlLineEdit);
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addLayout(topLayout1);
topLayout->addLayout(topLayout2);
QHBoxLayout *ssihubLayout = new QHBoxLayout;
ssihubLayout->addWidget(m_fieldListView);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(topLayout);
mainLayout->addLayout(ssihubLayout);
mainLayout->addWidget(statusLabel);
mainLayout->addWidget(buttonBox);
mainLayout->addWidget(m_wellPathsListView);
mainLayout->addWidget(buttonBox1);
setLayout(mainLayout);
setWindowTitle(tr("Import Well Paths"));
urlLineEdit->setFocus();
refreshButtonStatus();
resize(600, 400);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::startRequest(QUrl url)
{
reply = qnam.get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()),
this, SLOT(httpFinished()));
connect(reply, SIGNAL(readyRead()),
this, SLOT(httpReadyRead()));
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SLOT(updateDataReadProgress(qint64,qint64)));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::cancelDownload()
{
statusLabel->setText(tr("Download canceled."));
httpRequestAborted = true;
reply->abort();
refreshButtonStatus();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::httpFinished()
{
if (httpRequestAborted) {
if (m_file) {
m_file->close();
m_file->remove();
delete m_file;
m_file = 0;
}
reply->deleteLater();
progressDialog->hide();
return;
}
progressDialog->hide();
m_file->flush();
m_file->close();
QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (reply->error()) {
m_file->remove();
QMessageBox::information(this, tr("HTTP"),
tr("Download failed: %1.")
.arg(reply->errorString()));
} else if (!redirectionTarget.isNull()) {
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
if (QMessageBox::question(this, tr("HTTP"),
tr("Redirect to %1 ?").arg(newUrl.toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
url = newUrl;
reply->deleteLater();
m_file->open(QIODevice::WriteOnly);
m_file->resize(0);
startRequest(url);
return;
}
} else {
statusLabel->setText(tr("Downloaded data to %1.").arg(m_destinationFolder));
}
updateFromDownloadedFiles();
refreshButtonStatus();
reply->deleteLater();
reply = 0;
delete m_file;
m_file = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::httpReadyRead()
{
// this slot gets called every time the QNetworkReply has new data.
// We read all of its new data and write it into the file.
// That way we use less RAM than when reading it at the finished()
// signal of the QNetworkReply
if (m_file)
m_file->write(reply->readAll());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
{
if (httpRequestAborted)
return;
progressDialog->setMaximum(totalBytes);
progressDialog->setValue(bytesRead);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::refreshButtonStatus()
{
if (m_fieldListView->selectionModel()->selectedIndexes().size() > 0)
{
m_downloadWellPathsButton->setEnabled(true);
}
else
{
m_downloadWellPathsButton->setEnabled(false);
}
m_downloadFieldsButton->setEnabled(!urlSsiHubLineEdit->text().isEmpty());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator)
{
QDialog dlg;
Ui::Dialog ui;
ui.setupUi(&dlg);
dlg.adjustSize();
ui.siteDescription->setText(tr("%1 at %2").arg(authenticator->realm()).arg(url.host()));
// Did the URL have information? Fill the UI
// This is only relevant if the URL-supplied credentials were wrong
ui.userEdit->setText(url.userName());
ui.passwordEdit->setText(url.password());
if (dlg.exec() == QDialog::Accepted) {
authenticator->setUser(ui.userEdit->text());
authenticator->setPassword(ui.passwordEdit->text());
}
}
#ifndef QT_NO_OPENSSL
void FetchWellPathsDialog::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
{
QString errorString;
foreach (const QSslError &error, errors) {
if (!errorString.isEmpty())
errorString += ", ";
errorString += error.errorString();
}
if (QMessageBox::warning(this, tr("HTTP"),
tr("One or more SSL errors has occurred: %1").arg(errorString),
QMessageBox::Ignore | QMessageBox::Abort) == QMessageBox::Ignore) {
reply->ignoreSslErrors();
}
}
#endif
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::setUrl(const QString& httpAddress)
{
urlLineEdit->setText(httpAddress);
url = httpAddress;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::downloadWellPaths()
{
QModelIndex mi = m_fieldListView->currentIndex();
QString fieldName = m_fieldModel->data(mi, Qt::DisplayRole).toString();
QString completeUrlText = urlSsiHubLineEdit->text() + "/resinsight/projects/" + fieldName + "/wellpaths";
setUrl(completeUrlText);
QString fileName = jsonWellPathsFilePath();
if (QFile::exists(fileName))
{
QFile::remove(fileName);
m_wellFilePathList = QStringList();
m_wellPathsModel->setStringList(m_wellFilePathList);
}
m_file = new QFile(fileName);
if (!m_file->open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("HTTP"),
tr("Unable to save the file %1: %2.")
.arg(fileName).arg(m_file->errorString()));
delete m_file;
m_file = 0;
return;
}
progressDialog->setWindowTitle(tr("HTTP"));
progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
m_downloadWellPathsButton->setEnabled(false);
// schedule the request
httpRequestAborted = false;
startRequest(url);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::downloadFields()
{
QString completeUrlText = urlSsiHubLineEdit->text() + "/resinsight/projects";
setUrl(completeUrlText);
// Delete already wellPathList
{
QString wellFileName = jsonWellPathsFilePath();
if (QFile::exists(wellFileName))
{
QFile::remove(wellFileName);
m_wellFilePathList = QStringList();
m_wellPathsModel->setStringList(m_wellFilePathList);
}
}
QString fieldsFileName = jsonFieldsFilePath();
m_file = new QFile(fieldsFileName);
if (!m_file->open(QIODevice::WriteOnly)) {
QMessageBox::information(this, tr("HTTP"),
tr("Unable to save the file %1: %2.")
.arg(fieldsFileName).arg(m_file->errorString()));
delete m_file;
m_file = 0;
return;
}
progressDialog->setWindowTitle(tr("HTTP"));
progressDialog->setLabelText(tr("Downloading %1.").arg(fieldsFileName));
m_downloadFieldsButton->setEnabled(false);
// schedule the request
httpRequestAborted = false;
startRequest(url);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::setDestinationFolder(const QString& folder)
{
m_destinationFolder = folder;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::setSsiHubUrl(const QString& httpAddress)
{
QString validAddress(httpAddress);
if (validAddress.endsWith('/'))
{
validAddress = validAddress.left(validAddress.size() - 1);
}
urlSsiHubLineEdit->setText(validAddress);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected)
{
QModelIndexList idxList = selected.indexes();
if (idxList.size() == 1)
{
QString fieldName = m_fieldModel->data(idxList[0], Qt::DisplayRole).toString();
QString completeUrlText = urlSsiHubLineEdit->text() + "/resinsight/projects/" + fieldName;
setUrl(completeUrlText);
}
else
{
setUrl("");
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::updateFieldsModel()
{
QString fileName = jsonFieldsFilePath();
if (QFile::exists(fileName))
{
JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(fileName);
QStringList fieldNames;
QMapIterator<QString, QVariant> it(jsonMap);
while (it.hasNext())
{
it.next();
QString key = it.key();
if (key[0].isDigit())
{
QMap<QString, QVariant> fieldMap = it.value().toMap();
fieldNames.push_back(fieldMap["name"].toString());
}
}
m_fieldModel->setStringList(fieldNames);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString FetchWellPathsDialog::jsonFieldsFilePath()
{
return m_destinationFolder + "/fields.json";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString FetchWellPathsDialog::jsonWellPathsFilePath()
{
return m_destinationFolder + "/wellpaths.json";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::updateFromDownloadedFiles()
{
updateFieldsModel();
extractAndUpdateSingleWellFiles();
// Update well path model
m_wellPathsModel->setStringList(m_wellFilePathList);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::extractAndUpdateSingleWellFiles()
{
QString filename = jsonWellPathsFilePath();
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
{
return;
}
QString fileContent = file.readAll();
int pos = 0;
pos = fileContent.indexOf('{', pos);
while (pos >= 0)
{
int singleWellPathStart = pos;
// Move to first char after starting brace
pos++;
int startBracket = 1;
while (startBracket > 0 && pos < fileContent.size())
{
if (fileContent.at(pos) == '{')
{
startBracket++;
}
else if (fileContent.at(pos) == '}')
{
startBracket--;
}
pos++;
}
// Write out a single well path
{
QString singleWellPath = fileContent.mid(singleWellPathStart, pos - singleWellPathStart);
QUuid guid = QUuid::createUuid();
QString singleWellPathFilePath = m_destinationFolder + QString("/wellpath_%1.json").arg(guid);
QFile outputFile(singleWellPathFilePath);
if (outputFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
QTextStream out(&outputFile);
out << singleWellPath;
if (m_wellFilePathList.indexOf(singleWellPathFilePath) < 0)
{
m_wellFilePathList.push_back(singleWellPathFilePath);
}
}
}
// Find next starting brace
pos = fileContent.indexOf('{', pos);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList FetchWellPathsDialog::downloadedJsonWellPathFiles()
{
return m_wellFilePathList;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void FetchWellPathsDialog::showEvent(QShowEvent* event)
{
refreshButtonStatus();
QDialog::showEvent(event);
}
} // namespace ssihub

View File

@@ -18,25 +18,107 @@
#pragma once
#include <QtGui/QDialog>
#include <QtGui/QIcon>
#include <QDialog>
#include <QNetworkAccessManager>
#include <QUrl>
#include <QItemSelection>
QT_BEGIN_NAMESPACE
class QDialogButtonBox;
class QFile;
class QLabel;
class QLineEdit;
class QProgressDialog;
class QPushButton;
class QSslError;
class QAuthenticator;
class QNetworkReply;
class QStringListModel;
class QListView;
QT_END_NAMESPACE
class QGridLayout;
namespace ssihub {
//==================================================================================================
//
//
//
//==================================================================================================
class BasicAboutDialog : public QDialog
class FetchWellPathsDialog : public QDialog
{
public:
BasicAboutDialog(QWidget* parent);
Q_OBJECT
public:
FetchWellPathsDialog(QWidget *parent = 0);
void setSsiHubUrl(const QString& httpAddress);
void setDestinationFolder(const QString& folder);
void startRequest(QUrl url);
QStringList downloadedJsonWellPathFiles();
protected:
virtual void showEvent(QShowEvent* event);
private:
void setUrl(const QString& httpAddress);
QString jsonFieldsFilePath();
QString jsonWellPathsFilePath();
void updateFromDownloadedFiles();
void updateFieldsModel();
void extractAndUpdateSingleWellFiles();
private slots:
void downloadWellPaths();
void downloadFields();
void cancelDownload();
void httpFinished();
void httpReadyRead();
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
void refreshButtonStatus();
void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *);
void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
#ifndef QT_NO_OPENSSL
void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
#endif
private:
QLabel* statusLabel;
QLabel* urlLabel;
QLineEdit* urlLineEdit;
QLabel* urlSsiHubLabel;
QLineEdit* urlSsiHubLineEdit;
QPushButton* m_downloadFieldsButton;
QListView* m_fieldListView;
QListView* m_wellPathsListView;
QStringListModel* m_wellPathsModel;
QProgressDialog* progressDialog;
QPushButton* m_downloadWellPathsButton;
QDialogButtonBox* buttonBox;
QUrl url;
QNetworkAccessManager qnam;
QNetworkReply* reply;
QFile* m_file;
int httpGetId;
bool httpRequestAborted;
QString m_destinationFolder;
QStringListModel* m_fieldModel;
QStringList m_wellFilePathList;
};
}
} // namespace ssihub

View File

@@ -64,18 +64,17 @@ void Interface::setRegion(int east, int west, int north, int south)
//--------------------------------------------------------------------------------------------------
QStringList Interface::jsonWellPaths()
{
ssihub::WebServiceInterface ws;
FetchWellPathsDialog fetchWellPaths;
fetchWellPaths.setSsiHubUrl(m_webServiceAddress);
fetchWellPaths.setDestinationFolder(m_jsonDestinationFolder);
ws.setUrl(m_webServiceAddress);
QMap<QString, QVariant> params;
ws.fetchData("", params);
// BasicAboutDialog dialog(NULL);
// dialog.exec();
return m_importedWellPathFiles;
QStringList importedWellPathFiles;
if (fetchWellPaths.exec() == QDialog::Accepted)
{
importedWellPathFiles = fetchWellPaths.downloadedJsonWellPathFiles();
}
return importedWellPathFiles;
}
}; // namespace ssihub

View File

@@ -42,8 +42,6 @@ private:
int m_west;
int m_north;
int m_south;
QStringList m_importedWellPathFiles;
};
}

View File

@@ -21,7 +21,7 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QStringList>
#include "httpwindow.h"
#include "ssihubDialog.h"
//#include <QObject>
@@ -63,8 +63,8 @@ void WebServiceInterface::setUrl(const QString& url)
QStringList WebServiceInterface::fetchData(const QString& method, const QMap<QString, QVariant>& arguments)
{
HttpWindow httpWin;
httpWin.setUrl(m_httpAddress);
FetchWellPathsDialog httpWin;
httpWin.setSsiHubUrl(m_httpAddress);
httpWin.exec();

View File

@@ -0,0 +1,61 @@
cmake_minimum_required (VERSION 2.8)
project ( ssihubTestApplication )
set (QT_COMPONENTS_REQUIRED QtCore QtGui QtMain QtOpenGl QtNetwork QtScript QtScriptTools)
find_package (Qt4 COMPONENTS ${QT_COMPONENTS_REQUIRED} REQUIRED)
include (${QT_USE_FILE})
# Open GL
find_package( OpenGL )
add_subdirectory(../ssihubInterface "${CMAKE_CURRENT_BINARY_DIR}/ssihubInterface")
include_directories(
${ssihubInterface_SOURCE_DIR}
)
# Qt MOC
set ( QT_MOC_HEADERS
)
qt4_wrap_cpp( MOC_FILES_CPP
${QT_MOC_HEADERS}
)
# Resource file
set( QRC_FILES
)
# Runs RCC on specified files
qt4_add_resources( QRC_FILES_CPP
${QRC_FILES}
)
# add the executable
add_executable ( ${PROJECT_NAME}
main.cpp
${MOC_FILES_CPP}
${QRC_FILES_CPP}
)
target_link_libraries ( ${PROJECT_NAME}
ssihubInterface
${QT_LIBRARIES}
)
# Copy Qt Dlls
if (MSVC)
foreach (qtlib ${QT_COMPONENTS_REQUIRED})
# Debug
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_CURRENT_BINARY_DIR}/Debug/${qtlib}d4.dll)
# Release
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_CURRENT_BINARY_DIR}/Release/${qtlib}4.dll)
endforeach( qtlib )
endif(MSVC)

View File

@@ -0,0 +1,68 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QApplication>
#include <QDir>
#include "ssihubInterface.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QString destinationFolder("c:/tmp/resinsight_ws");
QString wsAddress("http://127.0.0.1:5000");
ssihub::Interface wsInterface;
wsInterface.setWebServiceAddress(wsAddress);
wsInterface.setJsonDestinationFolder(destinationFolder);
QStringList jsonWellPathFileNames = wsInterface.jsonWellPaths();
// void setWebServiceAddress(const QString wsAdress);
// void setJsonDestinationFolder(const QString folder);
// void setRegion(int east, int west, int north, int south);
//
// QStringList jsonWellPaths();
return app.exec();
}