-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
76 lines (71 loc) · 2.58 KB
/
mainwindow.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
#include "mainwindow.h"
#include <thread>
#include <QLabel>
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
m_centralWidget = new QWidget(this);
this->setCentralWidget( m_centralWidget );
m_layout = new QHBoxLayout( m_centralWidget );
m_layout->setMargin(0);
m_leftShoulder = new ShoulderWidget(true);
m_rightShoulder = new ShoulderWidget(false);
m_layout->addWidget(m_rightShoulder);
m_layout->addWidget(m_leftShoulder);
m_rightShoulder->resize(m_rightShoulder->X()+1, m_rightShoulder->Z()+1);
QWidget * techArea = new QWidget(this);
techArea->setFixedWidth(TECH_WIDGET_WIDTH);
QPushButton * resultButton = new QPushButton("Calculate", techArea);
m_layout->addWidget(techArea);
resultButton->resize(BUTTON_WIDTH, BUTTON_HEIGHT);
connect(resultButton, SIGNAL (released()), this, SLOT (Calculate()));
setFixedSize(FULL_WIDTH,
m_leftShoulder->Z() > m_rightShoulder->Z() ?
m_leftShoulder->Z()
:
m_rightShoulder->Z());
}
MainWindow::~MainWindow()
{}
void MainWindow::Calculate()
{
std::thread rightThread(&MainWindow::CalcAndDumpShoulder,
this,
m_rightShoulder->DataX(),
m_rightShoulder->DataZ(),
ALPHA_RES_RIGHT_FILENAME,
T_RES_RIGHT_FILENAME);
std::thread leftThread(&MainWindow::CalcAndDumpShoulder,
this,
m_leftShoulder->DataX(),
m_leftShoulder->DataZ(),
ALPHA_RES_LEFT_FILENAME,
T_RES_LEFT_FILENAME);
rightThread.join();
leftThread.join();
}
void MainWindow::CalcAndDumpShoulder(int xsize, int zsize,
char const afilename[], char const tfilename[])
{
ofstream aout, tout;
aout.open(afilename);
tout.open(tfilename);
BezierCoords2D * coords;
for (int ix = 0; ix < xsize; ix++)
{
for (int iz = 0; iz < zsize; iz++) {
coords = BezierCoords2D::FindAlpha(SIZE_X_VOXEL*xsize,
SIZE_Z_VOXEL*zsize,
SIZE_X_VOXEL*(ix+1),
SIZE_Z_VOXEL*(iz+1));
aout << coords->alpha() << " ";
tout << coords->t() << " ";
delete coords;
}
aout << "\n";
tout << "\n";
}
aout.close();
tout.close();
}