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

Linux Cross Reference
Tina4/src/tv/tv.c

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

  1 /**@(#)Tv ('logical' display device) creation & installation
  2 @(#)Basic tv creation and installation on tv_screens.
  3 **/
  4 
  5 #include <stdio.h>
  6 #include <string.h>
  7 #include <tina/sys.h>
  8 #include <tina/sysfuncs.h>
  9 #include <tina/math.h>
 10 #include <tina/mathfuncs.h>
 11 #include <tina/vision.h>
 12 #include <tina/visionfuncs.h>
 13 #include <tina/tv.h>
 14 #include <tina/tvfuncs.h>
 15 #include <tina/toolsfuncs.h>
 16 #include <tina/tw_Xfuncs.h>
 17 #include <tina/tw_Xfuncs.h>
 18 
 19 /* EXTERNS */
 20 extern void picture_free();
 21 extern void tv_screen_cmap_find_and_install();
 22 extern void tv_screen_named_font_set();
 23 extern void tv_screen_set_op();
 24 extern void tv_screen_set_linewidth();
 25 extern void tv_screen_save_size();
 26 extern void tv_screen_tv_set();
 27 extern void tv_screen_background_set();
 28 
 29 
 30 void    tv_free_background(Tv * tv)
 31 {
 32     if (tv == NULL)
 33         return;
 34     if (tv->backsave)
 35     {
 36         picture_free(tv->background);
 37         tv->background = NULL;
 38     }
 39 }
 40 
 41 void    tv_repaint(Tv * tv)
 42 {
 43     if (tv == NULL || tv->tv_screen == NULL)
 44         return;
 45 
 46     if (tv->backsave && tv->paint_mode == FULL_PAINT)
 47     {
 48         if (tv->background == NULL)
 49         {
 50             tv_erase(tv);
 51             tv->backdraw(tv, tv->drawdata);
 52             tv->background = tv_get_picture(tv);
 53         } else
 54             tv_show_picture(tv, tv->background);
 55     } else
 56         tv_erase(tv);
 57 
 58     switch (tv->paint_mode)
 59     {
 60     case FULL_PAINT:
 61         tv->fulldraw(tv, tv->drawdata);
 62         break;
 63     case SKEL_PAINT:
 64         tv->skeldraw(tv, tv->drawdata);
 65         break;
 66     }
 67 }
 68 
 69 Tv     *tv_create(char *label)
 70 {
 71     Tv     *tv = ts_ralloc(Tv);
 72 
 73     (void) strcpy(tv->label, label);
 74 
 75     tv->clone = 0;
 76 
 77     tv->tv_screen = NULL;
 78     tv->width = tv->height = 256;
 79     tv->init = null_function;
 80 
 81     tv->overlay_on = false;
 82     tv->color = black;          /* index into
 83                                  * tv->cmap_data_visible->std_lut[] */
 84     tv->op = rop_copy;
 85     tv->linewidth = 0;
 86     tv->linestyle = line_solid;
 87     *tv->font_name = '\0';      /* length STRING128 */
 88     tv->draw = NULL;
 89 
 90     tv->activity = (int)NULL;
 91     tv->proj3type = ORTH;
 92     tv->paint_mode = FULL_PAINT;
 93     tv->mouse = null_mouse();
 94     tv->mouse_reset = null_function;
 95     tv->pick = null_pick();
 96     tv->pick_reset = null_function;
 97     tv->backdraw = tv->fulldraw = tv->skeldraw = null_function;
 98     tv->drawdata = NULL;
 99     tv->backsave = false;
100     tv->background = NULL;
101 
102     tv->ul = vec2_zero();
103     tv->lr = vec2((float) tv->width, (float) tv->height);
104 
105     tv->movie = NULL;
106 
107     tv_camera3(tv, vec3_zero(), 1.0, 3.0, vec3_ez(), vec3_ey());
108     tv->axis_set = false;
109     tv_set_proj3_orth(tv);
110     tv_camera2(tv, vec2(128.0, 128.0), 128.0, vec2_ey());
111     tv_set_proj2(tv);
112 
113     /* tv's colormap info. */
114     tv->cmap_data_visible = NULL;
115     tv->cmap_create_fn = tv_standard_cmap_create;
116 
117     /* zbuffering option * */
118     tv->zbuff = NULL;
119 
120     return (tv);
121 }
122 
123 Tv     *tv_clone(Tv * tv)
124 {
125     char    clone[16];
126     Tv     *tv_new;
127 
128     if (tv == NULL)
129         return (NULL);
130 
131     tv_new = ts_ralloc(Tv);
132     *tv_new = *tv;
133     tv_new->pick.picklist = NULL;
134     tv_new->clone = ++(tv->clone);
135     (void) sprintf(clone, "%-8d", tv_new->clone);
136     (void) string_append(tv_new->label, tv->label, " clone ", clone, NULL);
137     tv_new->tv_screen = NULL;
138     tv_new->movie = NULL;
139     tv_new->background = NULL;
140     tv_new->zbuff = NULL;
141     tv_new->message_fn = NULL;
142     tv_new->message_data = NULL;
143     tv_new->header_fn = NULL;
144     tv_new->header_data = NULL;
145     return (tv_new);
146 }
147 
148 void    tv_install(Tv * tv, void *tv_screen)
149 {
150     void   *owner;
151     Tv     *tv_screen_tv_get();
152     void   *tv_screen_owner_get();
153 
154     if (tv && tv_screen)
155     {
156         /* Uninstall OLD tv_screen (loses link to its tv) */
157         if (tv->tv_screen)
158         {
159             tv_set_header(tv, "uninstalled");
160             tv_set_message(tv, "null");
161             tv_header_function_set(tv, NULL, NULL);
162             tv_message_function_set(tv, (void (*) ()) NULL, NULL);
163             tv_screen_tv_set(tv->tv_screen, (Tv *) NULL);
164         }
165         if (tv_screen_tv_get(tv_screen))
166         {
167             (tv_screen_tv_get(tv_screen))->tv_screen = NULL;
168         }
169         tv_screen_save_size(tv_screen);
170 
171         tv->tv_screen = tv_screen;
172         tv_screen_tv_set(tv_screen, tv);
173 
174         owner = tv_screen_owner_get(tv_screen);
175 #ifndef _PCC
176         tv_header_function_set(tv, (void (*) ()) tw_tool_title_reset, owner);
177 #endif
178 
179         tv_screen_cmap_find_and_install(tv, tv_screen);
180         tv_screen_color_set(tv->tv_screen, tv->cmap_data_visible->std_lut[tv->color]);
181         tv_screen_background_set(tv->tv_screen, tv->cmap_data_visible->std_lut[bkgrnd]);
182 
183         (void) tv_screen_set_op(tv->tv_screen, tv->op);
184         tv_screen_set_linewidth(tv->tv_screen, tv->linewidth);
185         tv_screen_set_linestyle(tv->tv_screen, tv->linestyle);
186         tv_screen_named_font_set(tv->tv_screen, tv->font_name);
187         tv_set_proj3(tv, tv->proj3type);
188         (void) tv_set_activity(tv, tv->activity);       /* sets message */
189         tv_rescale(tv);
190         tv_free_background(tv); /* Ie image */
191         if(tv->zbuff)
192             tv_set_zbuff(tv, tv->zbuff->zmin, tv->zbuff->zmax);
193         tv_repaint(tv);
194     }
195 }
196 
197 void    tv_install_clone(Tv * tv, void *tv_screen)
198 {
199     Tv     *tv_new;
200 
201     if (tv && tv_screen)
202     {
203         tv_new = tv_clone(tv);
204         tv_install(tv_new, tv_screen);
205     }
206 }
207 
208 void    tv_set_message(Tv * tv, char *name)
209 {
210     if (tv == NULL || tv->message_fn == NULL)
211         return;
212 
213     tv->message_fn(tv->message_data, name);
214 }
215 
216 void    tv_message_function_set(Tv * tv, void (*func) ( /* ??? */ ), void *data)
217 {
218     if (tv == NULL)
219         return;
220     tv->message_fn = func;
221     tv->message_data = data;
222     (void) tv_set_activity_message(tv);
223 }
224 
225 void    tv_set_header(Tv * tv, char *name)
226 {
227     if (tv == NULL || tv->header_fn == NULL)
228         return;
229 
230     tv->header_fn(tv->header_data, name);
231 }
232 
233 void    tv_header_function_set(Tv * tv, void (*func) ( /* ??? */ ), void *data)
234 {
235     if (tv == NULL)
236         return;
237     tv->header_fn = func;
238     tv->header_data = data;
239     tv_set_header(tv, tv->label);
240 }
241 
242 Tv     *tv_open(void *tv_screen, char *label)
243 {
244     Tv     *tv = NULL;
245 
246     if (tv_screen)
247     {
248         tv = tv_create(label);
249         tv_install(tv, tv_screen);
250     }
251     return (tv);
252 }
253 
254 static void tv_dummy_calls(void)
255 {                               /* for separate library complilation */
256     Tv     *tv = (Tv *) NULL;
257     double  zoom = 0.0;
258 
259     tv_zoom(tv, zoom);
260     (void) tv_cmap_create(tv);
261     (void) tv_get_im_roi(tv);
262     (void) tv_get_next();
263     tv_init(tv);
264 }
265 

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