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

Linux Cross Reference
Tina6/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    clip_suffix(base_name);
117    tw_sglobal_reset(pdir);
118    tw_sglobal_reset(pfile);
119 }
120 
121 static void tv_proc(void)
122 {
123     Tv     *left_tv_make();
124     Tv     *right_tv_make();
125     Tv     *threed_tv_make();
126 
127     left_tv_set(tvleft = left_tv_make());
128     right_tv_set(tvright = right_tv_make());
129     threed_tv_set(tvthreed = threed_tv_make());
130     tv_set_next(tvleft);
131 }
132 
133 
134 /* push / pop callbacks */
135 static void push_proc(void)
136 {
137     stereo_set_stack_image_type(infr_select);
138     stereo_push_stack();
139     if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
140     if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
141     image_choice_reset();
142 }
143 
144 static void pop_proc(void)
145 {
146     stereo_set_stack_image_type(infr_select);
147     stereo_pop_stack();
148     stereo_draw(left_tv_get());
149     stereo_draw(right_tv_get());
150     if (imcalc_tv_get()!=NULL) tv_init(imcalc_tv_get());
151     if (imcal2_tv_get()!=NULL) tv_init(imcal2_tv_get());
152     image_choice_reset();
153 }
154 
155 /* input / output callbacks */
156 static void input_proc(void)
157 {
158     parse_fname(base_name, file_name, fnum);
159     stereo_input(directory_name, file_name, file_type);
160     if (file_type == AIFF_FILE) stereo_draw(left_tv_get());
161     if (file_type == AIFF_FILE) stereo_draw(right_tv_get());
162 }
163 
164 static void output_proc(void)
165 {
166     parse_fname(base_name, file_name, fnum);
167     stereo_output(directory_name, file_name, file_type);
168 }
169 
170 /* mouse function callbacks */
171 static void left_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
172 {
173     tv_set_mouse(tvleft, (*func) ());
174     (void) tv_set_activity(tvleft, MOUSE);
175 }
176 
177 static void right_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
178 {
179     tv_set_mouse(tvright, (*func) ());
180     (void) tv_set_activity(tvright, MOUSE);
181 }
182 
183 
184 /* CHECK ITEM CALLBACKS */
185 
186 /* left/right display */
187 #define IMAGE_MASK  1
188 #define EDGE_MASK   2
189 #define CORNER_MASK 4
190 #define STRING_MASK 8
191 #define POLY_MASK   16
192 
193 static void left_check_proc(int val)
194 {
195     left_image_on((Bool) (val & IMAGE_MASK));
196     left_edges_on((Bool) (val & EDGE_MASK));
197     left_corners_on((Bool) (val & CORNER_MASK));
198     left_strings_on((Bool) (val & STRING_MASK));
199     left_poly_on((Bool) (val & POLY_MASK));
200 }
201 
202 static void right_check_proc(int val)
203 {
204     right_image_on((Bool) (val & IMAGE_MASK));
205     right_edges_on((Bool) (val & EDGE_MASK));
206     right_corners_on((Bool) (val & CORNER_MASK));
207     right_strings_on((Bool) (val & STRING_MASK));
208     right_poly_on((Bool) (val & POLY_MASK));
209 }
210 
211 /* threed display selection */
212 #define GEOM_MASK    1
213 #define GROUND_MASK  2
214 #define SURFACE_MASK 4
215 
216 static void threed_check_proc(int val)
217 {
218     threed_geom_on((Bool) (val & GEOM_MASK));
219     threed_ground_on((Bool) (val & GROUND_MASK));
220     threed_surface_on((Bool) (val & SURFACE_MASK));
221 }
222 
223 void    anaglyph_proc (void)
224 {
225   Tv     *tv = tv_get_next ();
226 
227   if (tv)
228     {
229       Imrect *imrect_left = (Imrect *) left_image_get ();
230       Imrect *imrect_right = (Imrect *) right_image_get ();
231       double  low = 0.0;
232       double  high = 0.0;
233       float   min_left, max_left, min_right, max_right;
234 
235       imf_minmax (imrect_left, &min_left, &max_left);
236       imf_minmax (imrect_right, &min_right, &max_right);
237 
238       low = (double) MIN (min_left, min_right);
239       high = (double) MAX (max_left, max_right);
240 
241       /* Set anaglyph colormap */
242       cmap_choice_proc (2);
243 
244       /* Display the new image */
245       tv_imrect_anaglyph (tv, imrect_left, imrect_right, low, high);
246     }
247 }
248 
249 /* CHOICE ITEM CALLBACKS */
250 
251 /* file choice callback */
252 static void file_choice_proc(int val)
253 {
254     file_type = val;
255 }
256 
257 /* tv choice callback */
258 static void tv_choice_proc(int val)
259 {
260     switch (val)
261     {
262         case 0:
263         tv_set_next(tvleft);
264         break;
265     case 1:
266         tv_set_next(tvright);
267         break;
268     case 2:
269         tv_set_next(tvthreed);
270         break;
271     }
272     infr_select = val;
273 }
274 
275 /* Stack data choice callback static void stack_data_choice_proc(val)
276  * int     val; { stereo_set_stack_data_type(val); } */
277 
278 static void inc_fnum_proc(void)
279 {
280   fnum++;
281   tw_iglobal_reset(pframe);
282 }
283 
284 static void dec_fnum_proc(void)
285 {
286   fnum--;
287   tw_iglobal_reset(pframe);
288 }
289 
290 /* Tool creation */
291 void    stereo_tool(int x, int y)
292 {
293     Tv_mouse null_mouse();
294     Tv_mouse pos_mouse();
295     Tv_mouse pixel_mouse();
296     Tv_mouse left_grey_mouse();
297     Tv_mouse right_grey_mouse();
298     static void *tv_screen = NULL;
299 
300     if (tv_screen)
301     {
302         tw_show_tool(tv_screen);
303         return;
304     }
305     tv_proc();
306 
307     tv_screen = tw_tool("Stereo Tool", x, y);
308 
309     tw_choice("Tv's: ", tv_choice_proc, 0, "left", "right", "threed",
310               NULL);
311 
312     tw_menubar("Mouse: ",
313                "Left",
314                "null", left_mouse_proc, null_mouse,
315                "pos", left_mouse_proc, pos_mouse,
316                "grey", left_mouse_proc, left_grey_mouse,
317                "pixel", left_mouse_proc, pixel_mouse,
318                NULL,
319                "Right",
320                "null", right_mouse_proc, null_mouse,
321                "pos", right_mouse_proc, pos_mouse,
322                "grey", right_mouse_proc, right_grey_mouse,
323                "pixel", right_mouse_proc, pixel_mouse,
324                NULL,
325                NULL);
326 
327     tw_newrow();
328     tw_check("Left:      ", left_check_proc, 1,
329              "image", "edge", "corner", "str", "geom",
330              NULL);
331     tw_newrow();
332     tw_check("Right:     ", right_check_proc, 1,
333              "image", "edge", "corner", "str", "geom",
334              NULL);
335     tw_newrow();
336     tw_check("Threed:    ", threed_check_proc, 1,
337              "geom", "ground", "surface",
338              NULL);
339     tw_newrow();
340 
341     tw_choice("File:", file_choice_proc, 0,
342               "AIFF", "ROI", "EDGE", "POLY", "LH_G", "RH_G", "CAM",
343               NULL);
344 
345     tw_newrow();
346 
347     tw_button("input", input_proc, NULL);
348     tw_button("output", output_proc, NULL);
349     pframe = (void *)tw_iglobal(" Frame Number (#):", &fnum, 5);
350     tw_button("<", dec_fnum_proc, NULL);
351     tw_button(">", inc_fnum_proc, NULL);
352 
353     tw_newrow();
354     pdir = (void *) tw_sglobal("Directory Name:", directory_name, 32);
355     tw_button("scan", scan_proc, NULL);
356     tw_newrow();
357     pfile = (void *) tw_sglobal("Base Name:     ", base_name, 32);
358 
359     tw_newrow();
360     tw_button("push", push_proc, NULL);
361     tw_button("pop", pop_proc, NULL);
362     tw_button ("anaglyph image", anaglyph_proc, NULL);
363     tw_label("                ");
364     tw_help_button("stereo_tool");
365 
366 
367     tw_end_tool();
368 }
369 

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