qvolray

changeset 30:40df2cdc6323

transfer function window
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Apr 2012 22:10:30 +0300
parents 93d889a3726a
children c1dd5b120504
files src/ui.cc src/ui.h src/ui_xferview.cc src/ui_xferview.h src/volray.cc
diffstat 5 files changed, 34 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/src/ui.cc	Sat Apr 14 20:52:53 2012 +0300
     1.2 +++ b/src/ui.cc	Sat Apr 14 22:10:30 2012 +0300
     1.3 @@ -3,6 +3,10 @@
     1.4  #include <vector>
     1.5  #include <QtGui>
     1.6  #include "ui.h"
     1.7 +#include "ui_maingl.h"
     1.8 +#include "ui_sliceview.h"
     1.9 +#include "ui_xferview.h"
    1.10 +
    1.11  
    1.12  static Volume *volume;
    1.13  std::vector<QGLWidget*> glwlist;
    1.14 @@ -64,16 +68,18 @@
    1.15  
    1.16  SideWindow::SideWindow()
    1.17  {
    1.18 -	QGroupBox *groupbox = new QGroupBox("Volume slice");
    1.19 +	QGroupBox *group_slice = new QGroupBox("Volume slice");
    1.20  	{
    1.21  		slice_view = new SliceGLView(glwlist[0]);
    1.22  		glwlist.push_back(slice_view);
    1.23  
    1.24  		QCheckBox *chk_clip = new QCheckBox("clip");
    1.25 +		chk_clip->setStatusTip("Enable clipping at the current slice");
    1.26  		chk_clip->setChecked(false);
    1.27  		connect(chk_clip, SIGNAL(stateChanged(int)), this, SLOT(clip_change(int)));
    1.28  
    1.29  		QSlider *zslider = new QSlider(Qt::Horizontal);
    1.30 +		zslider->setStatusTip("Change current Z slice");
    1.31  		zslider->setRange(0, 256);
    1.32  		zslider->setValue(volray_getvalue(VolRayOpt::ZCURSOR) * 256.0);
    1.33  		connect(zslider, SIGNAL(valueChanged(int)), this, SLOT(zslider_change(int)));
    1.34 @@ -83,14 +89,26 @@
    1.35  		vbox->addWidget(chk_clip);
    1.36  		vbox->addWidget(zslider);
    1.37  
    1.38 -		groupbox->setLayout(vbox);
    1.39 +		group_slice->setLayout(vbox);
    1.40 +	}
    1.41 +
    1.42 +	QGroupBox *group_xfer = new QGroupBox("Transfer function");
    1.43 +	{
    1.44 +		XFerGLView *xfer_view = new XFerGLView(glwlist[0]);
    1.45 +		glwlist.push_back(xfer_view);
    1.46 +
    1.47 +		QVBoxLayout *vbox = new QVBoxLayout;
    1.48 +		vbox->addWidget(xfer_view);
    1.49 +
    1.50 +		group_xfer->setLayout(vbox);
    1.51  	}
    1.52  
    1.53  	QWidget *win = new QWidget;
    1.54  	setWidget(win);
    1.55  
    1.56  	QVBoxLayout *vbox = new QVBoxLayout;
    1.57 -	vbox->addWidget(groupbox);
    1.58 +	vbox->addWidget(group_slice);
    1.59 +	vbox->addWidget(group_xfer);
    1.60  	vbox->addStretch();
    1.61  
    1.62  	win->setLayout(vbox);
     2.1 --- a/src/ui.h	Sat Apr 14 20:52:53 2012 +0300
     2.2 +++ b/src/ui.h	Sat Apr 14 22:10:30 2012 +0300
     2.3 @@ -4,10 +4,11 @@
     2.4  #include <QMainWindow>
     2.5  #include <QDockWidget>
     2.6  #include "volray.h"
     2.7 -#include "ui_maingl.h"
     2.8 -#include "ui_sliceview.h"
     2.9  
    2.10  class SideWindow;
    2.11 +class MainGLView;
    2.12 +class SliceGLView;
    2.13 +class XFerGLView;
    2.14  
    2.15  // This is the main application window (duh)
    2.16  class MainWindow : public QMainWindow {
    2.17 @@ -22,8 +23,6 @@
    2.18  
    2.19  public:
    2.20  	MainWindow();
    2.21 -
    2.22 -	void update();
    2.23  };
    2.24  
    2.25  /* This is the detachable window with the volume slice view
    2.26 @@ -34,6 +33,7 @@
    2.27  	Q_OBJECT
    2.28  
    2.29  	SliceGLView *slice_view;
    2.30 +	XFerGLView *xfer_view;
    2.31  
    2.32  private slots:
    2.33  	void zslider_change(int val);
    2.34 @@ -41,8 +41,6 @@
    2.35  
    2.36  public:
    2.37  	SideWindow();
    2.38 -
    2.39 -	void update();
    2.40  };
    2.41  
    2.42  // call to force a redisplay on all GL views
     3.1 --- a/src/ui_xferview.cc	Sat Apr 14 20:52:53 2012 +0300
     3.2 +++ b/src/ui_xferview.cc	Sat Apr 14 22:10:30 2012 +0300
     3.3 @@ -1,26 +1,26 @@
     3.4  #include "ui_xferview.h"
     3.5  #include "volray.h"
     3.6  
     3.7 -XFerView::XFerView(QGLWidget *share_widget)
     3.8 +XFerGLView::XFerGLView(QGLWidget *share_widget)
     3.9  	: QGLWidget(QGLFormat(QGL::DoubleBuffer), 0, share_widget)
    3.10  {
    3.11  }
    3.12  
    3.13 -QSize XFerView::minimumSizeHint() const
    3.14 +QSize XFerGLView::minimumSizeHint() const
    3.15  {
    3.16  	return QSize(160, 100);
    3.17  }
    3.18  
    3.19 -void XFerView::initializeGL()
    3.20 +void XFerGLView::initializeGL()
    3.21  {
    3.22  }
    3.23  
    3.24 -void XFerView::resizeGL(int xsz, int ysz)
    3.25 +void XFerGLView::resizeGL(int xsz, int ysz)
    3.26  {
    3.27  	glViewport(0, 0, xsz, ysz);
    3.28  }
    3.29  
    3.30 -void XFerView::paintGL()
    3.31 +void XFerGLView::paintGL()
    3.32  {
    3.33  	volray_draw_xfer();
    3.34  }
     4.1 --- a/src/ui_xferview.h	Sat Apr 14 20:52:53 2012 +0300
     4.2 +++ b/src/ui_xferview.h	Sat Apr 14 22:10:30 2012 +0300
     4.3 @@ -3,7 +3,7 @@
     4.4  
     4.5  #include <QGLWidget>
     4.6  
     4.7 -class XFerView : public QGLWidget {
     4.8 +class XFerGLView : public QGLWidget {
     4.9  private:
    4.10  	Q_OBJECT
    4.11  
    4.12 @@ -12,7 +12,7 @@
    4.13  	void paintGL();
    4.14  
    4.15  public:
    4.16 -	XFerView(QGLWidget *share_widget = 0);
    4.17 +	XFerGLView(QGLWidget *share_widget = 0);
    4.18  
    4.19  	QSize minimumSizeHint() const;
    4.20  };
     5.1 --- a/src/volray.cc	Sat Apr 14 20:52:53 2012 +0300
     5.2 +++ b/src/volray.cc	Sat Apr 14 22:10:30 2012 +0300
     5.3 @@ -233,8 +233,8 @@
     5.4  {
     5.5  	glMatrixMode(GL_MODELVIEW);
     5.6  	glPushMatrix();
     5.7 -	glTranslatef(-0.9, -0.9, 0);
     5.8 -	glScalef(0.5, 0.1, 1);
     5.9 +	glTranslatef(-1, -1, 0);
    5.10 +	glScalef(2, 2, 1);
    5.11  
    5.12  	glBindTexture(GL_TEXTURE_1D, xfer_tex);
    5.13  	glEnable(GL_TEXTURE_1D);