rev |
line source |
nuclear@72
|
1 #include "goatview.h"
|
nuclear@72
|
2
|
nuclear@72
|
3 GoatView::GoatView()
|
nuclear@72
|
4 {
|
nuclear@72
|
5 make_menu();
|
nuclear@72
|
6 make_dock();
|
nuclear@72
|
7 make_center();
|
nuclear@72
|
8
|
nuclear@72
|
9 statusBar();
|
nuclear@72
|
10
|
nuclear@72
|
11 setWindowTitle("GoatView");
|
nuclear@72
|
12 }
|
nuclear@72
|
13
|
nuclear@72
|
14 GoatView::~GoatView()
|
nuclear@72
|
15 {
|
nuclear@72
|
16 }
|
nuclear@72
|
17
|
nuclear@72
|
18 bool GoatView::make_menu()
|
nuclear@72
|
19 {
|
nuclear@72
|
20 QMenu *menu_file = menuBar()->addMenu("&File");
|
nuclear@72
|
21
|
nuclear@72
|
22 QAction *act_open_sce = new QAction("&Open Scene", this);
|
nuclear@72
|
23 act_open_sce->setShortcuts(QKeySequence::Open);
|
nuclear@72
|
24 connect(act_open_sce, &QAction::triggered, this, &GoatView::open_scene);
|
nuclear@72
|
25 menu_file->addAction(act_open_sce);
|
nuclear@72
|
26
|
nuclear@72
|
27 QAction *act_open_anm = new QAction("Open &Animation", this);
|
nuclear@72
|
28 connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
|
nuclear@72
|
29 menu_file->addAction(act_open_anm);
|
nuclear@72
|
30
|
nuclear@72
|
31 QAction *act_quit = new QAction("&Quit", this);
|
nuclear@72
|
32 act_quit->setShortcuts(QKeySequence::Quit);
|
nuclear@72
|
33 connect(act_quit, &QAction::triggered, [&](){qApp->quit();});
|
nuclear@72
|
34 menu_file->addAction(act_quit);
|
nuclear@72
|
35 return true;
|
nuclear@72
|
36 }
|
nuclear@72
|
37
|
nuclear@72
|
38 bool GoatView::make_dock()
|
nuclear@72
|
39 {
|
nuclear@72
|
40 // ---- side-dock ----
|
nuclear@72
|
41 QWidget *dock_cont = new QWidget;
|
nuclear@72
|
42 QVBoxLayout *dock_vbox = new QVBoxLayout;
|
nuclear@72
|
43 dock_cont->setLayout(dock_vbox);
|
nuclear@72
|
44
|
nuclear@72
|
45 QPushButton *bn_quit = new QPushButton("quit");
|
nuclear@72
|
46 dock_vbox->addWidget(bn_quit);
|
nuclear@72
|
47 connect(bn_quit, &QPushButton::clicked, [&](){qApp->quit();});
|
nuclear@72
|
48
|
nuclear@72
|
49 QDockWidget *dock = new QDockWidget("Scene graph", this);
|
nuclear@72
|
50 dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
nuclear@72
|
51 dock->setWidget(dock_cont);
|
nuclear@72
|
52 addDockWidget(Qt::LeftDockWidgetArea, dock);
|
nuclear@72
|
53
|
nuclear@72
|
54 // ---- bottom dock ----
|
nuclear@72
|
55 dock_cont = new QWidget;
|
nuclear@72
|
56 QHBoxLayout *dock_hbox = new QHBoxLayout;
|
nuclear@72
|
57 dock_cont->setLayout(dock_hbox);
|
nuclear@72
|
58
|
nuclear@72
|
59 QSlider *slider_time = new QSlider(Qt::Orientation::Horizontal);
|
nuclear@72
|
60 slider_time->setDisabled(true);
|
nuclear@72
|
61 dock_hbox->addWidget(slider_time);
|
nuclear@72
|
62
|
nuclear@72
|
63 dock = new QDockWidget("Animation", this);
|
nuclear@72
|
64 dock->setAllowedAreas(Qt::BottomDockWidgetArea);
|
nuclear@72
|
65 dock->setWidget(dock_cont);
|
nuclear@72
|
66 addDockWidget(Qt::BottomDockWidgetArea, dock);
|
nuclear@72
|
67
|
nuclear@72
|
68 return true;
|
nuclear@72
|
69 }
|
nuclear@72
|
70
|
nuclear@72
|
71 bool GoatView::make_center()
|
nuclear@72
|
72 {
|
nuclear@72
|
73 GoatViewport *vport = new GoatViewport;
|
nuclear@72
|
74 setCentralWidget(vport);
|
nuclear@72
|
75 return true;
|
nuclear@72
|
76 }
|
nuclear@72
|
77
|
nuclear@72
|
78 void GoatView::open_scene()
|
nuclear@72
|
79 {
|
nuclear@72
|
80 statusBar()->showMessage("opening scene...");
|
nuclear@72
|
81 }
|
nuclear@72
|
82
|
nuclear@72
|
83 void GoatView::open_anim()
|
nuclear@72
|
84 {
|
nuclear@72
|
85 statusBar()->showMessage("opening animation...");
|
nuclear@72
|
86 }
|
nuclear@72
|
87
|
nuclear@72
|
88
|
nuclear@72
|
89 // ---- OpenGL viewport ----
|
nuclear@72
|
90 GoatViewport::GoatViewport()
|
nuclear@72
|
91 : QGLWidget(QGLFormat(QGL::DepthBuffer))
|
nuclear@72
|
92 {
|
nuclear@72
|
93 }
|
nuclear@72
|
94
|
nuclear@72
|
95 GoatViewport::~GoatViewport()
|
nuclear@72
|
96 {
|
nuclear@72
|
97 }
|
nuclear@72
|
98
|
nuclear@72
|
99 QSize GoatViewport::sizeHint() const
|
nuclear@72
|
100 {
|
nuclear@72
|
101 return QSize(800, 600);
|
nuclear@72
|
102 }
|
nuclear@72
|
103
|
nuclear@72
|
104 void GoatViewport::initializeGL()
|
nuclear@72
|
105 {
|
nuclear@72
|
106 }
|
nuclear@72
|
107
|
nuclear@72
|
108 void GoatViewport::resizeGL(int xsz, int ysz)
|
nuclear@72
|
109 {
|
nuclear@72
|
110 glViewport(0, 0, xsz, ysz);
|
nuclear@72
|
111 }
|
nuclear@72
|
112
|
nuclear@72
|
113 void GoatViewport::paintGL()
|
nuclear@72
|
114 {
|
nuclear@72
|
115 glClearColor(1, 0, 0, 1);
|
nuclear@72
|
116 glClear(GL_COLOR_BUFFER_BIT);
|
nuclear@72
|
117 } |