-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·136 lines (111 loc) · 4.98 KB
/
main.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
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
/*
* Convex Hull 3D
* Copyright 2013 Simone Barbieri
*
* This file is part of Convex Hull 3D.
*
* Convex Hull 3D is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Convex Hull 3D is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Convex Hull 3D. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include <QWidget>
#include <QDialog>
#include <QMenu>
#include <QMenuBar>
#include "window_gl.h"
#include "engine.h"
#include "dcel/DCEL.hh"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget container;
container.resize(640, 680);
container.setFocusPolicy ( Qt::NoFocus );
Engine engine(NULL);
QMenuBar open_menu_bar(&container);
QMenu open_menu("&File", &container);
QAction open("&Open", &container);
open.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
open_menu.addAction(&open);
QAction reset("&Reset", &container);
reset.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
open_menu.addAction(&reset);
QAction save("&Save", &container);
save.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
open_menu.addAction(&save);
QAction close("&Close", &container);
close.setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4));
open_menu.addAction(&close);
QMenu draw_menu("&Drawmodes", &container);
QAction points("&Points", &container);
points.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
draw_menu.addAction(&points);
QAction wire("&Wireframe", &container);
wire.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
draw_menu.addAction(&wire);
QAction flat("&Flat shaded", &container);
flat.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F));
draw_menu.addAction(&flat);
QAction smooth("&Smooth shaded", &container);
smooth.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
draw_menu.addAction(&smooth);
/**** MENU CONVEX HULL ****/
QMenu convex_hull("Convex Hull", &container);
QAction calc("&Calculate CH", &container);
calc.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
convex_hull.addAction(&calc);
/**** MENU HELP ****/
QMenu help_menu("&?", &container);
QAction help("&Help", &container);
help.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H));
help_menu.addAction(&help);
QAction about("&About", &container);
about.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
help_menu.addAction(&about);
open_menu_bar.addMenu(&open_menu);
open_menu_bar.addMenu(&draw_menu);
open_menu_bar.addMenu(&convex_hull);
open_menu_bar.addMenu(&help_menu);
Window_gl window(&container);
window.setGeometry(0,22,640, 680);
container.show();
QDialog instructions( NULL );
instructions.setFixedSize(300,180);
instructions.setWindowTitle("Help");
QLabel instr_text("\nUp - Sposta l'osservatore verso l'alto\nDown - Sposta l'osservatore verso il basso\nLeft - Ruota verso sinistra\nRight - Ruota verso destra\nShift+Up - Zoom In\nShift+Down - Zoom out\n\nSi ricorda che il programma e' in grado di gestire\nsolo files di tipo .OFF.\nAltri formati non sono attualmente supportati.", &instructions);
instr_text.setTextFormat(Qt::AutoText);
instr_text.setWordWrap(true);
instructions.hide();
QDialog credits( NULL );
credits.setFixedSize(300,100);
credits.setWindowTitle("Credits");
QLabel cred_text("\tCGVew v.1.7\n\nA cura di Fabio Guggeri (guga2112@gmail.com)\ne Stefano Marras (mr.marras@gmail.com).\n", &credits);
cred_text.setTextFormat(Qt::AutoText);
cred_text.setWordWrap(true);
credits.hide();
QObject::connect( &open, SIGNAL(triggered()), &engine, SLOT(open_file()) );
QObject::connect( &reset, SIGNAL(triggered()), &window, SLOT(reset()) );
QObject::connect( &reset, SIGNAL(triggered()), &engine, SLOT(reset()) );
QObject::connect( &save, SIGNAL(triggered()), &engine, SLOT(save_file()) );
QObject::connect( &points, SIGNAL(triggered()), &window, SLOT(set_p_drawmode()) );
QObject::connect( &wire, SIGNAL(triggered()), &window, SLOT(set_w_drawmode()) );
QObject::connect( &flat, SIGNAL(triggered()), &window, SLOT(set_f_drawmode()) );
QObject::connect( &smooth, SIGNAL(triggered()), &window, SLOT(set_s_drawmode()) );
QObject::connect( &help, SIGNAL(triggered()), &instructions, SLOT(show()) );
QObject::connect( &about, SIGNAL(triggered()), &credits, SLOT(show()) );
QObject::connect( &close, SIGNAL(triggered()), &app, SLOT(quit()) );
QObject::connect( &engine, SIGNAL(send_dcel(QVector<DCEL>&)), &window, SLOT(add_dcel(QVector<DCEL>&)) );
QObject::connect( &calc, SIGNAL(triggered()), &engine, SLOT(calculate_ch()) );
window.setFocus();
return app.exec();
}