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

Linux Cross Reference
Tina5/tina-tools/tinatool/tlbase/tlbaseDisp_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/tlbaseDisp_tool.c,v $
 37  * Date    :  $Date: 2008/12/02 22:04:19 $
 38  * Version :  $Revision: 1.6 $
 39  * CVS Id  :  $Id: tlbaseDisp_tool.c,v 1.6 2008/12/02 22:04:19 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes : Tv Tool creation function and associated tv_screen procs (for XView & Motif).
 44  *
 45  *********
 46 */
 47 
 48 #include "tlbaseDisp_tool.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #    include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 #include <math.h>
 56 #include <tina/sys/sysDef.h>
 57 #include <tina/sys/sysPro.h>
 58 #include <tina/math/mathDef.h>
 59 #include <tina/math/mathPro.h>
 60 #include <tinatool/draw/drawDef.h>
 61 #include <tinatool/draw/drawPro.h>
 62 #include <tinatool/wdgts/wdgtsDef.h>
 63 #include <tinatool/wdgts/wdgtsPro.h>
 64 #include <tinatool/gphx/gphxDef.h>
 65 #include <tinatool/gphx/gphxPro.h>
 66 
 67 
 68 #define simple_pair_make(p1, p2) pair_make((void*) p1, 0, (void*) p2, 0)
 69 #define ERASE_TV 3
 70 
 71 /** tv_screen button procedures **/
 72 
 73 static void button_repaint_proc(void *tv_screen)
 74 {
 75   Tv *tv;
 76 
 77   if (tv_screen == NULL)
 78     return;
 79 
 80   tv = tv_screen_tv_get(tv_screen);
 81 
 82   if (tv == NULL)
 83     return;
 84   tv_free_background(tv);
 85   tv_repaint(tv);
 86 }
 87 
 88 static void size_proc(Pair * pair)
 89 {
 90   int size = (int) pair->to1;
 91   void *tv_screen = (void *) pair->to2;
 92 
 93   if (tv_screen == NULL)
 94     return;
 95 
 96   tv_screen_set_size(tv_screen, size, size);
 97 }
 98 
 99 static void activity_proc(Pair * pair)
100 {
101   int activity = (int) pair->to1;
102   void *tv_screen = (void *) pair->to2;
103 
104   if (tv_screen == NULL)
105     return;
106   (void) tv_set_activity(tv_screen_tv_get(tv_screen), activity);
107 }
108 
109 static void proj_proc(Pair * pair)
110 {
111   int proj = (int) pair->to1;
112   void *tv_screen = (void *) pair->to2;
113   Tv *tv;
114 
115   if (tv_screen == NULL)
116     return;
117 
118   tv = tv_screen_tv_get(tv_screen);
119 
120   if (tv == NULL)
121     return;
122 
123   tv_set_proj3(tv, proj);
124   tv_repaint(tv);
125 }
126 
127 static void paint_proc(Pair * pair)
128 {
129   int mode = (int) pair->to1;
130   void *tv_screen = (void *) pair->to2;
131   Tv *tv;
132 
133   if (tv_screen == NULL)
134     return;
135 
136   tv = tv_screen_tv_get(tv_screen);
137 
138   if (tv == NULL)
139     return;
140 
141   if (mode == ERASE_TV)
142     tv_erase(tv);
143   else
144     tv_set_paint_mode(tv, mode);
145 
146   if (mode == FULL_PAINT)
147     tv_repaint(tv);
148 }
149 
150 /*
151  * Button procedures are applied to current tv_screen: Since a button
152  * * has been hit, a tv_screen window has been entered and the current
153  * * tv_screen has been set. 
154  */
155 
156 static void install_proc(Pair * pair)
157 {
158   Tv *tv;
159   int *label = (void *) pair->to1;
160   void *tv_screen = (void *) pair->to2;
161   void tw_label_reset();
162   void tw_tool_title_reset();
163 
164   if (tv_screen == NULL)
165     return;
166 
167   tv_install(tv_get_next(), tv_screen);
168   tv = tv_screen_tv_get(tv_screen);
169   tv_message_function_set(tv, tw_label_reset, (void *) *label);
170 }
171 
172 static void clone_proc(Pair * pair)
173 {
174   Tv *tv;
175   int *label = (void *) pair->to1;
176   void *tv_screen = (void *) pair->to2;
177   void tw_label_reset();
178   void tw_tool_title_reset();
179 
180   if (tv_screen == NULL)
181     return;
182   tv_install_clone(tv_get_next(), tv_screen);
183   tv = tv_screen_tv_get(tv_screen);
184   tv_message_function_set(tv, tw_label_reset, (void *) *label);
185 }
186 
187 static void init_proc(void *tv_screen)
188 {
189   if (tv_screen == NULL || tv_screen_tv_get(tv_screen) == NULL)
190     return;
191   tv_init(tv_screen_tv_get(tv_screen));
192 }
193 
194 static void invert_2d_proc(void *tv_screen)
195 {
196   Tv *tv = tv_screen_tv_get(tv_screen);
197 
198   if (tv == NULL)
199     return;
200   tv_rot2(tv, PI);
201   tv_free_background(tv);
202   tv_repaint(tv);
203 }
204 
205 static void invert_3d_proc(void *tv_screen)
206 {
207   Tv *tv = tv_screen_tv_get(tv_screen);
208 
209   if (tv == NULL)
210     return;
211   tv_rot3(tv, PI);
212   tv->axis = vec3_minus(tv->axis);
213   tv_free_background(tv);
214   tv_repaint(tv);
215 }
216 
217 void *tv_tool_remote(int x, int y, char *display_name)
218 {
219   char name[64];
220   int canvas;
221   int owner;
222   int *label = ralloc(sizeof(int));
223   static int no = 0;
224   void canvas_upgrade();
225   void *tv_screen = tv_screen_struct_create();
226 
227   ++no;                         /*
228                                  * a new tool name number 
229                                  */
230 
231   (void) sprintf(name, "Tv Tool %d", no);
232 
233   owner = (int) tw_tool_remote(name, x, y, display_name);
234 
235   tw_menubar("",
236              "Size",
237              "256", size_proc, simple_pair_make(256, tv_screen),
238              "512", size_proc, simple_pair_make(512, tv_screen),
239              "768", size_proc, simple_pair_make(768, tv_screen),
240              NULL,
241              "Mouse",
242              "null", activity_proc, simple_pair_make(NULL, tv_screen),
243              "zoom", activity_proc, simple_pair_make(ZOOM, tv_screen),
244              "pick", activity_proc, simple_pair_make(PICK, tv_screen),
245              "mouse", activity_proc, simple_pair_make(MOUSE, tv_screen),
246              NULL,
247              "ROI",
248              "rect", activity_proc, simple_pair_make(ROI, tv_screen),
249              "poly", activity_proc, simple_pair_make(POLYROI, tv_screen),
250              "point", activity_proc, simple_pair_make(POINT, tv_screen),
251              "global", activity_proc, simple_pair_make(GLOBAL, tv_screen),
252              NULL,
253              "Proj",
254              "orth", proj_proc, simple_pair_make(ORTH, tv_screen),
255              "persp", proj_proc, simple_pair_make(PERSP, tv_screen),
256              "invert 2D", invert_2d_proc, tv_screen,
257              "invert 3D", invert_3d_proc, tv_screen,
258              NULL,
259              NULL);
260 
261   tw_newrow();
262   tw_button("install", install_proc, (void *) simple_pair_make((void *) label, tv_screen));
263   tw_button(" clone ", clone_proc, (void *) simple_pair_make((void *) label, tv_screen));
264   tw_button(" init  ", init_proc, (void *) tv_screen);
265   tw_button("repaint", button_repaint_proc, (void *) tv_screen);
266 
267     /**
268     tw_newrow();
269     tw_help_button("tv_tool");
270     **/
271   tw_newrow();
272   *label = (int) tw_label("null");
273 
274   tw_newrow();
275   canvas = (int) tw_canvas(256, 256);   /*
276                                          * Returns XV Canvas NOT paint
277                                          * * window 
278                                          */
279 
280   tw_end_tool();
281 
282   canvas_upgrade(canvas, owner, tv_screen);     /*
283                                                  * sets window, screen &
284                                                  * * visual 
285                                                  */
286 
287   tv_screen_set_size(tv_screen, 256, 256);
288   return (tv_screen);
289 }
290 
291 void *tv_tool(int x, int y)
292 {
293   return tv_tool_remote(x, y, (char *) NULL);
294 }
295 

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