tychoGUI  1.0
 All Data Structures Namespaces Files Functions Variables
local_simulation.cpp
Go to the documentation of this file.
1 #include "globals.h"
2 #include "local_simulation.h"
3 #include "ui_local_simulation.h"
4 
5 #include <QFileDialog>
6 #include <QProcess>
7 #include <QByteArray>
8 #include <QTextBrowser>
9 #include <QFile>
10 #include <QTextStream>
11 #include <QDebug>
12 #include <QMessageBox>
13 #include <iostream>
14 #include <fstream>
15 #include <string>
16 
21  QDialog(parent),
22  ui(new Ui::local_simulation)
23 {
24  ui->setupUi(this);
25 
26  proc = new QProcess(this);
27  connect(proc, SIGNAL(readyRead()), this, SLOT(readFromStdout()));
28 
29  connect(ui->tycho_exe,SIGNAL(clicked()), this, SLOT(tycho_exectuable()));
30  connect(ui->parameterfile, SIGNAL(clicked()), this, SLOT(parameterfile_path()));
31  connect(ui->run, SIGNAL(clicked()), this, SLOT(local_simulation_start()));
32  connect(ui->restart, SIGNAL(clicked()), this, SLOT(local_simulation_restart()));
33  connect(ui->stop, SIGNAL(clicked()), this, SLOT(local_simulation_stop()));
34  connect(ui->savelog, SIGNAL(clicked()), this, SLOT(save_log()));
35  connect(ui->reset, SIGNAL(clicked()), this, SLOT(reset_gui()));
36  connect(ui->Help, SIGNAL(clicked()), this, SLOT(open_help()));
37 
38  connect(ui->close, SIGNAL(clicked()), this, SLOT(close()));
39 
40  QFile file("config_tycho_gui.ini");
41  if(!file.open(QIODevice::ReadOnly)) {
42  QMessageBox::information(0, "error", "No config_tycho_gui.ini File found.");
43  }
44 
45  QTextStream in(&file);
46  QString line;
47  QStringList lines;
48 
49  while(!in.atEnd()) {
50  line = in.readLine();
51  lines.append(line);
52  }
53 
54  file.close();
55 
56 
57  //TYCHO exectubale standard directory found in config_tycho_gui.ini File
58  tycho_exe = lines.last();
59  //Automatically enter TYCHO executable and last saved parameterfile
60  ui->tycho_text->setText(tycho_exe);
62 }
63 
65 {
66  delete ui;
67 }
68 
73 
74  tycho_exe.clear();
75 
76  tycho_exe = QFileDialog::getOpenFileName(this, tr("The TYCHO Executable"), QString::null);
77 
78  ui->tycho_text->setText(tycho_exe);
79 
80 }
81 
86 
87  QString parameterfile_QString;
88 
89  parameterfile_QString = QFileDialog::getOpenFileName(this, tr("The TYCHO Executable"), QString::null);
90 
91  ui->parameterfile_text->setText(parameterfile_QString);
92 
93  parameter_file_global=parameterfile_QString;
94 
95 }
96 
101 
102  proc->close();
103 
104  ui->textBrowser->clear();
105 
106  parameterfile.clear();
107 
109 
110  if (tycho_exe.size()==0){
111  run_error_gui();
112  }
113  else
114  {
115  proc->start(tycho_exe, parameterfile);
116  }
117 
118 }
119 
124 
125  proc->close();
126 
127  parameterfile_restart.clear();
128 
129  ui->textBrowser->clear();
130 
132 
133  if (tycho_exe.size()==0){
134  run_error_gui();
135  }
136  else
137  {
139  }
140 
141 }
142 
147 
148  proc->close();
149 
150 }
151 
156 
157  ui->textBrowser->append(proc->readAll().constData());
158 }
159 
164 
165  QString txtfile = QFileDialog::getSaveFileName(this, tr("Save TYCHO Simulation Logfile"), ":", tr("logfile (*.txt)"));
166 
167  QFile file(txtfile);
168  if (file.open(QFile::WriteOnly | QFile::Truncate)) {
169  QTextStream out(&file);
170 
171  out << ui->textBrowser->toPlainText();
172 
173  }
174 
175 }
176 
181 
182  QFile file("config_tycho_gui.ini");
183  if(!file.open(QIODevice::ReadOnly)) {
184  QMessageBox::information(0, "error", "No config_tycho_gui.ini File found.");
185  }
186 
187  //TYCHO exectubale standard directory found in config_tycho_gui.ini File
188  QTextStream in(&file);
189  QString line;
190  QStringList lines;
191 
192  while(!in.atEnd()) {
193  line = in.readLine();
194  lines.append(line);
195  }
196 
197  file.close();
198 
199 
200  //TYCHO exectubale standard directory found in config_tycho_gui.ini File
201  tycho_exe = lines.last();
202  //Automatically enter TYCHO executable and last saved parameterfile
203  ui->tycho_text->setText(tycho_exe);
205 
206  parameter_file_global.clear();
207 
208  ui->tycho_text->setText(tycho_exe);
209  ui->parameterfile_text->setText("");
210 
211  ui->textBrowser->clear();
212 
213 }
214 
219 
220  pro_run = new run_error;
221  pro_run->show();
222 }
223 
228 
230  mylocal_simulation_help->show();
231 }
232