nuclear@27: #include nuclear@27: #include "ui_maingl.h" nuclear@27: #include "volray.h" nuclear@27: nuclear@27: MainGLView::MainGLView() nuclear@27: : QGLWidget(QGLFormat(QGL::DoubleBuffer), 0) nuclear@27: { nuclear@27: } nuclear@27: nuclear@27: QSize MainGLView::minimumSizeHint() const nuclear@27: { nuclear@27: return QSize(320, 200); nuclear@27: } nuclear@27: nuclear@27: QSize MainGLView::sizeHint() const nuclear@27: { nuclear@27: return QSize(1280, 800); nuclear@27: } nuclear@27: nuclear@27: void MainGLView::initializeGL() nuclear@27: { nuclear@27: if(!volray_init()) { nuclear@27: exit(0); nuclear@27: } nuclear@27: } nuclear@27: nuclear@27: void MainGLView::resizeGL(int xsz, int ysz) nuclear@27: { nuclear@27: volray_resize(xsz, ysz); nuclear@27: } nuclear@27: nuclear@27: void MainGLView::paintGL() nuclear@27: { nuclear@27: volray_draw(); nuclear@27: } nuclear@27: nuclear@27: static int button_number(Qt::MouseButton bn) nuclear@27: { nuclear@27: switch(bn) { nuclear@27: case Qt::LeftButton: nuclear@27: return 0; nuclear@27: case Qt::MidButton: nuclear@27: return 1; nuclear@27: case Qt::RightButton: nuclear@27: return 2; nuclear@27: default: nuclear@27: break; nuclear@27: } nuclear@27: return -1; nuclear@27: } nuclear@27: nuclear@27: void MainGLView::mousePressEvent(QMouseEvent *ev) nuclear@27: { nuclear@27: int bn = button_number(ev->button()); nuclear@27: if(bn >= 0) { nuclear@27: volray_mouse(bn, 1, ev->x(), ev->y()); nuclear@27: } nuclear@27: } nuclear@27: nuclear@27: void MainGLView::mouseReleaseEvent(QMouseEvent *ev) nuclear@27: { nuclear@27: int bn = button_number(ev->button()); nuclear@27: if(bn >= 0) { nuclear@27: volray_mouse(bn, 0, ev->x(), ev->y()); nuclear@27: } nuclear@27: } nuclear@27: nuclear@27: void MainGLView::mouseMoveEvent(QMouseEvent *ev) nuclear@27: { nuclear@27: volray_motion(ev->x(), ev->y()); nuclear@27: }