--- /dev/null
+// dialog.cpp
+
+#include "dialog.h"
+#include "ui_dialog.h"
+#include <QDebug>
+#include <QString>
+#include <QProcess>
+#include <QScrollBar>
+#include <QMessageBox>
+#include <QFileInfo>
+#include <QFileDialog>
+
+#include <QTextStream>
+#include <QFile>
+#include <QDesktopServices>
+#include <QUrl>
+
+Dialog::Dialog(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog)
+{
+ ui->setupUi(this);
+
+ // Play button for output - initially disabled
+ //ui->playOutputButton->setEnabled(false);
+ ui->openGnuplotButton->setEnabled(false);
+
+ // Create three processes
+ // 1.imachexec, 2.input play 3.output play
+ mImachexecProcess = new QProcess(this);
+ mGnuplotProcess = new QProcess(this);
+ //mOutputPlayProcess = new QProcess(this);
+
+ connect(mImachexecProcess, SIGNAL(started()), this, SLOT(processStarted()));
+
+ connect(mImachexecProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(readyReadStandardOutput()));
+ connect(mImachexecProcess, SIGNAL(finished(int)), this, SLOT(imachexecFinished()));
+}
+
+Dialog::~Dialog()
+{
+ delete ui;
+}
+
+void Dialog::processStarted()
+{
+ qDebug() << "processStarted()";
+}
+
+// imach start
+void Dialog::on_startButton_clicked()
+{
+ QString program = "imach";
+
+ QStringList arguments;
+
+ QString input = ui->fromLineEdit->text();
+ if(input.isEmpty()) {
+ qDebug() << "No input";
+ QMessageBox::information(this,
+ tr("imach"),tr("Input file not specified"));
+ return;
+ }
+ QString output = input;
+// QString output = ui->toLineEdit->text();
+// if(output.isEmpty()) {
+// qDebug() << "No output";
+// QMessageBox::information(this,
+// tr("imach"),tr("Output file not specified"));
+// return;
+// }
+
+// QString fileName = ui->toLineEdit->text();
+// qDebug() << "output file check " << fileName;
+// qDebug() << "QFile::exists(fileName) = " << QFile::exists(fileName);
+// if (QFile::exists(fileName)) {
+// if (QMessageBox::question(this, tr("imach"),
+// tr("There already exists a file called %1 in "
+// "the current directory. Overwrite?").arg(fileName),
+// QMessageBox::Yes|QMessageBox::No, QMessageBox::No)
+// == QMessageBox::No)
+// return;
+// QFile::remove(fileName);
+// while(QFile::exists(fileName)) {
+// qDebug() << "output file still there";
+// }
+// }
+
+// arguments << input << output;
+ arguments << input << " q";
+
+ qDebug() << arguments;
+
+ mImachexecProcess->setProcessChannelMode(QProcess::MergedChannels);
+ mImachexecProcess->start(program, arguments);
+}
+
+void Dialog::readyReadStandardOutput()
+{
+ mOutputString.append(mImachexecProcess->readAllStandardOutput());
+ ui->textEdit->setText(mOutputString);
+
+ // put the slider at the bottom
+ ui->textEdit->verticalScrollBar()
+ ->setSliderPosition(
+ ui->textEdit->verticalScrollBar()->maximum());
+}
+
+void Dialog::imachexecFinished()
+{
+ // Set the imachexec status by checking output gnuplot file's existence
+ //QString fileName = ui->toLineEdit->text();
+ QString fichnom = ui->fromLineEdit->text();
+ QFileInfo fileInfor(fichnom);
+ QString NomComplet = fileInfor.completeBaseName();
+ //QString NomSuffix = fileInfor.suffix();
+ //QString NomCheminsansEx = fileInfor.canonicalPath()+NomComplet;
+ QString NomCompGp = fileInfor.canonicalPath()+"/"+NomComplet+".gp";
+ //QFileInfo fileInfoGp(NomCompGp);
+
+ //if (QFile::exists(fileName)) {
+ if (QFile::exists(NomCompGp)) {
+ ui->imachStatusLabel
+ ->setText("IMaCh Status: Successful!");
+ //ui->playOutputButton->setEnabled(true);
+ ui->openGnuplotButton->setEnabled(true);
+ }
+ else {
+ ui->imachStatusLabel
+ ->setText("IMaCh Status: Failed!");
+ }
+}
+
+// Browse... button clicked - this is for input file
+void Dialog::on_fileOpenButton_clicked()
+{
+ QString fileName =
+ QFileDialog::getOpenFileName(
+ this,
+ tr("Open File"),
+ "/tmp/test",
+ tr("imach parameter files (*.imach *.txt *.log *.gp)"));
+ QFileInfo fileInfor(fileName);
+ if (!fileName.isEmpty()) {
+ ui->fromLineEdit->setText(fileName);
+ }
+
+}
+
+void Dialog::on_openLogButton_clicked()
+{
+ QString fichnom = ui->fromLineEdit->text();
+ QFileInfo fileInfor(fichnom);
+ QString NomComplet = fileInfor.completeBaseName();
+ QString NomCompLog = fileInfor.canonicalPath()+"/"+NomComplet+".log";
+ //QFileInfo fileInfolog(NomCompLog);
+ QDesktopServices::openUrl(QUrl("file://"+NomCompLog,QUrl::TolerantMode));
+}
+
+void Dialog::on_launchbrowButton_clicked()
+{
+ QString fichnom = ui->fromLineEdit->text();
+ QFileInfo fileInfor(fichnom);
+ QString NomComplet = fileInfor.completeBaseName();
+ QString NomCompLaunch = fileInfor.canonicalPath()+"/"+NomComplet+".htm";
+ //QFileInfo fileInfolog(NomCompLaunch;
+ QDesktopServices::openUrl(QUrl("file://"+NomCompLaunch,QUrl::TolerantMode));
+}
+
+void Dialog::on_openGnuplotButton_clicked()
+{
+ // QString program = "ffplay";
+ // QStringList arguments;
+ QString fichnom = ui->fromLineEdit->text();
+ QFileInfo fileInfor(fichnom);
+ QString NomComplet = fileInfor.completeBaseName();
+ //QString NomSuffix = fileInfor.suffix();
+ //QString NomCheminsansEx = fileInfor.canonicalPath()+NomComplet;
+ QString NomCompGp = fileInfor.canonicalPath()+"/"+NomComplet+".gp";
+ QFileInfo fileInfoGp(NomCompGp);
+ //QString input = NomCheminsansEx;
+ // arguments << input;
+ // mInputPlayProcess->start(program, arguments);
+ // QFile file(NomCompLog);
+ // if(!file.open(QIODevice::ReadOnly))
+ // QMessageBox::information(0,"info",file.errorString());
+
+ QDesktopServices::openUrl(QUrl("file://"+NomCompGp,QUrl::TolerantMode));
+//o QTextStream in(&file);
+//o ui->playInputButton->setText(in.readAll());
+}
+
+
+void Dialog::on_runGnuplotButton_clicked()
+{
+ QString program = "gnuplot";
+ QStringList arguments;
+ QString fichnom = ui->fromLineEdit->text();
+ QFileInfo fileInfor(fichnom);
+ QString NomComplet = fileInfor.completeBaseName();
+ QString NomCompGp = fileInfor.canonicalPath()+"/"+NomComplet+".gp";
+ //QFileInfo fileInfoGp(NomCompGp);
+ //QString input = NomCheminsansEx;
+ arguments << NomCompGp;
+ mGnuplotProcess->start(program, arguments);
+ // QFile file(NomCompLog);
+ // if(!file.open(QIODevice::ReadOnly))
+ // QMessageBox::information(0,"info",file.errorString());
+
+ //QDesktopServices::openUrl(QUrl("file://"+NomCompGp,QUrl::TolerantMode));
+//o QTextStream in(&file);
+//o ui->playInputButton->setText(in.readAll());
+}
+
+//void Dialog::on_playOutputButton_clicked()
+//{
+// QString program = "ffplay";
+// QStringList arguments;
+// QString output = ui->toLineEdit->text();
+// arguments << output;
+// mInputPlayProcess->start(program, arguments);
+//}
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Dialog</class>
+ <widget class="QDialog" name="Dialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>406</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="imachStatusLabel">
+ <property name="text">
+ <string>IMaCh parameter file</string>
+ </property>
+ <property name="buddy">
+ <cstring>fromLineEdit</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="fromLineEdit">
+ <property name="locale">
+ <locale language="French" country="France"/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="fileOpenButton">
+ <property name="text">
+ <string>Browse...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QPushButton" name="startButton">
+ <property name="text">
+ <string>Run imach</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0" colspan="3">
+ <widget class="QTextEdit" name="textEdit"/>
+ </item>
+ <item row="4" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QPushButton" name="runGnuplotButton">
+ <property name="text">
+ <string>Run Gnuplot file</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QPushButton" name="openLogButton">
+ <property name="text">
+ <string>Browse log file</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="openGnuplotButton">
+ <property name="text">
+ <string>Edit gnuplot file</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="6" column="2">
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QPushButton" name="launchbrowButton">
+ <property name="text">
+ <string>Visualize results</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>298</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>pushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>Dialog</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>267</x>
+ <y>125</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>267</x>
+ <y>174</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>