goat3d

view goatview/src/goatview.cc @ 97:32dccb16678f

[goatview] GUI layout fixes
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 21 May 2014 05:00:21 +0300
parents da100bf13f7f
children d7ab4f13f5af
line source
1 #include <stdio.h>
2 #include <limits.h>
3 #include <map>
4 #include "opengl.h"
5 #include <QtOpenGL/QtOpenGL>
6 #include <vmath/vmath.h>
7 #include "goatview.h"
8 #include "goat3d.h"
10 static void draw_grid();
11 static void draw_grid(float sz, int nlines, float alpha = 1.0f);
12 static void draw_node(goat3d_node *node);
13 static void draw_mesh(goat3d_mesh *mesh);
14 static int next_pow2(int x);
16 goat3d *scene;
17 static SceneModel *sdata;
18 static GoatViewport *glview;
20 static long anim_time;
21 static float cam_theta, cam_phi = 25, cam_dist = 8;
22 static float fov = 60.0;
23 static bool use_nodes = true;
24 static bool use_lighting = true;
25 static bool use_textures = true;
27 void post_redisplay()
28 {
29 if(glview) {
30 glview->updateGL();
31 }
32 }
35 GoatView::GoatView()
36 {
37 glview = 0;
38 scene_model = 0;
40 QGLFormat glfmt = QGLFormat::defaultFormat();
41 glfmt.setSampleBuffers(true);
42 QGLFormat::setDefaultFormat(glfmt);
44 QSettings settings;
45 resize(settings.value("main/size", QSize(1024, 768)).toSize());
46 move(settings.value("main/pos", QPoint(100, 100)).toPoint());
47 use_nodes = settings.value("use_nodes", true).toBool();
48 use_lighting = settings.value("use_lighting", true).toBool();
49 use_textures = settings.value("use_textures", true).toBool();
51 make_center(); // must be first
52 make_menu();
53 make_dock();
55 statusBar();
57 setWindowTitle("GoatView");
58 }
60 GoatView::~GoatView()
61 {
62 delete scene_model;
63 sdata = 0;
64 }
66 void GoatView::closeEvent(QCloseEvent *ev)
67 {
68 QSettings settings;
69 settings.setValue("main/size", size());
70 settings.setValue("main/pos", pos());
71 settings.setValue("use_nodes", use_nodes);
72 settings.setValue("use_lighting", use_lighting);
73 }
76 bool GoatView::load_scene(const char *fname)
77 {
78 if(scene) {
79 goat3d_free(scene);
80 }
81 if(!(scene = goat3d_create()) || goat3d_load(scene, fname) == -1) {
82 QMessageBox::critical(this, "Error", "Failed to load scene file: " + QString(fname));
83 return false;
84 }
86 float bmin[3], bmax[3];
87 if(goat3d_get_bounds(scene, bmin, bmax) != -1) {
88 float bsize = (Vector3(bmax[0], bmax[1], bmax[2]) - Vector3(bmin[0], bmin[1], bmin[2])).length();
89 cam_dist = bsize / tan(DEG_TO_RAD(fov) / 2.0);
90 printf("bounds size: %f, cam_dist: %f\n", bsize, cam_dist);
91 }
93 scene_model->set_scene(scene);
94 treeview->expandAll();
95 treeview->resizeColumnToContents(0);
97 sdata = scene_model; // set the global sdata ptr
98 post_redisplay();
99 return true;
100 }
102 bool GoatView::load_anim(const char *fname)
103 {
104 if(!scene) {
105 QMessageBox::critical(this, "Error", "You must load a scene before loading any animations!");
106 return false;
107 }
109 if(goat3d_load_anim(scene, fname) == -1) {
110 QMessageBox::critical(this, "Error", QString("Failed to load animation: ") + QString(fname));
111 return false;
112 }
115 long tstart = LONG_MAX, tend = LONG_MIN;
116 int num_nodes = goat3d_get_node_count(scene);
117 for(int i=0; i<num_nodes; i++) {
118 goat3d_node *node = goat3d_get_node(scene, i);
119 if(goat3d_get_node_parent(node)) {
120 continue;
121 }
123 long t0, t1;
124 if(goat3d_get_anim_timeline(node, &t0, &t1) != -1) {
125 if(t0 < tstart) tstart = t0;
126 if(t1 > tend) tend = t1;
127 }
128 }
130 if(tstart != LONG_MAX) {
131 grp_anim_ctl->setDisabled(false);
132 grp_anim_time->setDisabled(false);
134 slider_time->setMinimum(tstart);
135 slider_time->setMaximum(tend);
137 spin_time->setMinimum(tstart);
138 spin_time->setMaximum(tend);
140 label_time_start->setText(QString::number(tstart));
141 label_time_end->setText(QString::number(tend));
142 }
144 post_redisplay();
145 return true;
146 }
148 bool GoatView::make_menu()
149 {
150 // file menu
151 QMenu *menu_file = menuBar()->addMenu("&File");
153 QAction *act_open_sce = new QAction("&Open Scene", this);
154 act_open_sce->setShortcuts(QKeySequence::Open);
155 connect(act_open_sce, &QAction::triggered, this, &GoatView::open_scene);
156 menu_file->addAction(act_open_sce);
158 QAction *act_open_anm = new QAction("Open &Animation", this);
159 connect(act_open_anm, &QAction::triggered, this, &GoatView::open_anim);
160 menu_file->addAction(act_open_anm);
162 QAction *act_quit = new QAction("&Quit", this);
163 act_quit->setShortcuts(QKeySequence::Quit);
164 connect(act_quit, &QAction::triggered, [&](){ qApp->quit(); });
165 menu_file->addAction(act_quit);
167 // view menu
168 QMenu *menu_view = menuBar()->addMenu("&View");
170 QAction *act_use_nodes = new QAction("use nodes", this);
171 act_use_nodes->setCheckable(true);
172 act_use_nodes->setChecked(use_nodes);
173 connect(act_use_nodes, &QAction::triggered, this,
174 [&](){ use_nodes = !use_nodes; post_redisplay(); });
175 menu_view->addAction(act_use_nodes);
177 QAction *act_use_lighting = new QAction("lighting", this);
178 act_use_lighting->setCheckable(true);
179 act_use_lighting->setChecked(use_lighting);
180 connect(act_use_lighting, &QAction::triggered, glview, &GoatViewport::toggle_lighting);
181 menu_view->addAction(act_use_lighting);
183 // help menu
184 QMenu *menu_help = menuBar()->addMenu("&Help");
186 QAction *act_about = new QAction("&About", this);
187 connect(act_about, &QAction::triggered, this, &GoatView::show_about);
188 menu_help->addAction(act_about);
189 return true;
190 }
192 bool GoatView::make_dock()
193 {
194 // ---- side-dock ----
195 QWidget *dock_cont = new QWidget;
196 QVBoxLayout *dock_vbox = new QVBoxLayout;
197 dock_cont->setLayout(dock_vbox);
199 QDockWidget *dock = new QDockWidget(this);
200 dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
201 dock->setWidget(dock_cont);
202 addDockWidget(Qt::LeftDockWidgetArea, dock);
204 // make the tree view widget
205 treeview = new QTreeView;
206 treeview->setAlternatingRowColors(true);
207 treeview->setSelectionMode(QAbstractItemView::SingleSelection);
208 dock_vbox->addWidget(treeview);
210 scene_model = new SceneModel;
211 connect(scene_model, &SceneModel::dataChanged, [&](){ post_redisplay(); });
212 treeview->setModel(scene_model);
214 connect(treeview->selectionModel(), &QItemSelectionModel::selectionChanged,
215 [&](){ scene_model->selchange(treeview->selectionModel()->selectedIndexes()); });
217 // misc
218 QPushButton *bn_quit = new QPushButton("quit");
219 dock_vbox->addWidget(bn_quit);
220 connect(bn_quit, &QPushButton::clicked, [&](){ qApp->quit(); });
222 // ---- bottom dock ----
223 dock_cont = new QWidget;
224 QHBoxLayout *dock_hbox = new QHBoxLayout;
225 dock_cont->setLayout(dock_hbox);
227 // animation control box
228 grp_anim_ctl = new QGroupBox("Animation controls");
229 grp_anim_ctl->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
230 grp_anim_ctl->setDisabled(true);
231 dock_hbox->addWidget(grp_anim_ctl);
233 QVBoxLayout *anim_ctl_box = new QVBoxLayout;
234 grp_anim_ctl->setLayout(anim_ctl_box);
236 chk_loop = new QCheckBox("loop");
237 chk_loop->setChecked(false);
238 anim_ctl_box->addWidget(chk_loop);
240 QToolBar *toolbar_ctl = new QToolBar;
241 anim_ctl_box->addWidget(toolbar_ctl);
243 act_rewind = new QAction(style()->standardIcon(QStyle::SP_MediaSkipBackward), "Rewind", this);
244 connect(act_rewind, &QAction::triggered, [this](){ slider_time->setValue(slider_time->minimum()); });
245 toolbar_ctl->addAction(act_rewind);
247 act_play = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), "Play", this);
248 toolbar_ctl->addAction(act_play);
250 /* timeline controls
251 * /------------------------------\ grp_anim_time with vbox_timeline layout
252 * | /-------+---------+--------\ |
253 * | | label | spinbox | spacer | <-- hbox_timespin
254 * | \-------+---------+--------/ |
255 * +------------------------------+
256 * | /-------+---------+--------\ |
257 * | | label | slider | label | <-- hbox_timeslider
258 * | \-------+---------+--------/ |
259 * \------------------------------/
260 */
261 grp_anim_time = new QGroupBox("Timeline");
262 grp_anim_time->setDisabled(true);
263 dock_hbox->addWidget(grp_anim_time);
265 QVBoxLayout *vbox_timeline = new QVBoxLayout;
266 grp_anim_time->setLayout(vbox_timeline);
267 QHBoxLayout *hbox_timespin = new QHBoxLayout;
268 vbox_timeline->addLayout(hbox_timespin);
269 QHBoxLayout *hbox_timeslider = new QHBoxLayout;
270 vbox_timeline->addLayout(hbox_timeslider);
272 hbox_timespin->addWidget(new QLabel("msec"));
273 spin_time = new QSpinBox;
274 hbox_timespin->addWidget(spin_time);
275 hbox_timespin->addStretch();
277 label_time_start = new QLabel;
278 hbox_timeslider->addWidget(label_time_start);
280 slider_time = new QSlider(Qt::Orientation::Horizontal);
281 hbox_timeslider->addWidget(slider_time);
283 label_time_end = new QLabel;
284 hbox_timeslider->addWidget(label_time_end);
286 connect(slider_time, &QSlider::valueChanged,
287 [&](){ anim_time = slider_time->value(); spin_time->setValue(anim_time); post_redisplay(); });
289 typedef void (QSpinBox::*ValueChangedIntFunc)(int);
290 connect(spin_time, (ValueChangedIntFunc)&QSpinBox::valueChanged,
291 [&](){ anim_time = spin_time->value(); slider_time->setValue(anim_time); post_redisplay(); });
293 dock = new QDockWidget(this);
294 dock->setAllowedAreas(Qt::BottomDockWidgetArea);
295 dock->setWidget(dock_cont);
296 addDockWidget(Qt::BottomDockWidgetArea, dock);
298 return true;
299 }
301 bool GoatView::make_center()
302 {
303 glview = ::glview = new GoatViewport(this);
304 setCentralWidget(glview);
305 return true;
306 }
308 void GoatView::open_scene()
309 {
310 std::string fname = QFileDialog::getOpenFileName(this, "Open scene file", "",
311 "Goat3D Scene (*.goatsce);;All Files (*)").toStdString();
312 if(fname.empty()) {
313 statusBar()->showMessage("Abort: No file selected!");
314 return;
315 }
317 statusBar()->showMessage("opening scene file");
318 if(!load_scene(fname.c_str())) {
319 statusBar()->showMessage("failed to load scene file");
320 return;
321 }
322 statusBar()->showMessage("Successfully loaded scene: " + QString(fname.c_str()));
323 }
325 void GoatView::open_anim()
326 {
327 std::string fname = QFileDialog::getOpenFileName(this, "Open animation file", "",
328 "Goat3D Animation (*.goatanm);;All Files (*)").toStdString();
329 if(fname.empty()) {
330 statusBar()->showMessage("Abot: No file selected!");
331 return;
332 }
334 statusBar()->showMessage("opening animation file");
335 if(!load_anim(fname.c_str())) {
336 statusBar()->showMessage("failed to load animation file");
337 return;
338 }
339 statusBar()->showMessage("Successfully loaded animation: " + QString(fname.c_str()));
340 }
343 // ---- OpenGL viewport ----
344 GoatViewport::GoatViewport(QWidget *main_win)
345 : QGLWidget(QGLFormat(QGL::DepthBuffer | QGL::SampleBuffers))
346 {
347 this->main_win = main_win;
348 initialized = false;
349 }
351 GoatViewport::~GoatViewport()
352 {
353 }
355 QSize GoatViewport::sizeHint() const
356 {
357 return QSize(800, 600);
358 }
360 #define CRITICAL(error, detail) \
361 do { \
362 fprintf(stderr, "%s: %s\n", error, detail); \
363 QMessageBox::critical(main_win, error, detail); \
364 abort(); \
365 } while(0)
367 void GoatViewport::initializeGL()
368 {
369 if(initialized) return;
370 initialized = true;
372 init_opengl();
374 if(!GLEW_ARB_transpose_matrix) {
375 CRITICAL("OpenGL initialization failed", "ARB_transpose_matrix extension not found!");
376 }
378 glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
380 glEnable(GL_DEPTH_TEST);
381 glEnable(GL_CULL_FACE);
382 if(use_lighting) {
383 glEnable(GL_LIGHTING);
384 }
385 glEnable(GL_LIGHT0);
387 float ldir[] = {-1, 1, 2, 0};
388 glLightfv(GL_LIGHT0, GL_POSITION, ldir);
390 glEnable(GL_MULTISAMPLE);
391 }
393 void GoatViewport::resizeGL(int xsz, int ysz)
394 {
395 glViewport(0, 0, xsz, ysz);
396 glMatrixMode(GL_PROJECTION);
397 glLoadIdentity();
398 gluPerspective(60.0, (float)xsz / (float)ysz, 0.5, 5000.0);
399 }
401 void GoatViewport::paintGL()
402 {
403 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
405 glMatrixMode(GL_MODELVIEW);
406 glLoadIdentity();
407 glTranslatef(0, 0, -cam_dist);
408 glRotatef(cam_phi, 1, 0, 0);
409 glRotatef(cam_theta, 0, 1, 0);
411 draw_grid();
413 if(!scene) return;
415 if(use_nodes) {
416 int node_count = goat3d_get_node_count(scene);
417 for(int i=0; i<node_count; i++) {
418 goat3d_node *node = goat3d_get_node(scene, i);
419 if(!goat3d_get_node_parent(node)) {
420 draw_node(node); // only draw root nodes, the rest will be drawn recursively
421 }
422 }
423 } else {
424 int mesh_count = goat3d_get_mesh_count(scene);
425 for(int i=0; i<mesh_count; i++) {
426 goat3d_mesh *mesh = goat3d_get_mesh(scene, i);
427 draw_mesh(mesh);
428 }
429 }
430 }
432 void GoatViewport::toggle_lighting()
433 {
434 use_lighting = !use_lighting;
435 if(use_lighting) {
436 glEnable(GL_LIGHTING);
437 } else {
438 glDisable(GL_LIGHTING);
439 }
440 updateGL();
441 }
443 #ifndef GLEW_ARB_transpose_matrix
444 #error "GLEW_ARB_transpose_matrix undefined?"
445 #endif
447 static void draw_grid()
448 {
449 float viewsz_orig = cam_dist * tan(DEG_TO_RAD(fov) / 2.0);
450 float sz1 = next_pow2((int)viewsz_orig);
451 float sz0 = sz1 / 2.0;
452 float t = (viewsz_orig - sz0) / (sz1 - sz0);
453 float alpha = t < 0.333333 ? 0.0 : (t > 0.666666 ? 1.0 : (t - 0.333333) / 0.333333);
455 glPushAttrib(GL_ENABLE_BIT | GL_DEPTH_BITS);
457 glEnable(GL_BLEND);
458 glDepthFunc(GL_ALWAYS);
460 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
461 draw_grid(sz0 * 2.0, 10, 1.0 - alpha);
462 draw_grid(sz1 * 2.0, 10, alpha);
464 glPopAttrib();
465 }
467 static void draw_grid(float sz, int nlines, float alpha)
468 {
469 float hsz = sz / 2.0;
470 float offs = sz / (float)nlines;
472 glPushAttrib(GL_ENABLE_BIT);
473 glDisable(GL_LIGHTING);
474 glDisable(GL_TEXTURE_2D);
476 glLineWidth(2.0);
477 glBegin(GL_LINES);
478 glColor4f(1, 0, 0, alpha);
479 glVertex3f(-hsz, 0, 0);
480 glVertex3f(hsz, 0, 0);
481 glColor4f(0, 0, 1, alpha);
482 glVertex3f(0, 0, -hsz);
483 glVertex3f(0, 0, hsz);
484 glEnd();
486 glLineWidth(1.0);
487 glBegin(GL_LINES);
488 glColor4f(0.5, 0.5, 0.5, alpha);
489 for(int i=0; i<nlines / 2; i++) {
490 float dist = (float)(i + 1) * offs;
491 for(int j=0; j<2; j++) {
492 float sign = j > 0 ? -1.0 : 1.0;
493 glVertex3f(-hsz, 0, dist * sign);
494 glVertex3f(hsz, 0, dist * sign);
495 glVertex3f(dist * sign, 0, -hsz);
496 glVertex3f(dist * sign, 0, hsz);
497 }
498 }
499 glEnd();
501 glPopAttrib();
502 }
504 static void draw_node(goat3d_node *node)
505 {
506 SceneNodeData *data = sdata ? sdata->get_node_data(node) : 0;
507 if(!data) return;
509 float xform[16];
510 goat3d_get_node_matrix(node, xform, anim_time);
512 glPushMatrix();
513 glMultTransposeMatrixf(xform);
515 if(data->visible) {
516 if(goat3d_get_node_type(node) == GOAT3D_NODE_MESH) {
517 goat3d_mesh *mesh = (goat3d_mesh*)goat3d_get_node_object(node);
519 draw_mesh(mesh);
521 if(data->selected) {
522 float bmin[3], bmax[3];
523 goat3d_get_mesh_bounds(mesh, bmin, bmax);
525 glPushAttrib(GL_ENABLE_BIT);
526 glDisable(GL_LIGHTING);
528 glColor3f(0.3, 1, 0.2);
530 glBegin(GL_LINE_LOOP);
531 glVertex3f(bmin[0], bmin[1], bmin[2]);
532 glVertex3f(bmax[0], bmin[1], bmin[2]);
533 glVertex3f(bmax[0], bmin[1], bmax[2]);
534 glVertex3f(bmin[0], bmin[1], bmax[2]);
535 glEnd();
536 glBegin(GL_LINE_LOOP);
537 glVertex3f(bmin[0], bmax[1], bmin[2]);
538 glVertex3f(bmax[0], bmax[1], bmin[2]);
539 glVertex3f(bmax[0], bmax[1], bmax[2]);
540 glVertex3f(bmin[0], bmax[1], bmax[2]);
541 glEnd();
542 glBegin(GL_LINES);
543 glVertex3f(bmin[0], bmin[1], bmin[2]);
544 glVertex3f(bmin[0], bmax[1], bmin[2]);
545 glVertex3f(bmin[0], bmin[1], bmax[2]);
546 glVertex3f(bmin[0], bmax[1], bmax[2]);
547 glVertex3f(bmax[0], bmin[1], bmin[2]);
548 glVertex3f(bmax[0], bmax[1], bmin[2]);
549 glVertex3f(bmax[0], bmin[1], bmax[2]);
550 glVertex3f(bmax[0], bmax[1], bmax[2]);
551 glEnd();
553 glPopAttrib();
554 }
555 }
556 }
558 int num_child = goat3d_get_node_child_count(node);
559 for(int i=0; i<num_child; i++) {
560 draw_node(goat3d_get_node_child(node, i));
561 }
563 glPopMatrix();
564 }
566 static void draw_mesh(goat3d_mesh *mesh)
567 {
568 static const float white[] = {1, 1, 1, 1};
569 static const float black[] = {0, 0, 0, 1};
571 const float *color;
572 goat3d_material *mtl = goat3d_get_mesh_mtl(mesh);
574 if(mtl && (color = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_DIFFUSE))) {
575 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
576 glColor3fv(color);
577 } else {
578 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, white);
579 glColor3fv(white);
580 }
581 if(mtl && (color = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_SPECULAR))) {
582 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
583 } else {
584 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, black);
585 }
586 if(mtl && (color = goat3d_get_mtl_attrib(mtl, GOAT3D_MAT_ATTR_SHININESS))) {
587 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, color[0]);
588 } else {
589 glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0);
590 }
591 // TODO texture
594 int num_faces = goat3d_get_mesh_face_count(mesh);
595 int num_verts = goat3d_get_mesh_attrib_count(mesh, GOAT3D_MESH_ATTR_VERTEX);
597 glEnableClientState(GL_VERTEX_ARRAY);
598 glVertexPointer(3, GL_FLOAT, 0, goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_VERTEX));
600 float *data;
601 if((data = (float*)goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_NORMAL))) {
602 glEnableClientState(GL_NORMAL_ARRAY);
603 glNormalPointer(GL_FLOAT, 0, data);
604 }
605 if((data = (float*)goat3d_get_mesh_attribs(mesh, GOAT3D_MESH_ATTR_TEXCOORD))) {
606 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
607 glTexCoordPointer(2, GL_FLOAT, 0, data);
608 }
610 int *indices;
611 if((indices = goat3d_get_mesh_faces(mesh))) {
612 glDrawElements(GL_TRIANGLES, num_faces * 3, GL_UNSIGNED_INT, indices);
613 } else {
614 glDrawArrays(GL_TRIANGLES, 0, num_verts * 3);
615 }
617 glDisableClientState(GL_VERTEX_ARRAY);
618 glDisableClientState(GL_NORMAL_ARRAY);
619 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
620 }
623 static float prev_x, prev_y;
624 void GoatViewport::mousePressEvent(QMouseEvent *ev)
625 {
626 prev_x = ev->x();
627 prev_y = ev->y();
628 }
630 void GoatViewport::mouseMoveEvent(QMouseEvent *ev)
631 {
632 int dx = ev->x() - prev_x;
633 int dy = ev->y() - prev_y;
634 prev_x = ev->x();
635 prev_y = ev->y();
637 if(!dx && !dy) return;
639 if(ev->buttons() & Qt::LeftButton) {
640 cam_theta += dx * 0.5;
641 cam_phi += dy * 0.5;
643 if(cam_phi < -90) cam_phi = -90;
644 if(cam_phi > 90) cam_phi = 90;
645 }
646 if(ev->buttons() & Qt::RightButton) {
647 cam_dist += dy * 0.1;
649 if(cam_dist < 0.0) cam_dist = 0.0;
650 }
651 updateGL();
652 }
654 static const char *about_str =
655 "GoatView - Goat3D scene file viewer<br>"
656 "Copyright (C) 2014 John Tsiombikas &lt;<a href=\"mailto:nuclear@mutantstargoat.com\">nuclear@mutantstargoat.com</a>&gt;<br>"
657 "<br>"
658 "This program is free software: you can redistribute it and/or modify<br>"
659 "it under the terms of the GNU General Public License as published by<br>"
660 "the Free Software Foundation, either version 3 of the License, or<br>"
661 "(at your option) any later version.<br>"
662 "<br>"
663 "This program is distributed in the hope that it will be useful,<br>"
664 "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>"
665 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>"
666 "GNU General Public License for more details.<br>"
667 "<br>"
668 "You should have received a copy of the GNU General Public License<br>"
669 "along with this program. If not, see <a href=\"http://www.gnu.org/licenses/gpl\">http://www.gnu.org/licenses/gpl</a>.";
671 void GoatView::show_about()
672 {
673 QMessageBox::information(this, "About GoatView", about_str);
674 }
677 static int next_pow2(int x)
678 {
679 x--;
680 x = (x >> 1) | x;
681 x = (x >> 2) | x;
682 x = (x >> 4) | x;
683 x = (x >> 8) | x;
684 x = (x >> 16) | x;
685 return x + 1;
686 }