~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/covira/sagit.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* sagit.c
  2  *
  3  * @(#) sagit tv functionality
  4  *
  5  */
  6 #include <tina/all_tina.h>
  7 #include <tina/brain.h>
  8 #include <tina/brainfuncs.h>
  9 
 10 static Tv *sagit_tv = NULL;
 11 static Ipos sagit_pos;
 12 
 13 /******************************************************************************/
 14 
 15 Tv *sagit_tv_get(void)
 16 {
 17     return sagit_tv;
 18 }
 19 
 20 void sagit_tv_set(Tv * tv)
 21 {
 22     sagit_tv = tv;
 23 }
 24 
 25 /******************************************************************************/
 26 
 27 static int xold = -1;
 28 
 29 Bool sagit_changed(void)
 30 {
 31     if (ims_x_get() == xold)
 32         return (false);
 33     else
 34         return (true);
 35 }
 36 
 37 /******************************************************************************/
 38 
 39 static void sagit_backdraw(Tv * tv)
 40 {
 41     Imrect *im_sagit,*im_scale;
 42 
 43     xold = ims_x_get();
 44 
 45     if ((im_sagit = ims_xslice()) != NULL)
 46     {
 47         double scale = ims_zscale_get();
 48         im_scale = imf_scale(im_sagit, 0.0, 255.0);
 49         im_free(im_sagit);
 50         tv_camera2_roi_stretch(tv, im_scale->region, scale);
 51         tv_imrect2(tv, im_scale);
 52         im_free(im_scale);
 53     }
 54 }
 55 
 56 static void sagit_fulldraw(Tv * tv)
 57 {
 58     double x = ims_y_get();
 59     double y = ims_z_get();
 60     Tube *tube;
 61 
 62     tv_save_draw(tv);
 63     tv_set_linewidth(tv, 2);
 64     ims_all_strings_sagit_draw3(tv);
 65     tv_color_set(tv, green);
 66     tube = ims_tube_get();
 67     ims_sagit_tube_draw(tv);
 68     tv_reset_draw(tv);
 69 
 70     tv_set_overlay(tv);
 71     sagit_pos = tv_proj2(tv, vec2(x, y));
 72     tv_crosshair(tv, sagit_pos);
 73     tv_reset_draw(tv);
 74 }
 75 
 76 /******************************************************************************/
 77 
 78 static void sagit_crosshair_down_proc(Tv * tv, Ipos pos)
 79 {
 80     tv_set_overlay(tv);
 81     tv_crosshair(tv, sagit_pos);
 82     sagit_pos = pos;
 83     tv_crosshair(tv, sagit_pos);
 84 }
 85 
 86 static void sagit_crosshair_drag_proc(Tv * tv, Ipos pos)
 87 {
 88     tv_crosshair(tv, sagit_pos);
 89     sagit_pos = pos;
 90     tv_crosshair(tv, sagit_pos);
 91 }
 92 
 93 static void sagit_crosshair_up_proc(Tv * tv, Ipos pos)
 94 {
 95     Vec2 v = tv_backproj2(tv, pos);
 96 
 97     tv_crosshair(tv, sagit_pos);
 98     tv_reset_draw(tv);
 99 
100     ims_y_set(vec2_x(v));
101     ims_z_set(vec2_y(v));
102 
103     redraw_all();
104 }
105 
106 /******************************************************************************/
107 
108 static void sagit_voi_import_proc(Tv * tv, Ipos pos)
109 {
110     Vec2 v = tv_backproj2(tv, pos);
111 
112     ims_voi_mark();
113     ims_y_set(vec2_x(v));
114     ims_z_set(vec2_y(v));
115     ims_voi_import();
116 
117     redraw_all();
118 }
119 
120 static void sagit_voi_empty_proc(Tv * tv, Ipos pos)
121 {
122     Vec2 v = tv_backproj2(tv, pos);
123 
124     ims_y_set(vec2_x(v));
125     ims_z_set(vec2_y(v));
126     ims_voi_empty();
127 
128     redraw_all();
129 }
130 
131 /******************************************************************************/
132 
133 Tv_mouse sagit_cursor_mouse(void)
134 {
135     return mouse_define(
136                         LEFT_DOWN, sagit_crosshair_down_proc,
137                         LEFT_DRAG, sagit_crosshair_drag_proc,
138                         LEFT_UP, sagit_crosshair_up_proc,
139                         MIDDLE_DOWN, sagit_voi_import_proc,
140                         RIGHT_DOWN, sagit_voi_empty_proc,
141                         NULL);
142 }
143 
144 /* Create the sagit window. ************************************************** */
145 
146 void create_sagit_display(void)
147 {
148     sagit_tv = display_create("Sagittal (Working Y-Axis)", 290, 60, 256, 256);
149     tv_set_backdraw(sagit_tv, sagit_backdraw);
150     tv_set_fulldraw(sagit_tv, sagit_fulldraw);
151     tv_set_activity(sagit_tv, MOUSE);
152     tv_set_mouse(sagit_tv, sagit_cursor_mouse());
153 }
154 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.