glviewvol
diff src/xfer_view.cc @ 6:f22be47a3572
moved to TransferFuncs completely
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 30 Dec 2014 06:22:54 +0200 |
parents | 5417c25cb238 |
children | 71b479ffb9f7 |
line diff
1.1 --- a/src/xfer_view.cc Mon Dec 29 15:59:55 2014 +0200 1.2 +++ b/src/xfer_view.cc Tue Dec 30 06:22:54 2014 +0200 1.3 @@ -3,14 +3,13 @@ 1.4 #include "xfer_view.h" 1.5 #include "dicomview.h" 1.6 1.7 -static Renderer *rend; 1.8 +static TransferFunc *xfer; 1.9 1.10 static int act_color = 3; 1.11 -static CurvePoint *cpsel; 1.12 1.13 -bool xfview_init(Renderer *rendarg) 1.14 +bool xfview_init(TransferFunc *xferarg) 1.15 { 1.16 - rend = rendarg; 1.17 + xfer = xferarg; 1.18 return true; 1.19 } 1.20 1.21 @@ -42,38 +41,12 @@ 1.22 glVertex2f(-1, 1); 1.23 glEnd(); 1.24 1.25 - glEnable(GL_POINT_SMOOTH); 1.26 glEnable(GL_LINE_SMOOTH); 1.27 1.28 glEnable(GL_BLEND); 1.29 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1.30 1.31 - // draw selection outline 1.32 - if(act_color < 3) { 1.33 - glPointSize(13.0); 1.34 - glLineWidth(5.0); 1.35 - 1.36 - const Curve &sel_curve = rend->transfer_curve(act_color); 1.37 - glColor3f(0.7, 0.7, 0.7); 1.38 - glBegin(GL_LINE_STRIP); 1.39 - for(int i=0; i<nsamples; i++) { 1.40 - float t = (float)i / (float)(nsamples - 1); 1.41 - float val = sel_curve.value(t); 1.42 - glVertex2f(t * 2.0 - 1.0, val * 2.0 - 1.0); 1.43 - } 1.44 - glEnd(); 1.45 - glBegin(GL_POINTS); 1.46 - for(int i=0; i<sel_curve.get_num_points(); i++) { 1.47 - const CurvePoint *p = sel_curve.get_point(i); 1.48 - float x = 2.0 * (float)p->t_int / 65535.0 - 1.0; 1.49 - glVertex2f(x, p->value * 2.0 - 1.0); 1.50 - } 1.51 - glEnd(); 1.52 - } 1.53 - 1.54 - 1.55 - // draw curves and points 1.56 - glPointSize(9.0); 1.57 + // draw curve 1.58 glLineWidth(2.0); 1.59 1.60 for(int i=0; i<3; i++) { 1.61 @@ -84,22 +57,15 @@ 1.62 idx = i; 1.63 } 1.64 1.65 - const Curve &xfer = rend->transfer_curve(idx); 1.66 glColor3fv(line_color[idx]); 1.67 1.68 glBegin(GL_LINE_STRIP); 1.69 for(int j=0; j<nsamples; j++) { 1.70 float t = (float)j / (float)(nsamples - 1); 1.71 - float val = xfer.value(t); 1.72 - glVertex2f(t * 2.0 - 1.0, val * 2.0 - 1.0); 1.73 - } 1.74 - glEnd(); 1.75 + float vval[4]; 1.76 + xfer->map(t, vval); 1.77 1.78 - glBegin(GL_POINTS); 1.79 - for(int j=0; j<xfer.get_num_points(); j++) { 1.80 - const CurvePoint *p = xfer.get_point(j); 1.81 - float x = 2.0 * (float)p->t_int / 65535.0 - 1.0; 1.82 - glVertex2f(x, p->value * 2.0 - 1.0); 1.83 + glVertex2f(t * 2.0 - 1.0, vval[i] * 2.0 - 1.0); 1.84 } 1.85 glEnd(); 1.86 } 1.87 @@ -109,7 +75,7 @@ 1.88 1.89 void xfview_button(int bn, int press, int x, int y) 1.90 { 1.91 - if(bn == 2 && press && !cpsel) { 1.92 + if(bn == 2 && press) { 1.93 act_color = (act_color + 1) % 4; 1.94 redisplay(); 1.95 return; 1.96 @@ -118,7 +84,6 @@ 1.97 if(bn == 1) { 1.98 if(press) { 1.99 } else { 1.100 - cpsel = 0; 1.101 } 1.102 } 1.103 }