-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
131 lines (109 loc) · 2.58 KB
/
main.cpp
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
#include "mainwindow.h"
#include <QApplication>
#include <QCursor>
#include <QString>
#include <QMap>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
#include <QStringList>
//#include <QMapIterator>
//#include <Eigen/Dense>
//#include <boost/algorithm/string.hpp>
#include <cstdlib>
#include <ctime>
#include <iostream>
void readParams(QMap<QString, QString>& params)
{
QFile file("/home/pi/Documents/config.txt");
if(!file.open(QIODevice::ReadOnly))
QMessageBox::information(0, "error", file.errorString());
QTextStream in(&file);
while(!in.atEnd())
{
QString line = in.readLine();
QStringList fields = line.split("=");
params[fields[0]] = fields[1];
}
file.close();
}
/*
void writesum(QStringList args){
QFile file("/home/pi/log1.txt");
if(!file.open(QIODevice::WriteOnly)) {
QMessageBox::information(0, "error", file.errorString());
}
QTextStream out(&file);
for(int i = 0; i < args.size() ; ++i )
out << args[i] << "\n";
file.close();
}
*/
/*
void eigenMatrixToFile(const Eigen::MatrixXd& M, QString filename)
{
QFile file( filename );
if(!file.open(QFile::WriteOnly | QFile::Text))
return;
QTextStream out(&file);
for(int i = 0; i < M.rows(); ++i)
{
QStringList row;
for(int j = 0; j < M.cols(); ++j)
row << QString::number(M(i,j));
out << (row.join(" ") + "\n");
}
}
using Eigen::MatrixXd;
*/
/*
void toCons()
{
std::cout << "not enough args.\n";
}
*/
int main(int argc, char *argv[])
{
srand(time(nullptr));
QMap<QString, QString> params;
readParams(params);
//QMapIterator<QString, QString> i(params);
/* MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
eigenMatrixToFile(m, "/home/pi/log.txt");
*/
/* QFile file("/home/pi/log.txt");
if(!file.open(QIODevice::WriteOnly)) {
QMessageBox::information(0, "error", file.errorString());
}
QTextStream out(&file);
QMapIterator<QString, QString> i(params);
while(i.hasNext())
{
i.next();
out << i.key() << " " << i.value();
}
file.close();
*/
QApplication a(argc, argv);
/*
QStringList args = QCoreApplication::arguments();
if (args.size() != 4)
{
toCons();
exit(1);
}
writesum(args);
*/
//removing cursor
a.setOverrideCursor(QCursor(Qt::BlankCursor));
MainWindow w;
w.setParams(params);
w.setConfigs();
w.setWindowState(Qt::WindowFullScreen);
w.show();
return a.exec();
}