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

Linux Cross Reference
Tina4/src/tools/display/tv_tool.c

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

  1 /** @(#)Tv Tool creation function and associated tv_screen procs (for XView & Motif).
  2 **/
  3 
  4 #include <stdio.h>
  5 #include <math.h>
  6 #include <tina/sys.h>
  7 #include <tina/sysfuncs.h>
  8 #include <tina/math.h>
  9 #include <tina/mathfuncs.h>
 10 #include <tina/tv.h>
 11 #include <tina/tvfuncs.h>
 12 #include <tina/vision.h>
 13 #include <tina/toolsfuncs.h>
 14 #include <tina/tw_Xfuncs.h>
 15 
 16 /*
 17  * EXTERNS 
 18  */
 19 extern Tv *tv_get_next();
 20 extern Tv *tv_screen_tv_get();
 21 extern void *tw_tool_remote();
 22 extern void tv_screen_erase();
 23 extern void tv_screen_set_size();
 24 extern void tw_end_tool_remote();
 25 
 26 /*
 27  * Tv_screen *tv_screen_struct_create (window system specific) 
 28  */
 29 extern void *tv_screen_struct_create();
 30 
 31 
 32 /*
 33  * FORWARD REFS 
 34  */
 35 static void activity_proc(Pair * pair);
 36 static void button_repaint_proc(void *tv_screen);
 37 static void paint_proc(Pair * pair);
 38 static void proj_proc(Pair * pair);
 39 static void size_proc(Pair * pair);
 40 
 41 #define simple_pair_make(p1, p2) pair_make((void*) p1, (int) NULL, (void*) p2, (int) NULL)
 42 #define ERASE_TV 3
 43 
 44 /** tv_screen button procedures **/
 45 
 46 static void button_repaint_proc(void *tv_screen)
 47 {
 48   Tv *tv;
 49 
 50   if (tv_screen == NULL)
 51     return;
 52 
 53   tv = tv_screen_tv_get(tv_screen);
 54 
 55   if (tv == NULL)
 56     return;
 57   tv_free_background(tv);
 58   tv_repaint(tv);
 59 }
 60 
 61 static void size_proc(Pair * pair)
 62 {
 63   int size = (int) pair->to1;
 64   void *tv_screen = (void *) pair->to2;
 65 
 66   if (tv_screen == NULL)
 67     return;
 68 
 69   tv_screen_set_size(tv_screen, size, size);
 70 }
 71 
 72 static void activity_proc(Pair * pair)
 73 {
 74   int activity = (int) pair->to1;
 75   void *tv_screen = (void *) pair->to2;
 76 
 77   if (tv_screen == NULL)
 78     return;
 79   (void) tv_set_activity(tv_screen_tv_get(tv_screen), activity);
 80 }
 81 
 82 static void proj_proc(Pair * pair)
 83 {
 84   int proj = (int) pair->to1;
 85   void *tv_screen = (void *) pair->to2;
 86   Tv *tv;
 87 
 88   if (tv_screen == NULL)
 89     return;
 90 
 91   tv = tv_screen_tv_get(tv_screen);
 92 
 93   if (tv == NULL)
 94     return;
 95 
 96   tv_set_proj3(tv, proj);
 97   tv_repaint(tv);
 98 }
 99 
100 static void paint_proc(Pair * pair)
101 {
102   int mode = (int) pair->to1;
103   void *tv_screen = (void *) pair->to2;
104   Tv *tv;
105 
106   if (tv_screen == NULL)
107     return;
108 
109   tv = tv_screen_tv_get(tv_screen);
110 
111   if (tv == NULL)
112     return;
113 
114   if (mode == ERASE_TV)
115     tv_erase(tv);
116   else
117     tv_set_paint_mode(tv, mode);
118 
119   if (mode == FULL_PAINT)
120     tv_repaint(tv);
121 }
122 
123 /*
124  * Button procedures are applied to current tv_screen: Since a button
125  * * has been hit, a tv_screen window has been entered and the current
126  * * tv_screen has been set. 
127  */
128 
129 static void install_proc(Pair * pair)
130 {
131   Tv *tv;
132   int *label = (void *) pair->to1;
133   void *tv_screen = (void *) pair->to2;
134   void tw_label_reset();
135   void tw_tool_title_reset();
136 
137   if (tv_screen == NULL)
138     return;
139 
140   tv_install(tv_get_next(), tv_screen);
141   tv = tv_screen_tv_get(tv_screen);
142   tv_message_function_set(tv, tw_label_reset, (void *) *label);
143 }
144 
145 static void clone_proc(Pair * pair)
146 {
147   Tv *tv;
148   int *label = (void *) pair->to1;
149   void *tv_screen = (void *) pair->to2;
150   void tw_label_reset();
151   void tw_tool_title_reset();
152 
153   if (tv_screen == NULL)
154     return;
155   tv_install_clone(tv_get_next(), tv_screen);
156   tv = tv_screen_tv_get(tv_screen);
157   tv_message_function_set(tv, tw_label_reset, (void *) *label);
158 }
159 
160 static void init_proc(void *tv_screen)
161 {
162   if (tv_screen == NULL || tv_screen_tv_get(tv_screen) == NULL)
163     return;
164   tv_init(tv_screen_tv_get(tv_screen));
165 }
166 
167 static void invert_2d_proc(void *tv_screen)
168 {
169   Tv *tv = tv_screen_tv_get(tv_screen);
170 
171   if (tv == NULL)
172     return;
173   tv_rot2(tv, PI);
174   tv_free_background(tv);
175   tv_repaint(tv);
176 }
177 
178 static void invert_3d_proc(void *tv_screen)
179 {
180   Tv *tv = tv_screen_tv_get(tv_screen);
181 
182   if (tv == NULL)
183     return;
184   tv_rot3(tv, PI);
185   tv->axis = vec3_minus(tv->axis);
186   tv_free_background(tv);
187   tv_repaint(tv);
188 }
189 
190 void *tv_tool_remote(int x, int y, char *display_name)
191 {
192   char name[64];
193   int canvas;
194   int owner;
195   int *label = ralloc(sizeof(int));
196   static int no = 0;
197   void canvas_upgrade();
198   void *tv_screen = tv_screen_struct_create();
199 
200   ++no;                         /*
201                                  * a new tool name number 
202                                  */
203 
204   (void) sprintf(name, "Tv Tool %d", no);
205 
206   owner = (int) tw_tool_remote(name, x, y, display_name);
207 
208   tw_menubar("",
209              "Size",
210              "256", size_proc, simple_pair_make(256, tv_screen),
211              "512", size_proc, simple_pair_make(512, tv_screen),
212              "768", size_proc, simple_pair_make(768, tv_screen),
213              NULL,
214              "Mouse",
215              "null", activity_proc, simple_pair_make(NULL, tv_screen),
216              "zoom", activity_proc, simple_pair_make(ZOOM, tv_screen),
217              "pick", activity_proc, simple_pair_make(PICK, tv_screen),
218              "mouse", activity_proc, simple_pair_make(MOUSE, tv_screen),
219              NULL,
220              "ROI",
221              "rect", activity_proc, simple_pair_make(ROI, tv_screen),
222              "poly", activity_proc, simple_pair_make(POLYROI, tv_screen),
223              "point", activity_proc, simple_pair_make(POINT, tv_screen),
224              "global", activity_proc, simple_pair_make(GLOBAL, tv_screen),
225              NULL,
226              "Proj",
227              "orth", proj_proc, simple_pair_make(ORTH, tv_screen),
228              "persp", proj_proc, simple_pair_make(PERSP, tv_screen),
229              "invert 2D", invert_2d_proc, tv_screen,
230              "invert 3D", invert_3d_proc, tv_screen,
231              NULL,
232              NULL);
233 
234   tw_newrow();
235   tw_button("install", install_proc, (void *) simple_pair_make((void *) label, tv_screen));
236   tw_button(" clone ", clone_proc, (void *) simple_pair_make((void *) label, tv_screen));
237   tw_button(" init  ", init_proc, (void *) tv_screen);
238   tw_button("repaint", button_repaint_proc, (void *) tv_screen);
239 
240     /**
241     tw_newrow();
242     tw_help_button("tv_tool");
243     **/
244   tw_newrow();
245   *label = (int) tw_label("null");
246 
247   tw_newrow();
248   canvas = (int) tw_canvas(256, 256);   /*
249                                          * Returns XV Canvas NOT paint
250                                          * * window 
251                                          */
252 
253   tw_end_tool();
254 
255   canvas_upgrade(canvas, owner, tv_screen);     /*
256                                                  * sets window, screen &
257                                                  * * visual 
258                                                  */
259 
260   tv_screen_set_size(tv_screen, 256, 256);
261   return (tv_screen);
262 }
263 
264 void *tv_tool(int x, int y)
265 {
266   return tv_tool_remote(x, y, (char *) NULL);
267 }
268 

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