-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoutput.cpp
More file actions
140 lines (110 loc) · 5.6 KB
/
Copy pathoutput.cpp
File metadata and controls
140 lines (110 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include "output.h"
#include "ui_output.h"
#include "version.h"
#include <QDesktopServices>
#include <QMessageBox>
Output::Output(QWidget *parent, simulationVariables *simSettings) :
QDialog(parent),
ui(new Ui::Output)
{
settings = simSettings;
ui->setupUi(this);
setWindowTitle("Output settings");
setWindowIcon(QIcon ("://resources/icon.png"));
//Sort out end of run outputs
QFont font;
font.setWeight( QFont::Bold );
ui->output_title->setFont(font);
ui->output_title->setText("End of run outputs");
ui->intro_01->setAlignment(Qt::AlignJustify);
ui->label_f1->setFont(font);
ui->label_f2->setFont(font);
ui->label_f3->setFont(font);
ui->intro_01->setWordWrap(true);
ui->intro_01->setText("This output dialogue allows you to set the text for up to two custom output files to reflect the state of a completed simulation. For example, you can output the matrix, the number of characters or terminals, and the tree (which can also be output as a separate file - see below). You can include commands for downstream analysis of the data. For more details of how to write outputs, please see the TREvoSim documentation (available by clicking the button below).");
ui->intro_02->setWordWrap(true);
ui->intro_02->setText("In addition to the two custom files above, this option allows you to save the tree as a .nex file. Provide a base name here.");
QObject::connect(ui->docsPushButton, &QPushButton::clicked, this, &Output::docs);
ui->file_01_base->setText(settings->logFileNameBase01);
ui->file_01_extension->setText(settings->logFileExtension01);
ui->string_f1->insertPlainText(settings->logFileString01);
ui->string_f1->moveCursor (QTextCursor::Start) ;
ui->string_f1->ensureCursorVisible();
ui->c_write_file_01->setChecked(settings->writeFileOne);
ui->file_02_base->setText(settings->logFileNameBase02);
ui->file_02_extension->setText(settings->logFileExtension02);
ui->string_f2->insertPlainText(settings->logFileString02);
ui->string_f2->moveCursor (QTextCursor::Start) ;
ui->string_f2->ensureCursorVisible();
ui->c_write_file_02->setChecked(settings->writeFileTwo);
ui->c_write_tree->setChecked(settings->writeTree);
ui->file_03_base->setText(settings->logFileNameBase03);
//Sort out running log outputs
ui->output_title_2->setFont(font);
ui->output_title_2->setText("Running log output");
ui->intro_3->setAlignment(Qt::AlignJustify);
ui->intro_3->setWordWrap(true);
ui->intro_3->setText("This output dialogue allows you to set the text for a running log that reflects the state of a simulation as it runs. You can output, for example, the playing field, or the tree at a user-defined frequency. For more details of how to write outputs, please see the TREvoSim documentation (available by clicking the button below).");
QObject::connect(ui->docsPushButton_2, &QPushButton::clicked, this, &Output::docs);
ui->s_frequency->setValue(settings->runningLogFrequency);
ui->c_write_running_log->setChecked(settings->writeRunningLog);
if (settings->writeRunningLog) ui->running_log_body->setEnabled(true);
else ui->running_log_body->setEnabled(false);
ui->c_write_ee->setChecked(settings->writeEE);
ui->running_log_body->insertPlainText(settings->runningLogString);
QObject::connect(ui->c_write_running_log, &QCheckBox::stateChanged, this, &Output::slotWriteRunningLogChanged);
}
void Output::on_buttonBox_accepted()
{
settings->writeTree = ui->c_write_tree->isChecked();
settings->logFileNameBase01 = ui->file_01_base->text();
settings->logFileNameBase01.replace(" ", "_");
settings->logFileNameBase01.replace("\\", "/");
QString user_ext = ui->file_01_extension->text();
if (user_ext.length() != 0)
{
if (user_ext.at(0) != QChar('.') || user_ext.length() != 4) QMessageBox::warning(nullptr, "Oops", "I don't think extension 1 is valid. If it is, email RJG and he can sort.");
else
{
settings->logFileExtension01 = user_ext;
settings->logFileExtension01.replace(" ", "");
}
}
settings->logFileString01 = ui->string_f1->toPlainText();
settings->logFileNameBase02 = ui->file_02_base->text();
settings->logFileNameBase02.replace(" ", "_");
settings->logFileNameBase02.replace("\\", "/");
user_ext = ui->file_02_extension->text();
if (user_ext.length() != 0)
{
if (user_ext.at(0) != QChar('.') || user_ext.length() != 4) QMessageBox::warning(nullptr, "Oops", "I don't think extension 2 is valid. If it is, email RJG and he can sort.");
else
{
settings->logFileExtension02 = user_ext;
settings->logFileExtension02.replace(" ", "");
}
}
settings->logFileString02 = ui->string_f2->toPlainText();
settings->logFileNameBase03 = ui->file_03_base->text();
settings->logFileNameBase03.replace(" ", "_");
settings->logFileNameBase03.replace("\\", "/");
settings->writeEE = ui->c_write_ee->isChecked();
settings->writeFileOne = ui->c_write_file_01->isChecked();
settings->writeFileTwo = ui->c_write_file_02->isChecked();
settings->writeRunningLog = ui->c_write_running_log->isChecked();
settings->runningLogString = ui->running_log_body->toPlainText();
settings->runningLogFrequency = ui->s_frequency->value();
}
void Output::docs()
{
QDesktopServices::openUrl(QUrl(QString(DOCSURLLOG)));
}
void Output::slotWriteRunningLogChanged()
{
if (ui->c_write_running_log->isChecked())ui->running_log_body->setEnabled(true);
else ui->running_log_body->setEnabled(false);
}
Output::~Output()
{
delete ui;
}