qvolray

changeset 31:c1dd5b120504

separated the transfer function to a different subwindow and added shortcut for quit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 14 Apr 2012 22:32:14 +0300
parents 40df2cdc6323
children 7e5a2dd9bca6
files src/ui.cc src/ui.h
diffstat 2 files changed, 45 insertions(+), 13 deletions(-) [+]
line diff
     1.1 --- a/src/ui.cc	Sat Apr 14 22:10:30 2012 +0300
     1.2 +++ b/src/ui.cc	Sat Apr 14 22:32:14 2012 +0300
     1.3 @@ -20,12 +20,18 @@
     1.4  	setCentralWidget(maingl);
     1.5  	glwlist.push_back(maingl);
     1.6  
     1.7 -	// side-window
     1.8 +	// slice view sub-window
     1.9  	sidewin = new SideWindow;
    1.10  	sidewin->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    1.11  	sidewin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    1.12  	addDockWidget(Qt::LeftDockWidgetArea, sidewin);
    1.13  
    1.14 +	// transfer function sub-window
    1.15 +	xferwin = new XFerWin;
    1.16 +	xferwin->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
    1.17 +	xferwin->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    1.18 +	addDockWidget(Qt::LeftDockWidgetArea, xferwin);
    1.19 +
    1.20  	// actions
    1.21  	QAction *act_open = new QAction(qApp->style()->standardIcon(QStyle::SP_DialogOpenButton), "&Open...", this);
    1.22  	act_open->setStatusTip("Open a volume dataset");
    1.23 @@ -33,6 +39,8 @@
    1.24  
    1.25  	QAction *act_quit = new QAction("&Quit", this);
    1.26  	act_quit->setStatusTip("Quit");
    1.27 +	//act_quit->setShortcut(QKeySequence(QKeySequence::Quit));
    1.28 +	act_quit->setShortcut(QKeySequence(tr("Ctrl+Q", "File|Quit")));
    1.29  	QObject::connect(act_quit, SIGNAL(triggered()), this, SLOT(close()));
    1.30  
    1.31  	// menus
    1.32 @@ -92,6 +100,29 @@
    1.33  		group_slice->setLayout(vbox);
    1.34  	}
    1.35  
    1.36 +	QWidget *win = new QWidget;
    1.37 +	setWidget(win);
    1.38 +
    1.39 +	QVBoxLayout *vbox = new QVBoxLayout;
    1.40 +	vbox->addWidget(group_slice);
    1.41 +	vbox->addStretch();
    1.42 +
    1.43 +	win->setLayout(vbox);
    1.44 +}
    1.45 +
    1.46 +void SideWindow::zslider_change(int val)
    1.47 +{
    1.48 +	volray_setvalue(VolRayOpt::ZCURSOR, (float)val / 256.0);
    1.49 +}
    1.50 +
    1.51 +void SideWindow::clip_change(int checked)
    1.52 +{
    1.53 +	volray_setvalue(VolRayOpt::ZCLIP, checked);
    1.54 +}
    1.55 +
    1.56 +
    1.57 +XFerWin::XFerWin()
    1.58 +{
    1.59  	QGroupBox *group_xfer = new QGroupBox("Transfer function");
    1.60  	{
    1.61  		XFerGLView *xfer_view = new XFerGLView(glwlist[0]);
    1.62 @@ -107,23 +138,12 @@
    1.63  	setWidget(win);
    1.64  
    1.65  	QVBoxLayout *vbox = new QVBoxLayout;
    1.66 -	vbox->addWidget(group_slice);
    1.67  	vbox->addWidget(group_xfer);
    1.68  	vbox->addStretch();
    1.69  
    1.70  	win->setLayout(vbox);
    1.71  }
    1.72  
    1.73 -void SideWindow::zslider_change(int val)
    1.74 -{
    1.75 -	volray_setvalue(VolRayOpt::ZCURSOR, (float)val / 256.0);
    1.76 -}
    1.77 -
    1.78 -void SideWindow::clip_change(int checked)
    1.79 -{
    1.80 -	volray_setvalue(VolRayOpt::ZCLIP, checked);
    1.81 -}
    1.82 -
    1.83  
    1.84  void post_redisplay()
    1.85  {
     2.1 --- a/src/ui.h	Sat Apr 14 22:10:30 2012 +0300
     2.2 +++ b/src/ui.h	Sat Apr 14 22:32:14 2012 +0300
     2.3 @@ -6,6 +6,8 @@
     2.4  #include "volray.h"
     2.5  
     2.6  class SideWindow;
     2.7 +class XFerWin;
     2.8 +
     2.9  class MainGLView;
    2.10  class SliceGLView;
    2.11  class XFerGLView;
    2.12 @@ -17,6 +19,7 @@
    2.13  
    2.14  	MainGLView *maingl;
    2.15  	SideWindow *sidewin;
    2.16 +	XFerWin *xferwin;
    2.17  
    2.18  private slots:
    2.19  	void open_volume();
    2.20 @@ -33,7 +36,6 @@
    2.21  	Q_OBJECT
    2.22  
    2.23  	SliceGLView *slice_view;
    2.24 -	XFerGLView *xfer_view;
    2.25  
    2.26  private slots:
    2.27  	void zslider_change(int val);
    2.28 @@ -43,6 +45,16 @@
    2.29  	SideWindow();
    2.30  };
    2.31  
    2.32 +class XFerWin : public QDockWidget {
    2.33 +private:
    2.34 +	Q_OBJECT
    2.35 +
    2.36 +	XFerGLView *xfer_view;
    2.37 +
    2.38 +public:
    2.39 +	XFerWin();
    2.40 +};
    2.41 +
    2.42  // call to force a redisplay on all GL views
    2.43  void post_redisplay();
    2.44