-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataManager.cpp
More file actions
166 lines (134 loc) · 3.78 KB
/
DataManager.cpp
File metadata and controls
166 lines (134 loc) · 3.78 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include "DataManager.h"
#include <stdio.h>
#include <iostream>
//#include "dstat.h"
#include <memory>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cuda/vector_functions.h>
#include <fstream>
DataManager::DataManager(AppSettings * appSettings)
{
this->appSettings = appSettings;
LoadParameters();
}
void DataManager::LoadParameters()
{
QList<QString> filter = QStringList("*.par");
QList<QFileInfo> files = QDir(":/res/vechist/").entryInfoList(filter, QDir::Files | QDir::Readable);
foreach(QFileInfo fileInfo, files) {
QFile file(fileInfo.absoluteFilePath());
if (file.open(QIODevice::ReadOnly)) {
while (!file.atEnd()) {
QList<QByteArray> tokens = file.readLine().simplified().split(' ');
QList<QByteArray>::const_iterator it = tokens.begin();
if (it == tokens.end())
continue;
QByteArray type = *it;
if (++it == tokens.end())
continue;
QByteArray name = *it;
bool singleElement = (tokens.size() == 3); // type, name and one value
char counter[10] = "000000000";
int counterPos = 8; // position of last digit
while (++it != tokens.end()) {
if (type == "string") {
valStrings[name.toStdString()] = it->toStdString();
}
//m_parameterNames << name;
//if (!singleElement) {
// m_parameterNames.back() += "[";
// m_parameterNames.back() += counter + counterPos;
// m_parameterNames.back() += "]";
// int j = 8; // position of last digit
// ++counter[j];
// while (j > 0 && counter[j] > '9') {
// counter[j] = '0';
// ++counter[--j];
// }
// if (j < counterPos)
// counterPos = j;
//}
//if (type == "color") {
// layout->addWidget(new QLabel(m_parameterNames.back()));
// bool ok;
// ColorEdit *colorEdit = new ColorEdit(it->toUInt(&ok, 16), m_parameterNames.size() - 1);
// m_parameterEdits << colorEdit;
// layout->addWidget(colorEdit);
// connect(colorEdit, SIGNAL(colorChanged(QRgb,int)), this, SLOT(setColorParameter(QRgb,int)));
// ++row;
//} else if (type == "float") {
// layout->addWidget(new QLabel(m_parameterNames.back()));
// bool ok;
// FloatEdit *floatEdit = new FloatEdit(it->toFloat(&ok), m_parameterNames.size() - 1);
// m_parameterEdits << floatEdit;
// layout->addWidget(floatEdit);
// connect(floatEdit, SIGNAL(valueChanged(float,int)), this, SLOT(setFloatParameter(float,int)));
// ++row;
//}
}
}
file.close();
}
}
}
DataManager::~DataManager()
{
}
int DataManager::GetCubemapSize()
{
return cubemap_size;
}
void DataManager::GetVolumeSize(int &nx, int &ny, int&nz)
{
nx = dim[0];
ny = dim[1];
nz = dim[2];
}
void DataManager::GetQCube(int &x, int &y, int &z, int &nx, int &ny, int &nz)
{
x = qCubePos[0];
y = qCubePos[1];
z = qCubePos[2];
nx = qCubeSize[0];
ny = qCubeSize[1];
nz = qCubeSize[2];
}
void DataManager::SetQCube(int x, int y, int z, int nx, int ny, int nz)
{
qCubePos[0] = x;
qCubePos[1] = y;
qCubePos[2] = z;
qCubeSize[0] = nx;
qCubeSize[1] = ny;
qCubeSize[2] = nz;
}
void DataManager::MoveCube(int x, int y, int z)
{
if (!CubeInsideVolumeX(qCubePos[0] + x, qCubeSize[0]))
x = 0;
if (!CubeInsideVolumeY(qCubePos[1] + y, qCubeSize[1]))
y = 0;
if (!CubeInsideVolumeZ(qCubePos[2] + z, qCubeSize[2]))
z = 0;
qCubePos[0] += x;
qCubePos[1] += y;
qCubePos[2] += z;
}
bool DataManager::CubeInsideVolumeX(int x, int nx)
{
return x >= 0 && (x + nx) <= dim[0];
}
bool DataManager::CubeInsideVolumeY(int x, int nx)
{
return x >= 0 && (x + nx) <= dim[1];
}
bool DataManager::CubeInsideVolumeZ(int x, int nx)
{
return x >= 0 && (x + nx) <= dim[2];
}
string DataManager::GetStringVal(string name)
{
return valStrings[name];
}