# HG changeset patch # User John Tsiombikas # Date 1334410530 -10800 # Node ID aeef3c2ae47282aef2393c1ecfe6bdfe961f6636 # Parent 011ac823600ce885218e3687a5e6ce91f6b64833 the slice widget works fine diff -r 011ac823600c -r aeef3c2ae472 src/ui.cc --- a/src/ui.cc Sat Apr 14 06:37:31 2012 +0300 +++ b/src/ui.cc Sat Apr 14 16:35:30 2012 +0300 @@ -1,19 +1,20 @@ #include #include +#include #include #include "ui.h" static Volume *volume; - -static MainGLView *maingl; +std::vector glwlist; MainWindow::MainWindow() { setWindowTitle("Volume Renderer"); - // OpenGL view + // OpenGL view (this must be initialized first) maingl = new MainGLView; setCentralWidget(maingl); + glwlist.push_back(maingl); // side-window sidewin = new SideWindow; @@ -65,7 +66,8 @@ { QGroupBox *groupbox = new QGroupBox("Volume slice"); { - slice_view = new SliceGLView(maingl); + slice_view = new SliceGLView(glwlist[0]); + glwlist.push_back(slice_view); QCheckBox *chk_clip = new QCheckBox("clip"); chk_clip->setChecked(false); @@ -104,7 +106,10 @@ volray_setvalue(VOLRAY_ZCLIP, checked); } + void post_redisplay() { - maingl->updateGL(); + for(auto glw : glwlist) { + glw->updateGL(); + } } diff -r 011ac823600c -r aeef3c2ae472 src/ui.h --- a/src/ui.h Sat Apr 14 06:37:31 2012 +0300 +++ b/src/ui.h Sat Apr 14 16:35:30 2012 +0300 @@ -22,6 +22,8 @@ public: MainWindow(); + + void update(); }; /* This is the detachable window with the volume slice view @@ -39,6 +41,8 @@ public: SideWindow(); + + void update(); }; // call to force a redisplay on all GL views diff -r 011ac823600c -r aeef3c2ae472 src/ui_sliceview.cc --- a/src/ui_sliceview.cc Sat Apr 14 06:37:31 2012 +0300 +++ b/src/ui_sliceview.cc Sat Apr 14 16:35:30 2012 +0300 @@ -1,4 +1,5 @@ #include "ui_sliceview.h" +#include "volray.h" SliceGLView::SliceGLView(QGLWidget *share_widget) : QGLWidget(QGLFormat(QGL::DoubleBuffer), 0, share_widget) @@ -21,5 +22,5 @@ void SliceGLView::paintGL() { - glClear(GL_COLOR_BUFFER_BIT); + volray_draw_slice(); } diff -r 011ac823600c -r aeef3c2ae472 src/ui_sliceview.h --- a/src/ui_sliceview.h Sat Apr 14 06:37:31 2012 +0300 +++ b/src/ui_sliceview.h Sat Apr 14 16:35:30 2012 +0300 @@ -11,6 +11,8 @@ void resizeGL(int xsz, int ysz); void paintGL(); + void draw_slice() const; + public: SliceGLView(QGLWidget *share_widget = 0); diff -r 011ac823600c -r aeef3c2ae472 src/volray.cc --- a/src/volray.cc Sat Apr 14 06:37:31 2012 +0300 +++ b/src/volray.cc Sat Apr 14 16:35:30 2012 +0300 @@ -143,7 +143,7 @@ if(volume) { render_volume(); - draw_slice(); + //draw_slice(); draw_xfer_func(); } @@ -206,14 +206,8 @@ glPopMatrix(); } -static void draw_slice(void) +void volray_draw_slice(void) { - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glTranslatef(0.9, 0.9, 0); - glScalef(0.3, 0.3 * ((float)win_xsz / win_ysz), 1); - glTranslatef(-1, -1, 0); - glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_3D, volume->get_texture()); glEnable(GL_TEXTURE_3D); @@ -238,7 +232,6 @@ glDisable(GL_TEXTURE_1D); glActiveTexture(GL_TEXTURE0); glDisable(GL_TEXTURE_3D); - glPopMatrix(); } static void draw_xfer_func(void) diff -r 011ac823600c -r aeef3c2ae472 src/volray.h --- a/src/volray.h Sat Apr 14 06:37:31 2012 +0300 +++ b/src/volray.h Sat Apr 14 16:35:30 2012 +0300 @@ -18,6 +18,7 @@ void volray_resize(int xsz, int ysz); void volray_draw(); +void volray_draw_slice(); void volray_mouse(int bn, int state, int x, int y); void volray_motion(int x, int y);