# HG changeset patch # User John Tsiombikas # Date 1419996107 -7200 # Node ID 89efc666105c33e9202fa20f0ec64044124149e3 # Parent 931a6b35f1cd5047cdd80b9e5e3470c87f642bc1 mostly done diff -r 931a6b35f1cd -r 89efc666105c sdr/fast.p.glsl --- a/sdr/fast.p.glsl Tue Dec 30 21:20:57 2014 +0200 +++ b/sdr/fast.p.glsl Wed Dec 31 05:21:47 2014 +0200 @@ -1,16 +1,18 @@ +#version 120 + uniform sampler3D vol_tex; uniform sampler1D xfer_tex; -const vec3 light_dir[3] = { +uniform vec3 light_dir[3] = vec3[3]( vec3(0.5, 0.5, 1.0), vec3(-1.0, 0.2, 0.5), vec3(-0.2, 0.0, -7.0) -}; -const vec3 light_color[3] = { +); +uniform vec3 light_color[3] = vec3[3]( vec3(0.9, 0.7, 0.68), vec3(0.5, 0.6, 0.9), vec3(0.3, 0.3, 0.3) -}; +); const vec3 ambient = vec3(0.1, 0.1, 0.1); const vec3 vdir = vec3(0.0, 0.0, 1.0); diff -r 931a6b35f1cd -r 89efc666105c sdr/fast.v.glsl --- a/sdr/fast.v.glsl Tue Dec 30 21:20:57 2014 +0200 +++ b/sdr/fast.v.glsl Wed Dec 31 05:21:47 2014 +0200 @@ -1,3 +1,5 @@ +uniform float zscale; + void main() { mat4 mvmat = gl_ModelViewMatrix; @@ -6,5 +8,5 @@ vec4 vertex = gl_Vertex; gl_Position = gl_ProjectionMatrix * mvmat * vertex; - gl_TexCoord[0].xyz = gl_NormalMatrix * (vertex.xyz * vec3(1.0, 1.0, -1.0) * 1.732051) * 0.5 + 0.5; + gl_TexCoord[0].xyz = gl_NormalMatrix * (vertex.xyz * vec3(1.0, 1.0, -1.0) * 1.732051) * vec3(1.0, 1.0, zscale) * 0.5 + 0.5; } diff -r 931a6b35f1cd -r 89efc666105c src/dicomview.cc --- a/src/dicomview.cc Tue Dec 30 21:20:57 2014 +0200 +++ b/src/dicomview.cc Wed Dec 31 05:21:47 2014 +0200 @@ -134,43 +134,51 @@ } } +static bool zscaling; + void ev_keyboard(int key, int press, int x, int y) { RendererFast *fr; - if(press) { - switch(key) { - case 27: + switch(key) { + case 27: + if(press) { quit(); + } + break; - case '=': - if((fr = dynamic_cast(rend))) { - int n = fr->get_proxy_count(); - int add = n / 4; - n += add < 1 ? 1 : add; - printf("proxy count: %d\n", n); - fr->set_proxy_count(n); - } + case 'z': + case 'Z': + zscaling = press; + break; + + case '=': + if(press && (fr = dynamic_cast(rend))) { + int n = fr->get_proxy_count(); + int add = n / 4; + n += add < 1 ? 1 : add; + printf("proxy count: %d\n", n); + fr->set_proxy_count(n); redisplay(); - break; + } + break; - case '-': - if((fr = dynamic_cast(rend))) { - int n = fr->get_proxy_count(); - int sub = n / 4; - n -= sub < 1 ? 1 : sub; + case '-': + if(press && (fr = dynamic_cast(rend))) { + int n = fr->get_proxy_count(); + int sub = n / 4; + n -= sub < 1 ? 1 : sub; - if(n < 1) n = 1; + if(n < 1) n = 1; - printf("proxy count: %d\n", n); - fr->set_proxy_count(n); - } + printf("proxy count: %d\n", n); + fr->set_proxy_count(n); redisplay(); - break; + } + break; - default: - break; - } + default: + break; } } @@ -202,6 +210,13 @@ if((dx | dy) == 0) return; + if(bnstate[0] && zscaling) { + float s = rend->get_zscale() + (float)dy / (float)win_height; + rend->set_zscale(s < 0.0 ? 0.0 : s); + redisplay(); + return; + } + if(splitter_dragging) { splitter_y += dy; redisplay(); diff -r 931a6b35f1cd -r 89efc666105c src/rend_fast.cc --- a/src/rend_fast.cc Tue Dec 30 21:20:57 2014 +0200 +++ b/src/rend_fast.cc Wed Dec 31 05:21:47 2014 +0200 @@ -3,6 +3,7 @@ #include "rend_fast.h" #include "sdr.h" +#define DEF_PROXY_COUNT 512 #define XFER_MAP_SZ 512 static unsigned int sdr; @@ -12,7 +13,7 @@ { vol_tex = xfer_tex = 0; vol_tex_valid = xfer_tex_valid = false; - proxy_count = 256; + proxy_count = DEF_PROXY_COUNT; vbo_proxy_count = 0; } @@ -190,6 +191,7 @@ set_uniform_int(sdr, "vol_tex", 0); set_uniform_int(sdr, "xfer_tex", 1); + set_uniform_float(sdr, "zscale", zscale); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff -r 931a6b35f1cd -r 89efc666105c src/renderer.cc --- a/src/renderer.cc Tue Dec 30 21:20:57 2014 +0200 +++ b/src/renderer.cc Wed Dec 31 05:21:47 2014 +0200 @@ -10,6 +10,8 @@ for(int i=0; ixfer = xfer; diff -r 931a6b35f1cd -r 89efc666105c src/renderer.h --- a/src/renderer.h Tue Dec 30 21:20:57 2014 +0200 +++ b/src/renderer.h Wed Dec 31 05:21:47 2014 +0200 @@ -14,6 +14,7 @@ float clip_plane[MAX_CLIP_PLANES][4]; // nx,ny,nz,dist TransferFunc *xfer; + float zscale; public: Renderer(); @@ -25,6 +26,9 @@ virtual void set_volume(Volume *vol); virtual Volume *get_volume() const; + virtual void set_zscale(float zs); + virtual float get_zscale() const; + virtual void set_transfer_function(TransferFunc *xfer); virtual TransferFunc *get_transfer_function() const;