# HG changeset patch # User John Tsiombikas # Date 1334425973 -10800 # Node ID 93d889a3726a8318743a1d43d5f823b2f1ce70ba # Parent aeef3c2ae47282aef2393c1ecfe6bdfe961f6636 foo diff -r aeef3c2ae472 -r 93d889a3726a qvolray.pro --- a/qvolray.pro Sat Apr 14 16:35:30 2012 +0300 +++ b/qvolray.pro Sat Apr 14 20:52:53 2012 +0300 @@ -24,7 +24,8 @@ # the moc needs to run for these headers HEADERS = src/ui.h \ src/ui_maingl.h \ - src/ui_sliceview.h + src/ui_sliceview.h \ + src/ui_xferview.h SOURCES = src/main.cc \ src/sdr.c \ @@ -33,4 +34,5 @@ src/ui.cc \ src/ui_maingl.cc \ src/ui_sliceview.cc \ + src/ui_xferview.cc \ src/demo.cc diff -r aeef3c2ae472 -r 93d889a3726a src/main.cc --- a/src/main.cc Sat Apr 14 16:35:30 2012 +0300 +++ b/src/main.cc Sat Apr 14 20:52:53 2012 +0300 @@ -1,9 +1,11 @@ #include #include "ui.h" +#include "volray.h" int main(int argc, char **argv) { QApplication app(argc, argv); + parse_args(argc, argv); MainWindow gui; diff -r aeef3c2ae472 -r 93d889a3726a src/ui.cc --- a/src/ui.cc Sat Apr 14 16:35:30 2012 +0300 +++ b/src/ui.cc Sat Apr 14 20:52:53 2012 +0300 @@ -75,7 +75,7 @@ QSlider *zslider = new QSlider(Qt::Horizontal); zslider->setRange(0, 256); - zslider->setValue(volray_getvalue(VOLRAY_ZCURSOR) * 256.0); + zslider->setValue(volray_getvalue(VolRayOpt::ZCURSOR) * 256.0); connect(zslider, SIGNAL(valueChanged(int)), this, SLOT(zslider_change(int))); QVBoxLayout *vbox = new QVBoxLayout; @@ -98,12 +98,12 @@ void SideWindow::zslider_change(int val) { - volray_setvalue(VOLRAY_ZCURSOR, (float)val / 256.0); + volray_setvalue(VolRayOpt::ZCURSOR, (float)val / 256.0); } void SideWindow::clip_change(int checked) { - volray_setvalue(VOLRAY_ZCLIP, checked); + volray_setvalue(VolRayOpt::ZCLIP, checked); } diff -r aeef3c2ae472 -r 93d889a3726a src/ui_sliceview.h --- a/src/ui_sliceview.h Sat Apr 14 16:35:30 2012 +0300 +++ b/src/ui_sliceview.h Sat Apr 14 20:52:53 2012 +0300 @@ -11,8 +11,6 @@ void resizeGL(int xsz, int ysz); void paintGL(); - void draw_slice() const; - public: SliceGLView(QGLWidget *share_widget = 0); diff -r aeef3c2ae472 -r 93d889a3726a src/ui_xferview.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui_xferview.cc Sat Apr 14 20:52:53 2012 +0300 @@ -0,0 +1,26 @@ +#include "ui_xferview.h" +#include "volray.h" + +XFerView::XFerView(QGLWidget *share_widget) + : QGLWidget(QGLFormat(QGL::DoubleBuffer), 0, share_widget) +{ +} + +QSize XFerView::minimumSizeHint() const +{ + return QSize(160, 100); +} + +void XFerView::initializeGL() +{ +} + +void XFerView::resizeGL(int xsz, int ysz) +{ + glViewport(0, 0, xsz, ysz); +} + +void XFerView::paintGL() +{ + volray_draw_xfer(); +} diff -r aeef3c2ae472 -r 93d889a3726a src/ui_xferview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui_xferview.h Sat Apr 14 20:52:53 2012 +0300 @@ -0,0 +1,20 @@ +#ifndef UI_XFERVIEW_H_ +#define UI_XFERVIEW_H_ + +#include + +class XFerView : public QGLWidget { +private: + Q_OBJECT + + void initializeGL(); + void resizeGL(int xsz, int ysz); + void paintGL(); + +public: + XFerView(QGLWidget *share_widget = 0); + + QSize minimumSizeHint() const; +}; + +#endif // UI_XFERVIEW_H_ diff -r aeef3c2ae472 -r 93d889a3726a src/volray.cc --- a/src/volray.cc Sat Apr 14 16:35:30 2012 +0300 +++ b/src/volray.cc Sat Apr 14 20:52:53 2012 +0300 @@ -19,15 +19,12 @@ #define XFER_MAP_SZ 512 static void render_volume(); -static void draw_slice(); -static void draw_xfer_func(); /* void keyb(unsigned char key, int x, int y); void keyb_up(unsigned char key, int x, int y); void mouse(int bn, int state, int x, int y); void motion(int x, int y); -int parse_args(int argc, char **argv); */ static void create_ray_texture(int xsz, int ysz, float vfov, Vector2 *tex_scale); @@ -88,10 +85,10 @@ return volume; } -void volray_setvalue(int which, float val) +void volray_setvalue(VolRayOpt which, float val) { switch(which) { - case VOLRAY_ZCURSOR: + case VolRayOpt::ZCURSOR: cur_z = val; if(clip_z) { set_uniform_float(vol_sdr, "zclip", cur_z); @@ -99,7 +96,7 @@ post_redisplay(); break; - case VOLRAY_ZCLIP: + case VolRayOpt::ZCLIP: clip_z = val > 0.5; set_uniform_float(vol_sdr, "zclip", clip_z ? cur_z : 0.0); post_redisplay(); @@ -110,13 +107,13 @@ } } -float volray_getvalue(int which) +float volray_getvalue(VolRayOpt which) { switch(which) { - case VOLRAY_ZCURSOR: + case VolRayOpt::ZCURSOR: return cur_z; - case VOLRAY_ZCLIP: + case VolRayOpt::ZCLIP: return clip_z > 0.5 ? 1.0 : 0.0; break; @@ -143,8 +140,6 @@ if(volume) { render_volume(); - //draw_slice(); - draw_xfer_func(); } assert(glGetError() == GL_NO_ERROR); @@ -234,7 +229,7 @@ glDisable(GL_TEXTURE_3D); } -static void draw_xfer_func(void) +void volray_draw_xfer(void) { glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -396,7 +391,6 @@ //} } -#if 0 int parse_args(int argc, char **argv) { int i; @@ -426,21 +420,12 @@ return -1; } } else { - if(fname) { - fprintf(stderr, "unexpected argument: %s\n", argv[i]); - return -1; - } - fname = argv[i]; + fprintf(stderr, "unexpected argument: %s\n", argv[i]); } } - if(!fname) { - fprintf(stderr, "pass the volume descriptor filename\n"); - return -1; - } return 0; } -#endif static void create_ray_texture(int xsz, int ysz, float vfov, Vector2 *tex_scale) diff -r aeef3c2ae472 -r 93d889a3726a src/volray.h --- a/src/volray.h Sat Apr 14 16:35:30 2012 +0300 +++ b/src/volray.h Sat Apr 14 20:52:53 2012 +0300 @@ -8,19 +8,22 @@ void volray_setvolume(Volume *vol); Volume *volray_getvolume(); -enum { - VOLRAY_ZCURSOR, - VOLRAY_ZCLIP +enum class VolRayOpt { + ZCURSOR, + ZCLIP }; -void volray_setvalue(int which, float val); -float volray_getvalue(int which); +void volray_setvalue(VolRayOpt which, float val); +float volray_getvalue(VolRayOpt which); void volray_resize(int xsz, int ysz); void volray_draw(); void volray_draw_slice(); +void volray_draw_xfer(); void volray_mouse(int bn, int state, int x, int y); void volray_motion(int x, int y); +int parse_args(int argc, char **argv); + #endif // VOLRAY_H_