qvolray

diff src/ui.cc @ 27:011ac823600c

broken up the OpenGL code to multiple source files (untested)
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Apr 2012 06:37:31 +0300
parents f4cc61b5a3eb
children aeef3c2ae472
line diff
     1.1 --- a/src/ui.cc	Sat Apr 14 04:59:14 2012 +0300
     1.2 +++ b/src/ui.cc	Sat Apr 14 06:37:31 2012 +0300
     1.3 @@ -1,21 +1,18 @@
     1.4  #include <stdio.h>
     1.5  #include <stdlib.h>
     1.6 -#include <vector>
     1.7  #include <QtGui>
     1.8  #include "ui.h"
     1.9  
    1.10  static Volume *volume;
    1.11  
    1.12 -static GLView *maingl;
    1.13 -static std::vector<GLView*> glviews;
    1.14 +static MainGLView *maingl;
    1.15  
    1.16  MainWindow::MainWindow()
    1.17  {
    1.18  	setWindowTitle("Volume Renderer");
    1.19  
    1.20  	// OpenGL view
    1.21 -	maingl = new GLView;
    1.22 -	glviews.push_back(maingl);
    1.23 +	maingl = new MainGLView;
    1.24  	setCentralWidget(maingl);
    1.25  
    1.26  	// side-window
    1.27 @@ -68,8 +65,7 @@
    1.28  {
    1.29  	QGroupBox *groupbox = new QGroupBox("Volume slice");
    1.30  	{
    1.31 -		GLView *slice_view = new GLView;
    1.32 -		glviews.push_back(slice_view);
    1.33 +		slice_view = new SliceGLView(maingl);
    1.34  
    1.35  		QCheckBox *chk_clip = new QCheckBox("clip");
    1.36  		chk_clip->setChecked(false);
    1.37 @@ -112,72 +108,3 @@
    1.38  {
    1.39  	maingl->updateGL();
    1.40  }
    1.41 -
    1.42 -
    1.43 -GLView::GLView(QWidget *parent)
    1.44 -	: QGLWidget(QGLFormat(QGL::DoubleBuffer), parent)
    1.45 -{
    1.46 -}
    1.47 -
    1.48 -QSize GLView::minimumSizeHint() const
    1.49 -{
    1.50 -	return QSize(320, 200);
    1.51 -}
    1.52 -
    1.53 -QSize GLView::sizeHint() const
    1.54 -{
    1.55 -	return QSize(1280, 800);
    1.56 -}
    1.57 -
    1.58 -void GLView::initializeGL()
    1.59 -{
    1.60 -	if(!volray_init()) {
    1.61 -		exit(0);
    1.62 -	}
    1.63 -}
    1.64 -
    1.65 -void GLView::resizeGL(int xsz, int ysz)
    1.66 -{
    1.67 -	volray_resize(xsz, ysz);
    1.68 -}
    1.69 -
    1.70 -void GLView::paintGL()
    1.71 -{
    1.72 -	volray_draw();
    1.73 -}
    1.74 -
    1.75 -static int button_number(Qt::MouseButton bn)
    1.76 -{
    1.77 -	switch(bn) {
    1.78 -	case Qt::LeftButton:
    1.79 -		return 0;
    1.80 -	case Qt::MidButton:
    1.81 -		return 1;
    1.82 -	case Qt::RightButton:
    1.83 -		return 2;
    1.84 -	default:
    1.85 -		break;
    1.86 -	}
    1.87 -	return -1;
    1.88 -}
    1.89 -
    1.90 -void GLView::mousePressEvent(QMouseEvent *ev)
    1.91 -{
    1.92 -	int bn = button_number(ev->button());
    1.93 -	if(bn >= 0) {
    1.94 -		volray_mouse(bn, 1, ev->x(), ev->y());
    1.95 -	}
    1.96 -}
    1.97 -
    1.98 -void GLView::mouseReleaseEvent(QMouseEvent *ev)
    1.99 -{
   1.100 -	int bn = button_number(ev->button());
   1.101 -	if(bn >= 0) {
   1.102 -		volray_mouse(bn, 0, ev->x(), ev->y());
   1.103 -	}
   1.104 -}
   1.105 -
   1.106 -void GLView::mouseMoveEvent(QMouseEvent *ev)
   1.107 -{
   1.108 -	volray_motion(ev->x(), ev->y());
   1.109 -}