tweak output format for gnuplot data export
This commit is contained in:
@ -116,25 +116,24 @@ void ChartWindow::exportDat()
|
|||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
QTextStream out(&file);
|
||||||
|
constexpr int fw = 16;
|
||||||
|
out.setFieldAlignment(QTextStream::AlignRight);
|
||||||
|
out.setRealNumberPrecision(8);
|
||||||
|
|
||||||
file.write("# Thermodynamic data from ");
|
out << "# Thermodynamic data from " << filename << "\n";
|
||||||
file.write(filename.toLocal8Bit());
|
out << "# Step";
|
||||||
file.write("\n# Columns:");
|
for (auto &c : charts)
|
||||||
for (auto &c : charts) {
|
out << qSetFieldWidth(0) << ' ' << qSetFieldWidth(fw) << c->get_title();
|
||||||
file.write(" ");
|
out << qSetFieldWidth(0) << '\n';
|
||||||
file.write(c->get_title());
|
|
||||||
}
|
|
||||||
file.write("\n");
|
|
||||||
|
|
||||||
int lines = charts[0]->get_count();
|
int lines = charts[0]->get_count();
|
||||||
for (int i = 0; i < lines; ++i) {
|
for (int i = 0; i < lines; ++i) {
|
||||||
// timestep
|
// timestep
|
||||||
file.write(QString::number(charts[0]->get_step(i)).toLocal8Bit());
|
out << qSetFieldWidth(0) << ' ' << qSetFieldWidth(fw) << charts[0]->get_step(i);
|
||||||
for (auto &c : charts) {
|
for (auto &c : charts)
|
||||||
file.write(" ");
|
out << qSetFieldWidth(0) << ' ' << qSetFieldWidth(fw) << c->get_data(i);
|
||||||
file.write(QString::number(c->get_data(i)).toLocal8Bit());
|
out << qSetFieldWidth(0) << '\n';
|
||||||
}
|
|
||||||
file.write("\n");
|
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user