qvolray
changeset 29:93d889a3726a
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Apr 2012 20:52:53 +0300 |
parents | aeef3c2ae472 |
children | 40df2cdc6323 |
files | qvolray.pro src/main.cc src/ui.cc src/ui_sliceview.h src/ui_xferview.cc src/ui_xferview.h src/volray.cc src/volray.h |
diffstat | 8 files changed, 70 insertions(+), 34 deletions(-) [+] |
line diff
1.1 --- a/qvolray.pro Sat Apr 14 16:35:30 2012 +0300 1.2 +++ b/qvolray.pro Sat Apr 14 20:52:53 2012 +0300 1.3 @@ -24,7 +24,8 @@ 1.4 # the moc needs to run for these headers 1.5 HEADERS = src/ui.h \ 1.6 src/ui_maingl.h \ 1.7 - src/ui_sliceview.h 1.8 + src/ui_sliceview.h \ 1.9 + src/ui_xferview.h 1.10 1.11 SOURCES = src/main.cc \ 1.12 src/sdr.c \ 1.13 @@ -33,4 +34,5 @@ 1.14 src/ui.cc \ 1.15 src/ui_maingl.cc \ 1.16 src/ui_sliceview.cc \ 1.17 + src/ui_xferview.cc \ 1.18 src/demo.cc
2.1 --- a/src/main.cc Sat Apr 14 16:35:30 2012 +0300 2.2 +++ b/src/main.cc Sat Apr 14 20:52:53 2012 +0300 2.3 @@ -1,9 +1,11 @@ 2.4 #include <QApplication> 2.5 #include "ui.h" 2.6 +#include "volray.h" 2.7 2.8 int main(int argc, char **argv) 2.9 { 2.10 QApplication app(argc, argv); 2.11 + parse_args(argc, argv); 2.12 2.13 MainWindow gui; 2.14
3.1 --- a/src/ui.cc Sat Apr 14 16:35:30 2012 +0300 3.2 +++ b/src/ui.cc Sat Apr 14 20:52:53 2012 +0300 3.3 @@ -75,7 +75,7 @@ 3.4 3.5 QSlider *zslider = new QSlider(Qt::Horizontal); 3.6 zslider->setRange(0, 256); 3.7 - zslider->setValue(volray_getvalue(VOLRAY_ZCURSOR) * 256.0); 3.8 + zslider->setValue(volray_getvalue(VolRayOpt::ZCURSOR) * 256.0); 3.9 connect(zslider, SIGNAL(valueChanged(int)), this, SLOT(zslider_change(int))); 3.10 3.11 QVBoxLayout *vbox = new QVBoxLayout; 3.12 @@ -98,12 +98,12 @@ 3.13 3.14 void SideWindow::zslider_change(int val) 3.15 { 3.16 - volray_setvalue(VOLRAY_ZCURSOR, (float)val / 256.0); 3.17 + volray_setvalue(VolRayOpt::ZCURSOR, (float)val / 256.0); 3.18 } 3.19 3.20 void SideWindow::clip_change(int checked) 3.21 { 3.22 - volray_setvalue(VOLRAY_ZCLIP, checked); 3.23 + volray_setvalue(VolRayOpt::ZCLIP, checked); 3.24 } 3.25 3.26
4.1 --- a/src/ui_sliceview.h Sat Apr 14 16:35:30 2012 +0300 4.2 +++ b/src/ui_sliceview.h Sat Apr 14 20:52:53 2012 +0300 4.3 @@ -11,8 +11,6 @@ 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 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/src/ui_xferview.cc Sat Apr 14 20:52:53 2012 +0300 5.3 @@ -0,0 +1,26 @@ 5.4 +#include "ui_xferview.h" 5.5 +#include "volray.h" 5.6 + 5.7 +XFerView::XFerView(QGLWidget *share_widget) 5.8 + : QGLWidget(QGLFormat(QGL::DoubleBuffer), 0, share_widget) 5.9 +{ 5.10 +} 5.11 + 5.12 +QSize XFerView::minimumSizeHint() const 5.13 +{ 5.14 + return QSize(160, 100); 5.15 +} 5.16 + 5.17 +void XFerView::initializeGL() 5.18 +{ 5.19 +} 5.20 + 5.21 +void XFerView::resizeGL(int xsz, int ysz) 5.22 +{ 5.23 + glViewport(0, 0, xsz, ysz); 5.24 +} 5.25 + 5.26 +void XFerView::paintGL() 5.27 +{ 5.28 + volray_draw_xfer(); 5.29 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/src/ui_xferview.h Sat Apr 14 20:52:53 2012 +0300 6.3 @@ -0,0 +1,20 @@ 6.4 +#ifndef UI_XFERVIEW_H_ 6.5 +#define UI_XFERVIEW_H_ 6.6 + 6.7 +#include <QGLWidget> 6.8 + 6.9 +class XFerView : public QGLWidget { 6.10 +private: 6.11 + Q_OBJECT 6.12 + 6.13 + void initializeGL(); 6.14 + void resizeGL(int xsz, int ysz); 6.15 + void paintGL(); 6.16 + 6.17 +public: 6.18 + XFerView(QGLWidget *share_widget = 0); 6.19 + 6.20 + QSize minimumSizeHint() const; 6.21 +}; 6.22 + 6.23 +#endif // UI_XFERVIEW_H_
7.1 --- a/src/volray.cc Sat Apr 14 16:35:30 2012 +0300 7.2 +++ b/src/volray.cc Sat Apr 14 20:52:53 2012 +0300 7.3 @@ -19,15 +19,12 @@ 7.4 #define XFER_MAP_SZ 512 7.5 7.6 static void render_volume(); 7.7 -static void draw_slice(); 7.8 -static void draw_xfer_func(); 7.9 7.10 /* 7.11 void keyb(unsigned char key, int x, int y); 7.12 void keyb_up(unsigned char key, int x, int y); 7.13 void mouse(int bn, int state, int x, int y); 7.14 void motion(int x, int y); 7.15 -int parse_args(int argc, char **argv); 7.16 */ 7.17 7.18 static void create_ray_texture(int xsz, int ysz, float vfov, Vector2 *tex_scale); 7.19 @@ -88,10 +85,10 @@ 7.20 return volume; 7.21 } 7.22 7.23 -void volray_setvalue(int which, float val) 7.24 +void volray_setvalue(VolRayOpt which, float val) 7.25 { 7.26 switch(which) { 7.27 - case VOLRAY_ZCURSOR: 7.28 + case VolRayOpt::ZCURSOR: 7.29 cur_z = val; 7.30 if(clip_z) { 7.31 set_uniform_float(vol_sdr, "zclip", cur_z); 7.32 @@ -99,7 +96,7 @@ 7.33 post_redisplay(); 7.34 break; 7.35 7.36 - case VOLRAY_ZCLIP: 7.37 + case VolRayOpt::ZCLIP: 7.38 clip_z = val > 0.5; 7.39 set_uniform_float(vol_sdr, "zclip", clip_z ? cur_z : 0.0); 7.40 post_redisplay(); 7.41 @@ -110,13 +107,13 @@ 7.42 } 7.43 } 7.44 7.45 -float volray_getvalue(int which) 7.46 +float volray_getvalue(VolRayOpt which) 7.47 { 7.48 switch(which) { 7.49 - case VOLRAY_ZCURSOR: 7.50 + case VolRayOpt::ZCURSOR: 7.51 return cur_z; 7.52 7.53 - case VOLRAY_ZCLIP: 7.54 + case VolRayOpt::ZCLIP: 7.55 return clip_z > 0.5 ? 1.0 : 0.0; 7.56 break; 7.57 7.58 @@ -143,8 +140,6 @@ 7.59 7.60 if(volume) { 7.61 render_volume(); 7.62 - //draw_slice(); 7.63 - draw_xfer_func(); 7.64 } 7.65 7.66 assert(glGetError() == GL_NO_ERROR); 7.67 @@ -234,7 +229,7 @@ 7.68 glDisable(GL_TEXTURE_3D); 7.69 } 7.70 7.71 -static void draw_xfer_func(void) 7.72 +void volray_draw_xfer(void) 7.73 { 7.74 glMatrixMode(GL_MODELVIEW); 7.75 glPushMatrix(); 7.76 @@ -396,7 +391,6 @@ 7.77 //} 7.78 } 7.79 7.80 -#if 0 7.81 int parse_args(int argc, char **argv) 7.82 { 7.83 int i; 7.84 @@ -426,21 +420,12 @@ 7.85 return -1; 7.86 } 7.87 } else { 7.88 - if(fname) { 7.89 - fprintf(stderr, "unexpected argument: %s\n", argv[i]); 7.90 - return -1; 7.91 - } 7.92 - fname = argv[i]; 7.93 + fprintf(stderr, "unexpected argument: %s\n", argv[i]); 7.94 } 7.95 } 7.96 7.97 - if(!fname) { 7.98 - fprintf(stderr, "pass the volume descriptor filename\n"); 7.99 - return -1; 7.100 - } 7.101 return 0; 7.102 } 7.103 -#endif 7.104 7.105 7.106 static void create_ray_texture(int xsz, int ysz, float vfov, Vector2 *tex_scale)
8.1 --- a/src/volray.h Sat Apr 14 16:35:30 2012 +0300 8.2 +++ b/src/volray.h Sat Apr 14 20:52:53 2012 +0300 8.3 @@ -8,19 +8,22 @@ 8.4 void volray_setvolume(Volume *vol); 8.5 Volume *volray_getvolume(); 8.6 8.7 -enum { 8.8 - VOLRAY_ZCURSOR, 8.9 - VOLRAY_ZCLIP 8.10 +enum class VolRayOpt { 8.11 + ZCURSOR, 8.12 + ZCLIP 8.13 }; 8.14 8.15 -void volray_setvalue(int which, float val); 8.16 -float volray_getvalue(int which); 8.17 +void volray_setvalue(VolRayOpt which, float val); 8.18 +float volray_getvalue(VolRayOpt which); 8.19 8.20 void volray_resize(int xsz, int ysz); 8.21 void volray_draw(); 8.22 void volray_draw_slice(); 8.23 +void volray_draw_xfer(); 8.24 8.25 void volray_mouse(int bn, int state, int x, int y); 8.26 void volray_motion(int x, int y); 8.27 8.28 +int parse_args(int argc, char **argv); 8.29 + 8.30 #endif // VOLRAY_H_