qvolray
view src/ui_maingl.cc @ 28:aeef3c2ae472
the slice widget works fine
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Apr 2012 16:35:30 +0300 |
parents | |
children |
line source
1 #include <QtGui>
2 #include "ui_maingl.h"
3 #include "volray.h"
5 MainGLView::MainGLView()
6 : QGLWidget(QGLFormat(QGL::DoubleBuffer), 0)
7 {
8 }
10 QSize MainGLView::minimumSizeHint() const
11 {
12 return QSize(320, 200);
13 }
15 QSize MainGLView::sizeHint() const
16 {
17 return QSize(1280, 800);
18 }
20 void MainGLView::initializeGL()
21 {
22 if(!volray_init()) {
23 exit(0);
24 }
25 }
27 void MainGLView::resizeGL(int xsz, int ysz)
28 {
29 volray_resize(xsz, ysz);
30 }
32 void MainGLView::paintGL()
33 {
34 volray_draw();
35 }
37 static int button_number(Qt::MouseButton bn)
38 {
39 switch(bn) {
40 case Qt::LeftButton:
41 return 0;
42 case Qt::MidButton:
43 return 1;
44 case Qt::RightButton:
45 return 2;
46 default:
47 break;
48 }
49 return -1;
50 }
52 void MainGLView::mousePressEvent(QMouseEvent *ev)
53 {
54 int bn = button_number(ev->button());
55 if(bn >= 0) {
56 volray_mouse(bn, 1, ev->x(), ev->y());
57 }
58 }
60 void MainGLView::mouseReleaseEvent(QMouseEvent *ev)
61 {
62 int bn = button_number(ev->button());
63 if(bn >= 0) {
64 volray_mouse(bn, 0, ev->x(), ev->y());
65 }
66 }
68 void MainGLView::mouseMoveEvent(QMouseEvent *ev)
69 {
70 volray_motion(ev->x(), ev->y());
71 }