-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaindialog.cpp
90 lines (75 loc) · 1.91 KB
/
maindialog.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
#include "maindialog.h"
#include "ui_maindialog.h"
#include "viewsettings.h"
MainDialog::MainDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::MainDialog)
{
this->ui->setupUi(this);
this->setWindowFlags(
Qt::Window |
Qt::WindowMinimizeButtonHint |
Qt::CustomizeWindowHint
);
// CONNECTIONS
connect(
this->ui->btnOpenFile,
SIGNAL (clicked()),
this,
SLOT(getSceneFile())
);
connect(
this->ui->btnViewScene,
SIGNAL (clicked()),
this,
SLOT(viewModel())
);
connect(
this->ui->btnClose,
SIGNAL (clicked()),
this,
SLOT(close())
);
}
void MainDialog::setSpeedValue(int value)
{
this->ui->lcdSpeed->display(value);
}
void MainDialog::getSceneFile()
{
QUrl sourceFileName;
QWidget *container = new QWidget();
QFileDialog dialog;
dialog.setFileMode(QFileDialog::AnyFile);
sourceFileName = dialog.getOpenFileUrl(
container,
QStringLiteral("Выберете файл..."),
QUrl("/example/"),
"Файл сцены (*.obj *.dae *.3ds)"
);
this->ui->edtSceneFile->setText(
sourceFileName.toString().mid(8)
);
}
void MainDialog::viewModel()
{
ViewSettings params;
params.sceneFile = this->ui->edtSceneFile->text();
params.backgroundColor = Viewer::BACKGROUND_COLOR[
this->ui->cmbBackgroundColor->currentIndex()
];
params.speed = float(this->ui->lcdSpeed->value());
params.resolution.height = Viewer::RESOLUTIONS[
this->ui->cmbResolution->currentIndex()
][1];
params.resolution.width = Viewer::RESOLUTIONS[
this->ui->cmbResolution->currentIndex()
][0];
this->m_viewer = new SceneViewer(params);
this->m_viewer->exec(this->ui->edtSceneFile->text());
}
MainDialog::~MainDialog()
{
delete this->ui;
delete this->m_viewer;
}