qvolray

changeset 28:aeef3c2ae472

the slice widget works fine
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Apr 2012 16:35:30 +0300
parents 011ac823600c
children 93d889a3726a
files src/ui.cc src/ui.h src/ui_sliceview.cc src/ui_sliceview.h src/volray.cc src/volray.h
diffstat 6 files changed, 21 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/src/ui.cc	Sat Apr 14 06:37:31 2012 +0300
     1.2 +++ b/src/ui.cc	Sat Apr 14 16:35:30 2012 +0300
     1.3 @@ -1,19 +1,20 @@
     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 MainGLView *maingl;
    1.13 +std::vector<QGLWidget*> glwlist;
    1.14  
    1.15  MainWindow::MainWindow()
    1.16  {
    1.17  	setWindowTitle("Volume Renderer");
    1.18  
    1.19 -	// OpenGL view
    1.20 +	// OpenGL view (this must be initialized first)
    1.21  	maingl = new MainGLView;
    1.22  	setCentralWidget(maingl);
    1.23 +	glwlist.push_back(maingl);
    1.24  
    1.25  	// side-window
    1.26  	sidewin = new SideWindow;
    1.27 @@ -65,7 +66,8 @@
    1.28  {
    1.29  	QGroupBox *groupbox = new QGroupBox("Volume slice");
    1.30  	{
    1.31 -		slice_view = new SliceGLView(maingl);
    1.32 +		slice_view = new SliceGLView(glwlist[0]);
    1.33 +		glwlist.push_back(slice_view);
    1.34  
    1.35  		QCheckBox *chk_clip = new QCheckBox("clip");
    1.36  		chk_clip->setChecked(false);
    1.37 @@ -104,7 +106,10 @@
    1.38  	volray_setvalue(VOLRAY_ZCLIP, checked);
    1.39  }
    1.40  
    1.41 +
    1.42  void post_redisplay()
    1.43  {
    1.44 -	maingl->updateGL();
    1.45 +	for(auto glw : glwlist) {
    1.46 +		glw->updateGL();
    1.47 +	}
    1.48  }
     2.1 --- a/src/ui.h	Sat Apr 14 06:37:31 2012 +0300
     2.2 +++ b/src/ui.h	Sat Apr 14 16:35:30 2012 +0300
     2.3 @@ -22,6 +22,8 @@
     2.4  
     2.5  public:
     2.6  	MainWindow();
     2.7 +
     2.8 +	void update();
     2.9  };
    2.10  
    2.11  /* This is the detachable window with the volume slice view
    2.12 @@ -39,6 +41,8 @@
    2.13  
    2.14  public:
    2.15  	SideWindow();
    2.16 +
    2.17 +	void update();
    2.18  };
    2.19  
    2.20  // call to force a redisplay on all GL views
     3.1 --- a/src/ui_sliceview.cc	Sat Apr 14 06:37:31 2012 +0300
     3.2 +++ b/src/ui_sliceview.cc	Sat Apr 14 16:35:30 2012 +0300
     3.3 @@ -1,4 +1,5 @@
     3.4  #include "ui_sliceview.h"
     3.5 +#include "volray.h"
     3.6  
     3.7  SliceGLView::SliceGLView(QGLWidget *share_widget)
     3.8  	: QGLWidget(QGLFormat(QGL::DoubleBuffer), 0, share_widget)
     3.9 @@ -21,5 +22,5 @@
    3.10  
    3.11  void SliceGLView::paintGL()
    3.12  {
    3.13 -	glClear(GL_COLOR_BUFFER_BIT);
    3.14 +	volray_draw_slice();
    3.15  }
     4.1 --- a/src/ui_sliceview.h	Sat Apr 14 06:37:31 2012 +0300
     4.2 +++ b/src/ui_sliceview.h	Sat Apr 14 16:35:30 2012 +0300
     4.3 @@ -11,6 +11,8 @@
     4.4  	void resizeGL(int xsz, int ysz);
     4.5  	void paintGL();
     4.6  
     4.7 +	void draw_slice() const;
     4.8 +
     4.9  public:
    4.10  	SliceGLView(QGLWidget *share_widget = 0);
    4.11  
     5.1 --- a/src/volray.cc	Sat Apr 14 06:37:31 2012 +0300
     5.2 +++ b/src/volray.cc	Sat Apr 14 16:35:30 2012 +0300
     5.3 @@ -143,7 +143,7 @@
     5.4  
     5.5  	if(volume) {
     5.6  		render_volume();
     5.7 -		draw_slice();
     5.8 +		//draw_slice();
     5.9  		draw_xfer_func();
    5.10  	}
    5.11  
    5.12 @@ -206,14 +206,8 @@
    5.13  	glPopMatrix();
    5.14  }
    5.15  
    5.16 -static void draw_slice(void)
    5.17 +void volray_draw_slice(void)
    5.18  {
    5.19 -	glMatrixMode(GL_MODELVIEW);
    5.20 -	glPushMatrix();
    5.21 -	glTranslatef(0.9, 0.9, 0);
    5.22 -	glScalef(0.3, 0.3 * ((float)win_xsz / win_ysz), 1);
    5.23 -	glTranslatef(-1, -1, 0);
    5.24 -
    5.25  	glActiveTexture(GL_TEXTURE0);
    5.26  	glBindTexture(GL_TEXTURE_3D, volume->get_texture());
    5.27  	glEnable(GL_TEXTURE_3D);
    5.28 @@ -238,7 +232,6 @@
    5.29  	glDisable(GL_TEXTURE_1D);
    5.30  	glActiveTexture(GL_TEXTURE0);
    5.31  	glDisable(GL_TEXTURE_3D);
    5.32 -	glPopMatrix();
    5.33  }
    5.34  
    5.35  static void draw_xfer_func(void)
     6.1 --- a/src/volray.h	Sat Apr 14 06:37:31 2012 +0300
     6.2 +++ b/src/volray.h	Sat Apr 14 16:35:30 2012 +0300
     6.3 @@ -18,6 +18,7 @@
     6.4  
     6.5  void volray_resize(int xsz, int ysz);
     6.6  void volray_draw();
     6.7 +void volray_draw_slice();
     6.8  
     6.9  void volray_mouse(int bn, int state, int x, int y);
    6.10  void volray_motion(int x, int y);