-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfilereader.cpp
71 lines (63 loc) · 1.88 KB
/
filereader.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
#include "filereader.h"
FileReader::FileReader(QObject *parent) :
QObject(parent)
{
//
}
void FileReader::startReadData()
{
QFile file("ace_swepam_1m.txt");
file.open(QIODevice::ReadOnly);
QTextStream fileStream(&file);
QString str;
ready = false;
QVector<QStringList> fileData;
do {
str = fileStream.readLine();
QStringList splitedStr = str.split(" ", QString::SkipEmptyParts);
fileData.append(splitedStr);
} while (!fileStream.atEnd());
if(x_data_list.empty() && y_data_list.empty())
{
//kopiuje wszystko od 14 linii w gore
for(int i = 18; i < fileData.size(); i++)
{
if(fileData.at(i).at(6).toInt() == 0)
{
QVector<float> lines;
x_data_list.append(fileData.at(i).at(5).toInt());
lines.append(fileData.at(i).at(7).toFloat());
lines.append(fileData.at(i).at(8).toFloat());
lines.append(fileData.at(i).at(9).toFloat());
y_data_list.append(lines);
}
}
}
else if(!x_data_list.empty() && !y_data_list.empty())
{
if(fileData.at(fileData.size() - 2).at(6).toInt() == 0)
{
QVector<float> line;
x_data_list.append(fileData.at(fileData.size() - 2).at(5).toInt());
line.append(fileData.at(fileData.size() - 2).at(7).toFloat());
line.append(fileData.at(fileData.size() - 2).at(8).toFloat());
line.append(fileData.at(fileData.size() - 2).at(9).toFloat());
y_data_list.append(line);
}
}
fileData.clear();
emit(dataReady(x_data_list, y_data_list));
file.close();
}
QVector<long long int> FileReader::getXdata(void)
{
return x_data_list;
}
QVector<QVector<float> > FileReader::getYdata(void)
{
return y_data_list;
}
bool FileReader::checkState()
{
return ready;
}