-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathArcSimWindow.cpp
More file actions
105 lines (94 loc) · 2.2 KB
/
ArcSimWindow.cpp
File metadata and controls
105 lines (94 loc) · 2.2 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
#include "ArcsimWindow.h"
#include "global_data_holder.h"
#include "cloth\clothManager.h"
#include "cloth\SmplManager.h"
#include "cloth\TransformInfo.h"
#include "arcsim\ArcSimManager.h"
#include "Renderable\ObjMesh.h"
#include "tinyxml\tinyxml.h"
#include <QFileInfo>
#include <random>
#include <fstream>
ArcsimWindow::ArcsimWindow(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
m_updateMeshView_timer = startTimer(30);
}
ArcsimWindow::~ArcsimWindow()
{
}
void ArcsimWindow::closeEvent(QCloseEvent* ev)
{
if (g_dataholder.m_arcsimManager)
g_dataholder.m_arcsimManager->stop_simulate_loop_otherthread();
}
void ArcsimWindow::init()
{
ui.widget->init(g_dataholder.m_arcsimManager.get());
}
void ArcsimWindow::timerEvent(QTimerEvent* ev)
{
if (ev->timerId() == m_updateMeshView_timer)
{
if (g_dataholder.m_arcsimManager->updateMesh())
ui.widget->updateGL();
setWindowTitle(g_dataholder.m_arcsimManager->getIterInfo().c_str());
}
}
void ArcsimWindow::on_actionLoad_conf_triggered()
{
try
{
QString name = QFileDialog::getOpenFileName(this, "open arcsim config", "data/arcsim", "*.json");
if (name.isEmpty())
return;
g_dataholder.m_arcsimManager->loadFromJsonConfig(name.toStdString());
ui.widget->resetCamera();
ui.widget->updateGL();
}
catch (std::exception e)
{
std::cout << e.what() << std::endl;
}
}
void ArcsimWindow::on_actionSave_cloth_triggered()
{
try
{
QString name = QFileDialog::getSaveFileName(this, "save cloth meshes", "data/arcsim", "*.obj");
if (name.isEmpty())
return;
if (!name.toLower().endsWith(".obj"))
name.append(".obj");
g_dataholder.m_arcsimManager->getClothMesh()->saveObj(name.toStdString().c_str());
}
catch (std::exception e)
{
std::cout << e.what() << std::endl;
}
}
void ArcsimWindow::on_pbFromCloths_clicked()
{
try
{
g_dataholder.m_arcsimManager->loadFromClothManager(g_dataholder.m_clothManager.get());
ui.widget->resetCamera();
ui.widget->updateGL();
}
catch (std::exception e)
{
std::cout << e.what() << std::endl;
}
}
void ArcsimWindow::on_pbStartSimulation_clicked()
{
try
{
g_dataholder.m_arcsimManager->start_simulate_loop_otherthread();
}
catch (std::exception e)
{
std::cout << e.what() << std::endl;
}
}