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

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

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

  1 /* work.c
  2  *
  3  * @(#) work tv functionality
  4  *
  5  */
  6 #include <tina/all_tina.h>
  7 #include <tina/brain.h>
  8 #include <tina/brainfuncs.h>
  9 
 10 static Tv *work_tv = NULL;
 11 
 12 static Bool cursor_mode = true;
 13 
 14 void work_cursor_mode_set(Bool flag)
 15 {
 16     cursor_mode = flag;
 17 }
 18 
 19 Tv *work_tv_get(void)
 20 {
 21     return (work_tv);
 22 }
 23 
 24 void work_tv_set(Tv * tv)
 25 {
 26     work_tv = tv;
 27 }
 28 
 29 static Ipos work_pos;
 30 
 31 static void work_init(Tv * tv)
 32 {
 33     ims_camera2(tv);
 34     tv_free_background(tv);
 35 }
 36 
 37 static int image_display;
 38 
 39 void work_image_choice_proc(int val)
 40 {
 41     switch (val)
 42     {
 43             case 0:
 44             image_display = IMS_IMAGE;
 45             tv_free_background(work_tv);
 46             tv_repaint(work_tv);
 47             break;
 48         case 1:
 49             image_display = IMS_POT;
 50             tv_free_background(work_tv);
 51             tv_repaint(work_tv);
 52             break;
 53         case 2:
 54             image_display = IMS_NONE;
 55             tv_free_background(work_tv);
 56             tv_repaint(work_tv);
 57             break;
 58     }
 59 }
 60 
 61 static void work_backdraw(Tv * tv)
 62 {
 63     switch (image_display)
 64     {
 65             case IMS_IMAGE:
 66             ims_image_draw(tv);
 67             break;
 68         case IMS_POT:
 69             ims_pot_draw(tv);
 70             break;
 71         case IMS_NONE:
 72             tv_erase(tv);
 73             break;
 74     }
 75 }
 76 
 77 static int voi_display;
 78 
 79 void work_voi_choice_proc(int val)
 80 {
 81     switch (val)
 82     {
 83             case 0:
 84             voi_display = IMS_SPLINE;
 85             tv_repaint(work_tv);
 86             break;
 87         case 1:
 88             voi_display = IMS_STRING;
 89             tv_repaint(work_tv);
 90             break;
 91         case 2:
 92             voi_display = IMS_SNAKE;
 93             tv_repaint(work_tv);
 94             break;
 95         case 3:
 96             voi_display = IMS_NONE;
 97             tv_repaint(work_tv);
 98             break;
 99     }
100 }
101 
102 static void work_fulldraw(Tv * tv)
103 {
104     tv_save_draw(tv);
105     tv_set_linewidth(tv, 2);
106     switch (voi_display)
107     {
108         case IMS_SPLINE:
109             ims_all_splines_draw(tv);
110             break;
111         case IMS_STRING:
112             ims_all_strings_draw(tv);
113             break;
114         case IMS_SNAKE:
115             ims_all_snakes_draw(tv);
116             break;
117         case IMS_NONE:
118             break;
119     }
120     ims_tube_draw(tv);
121     tv_reset_draw(tv);
122 
123     if (cursor_mode)
124     {
125         tv_set_overlay(tv);
126         work_pos = tv_proj2(tv, vec2(ims_x_get(), ims_y_get()));
127         tv_crosshair(tv, work_pos);
128         tv_reset_draw(tv);
129     }
130 }
131 
132 static void work_crosshair_down_proc(Tv * tv, Ipos pos)
133 {
134     tv_set_overlay(tv);
135     tv_crosshair(tv, work_pos);
136     work_pos = pos;
137     tv_crosshair(tv, work_pos);
138 }
139 
140 static void work_crosshair_drag_proc(Tv * tv, Ipos pos)
141 {
142     tv_crosshair(tv, work_pos);
143     work_pos = pos;
144     tv_crosshair(tv, work_pos);
145 }
146 
147 static void work_crosshair_up_proc(Tv * tv, Ipos pos)
148 {
149     Vec2 v = tv_backproj2(tv, pos);
150 
151     tv_crosshair(tv, work_pos);
152     tv_reset_draw(tv);
153 
154     ims_x_set(vec2_x(v));
155     ims_y_set(vec2_y(v));
156 
157     redraw_all();
158 }
159 
160 void work_zoom_proc(Tv * tv, Ipos pos)
161 {
162     tv->centre2 = tv_backproj2(tv, pos);
163     tv->scalex *= 1.4142;
164     tv->scaley *= 1.4142;
165     tv->cx = tv->width / 2.0;
166     tv->cy = tv->height / 2.0;
167     tv_free_background(tv);
168     tv_repaint(tv);
169 }
170 
171 void work_init_proc(Tv * tv, Ipos pos)
172 {
173     work_init(tv);
174     tv_repaint(tv);
175 }
176 
177 Tv_mouse work_cursor_mouse(void)
178 {
179     return mouse_define(
180                         LEFT_DOWN, work_crosshair_down_proc,
181                         LEFT_DRAG, work_crosshair_drag_proc,
182                         LEFT_UP, work_crosshair_up_proc,
183                         MIDDLE_DOWN, work_zoom_proc,
184                         RIGHT_DOWN, work_init_proc,
185                         NULL);
186 }
187 
188 void create_work_display(void)
189 {
190     work_tv = display_create("Working (Transverse) Image", 20, 360, 512, 512);
191     tv_set_init(work_tv, work_init);
192     tv_set_backdraw(work_tv, work_backdraw);
193     tv_set_fulldraw(work_tv, work_fulldraw);
194     tv_set_activity(work_tv, MOUSE);
195     tv_set_mouse(work_tv, work_cursor_mouse());
196 }
197 

~ [ 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.