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

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

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

  1 /* view_tool.c
  2  *
  3  * tool for setting standard view and dump parameters for tina view tools
  4  */
  5 
  6 #define VIEW_TOOL_INCLUDED
  7 
  8 #include <math.h>
  9 #include <tina/sys.h>
 10 #include <tina/sysfuncs.h>
 11 #include <tina/math.h>
 12 #include <tina/mathfuncs.h>
 13 #include <tina/tv.h>
 14 #include <tina/tvfuncs.h>
 15 #include <tina/vision.h>
 16 #include <tina/visionfuncs.h>
 17 #include <tina/toolsfuncs.h>
 18 #include <tina/tw_Xfuncs.h>
 19 #include <tina/draw.h>
 20 #include <tina/drawfuncs.h>
 21 
 22 /* EXTERNS  */
 23 extern void tw_show_tool ();
 24 extern void *tw_tool ();
 25 extern void *tw_fglobal ();
 26 extern void *tw_iglobal ();
 27 extern void *tw_ivalue ();
 28 
 29 static int bkgrnd_val = 0;
 30 
 31 /* FORWARD REFS */
 32 static void bkgrnd_choice_proc (int value);
 33 void cmap_choice_proc (int value);
 34 static void dim_set (double d);
 35 static double dim_get (void);
 36 static void *currenttv;
 37 static char tv_namestr[256] = "";
 38 static int fspeed = 100;
 39 static int fcount = 4;
 40 static double x_rot = 0;
 41 static double y_rot = 0.5;
 42 static int count = 10;
 43 
 44 /* EXTERNS */
 45 
 46 static void bkgrnd_choice_proc (int value)
 47 {
 48     Tv     *tv = tv_get_next ();
 49 
 50     if (tv == NULL || tv->cmap_data_visible == NULL || tv->cmap_data_visible->std_lut==NULL) return;
 51     switch (value)
 52       {
 53       case 0:
 54           tv_reset_color (tv, bkgrnd, 255, 255, 255);
 55           break;
 56       case 1:
 57           tv_reset_color (tv, bkgrnd, 180, 180, 180);
 58           break;
 59       case 2:
 60           tv_reset_color (tv, bkgrnd, 96, 96, 96);
 61           break;
 62       case 3:
 63           tv_reset_color (tv, bkgrnd, 0, 0, 0);
 64           break;
 65       case 4:
 66           tv_reset_color (tv, bkgrnd, 0, 0, 255);
 67           break;
 68       }
 69       bkgrnd_val =  value;
 70       tv_screen_background_set(tv->tv_screen, tv->cmap_data_visible->std_lut[bkgrnd]);
 71       tv_free_background (tv);
 72       tv_repaint (tv);
 73 }
 74 
 75 static void col_choice_proc(int value)
 76 {
 77     switch (value)
 78     {
 79         case 0:
 80         tv_set_color(tv_get_next(), black);
 81         break;
 82     case 1:
 83         tv_set_color(tv_get_next(), blue);
 84         break;
 85     case 2:
 86         tv_set_color(tv_get_next(), white);
 87         break;
 88     case 3:
 89         tv_set_color(tv_get_next(), red);
 90         break;
 91     }
 92     tv_repaint(tv_get_next());
 93 }
 94 
 95 void cmap_choice_proc (int value)
 96 {
 97     extern void tv_screen_cmap_find_and_install ();
 98     Tv     *tv = tv_get_next ();
 99     static Bool first_time = true;
100 
101     if (tv && tv->tv_screen && !first_time)
102       {
103           Bool (*cmap_create_fn) () = NULL;
104           extern void tv_cmap_create_fn_set ();
105 
106           switch (value)
107             {
108             case 0:
109                 cmap_create_fn = tv_standard_cmap_create;
110                 break;
111             case 1:
112                 cmap_create_fn = tv_grey_cmap_create;
113                 break;
114             case 2:
115                 cmap_create_fn = tv_anag_cmap_create;
116                 break;
117             case 3:
118                 cmap_create_fn = tv_false_cmap_create;
119                 break;
120             default:
121                 break;
122             }
123           tv->cmap_create_fn = cmap_create_fn;
124           tv_screen_cmap_find_and_install (tv, tv->tv_screen);
125           tv_screen_color_set(tv->tv_screen, tv->cmap_data_visible->std_lut[tv->color]);
126           bkgrnd_choice_proc(bkgrnd_val);
127       }
128     first_time = false;
129 }
130 
131 void    cmap_show_proc (void)
132 {
133     Tv     *tv = tv_get_next ();
134 
135     static void *tv_screen = NULL;
136 
137     if (tv)
138       {
139           static     Tv     *cmap_tv = NULL;
140           int     width = 768;
141           int     height = 768;
142           if (tv_screen)
143             {
144                 tw_show_tool (tv_screen_owner_get (tv_screen)); /* popup tool */
145             }
146           else
147             {                   /* Create & popup tool to display colormap */
148                 cmap_tv = tv_create ("Colormap tool");
149                 tv_screen = display_tool (0, 0, width, height);
150                 tv_install (cmap_tv, tv_screen);
151             }
152           cmap_show (tv->cmap_data_visible, cmap_tv);
153       }
154 }
155 
156 void push_tv_screen(void)
157 {
158   Imrect  *tv_screen2imrect();
159 
160   stack_push(tv_screen2imrect(), IMRECT, im_free);
161 }
162 
163 
164 static void cmap_lookup_show_proc (void)
165 {
166     Tv     *tv = tv_get_next ();
167 
168     if (tv)
169       {
170           tv_cmap_lookup_print (tv);
171       }
172 }
173 
174 static double dim = 4.0;
175 
176 static void dim_set (double d)
177 {
178     dim = d;
179 }
180 
181 static double dim_get (void)
182 {
183     return (dim);
184 }
185 
186 static void dump_proc (void)
187 {
188     void dump_tool();
189     dump_tool();
190 }
191 
192 
193 static void line_width_choice_proc (int value)
194 {
195     Tv     *tv = tv_get_next ();
196 
197     (void) tv_set_linewidth (tv, value);
198 }
199 
200 void viewtool_tv_update(void)
201 {
202     Tv     *tv = tv_get_next ();
203 
204     if (tv!=NULL) strcpy(tv_namestr, tv->label);
205     (void)tw_sglobal_reset(currenttv);
206 }
207 
208 static void movie_manual_start (void)
209 {
210   tv_start_movie (tv_get_next ());
211 }
212 
213 static void movie_manual_next (void)
214 {
215   tv_make_movie (tv_get_next ());
216 }
217 
218 static void show_movie_proc (void)
219 {
220   Tv     *tv = tv_get_next ();
221   void timer_handler_install(long int length);
222   int i;
223 
224   if (tv == NULL || tv->tv_screen == NULL)
225     return;
226   if (fspeed < 1) fspeed = 1;
227   timer_handler_install(10000*fspeed);
228   
229   tv_loop_movie (tv, fcount);
230   timer_handler_uninstall();
231 }
232 
233 static void make_movie_proc (void)
234 {
235   Tv     *tv = tv_get_next ();
236   double  theta;
237   Vec3    v =
238   {Vec3_id};
239   int     i;
240 
241   if (tv == NULL || tv->tv_screen == NULL)
242     return;
243 
244   if (tv->zoomlevel != ZOOM3 && tv->zoomlevel != ZOOMGR)
245     return;
246 
247   if (tv->zoomlevel == ZOOMGR)
248     {                           /* can only rotate about z axis */
249       v = vec3_ez ();
250       theta = sqrt (x_rot * x_rot + y_rot * y_rot);
251       if (theta == 0.0)
252         return;
253 
254     }
255   else
256     {
257       v = vec3_sum (vec3_times (x_rot / count, tv->ex3),
258                     vec3_times (y_rot / count, tv->ey3));
259       theta = vec3_mod (v);
260       if (theta == 0.0)
261         return;
262       v = vec3_times (1 / theta, v);    /* to make it unit */
263     }
264 
265   tv_start_movie (tv);
266   tv_repaint (tv);
267   tv_make_movie (tv);
268   for (i = 0; i < count; ++i)
269     {
270       tv_twist (tv, theta, v);
271       tv_repaint (tv);
272       tv_make_movie (tv);
273     }
274 }
275 
276 static void rand_movie_proc (void)
277 {
278   Tv     *tv = tv_get_next ();
279   void timer_handler_install(long int length);
280   int i;
281 
282   if (tv == NULL || tv->tv_screen == NULL)
283     return;
284   if (fspeed < 1) fspeed = 1;
285   timer_handler_install(10000*fspeed);
286   
287   tv_random_movie (tv, fcount);
288   timer_handler_uninstall();
289 }
290 
291 
292 void    view_tool (int x, int y)
293 {
294     static void *tool = NULL;
295     char   *default_font_get ();
296     void    default_font_set ();
297 
298     if (tool)
299       {
300           tw_show_tool (tool);
301           return;
302       }
303     tool = tw_tool ("View Tool", x, y);
304 
305     currenttv = tw_sglobal("Current TV: ", tv_namestr, 20);
306     set_view_tool_func((void (*) ())viewtool_tv_update);
307     tw_button ("dump", dump_proc, NULL);
308     tw_label("      ");
309     tw_help_button("view_tool");
310 
311     tw_newrow();
312     tw_choice ("Bkgrnd ", bkgrnd_choice_proc, bkgrnd_val,
313            "white", "light grey", "dark grey", "black", "blue", NULL);
314     tw_newrow ();
315     tw_choice ("Line ", line_width_choice_proc, 0, "", "1", "2", "3", NULL);
316     tw_choice("Color", col_choice_proc, 0, "black", "blue", "white", "red", NULL);
317     tw_newrow();
318     tw_choice ("Colormap", cmap_choice_proc, 0, "Standard", "Greyscale",
319                "Anaglyph", "False colour", NULL);
320     tw_newrow ();
321     (void) tw_ivalue ("N default colors:", ndefault_colors_get,
322                       (void (*)()) ndefault_colors_set, 3);
323     (void) tw_svalue ("Default Font : ", default_font_get, default_font_set, 12);
324     tw_newrow ();
325     tw_button ("Show cmap", cmap_show_proc, NULL);
326     tw_button ("Show tv`s cmap_lookup", cmap_lookup_show_proc, NULL);
327     tw_button ("Push tv screen", push_tv_screen, NULL);
328 
329     tw_newrow ();
330 
331     (void) tw_label ("Movie");
332     tw_button ("init", movie_manual_start, NULL);
333     tw_button ("add one", movie_manual_next, NULL);
334     tw_button ("make seq", make_movie_proc, NULL);
335     tw_button ("show", show_movie_proc, NULL);
336     tw_button ("random", rand_movie_proc, NULL);
337     
338     tw_newrow ();
339     
340     (void) tw_fglobal ("Rot x:", &x_rot, 10);
341     (void) tw_fglobal ("Rot y:", &y_rot, 10);
342     (void) tw_iglobal ("Steps:", &count, 5);
343 
344     tw_newrow ();
345     tw_iglobal("Timer (0.01 sec):", &fspeed, 5);
346     tw_iglobal(" Count :", &fcount, 5);
347     tw_end_tool ();
348 
349     viewtool_tv_update();
350 }
351 

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