goat3d

diff goatview/src/goatview.cc @ 72:36e39632db75

- fixed exporter animation bounds calculation - fixed missing scene name in exported meshes - rewritting goatview as a full GUI app with Qt
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 May 2014 03:31:35 +0300
parents
children 9862541fdcf5
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/goatview/src/goatview.cc	Tue May 06 03:31:35 2014 +0300
     1.3 @@ -0,0 +1,117 @@
     1.4 +#include "goatview.h"
     1.5 +
     1.6 +GoatView::GoatView()
     1.7 +{
     1.8 +	make_menu();
     1.9 +	make_dock();
    1.10 +	make_center();
    1.11 +
    1.12 +	statusBar();
    1.13 +
    1.14 +	setWindowTitle("GoatView");
    1.15 +}
    1.16 +
    1.17 +GoatView::~GoatView()
    1.18 +{
    1.19 +}
    1.20 +
    1.21 +bool GoatView::make_menu()
    1.22 +{
    1.23 +	QMenu *menu_file = menuBar()->addMenu("&File");
    1.24 +
    1.25 +	QAction *act_open_sce = new QAction("&Open Scene", this);
    1.26 +	act_open_sce->setShortcuts(QKeySequence::Open);
    1.27 +	connect(act_open_sce, &QAction::triggered, this, &GoatView::open_scene);
    1.28 +	menu_file->addAction(act_open_sce);
    1.29 +
    1.30 +	QAction *act_open_anm = new QAction("Open &Animation", this);
    1.31 +	connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
    1.32 +	menu_file->addAction(act_open_anm);
    1.33 +
    1.34 +	QAction *act_quit = new QAction("&Quit", this);
    1.35 +	act_quit->setShortcuts(QKeySequence::Quit);
    1.36 +	connect(act_quit, &QAction::triggered, [&](){qApp->quit();});
    1.37 +	menu_file->addAction(act_quit);
    1.38 +	return true;
    1.39 +}
    1.40 +
    1.41 +bool GoatView::make_dock()
    1.42 +{
    1.43 +	// ---- side-dock ----
    1.44 +	QWidget *dock_cont = new QWidget;
    1.45 +	QVBoxLayout *dock_vbox = new QVBoxLayout;
    1.46 +	dock_cont->setLayout(dock_vbox);
    1.47 +
    1.48 +	QPushButton *bn_quit = new QPushButton("quit");
    1.49 +	dock_vbox->addWidget(bn_quit);
    1.50 +	connect(bn_quit, &QPushButton::clicked, [&](){qApp->quit();});
    1.51 +
    1.52 +	QDockWidget *dock = new QDockWidget("Scene graph", this);
    1.53 +	dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    1.54 +	dock->setWidget(dock_cont);
    1.55 +	addDockWidget(Qt::LeftDockWidgetArea, dock);
    1.56 +
    1.57 +	// ---- bottom dock ----
    1.58 +	dock_cont = new QWidget;
    1.59 +	QHBoxLayout *dock_hbox = new QHBoxLayout;
    1.60 +	dock_cont->setLayout(dock_hbox);
    1.61 +
    1.62 +	QSlider *slider_time = new QSlider(Qt::Orientation::Horizontal);
    1.63 +	slider_time->setDisabled(true);
    1.64 +	dock_hbox->addWidget(slider_time);
    1.65 +
    1.66 +	dock = new QDockWidget("Animation", this);
    1.67 +	dock->setAllowedAreas(Qt::BottomDockWidgetArea);
    1.68 +	dock->setWidget(dock_cont);
    1.69 +	addDockWidget(Qt::BottomDockWidgetArea, dock);
    1.70 +
    1.71 +	return true;
    1.72 +}
    1.73 +
    1.74 +bool GoatView::make_center()
    1.75 +{
    1.76 +	GoatViewport *vport = new GoatViewport;
    1.77 +	setCentralWidget(vport);
    1.78 +	return true;
    1.79 +}
    1.80 +
    1.81 +void GoatView::open_scene()
    1.82 +{
    1.83 +	statusBar()->showMessage("opening scene...");
    1.84 +}
    1.85 +
    1.86 +void GoatView::open_anim()
    1.87 +{
    1.88 +	statusBar()->showMessage("opening animation...");
    1.89 +}
    1.90 +
    1.91 +
    1.92 +// ---- OpenGL viewport ----
    1.93 +GoatViewport::GoatViewport()
    1.94 +	: QGLWidget(QGLFormat(QGL::DepthBuffer))
    1.95 +{
    1.96 +}
    1.97 +
    1.98 +GoatViewport::~GoatViewport()
    1.99 +{
   1.100 +}
   1.101 +
   1.102 +QSize GoatViewport::sizeHint() const
   1.103 +{
   1.104 +	return QSize(800, 600);
   1.105 +}
   1.106 +
   1.107 +void GoatViewport::initializeGL()
   1.108 +{
   1.109 +}
   1.110 +
   1.111 +void GoatViewport::resizeGL(int xsz, int ysz)
   1.112 +{
   1.113 +	glViewport(0, 0, xsz, ysz);
   1.114 +}
   1.115 +
   1.116 +void GoatViewport::paintGL()
   1.117 +{
   1.118 +	glClearColor(1, 0, 0, 1);
   1.119 +	glClear(GL_COLOR_BUFFER_BIT);
   1.120 +}
   1.121 \ No newline at end of file