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

Linux Cross Reference
Tina5/tina-tools/tinatool/tlbase/tlbaseView_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/tlbaseView_tool.c,v $
 37  * Date    :  $Date: 2007/02/15 01:55:50 $
 38  * Version :  $Revision: 1.4 $
 39  * CVS Id  :  $Id: tlbaseView_tool.c,v 1.4 2007/02/15 01:55:50 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : tool for setting standard view and dump parameters for tina view tools
 44  *
 45  *********
 46 */
 47 
 48 #if HAVE_CONFIG_H
 49 #include <config.h>
 50 #endif
 51 
 52 
 53 /* view_tool.c
 54  *
 55  * tool for setting standard view and dump parameters for tina view tools
 56  */
 57 
 58 #define VIEW_TOOL_INCLUDED
 59 
 60 #include <math.h>
 61 
 62 #include <tina/sys/sysDef.h>
 63 #include <tina/sys/sysPro.h>
 64 #include <tina/math/mathDef.h>
 65 #include <tina/math/mathPro.h>
 66 #include <tina/image/imgDef.h>
 67 #include <tina/image/imgPro.h>
 68 
 69 #include <tinatool/draw/drawDef.h>
 70 #include <tinatool/draw/drawPro.h>
 71 #include <tinatool/gphx/gphxPro.h>
 72 #include <tinatool/wdgts/wdgtsDef.h>
 73 #include <tinatool/wdgts/wdgtsPro.h>
 74 #include <tinatool/tlbase/tlbase_DispPro.h>
 75 #include <tinatool/tlbase/tlbaseInfr_stack.h>
 76 #include <tinatool/tlbase/tlbaseView_display.h>
 77 
 78 static int bkgrnd_val = 0;
 79 
 80 /* FORWARD REFS */
 81 static void bkgrnd_choice_proc (int value);
 82 void cmap_choice_proc (int value);
 83 static void dim_set (double d);
 84 static double dim_get (void);
 85 static void *currenttv;
 86 static char tv_namestr[256] = "";
 87 static int fspeed = 100;
 88 static int fcount = 4;
 89 static double x_rot = 0;
 90 static double y_rot = 0.5;
 91 static int count = 10;
 92 
 93 /* EXTERNS */
 94 
 95 static void bkgrnd_choice_proc (int value)
 96 {
 97     Tv     *tv = tv_get_next ();
 98 
 99     if (tv == NULL || tv->cmap_data_visible == NULL || tv->cmap_data_visible->std_lut==NULL) return;
100     switch (value)
101       {
102       case 0:
103           tv_reset_color (tv, bkgrnd, 255, 255, 255);
104           break;
105       case 1:
106           tv_reset_color (tv, bkgrnd, 180, 180, 180);
107           break;
108       case 2:
109           tv_reset_color (tv, bkgrnd, 96, 96, 96);
110           break;
111       case 3:
112           tv_reset_color (tv, bkgrnd, 0, 0, 0);
113           break;
114       case 4:
115           tv_reset_color (tv, bkgrnd, 0, 0, 255);
116           break;
117       }
118       bkgrnd_val =  value;
119       tv_screen_background_set(tv->tv_screen, tv->cmap_data_visible->std_lut[bkgrnd]);
120       tv_free_background (tv);
121       tv_repaint (tv);
122 }
123 
124 static void col_choice_proc(int value)
125 {
126     switch (value)
127     {
128         case 0:
129         tv_set_color(tv_get_next(), black);
130         break;
131     case 1:
132         tv_set_color(tv_get_next(), blue);
133         break;
134     case 2:
135         tv_set_color(tv_get_next(), white);
136         break;
137     case 3:
138         tv_set_color(tv_get_next(), red);
139         break;
140     }
141     tv_repaint(tv_get_next());
142 }
143 
144 void cmap_choice_proc (int value)
145 {
146     extern void tv_screen_cmap_find_and_install ();
147     Tv     *tv = tv_get_next ();
148     static Bool first_time = true;
149 
150     if (tv && tv->tv_screen && !first_time)
151       {
152           Bool (*cmap_create_fn) () = NULL;
153           extern void tv_cmap_create_fn_set ();
154 
155           switch (value)
156             {
157             case 0:
158                 cmap_create_fn = tv_standard_cmap_create;
159                 break;
160             case 1:
161                 cmap_create_fn = tv_grey_cmap_create;
162                 break;
163             case 2:
164                 cmap_create_fn = tv_anag_cmap_create;
165                 break;
166             case 3:
167                 cmap_create_fn = tv_false_cmap_create;
168                 break;
169             default:
170                 break;
171             }
172           tv->cmap_create_fn = cmap_create_fn;
173           tv_screen_cmap_find_and_install (tv, tv->tv_screen);
174           tv_screen_color_set(tv->tv_screen, tv->cmap_data_visible->std_lut[tv->color]);
175           bkgrnd_choice_proc(bkgrnd_val);
176       }
177     first_time = false;
178 }
179 
180 void    cmap_show_proc (void)
181 {
182     Tv     *tv = tv_get_next ();
183 
184     static void *tv_screen = NULL;
185 
186     if (tv)
187       {
188           static     Tv     *cmap_tv = NULL;
189           int     width = 768;
190           int     height = 768;
191           if (tv_screen)
192             {
193                 tw_show_tool(tv_screen_owner_get (tv_screen));  /* popup tool */
194             }
195           else
196             {                   /* Create & popup tool to display colormap */
197                 cmap_tv = tv_create ("Colormap tool");
198                 tv_screen = display_tool (0, 0, width, height);
199                 tv_install (cmap_tv, tv_screen);
200             }
201           cmap_show (tv->cmap_data_visible, cmap_tv);
202       }
203 }
204 
205 void push_tv_screen(void)
206 {
207   Imrect  *tv_screen2imrect();
208 
209   stack_push(tv_screen2imrect(), IMRECT, im_free);
210 }
211 
212 
213 static void cmap_lookup_show_proc (void)
214 {
215     Tv     *tv = tv_get_next ();
216 
217     if (tv)
218       {
219           tv_cmap_lookup_print (tv);
220       }
221 }
222 
223 static double dim = 4.0;
224 
225 static void dim_set (double d)
226 {
227     dim = d;
228 }
229 
230 static double dim_get (void)
231 {
232     return (dim);
233 }
234 
235 static void dump_proc (void)
236 {
237     void dump_tool();
238     dump_tool();
239 }
240 
241 
242 static void line_width_choice_proc (int value)
243 {
244     Tv     *tv = tv_get_next ();
245 
246     (void) tv_set_linewidth (tv, value);
247 }
248 
249 void viewtool_tv_update(void)
250 {
251     Tv     *tv = tv_get_next ();
252 
253     if (tv!=NULL) strcpy(tv_namestr, tv->label);
254     (void)tw_sglobal_reset(currenttv);
255 }
256 
257 static void set_bigtolittle_proc (void)
258 {
259     void toggle_bigtolittle(void);
260     toggle_bigtolittle();
261 }
262 
263 static void movie_manual_start (void)
264 {
265   tv_start_movie (tv_get_next ());
266 }
267 
268 static void movie_manual_next (void)
269 {
270   tv_make_movie (tv_get_next ());
271 }
272 
273 static void show_movie_proc (void)
274 {
275   Tv     *tv = tv_get_next ();
276   void timer_handler_install(long int length);
277   int i;
278 
279   if (tv == NULL || tv->tv_screen == NULL)
280     return;
281   if (fspeed < 1) fspeed = 1;
282   timer_handler_install(10000*fspeed);
283   
284   tv_loop_movie (tv, fcount);
285   timer_handler_uninstall();
286 }
287 
288 static void make_movie_proc (void)
289 {
290   Tv     *tv = tv_get_next ();
291   double  theta;
292   Vec3    v =
293   {Vec3_id};
294   int     i;
295 
296   if (tv == NULL || tv->tv_screen == NULL)
297     return;
298 
299   if (tv->zoomlevel != ZOOM3 && tv->zoomlevel != ZOOMGR)
300     return;
301 
302   if (tv->zoomlevel == ZOOMGR)
303     {                           /* can only rotate about z axis */
304       v = vec3_ez ();
305       theta = sqrt (x_rot * x_rot + y_rot * y_rot);
306       if (theta == 0.0)
307         return;
308 
309     }
310   else
311     {
312       v = vec3_sum (vec3_times (x_rot / count, tv->ex3),
313                     vec3_times (y_rot / count, tv->ey3));
314       theta = vec3_mod (v);
315       if (theta == 0.0)
316         return;
317       v = vec3_times (1 / theta, v);    /* to make it unit */
318     }
319 
320   tv_start_movie (tv);
321   tv_repaint (tv);
322   tv_make_movie (tv);
323   for (i = 0; i < count; ++i)
324     {
325       tv_twist (tv, theta, v);
326       tv_repaint (tv);
327       tv_make_movie (tv);
328     }
329 }
330 
331 static void rand_movie_proc (void)
332 {
333   Tv     *tv = tv_get_next ();
334   void timer_handler_install(long int length);
335   int i;
336 
337   if (tv == NULL || tv->tv_screen == NULL)
338     return;
339   if (fspeed < 1) fspeed = 1;
340   timer_handler_install(10000*fspeed);
341   
342   tv_random_movie (tv, fcount);
343   timer_handler_uninstall();
344 }
345 
346 
347 void    view_tool (int x, int y)
348 {
349     static void *tool = NULL;
350     char   *default_font_get ();
351     void    default_font_set ();
352 
353     if (tool)
354       {
355           tw_show_tool (tool);
356           return;
357       }
358     tool = tw_tool ("View Tool", x, y);
359 
360     currenttv = tw_sglobal("Current TV: ", tv_namestr, 20);
361     set_view_tool_func((void (*) ())viewtool_tv_update);
362     tw_button ("dump", dump_proc, NULL);
363     tw_label("      ");
364     tw_help_button("view_tool");
365 
366     tw_newrow();
367     tw_choice ("Bkgrnd ", bkgrnd_choice_proc, bkgrnd_val,
368            "white", "light grey", "dark grey", "black", "blue", NULL);
369     tw_newrow ();
370     tw_choice ("Line ", line_width_choice_proc, 0, "", "1", "2", "3", NULL);
371     tw_choice("Color", col_choice_proc, 0, "black", "blue", "white", "red", NULL);
372     tw_newrow();
373     tw_choice ("Colormap", cmap_choice_proc, 0, "Standard", "Greyscale",
374                "Anaglyph", "False colour", NULL);
375     tw_newrow ();
376     (void) tw_ivalue ("default colors:", ndefault_colors_get,
377                       (void (*)()) ndefault_colors_set, 3);
378     (void) tw_svalue ("Default Font : ", default_font_get, default_font_set, 10);
379     tw_button("endian", set_bigtolittle_proc, NULL);
380     tw_newrow ();
381     tw_button ("Show cmap", cmap_show_proc, NULL);
382     tw_button ("Show tv`s cmap_lookup", cmap_lookup_show_proc, NULL);
383     tw_button ("Push tv screen", push_tv_screen, NULL);
384 
385     tw_newrow ();
386 
387     (void) tw_label ("Movie");
388     tw_button ("init", movie_manual_start, NULL);
389     tw_button ("add one", movie_manual_next, NULL);
390     tw_button ("make seq", make_movie_proc, NULL);
391     tw_button ("show", show_movie_proc, NULL);
392     tw_button ("random", rand_movie_proc, NULL);
393     
394     tw_newrow ();
395     
396     (void) tw_fglobal ("Rot x:", &x_rot, 10);
397     (void) tw_fglobal ("Rot y:", &y_rot, 10);
398     (void) tw_iglobal ("Steps:", &count, 5);
399 
400     tw_newrow ();
401     tw_iglobal("Timer (0.01 sec):", &fspeed, 5);
402     tw_iglobal(" Count :", &fcount, 5);
403     tw_end_tool ();
404 
405     viewtool_tv_update();
406 }
407 

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