goat3d

view goatview/src/goatview.cc @ 73:9862541fdcf5

- build qt goatview on linux - fixed line endings in a bunch of files
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 May 2014 03:57:11 +0300
parents 36e39632db75
children ab66cdabf6f2
line source
1 #include "goatview.h"
3 GoatView::GoatView()
4 {
5 make_menu();
6 make_dock();
7 make_center();
9 statusBar();
11 setWindowTitle("GoatView");
12 }
14 GoatView::~GoatView()
15 {
16 }
18 bool GoatView::make_menu()
19 {
20 QMenu *menu_file = menuBar()->addMenu("&File");
22 QAction *act_open_sce = new QAction("&Open Scene", this);
23 act_open_sce->setShortcuts(QKeySequence::Open);
24 connect(act_open_sce, &QAction::triggered, this, &GoatView::open_scene);
25 menu_file->addAction(act_open_sce);
27 QAction *act_open_anm = new QAction("Open &Animation", this);
28 connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
29 menu_file->addAction(act_open_anm);
31 QAction *act_quit = new QAction("&Quit", this);
32 act_quit->setShortcuts(QKeySequence::Quit);
33 connect(act_quit, &QAction::triggered, [&](){qApp->quit();});
34 menu_file->addAction(act_quit);
35 return true;
36 }
38 bool GoatView::make_dock()
39 {
40 // ---- side-dock ----
41 QWidget *dock_cont = new QWidget;
42 QVBoxLayout *dock_vbox = new QVBoxLayout;
43 dock_cont->setLayout(dock_vbox);
45 QPushButton *bn_quit = new QPushButton("quit");
46 dock_vbox->addWidget(bn_quit);
47 connect(bn_quit, &QPushButton::clicked, [&](){qApp->quit();});
49 QDockWidget *dock = new QDockWidget("Scene graph", this);
50 dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
51 dock->setWidget(dock_cont);
52 addDockWidget(Qt::LeftDockWidgetArea, dock);
54 // ---- bottom dock ----
55 dock_cont = new QWidget;
56 QHBoxLayout *dock_hbox = new QHBoxLayout;
57 dock_cont->setLayout(dock_hbox);
59 QSlider *slider_time = new QSlider(Qt::Orientation::Horizontal);
60 slider_time->setDisabled(true);
61 dock_hbox->addWidget(slider_time);
63 dock = new QDockWidget("Animation", this);
64 dock->setAllowedAreas(Qt::BottomDockWidgetArea);
65 dock->setWidget(dock_cont);
66 addDockWidget(Qt::BottomDockWidgetArea, dock);
68 return true;
69 }
71 bool GoatView::make_center()
72 {
73 GoatViewport *vport = new GoatViewport;
74 setCentralWidget(vport);
75 return true;
76 }
78 void GoatView::open_scene()
79 {
80 statusBar()->showMessage("opening scene...");
81 }
83 void GoatView::open_anim()
84 {
85 statusBar()->showMessage("opening animation...");
86 }
89 // ---- OpenGL viewport ----
90 GoatViewport::GoatViewport()
91 : QGLWidget(QGLFormat(QGL::DepthBuffer))
92 {
93 }
95 GoatViewport::~GoatViewport()
96 {
97 }
99 QSize GoatViewport::sizeHint() const
100 {
101 return QSize(800, 600);
102 }
104 void GoatViewport::initializeGL()
105 {
106 }
108 void GoatViewport::resizeGL(int xsz, int ysz)
109 {
110 glViewport(0, 0, xsz, ysz);
111 }
113 void GoatViewport::paintGL()
114 {
115 glClearColor(1, 0, 0, 1);
116 glClear(GL_COLOR_BUFFER_BIT);
117 }