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

Linux Cross Reference
Tina5/tina-tools/tinatool/tlbase/tlbaseSter_tool.c

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

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlbase/tlbaseSter_tool.c,v $
 37  * Date    :  $Date: 2009/03/27 16:01:50 $
 38  * Version :  $Revision: 1.5 $
 39  * CVS Id  :  $Id: tlbaseSter_tool.c,v 1.5 2009/03/27 16:01:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : most basic tv_screen level code for managing stereo resources, data
 44  *         structures and tv devices.
 45  * 
 46  *         deals with file based i/o as well as display selection
 47  *
 48  *********
 49 */
 50 
 51 #include "tlbaseSter_tool.h"
 52 
 53 #if HAVE_CONFIG_H
 54 #include <config.h>
 55 #endif
 56 
 57 #include <stdio.h>
 58 #include <sys/param.h>
 59 
 60 #include <tina/sys/sysDef.h>
 61 #include <tina/sys/sysPro.h>
 62 #include <tina/image/imgDef.h>
 63 #include <tina/image/imgPro.h>
 64 #include <tina/file/fileUtil_name.h>
 65 
 66 #include <tinatool/wdgts/wdgtsDef.h>
 67 #include <tinatool/wdgts/wdgtsPro.h>
 68 #include <tinatool/draw/drawDef.h>
 69 #include <tinatool/draw/drawPro.h>
 70 #include <tinatool/tlbase/tlbase_InfrDef.h>
 71 #include <tinatool/tlbase/tlbase_InfrPro.h>
 72 #include <tinatool/tlbase/tlbase_ImcDef.h>
 73 #include <tinatool/tlbase/tlbase_ImcPro.h>
 74 #include <tinatool/tlbase/tlbaseSter_left.h>
 75 #include <tinatool/tlbase/tlbaseSter_right.h>
 76 #include <tinatool/tlbase/tlbaseSter_thrd.h>
 77 #include <tinatool/tlbase/tlbaseSter_file.h>
 78 #include <tinatool/tlbase/tlbaseSter_stack.h>
 79 #include <tinatool/tlbase/tlbaseView_tool.h>
 80 
 81 #define LEFT_INFR   0
 82 #define RIGHT_INFR  1
 83 #define THREED_INFR 2
 84 #define AIFF_FILE   0
 85 
 86 
 87 /* STATIC GLOBALS */
 88 static char directory_name[MAXPATHLEN];
 89 static char base_name[MAXPATHLEN];
 90 static char file_name[MAXPATHLEN];
 91 static int infr_select = LEFT_INFR;
 92 static int file_type = AIFF_FILE;
 93 static void *pframe;
 94 static void *pdir=NULL, *pfile=NULL;
 95 static int fnum = 0;
 96 
 97 /* CALLBACK FUNCTIONS */
 98 
 99 /* tv selection */
100 static Tv *tvleft;
101 static Tv *tvright;
102 static Tv *tvthreed;
103 
104 static void    stereo_draw(Tv *tv)
105 {
106     if(tv!=NULL)
107     {
108         tv_free_background(tv);
109         tv_repaint(tv);
110     }
111 }
112 
113 static void scan_proc(void)
114 {
115    scan_files(directory_name, base_name);
116    tw_sglobal_reset(pdir);
117    tw_sglobal_reset(pfile);
118 }
119 
120 static void tv_proc(void)
121 {
122     Tv     *left_tv_make();
123     Tv     *right_tv_make();
124     Tv     *threed_tv_make();
125 
126     left_tv_set(tvleft = left_tv_make());
127     right_tv_set(tvright = right_tv_make());
128     threed_tv_set(tvthreed = threed_tv_make());
129     tv_set_next(tvleft);
130 }
131 
132 
133 /* push / pop callbacks */
134 static void push_proc(void)
135 {
136     stereo_set_stack_image_type(infr_select);
137     stereo_push_stack();
138     if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
139     if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
140     image_choice_reset();
141 }
142 
143 static void pop_proc(void)
144 {
145     stereo_set_stack_image_type(infr_select);
146     stereo_pop_stack();
147     stereo_draw(left_tv_get());
148     stereo_draw(right_tv_get());
149     if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
150     if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
151     image_choice_reset();
152 }
153 
154 /* input / output callbacks */
155 static void input_proc(void)
156 {
157     parse_fname(base_name, file_name, fnum);
158     stereo_input(directory_name, file_name, file_type);
159     if (file_type == AIFF_FILE) stereo_draw(left_tv_get());
160     if (file_type == AIFF_FILE) stereo_draw(right_tv_get());
161 }
162 
163 static void output_proc(void)
164 {
165     parse_fname(base_name, file_name, fnum);
166     stereo_output(directory_name, file_name, file_type);
167 }
168 
169 /* mouse function callbacks */
170 static void left_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
171 {
172     tv_set_mouse(tvleft, (*func) ());
173     (void) tv_set_activity(tvleft, MOUSE);
174 }
175 
176 static void right_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
177 {
178     tv_set_mouse(tvright, (*func) ());
179     (void) tv_set_activity(tvright, MOUSE);
180 }
181 
182 
183 /* CHECK ITEM CALLBACKS */
184 
185 /* left/right display */
186 #define IMAGE_MASK  1
187 #define EDGE_MASK   2
188 #define CORNER_MASK 4
189 #define STRING_MASK 8
190 #define POLY_MASK   16
191 
192 static void left_check_proc(int val)
193 {
194     left_image_on((Bool) (val & IMAGE_MASK));
195     left_edges_on((Bool) (val & EDGE_MASK));
196     left_corners_on((Bool) (val & CORNER_MASK));
197     left_strings_on((Bool) (val & STRING_MASK));
198     left_poly_on((Bool) (val & POLY_MASK));
199 }
200 
201 static void right_check_proc(int val)
202 {
203     right_image_on((Bool) (val & IMAGE_MASK));
204     right_edges_on((Bool) (val & EDGE_MASK));
205     right_corners_on((Bool) (val & CORNER_MASK));
206     right_strings_on((Bool) (val & STRING_MASK));
207     right_poly_on((Bool) (val & POLY_MASK));
208 }
209 
210 /* threed display selection */
211 #define GEOM_MASK    1
212 #define GROUND_MASK  2
213 #define SURFACE_MASK 4
214 
215 static void threed_check_proc(int val)
216 {
217     threed_geom_on((Bool) (val & GEOM_MASK));
218     threed_ground_on((Bool) (val & GROUND_MASK));
219     threed_surface_on((Bool) (val & SURFACE_MASK));
220 }
221 
222 void    anaglyph_proc (void)
223 {
224   Tv     *tv = tv_get_next ();
225 
226   if (tv)
227     {
228       Imrect *imrect_left = (Imrect *) left_image_get ();
229       Imrect *imrect_right = (Imrect *) right_image_get ();
230       double  low = 0.0;
231       double  high = 0.0;
232       float   min_left, max_left, min_right, max_right;
233 
234       imf_minmax (imrect_left, &min_left, &max_left);
235       imf_minmax (imrect_right, &min_right, &max_right);
236 
237       low = (double) MIN (min_left, min_right);
238       high = (double) MAX (max_left, max_right);
239 
240       /* Set anaglyph colormap */
241       cmap_choice_proc (2);
242 
243       /* Display the new image */
244       tv_imrect_anaglyph (tv, imrect_left, imrect_right, low, high);
245     }
246 }
247 
248 /* CHOICE ITEM CALLBACKS */
249 
250 /* file choice callback */
251 static void file_choice_proc(int val)
252 {
253     file_type = val;
254 }
255 
256 /* tv choice callback */
257 static void tv_choice_proc(int val)
258 {
259     switch (val)
260     {
261         case 0:
262         tv_set_next(tvleft);
263         break;
264     case 1:
265         tv_set_next(tvright);
266         break;
267     case 2:
268         tv_set_next(tvthreed);
269         break;
270     }
271     infr_select = val;
272 }
273 
274 /* Stack data choice callback static void stack_data_choice_proc(val)
275  * int     val; { stereo_set_stack_data_type(val); } */
276 
277 static void inc_fnum_proc(void)
278 {
279   fnum++;
280   tw_iglobal_reset(pframe);
281 }
282 
283 static void dec_fnum_proc(void)
284 {
285   fnum--;
286   tw_iglobal_reset(pframe);
287 }
288 
289 /* Tool creation */
290 void    stereo_tool(int x, int y)
291 {
292     Tv_mouse null_mouse();
293     Tv_mouse pos_mouse();
294     Tv_mouse pixel_mouse();
295     Tv_mouse left_grey_mouse();
296     Tv_mouse right_grey_mouse();
297     static void *tv_screen = NULL;
298 
299     if (tv_screen)
300     {
301         tw_show_tool(tv_screen);
302         return;
303     }
304     tv_proc();
305 
306     tv_screen = tw_tool("Stereo Tool", x, y);
307 
308     tw_choice("Tv's: ", tv_choice_proc, 0, "left", "right", "threed",
309               NULL);
310 
311     tw_menubar("Mouse: ",
312                "Left",
313                "null", left_mouse_proc, null_mouse,
314                "pos", left_mouse_proc, pos_mouse,
315                "grey", left_mouse_proc, left_grey_mouse,
316                "pixel", left_mouse_proc, pixel_mouse,
317                NULL,
318                "Right",
319                "null", right_mouse_proc, null_mouse,
320                "pos", right_mouse_proc, pos_mouse,
321                "grey", right_mouse_proc, right_grey_mouse,
322                "pixel", right_mouse_proc, pixel_mouse,
323                NULL,
324                NULL);
325 
326     tw_newrow();
327     tw_check("Left:      ", left_check_proc, 1,
328              "image", "edge", "corner", "str", "geom",
329              NULL);
330     tw_newrow();
331     tw_check("Right:     ", right_check_proc, 1,
332              "image", "edge", "corner", "str", "geom",
333              NULL);
334     tw_newrow();
335     tw_check("Threed:    ", threed_check_proc, 1,
336              "geom", "ground", "surface",
337              NULL);
338     tw_newrow();
339 
340     tw_choice("File:", file_choice_proc, 0,
341               "AIFF", "ROI", "EDGE", "POLY", "LH_G", "RH_G", "CAM",
342               NULL);
343 
344     tw_newrow();
345 
346     tw_button("input", input_proc, NULL);
347     tw_button("output", output_proc, NULL);
348     pframe = (void *)tw_iglobal(" Frame Number (#):", &fnum, 5);
349     tw_button("<", dec_fnum_proc, NULL);
350     tw_button(">", inc_fnum_proc, NULL);
351 
352     tw_newrow();
353     pdir = (void *) tw_sglobal("Directory Name:", directory_name, 32);
354     tw_button("scan", scan_proc, NULL);
355     tw_newrow();
356     pfile = (void *) tw_sglobal("Base Name:     ", base_name, 32);
357 
358     tw_newrow();
359     tw_button("push", push_proc, NULL);
360     tw_button("pop", pop_proc, NULL);
361     tw_button ("anaglyph image", anaglyph_proc, NULL);
362     tw_label("                ");
363     tw_help_button("stereo_tool");
364 
365 
366     tw_end_tool();
367 }
368 

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