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

Linux Cross Reference
Tina4/src/tools/stereo/ster_tool.c

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

  1 /* stereo_tool.c
  2  * 
  3  * most basic tv_screen level code for managing stereo resources, data
  4  * structures and tv devices.
  5  * 
  6  * deals with file based i/o as well as display selection
  7  * 
  8  */
  9 
 10 #include <stdio.h>
 11 #include <sys/param.h>
 12 #include <tina/sys.h>
 13 #include <tina/sysfuncs.h>
 14 #include <tina/math.h>
 15 #include <tina/mathfuncs.h>
 16 #include <tina/vision.h>
 17 #include <tina/visionfuncs.h>
 18 #include <tina/file.h>
 19 #include <tina/file_gen.h>
 20 #include <tina/filefuncs.h>
 21 #include <tina/tv.h>
 22 #include <tina/tvfuncs.h>
 23 #include <tina/toolsfuncs.h>
 24 #include <tina/tw_Xfuncs.h>
 25 
 26 #define LEFT_INFR   0
 27 #define RIGHT_INFR  1
 28 #define THREED_INFR 2
 29 #define AIFF_FILE   0
 30 
 31 /* EXTERNS  */
 32 extern void tw_show_tool();
 33 extern void *tw_tool();
 34 extern void cmap_choice_proc(int num);
 35 
 36 /* STATIC GLOBALS */
 37 static char directory_name[MAXPATHLEN];
 38 static char base_name[MAXPATHLEN];
 39 static char file_name[MAXPATHLEN];
 40 static int infr_select = LEFT_INFR;
 41 static int file_type = AIFF_FILE;
 42 static void *pframe;
 43 static void *pdir=NULL, *pfile=NULL;
 44 static int fnum = 0;
 45 
 46 /* CALLBACK FUNCTIONS */
 47 
 48 /* tv selection */
 49 static Tv *tvleft;
 50 static Tv *tvright;
 51 static Tv *tvthreed;
 52 
 53 static void    stereo_draw(Tv *tv)
 54 {
 55     if(tv!=NULL)
 56     {
 57         tv_free_background(tv);
 58         tv_repaint(tv);
 59     }
 60 }
 61 
 62 static void scan_proc(void)
 63 {
 64    scan_files(directory_name, base_name);
 65    tw_sglobal_reset(pdir);
 66    tw_sglobal_reset(pfile);
 67 }
 68 
 69 static void tv_proc(void)
 70 {
 71     Tv     *left_tv_make();
 72     Tv     *right_tv_make();
 73     Tv     *threed_tv_make();
 74 
 75     left_tv_set(tvleft = left_tv_make());
 76     right_tv_set(tvright = right_tv_make());
 77     threed_tv_set(tvthreed = threed_tv_make());
 78     tv_set_next(tvleft);
 79 }
 80 
 81 
 82 /* push / pop callbacks */
 83 static void push_proc(void)
 84 {
 85     stereo_set_stack_image_type(infr_select);
 86     stereo_push_stack();
 87     if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
 88     if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
 89     image_choice_reset();
 90 }
 91 
 92 static void pop_proc(void)
 93 {
 94     stereo_set_stack_image_type(infr_select);
 95     stereo_pop_stack();
 96     stereo_draw(left_tv_get());
 97     stereo_draw(right_tv_get());
 98     if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
 99     if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
100     image_choice_reset();
101 }
102 
103 /* input / output callbacks */
104 static void input_proc(void)
105 {
106     parse_fname(base_name, file_name, fnum);
107     stereo_input(directory_name, file_name, file_type);
108     if (file_type == AIFF_FILE) stereo_draw(left_tv_get());
109     if (file_type == AIFF_FILE) stereo_draw(right_tv_get());
110 }
111 
112 static void output_proc(void)
113 {
114     parse_fname(base_name, file_name, fnum);
115     stereo_output(directory_name, file_name, file_type);
116 }
117 
118 /* mouse function callbacks */
119 static void left_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
120 {
121     tv_set_mouse(tvleft, (*func) ());
122     (void) tv_set_activity(tvleft, MOUSE);
123 }
124 
125 static void right_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
126 {
127     tv_set_mouse(tvright, (*func) ());
128     (void) tv_set_activity(tvright, MOUSE);
129 }
130 
131 
132 /* CHECK ITEM CALLBACKS */
133 
134 /* left/right display */
135 #define IMAGE_MASK  1
136 #define EDGE_MASK   2
137 #define CORNER_MASK 4
138 #define STRING_MASK 8
139 #define POLY_MASK   16
140 
141 static void left_check_proc(int val)
142 {
143     left_image_on((Bool) (val & IMAGE_MASK));
144     left_edges_on((Bool) (val & EDGE_MASK));
145     left_corners_on((Bool) (val & CORNER_MASK));
146     left_strings_on((Bool) (val & STRING_MASK));
147     left_poly_on((Bool) (val & POLY_MASK));
148 }
149 
150 static void right_check_proc(int val)
151 {
152     right_image_on((Bool) (val & IMAGE_MASK));
153     right_edges_on((Bool) (val & EDGE_MASK));
154     right_corners_on((Bool) (val & CORNER_MASK));
155     right_strings_on((Bool) (val & STRING_MASK));
156     right_poly_on((Bool) (val & POLY_MASK));
157 }
158 
159 /* threed display selection */
160 #define GEOM_MASK    1
161 #define GROUND_MASK  2
162 #define SURFACE_MASK 4
163 
164 static void threed_check_proc(int val)
165 {
166     threed_geom_on((Bool) (val & GEOM_MASK));
167     threed_ground_on((Bool) (val & GROUND_MASK));
168     threed_surface_on((Bool) (val & SURFACE_MASK));
169 }
170 
171 void    anaglyph_proc (void)
172 {
173   Tv     *tv = tv_get_next ();
174 
175   if (tv)
176     {
177       Imrect *imrect_left = (Imrect *) left_image_get ();
178       Imrect *imrect_right = (Imrect *) right_image_get ();
179       double  low = 0.0;
180       double  high = 0.0;
181       float   min_left, max_left, min_right, max_right;
182 
183       imf_minmax (imrect_left, &min_left, &max_left);
184       imf_minmax (imrect_right, &min_right, &max_right);
185 
186       low = (double) MIN (min_left, min_right);
187       high = (double) MAX (max_left, max_right);
188 
189       /* Set anaglyph colormap */
190       cmap_choice_proc (2);
191 
192       /* Display the new image */
193       tv_imrect_anaglyph (tv, imrect_left, imrect_right, low, high);
194     }
195 }
196 
197 /* CHOICE ITEM CALLBACKS */
198 
199 /* file choice callback */
200 static void file_choice_proc(int val)
201 {
202     file_type = val;
203 }
204 
205 /* tv choice callback */
206 static void tv_choice_proc(int val)
207 {
208     switch (val)
209     {
210         case 0:
211         tv_set_next(tvleft);
212         break;
213     case 1:
214         tv_set_next(tvright);
215         break;
216     case 2:
217         tv_set_next(tvthreed);
218         break;
219     }
220     infr_select = val;
221 }
222 
223 /* Stack data choice callback static void stack_data_choice_proc(val)
224  * int     val; { stereo_set_stack_data_type(val); } */
225 
226 static void inc_fnum_proc(void)
227 {
228   fnum++;
229   tw_iglobal_reset(pframe);
230 }
231 
232 static void dec_fnum_proc(void)
233 {
234   fnum--;
235   tw_iglobal_reset(pframe);
236 }
237 
238 /* Tool creation */
239 void    stereo_tool(int x, int y)
240 {
241     Tv_mouse null_mouse();
242     Tv_mouse pos_mouse();
243     Tv_mouse pixel_mouse();
244     Tv_mouse left_grey_mouse();
245     Tv_mouse right_grey_mouse();
246     static void *tv_screen = NULL;
247 
248     if (tv_screen)
249     {
250         tw_show_tool(tv_screen);
251         return;
252     }
253     /* Initialise image pathname from environment variable (or #define) */
254     (void) environ_pathname_get(directory_name, base_name,
255                                 "TINA_IMAGE_DEFAULT",
256                                 TINA_IMAGE_DEFAULT_PATHNAME);
257 
258     tv_proc();
259 
260     tv_screen = tw_tool("Stereo Tool", x, y);
261 
262     tw_choice("Tv's: ", tv_choice_proc, 0, "left", "right", "threed",
263               NULL);
264 
265     tw_menubar("Mouse: ",
266                "left",
267                "null", left_mouse_proc, null_mouse,
268                "pos", left_mouse_proc, pos_mouse,
269                "grey", left_mouse_proc, left_grey_mouse,
270                "pixel", left_mouse_proc, pixel_mouse,
271                NULL,
272                "right",
273                "null", right_mouse_proc, null_mouse,
274                "pos", right_mouse_proc, pos_mouse,
275                "grey", right_mouse_proc, right_grey_mouse,
276                "pixel", right_mouse_proc, pixel_mouse,
277                NULL,
278                NULL);
279 
280     tw_newrow();
281     tw_check("Left:      ", left_check_proc, 1,
282              "image", "edge", "corner", "str", "geom",
283              NULL);
284     tw_newrow();
285     tw_check("Right:     ", right_check_proc, 1,
286              "image", "edge", "corner", "str", "geom",
287              NULL);
288     tw_newrow();
289     tw_check("Threed:    ", threed_check_proc, 1,
290              "geom", "ground", "surface",
291              NULL);
292     tw_newrow();
293 
294     tw_choice("File:", file_choice_proc, 0,
295               "AIFF", "ROI", "EDGE", "POLY", "LH_G", "RH_G", "CAM",
296               NULL);
297 
298     tw_newrow();
299 
300     tw_button("input", input_proc, NULL);
301     tw_button("output", output_proc, NULL);
302     pframe = (void *)tw_iglobal(" Frame Number (#):", &fnum, 5);
303     tw_button("<", dec_fnum_proc, NULL);
304     tw_button(">", inc_fnum_proc, NULL);
305 
306     tw_newrow();
307     pdir = (void *) tw_sglobal("Directory Name:", directory_name, 32);
308     tw_button("scan", scan_proc, NULL);
309     tw_newrow();
310     pfile = (void *) tw_sglobal("Base Name:     ", base_name, 32);
311 
312     tw_newrow();
313     tw_button("push", push_proc, NULL);
314     tw_button("pop", pop_proc, NULL);
315     tw_button ("anaglyph image", anaglyph_proc, NULL);
316     tw_label("                ");
317     tw_help_button("stereo_tool");
318 
319 
320     tw_end_tool();
321 }
322 

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