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

Linux Cross Reference
Tina6/tina-tools/tinatool/draw/drawTv_tv.c

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

  1 /*********
  2  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  3  * University of Manchester, UK.  All rights reserved.
  4  * 
  5  * Redistribution and use in source and binary forms, with or without modification, 
  6  * are permitted provided that the following conditions are met:
  7  * 
  8  *   . Redistributions of source code must retain the above copyright notice, 
  9  *     this list of conditions and the following disclaimer.
 10  *    
 11  *   . Redistributions in binary form must reproduce the above copyright notice,
 12  *     this list of conditions and the following disclaimer in the documentation 
 13  *     and/or other materials provided with the distribution.
 14  * 
 15  *   . Neither the name of the University of Manchester nor the names of its
 16  *     contributors may be used to endorse or promote products derived from this 
 17  *     software without specific prior written permission.
 18  * 
 19  * 
 20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 30  * POSSIBILITY OF SUCH DAMAGE.
 31  *
 32  **********
 33  *
 34  * Program :    TINA
 35  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/draw/drawTv_tv.c,v $
 36  * Date    :  $Date: 2008/12/02 22:04:19 $
 37  * Version :  $Revision: 1.3 $
 38  * CVS Id  :  $Id: drawTv_tv.c,v 1.3 2008/12/02 22:04:19 paul Exp $
 39  *
 40  * Author  : Legacy TINA
 41  *
 42  * Notes :
 43  * Tv ('logical' display device) creation & installation
 44  * Basic tv creation and installation on tv_screens.
 45  *
 46  *
 47  *********
 48 */
 49 
 50 #include "drawTv_tv.h"
 51 
 52 #if HAVE_CONFIG_H
 53   #include <config.h>
 54 #endif
 55 
 56 #include <stdio.h>
 57 #include <string.h>
 58 #include <tina/sys/sysDef.h>
 59 #include <tina/sys/sysPro.h>
 60 #include <tina/math/mathDef.h>
 61 #include <tina/math/mathPro.h>
 62 #include <tina/geometry/geomDef.h>
 63 #include <tina/geometry/geomPro.h>
 64 #include <tinatool/draw/draw_TvDef.h>
 65 #include <tinatool/draw/draw_TvPro.h>
 66 #include <tinatool/gphx/gphxPro.h>
 67 #include <tinatool/wdgts/wdgtsPro.h>
 68 
 69 /* EXTERNS
 70 extern void picture_free();
 71 extern void tv_screen_cmap_find_and_install();
 72 extern void tv_screen_named_font_set();
 73 extern void tv_screen_set_op();
 74 extern void tv_screen_set_linewidth();
 75 extern void tv_screen_save_size();
 76 extern void tv_screen_tv_set();
 77 extern void tv_screen_background_set();
 78 extern void tw_tool_title_reset();
 79 */
 80 
 81 void    tv_free_background(Tv * tv)
 82 {
 83     if (tv == NULL)
 84         return;
 85     if (tv->backsave)
 86     {
 87         picture_free(tv->background);
 88         tv->background = NULL;
 89     }
 90 }
 91 
 92 void    tv_repaint(Tv * tv)
 93 {
 94     if (tv == NULL || tv->tv_screen == NULL)
 95         return;
 96 
 97     if (tv->backsave && tv->paint_mode == FULL_PAINT)
 98     {
 99         if (tv->background == NULL)
100         {
101             tv_erase(tv);
102             tv->backdraw(tv, tv->drawdata);
103             tv->background = tv_get_picture(tv);
104         } else
105             tv_show_picture(tv, tv->background);
106     } else
107         tv_erase(tv);
108 
109     switch (tv->paint_mode)
110     {
111     case FULL_PAINT:
112         tv->fulldraw(tv, tv->drawdata);
113         break;
114     case SKEL_PAINT:
115         tv->skeldraw(tv, tv->drawdata);
116         break;
117     }
118 }
119 
120 Tv     *tv_create(char *label)
121 {
122     Tv     *tv = ts_ralloc(Tv);
123 
124     (void) strcpy(tv->label, label);
125 
126     tv->clone = 0;
127 
128     tv->tv_screen = NULL;
129     tv->width = tv->height = 256;
130     tv->init = null_function;
131 
132     tv->overlay_on = false;
133     tv->color = black;          /* index into
134                                  * tv->cmap_data_visible->std_lut[] */
135     tv->op = rop_copy;
136     tv->linewidth = 0;
137     tv->linestyle = line_solid;
138     *tv->font_name = '\0';      /* length STRING128 */
139     tv->draw = NULL;
140 
141     tv->activity = 0;
142     tv->proj3type = ORTH;
143     tv->paint_mode = FULL_PAINT;
144     tv->mouse = null_mouse();
145     tv->mouse_reset = null_function;
146     tv->pick = null_pick();
147     tv->pick_reset = null_function;
148     tv->keyboard_func = tv->backdraw = tv->fulldraw = tv->skeldraw = null_function;
149     tv->drawdata = NULL;
150     tv->backsave = false;
151     tv->background = NULL;
152 
153     tv->ul = vec2_zero();
154     tv->lr = vec2((float) tv->width, (float) tv->height);
155 
156     tv->movie = NULL;
157 
158     tv_camera3(tv, vec3_zero(), 1.0, 3.0, vec3_ez(), vec3_ey());
159     tv->axis_set = false;
160     tv_set_proj3_orth(tv);
161     tv_camera2(tv, vec2(128.0, 128.0), 128.0, vec2_ey());
162     tv_set_proj2(tv);
163 
164     /* tv's colormap info. */
165     tv->cmap_data_visible = NULL;
166     tv->cmap_create_fn = tv_standard_cmap_create;
167 
168     /* zbuffering option * */
169     tv->zbuff = NULL;
170 
171     return (tv);
172 }
173 
174 Tv     *tv_clone(Tv * tv)
175 {
176     char    clone[16];
177     Tv     *tv_new;
178 
179     if (tv == NULL)
180         return (NULL);
181 
182     tv_new = ts_ralloc(Tv);
183     *tv_new = *tv;
184     tv_new->pick.picklist = NULL;
185     tv_new->clone = ++(tv->clone);
186     (void) sprintf(clone, "%-8d", tv_new->clone);
187     (void) string_append(tv_new->label, tv->label, " clone ", clone, NULL);
188     tv_new->tv_screen = NULL;
189     tv_new->movie = NULL;
190     tv_new->background = NULL;
191     tv_new->zbuff = NULL;
192     tv_new->message_fn = NULL;
193     tv_new->message_data = NULL;
194     tv_new->header_fn = NULL;
195     tv_new->header_data = NULL;
196     return (tv_new);
197 }
198 
199 void    tv_install(Tv * tv, void *tv_screen)
200 {
201     void   *owner;
202     Tv     *tv_screen_tv_get();
203     void   *tv_screen_owner_get();
204 
205     if (tv && tv_screen)
206     {
207         /* Uninstall OLD tv_screen (loses link to its tv) */
208         if (tv->tv_screen)
209         {
210             tv_set_header(tv, "uninstalled");
211             tv_set_message(tv, "null");
212             tv_header_function_set(tv, NULL, NULL);
213             tv_message_function_set(tv, (void (*) ()) NULL, NULL);
214             tv_screen_tv_set(tv->tv_screen, (Tv *) NULL);
215         }
216         if (tv_screen_tv_get(tv_screen))
217         {
218             (tv_screen_tv_get(tv_screen))->tv_screen = NULL;
219         }
220         tv_screen_save_size(tv_screen);
221 
222         tv->tv_screen = tv_screen;
223         tv_screen_tv_set(tv_screen, tv);
224 
225         owner = tv_screen_owner_get(tv_screen);
226         tv_header_function_set(tv, (void (*) ()) tw_tool_title_reset, owner);
227 
228         tv_screen_cmap_find_and_install(tv, tv_screen);
229         tv_screen_color_set(tv->tv_screen, tv->cmap_data_visible->std_lut[tv->color]);
230         tv_screen_background_set(tv->tv_screen, tv->cmap_data_visible->std_lut[bkgrnd]);
231 
232         (void) tv_screen_set_op(tv->tv_screen, tv->op);
233         tv_screen_set_linewidth(tv->tv_screen, tv->linewidth);
234         tv_screen_set_linestyle(tv->tv_screen, tv->linestyle);
235         tv_screen_named_font_set(tv->tv_screen, tv->font_name);
236         tv_set_proj3(tv, tv->proj3type);
237         (void) tv_set_activity(tv, tv->activity);       /* sets message */
238         tv_rescale(tv);
239         tv_free_background(tv); /* Ie image */
240         if(tv->zbuff)
241             tv_set_zbuff(tv, tv->zbuff->zmin, tv->zbuff->zmax);
242         tv_repaint(tv);
243     }
244 }
245 
246 void    tv_install_clone(Tv * tv, void *tv_screen)
247 {
248     Tv     *tv_new;
249 
250     if (tv && tv_screen)
251     {
252         tv_new = tv_clone(tv);
253         tv_install(tv_new, tv_screen);
254     }
255 }
256 
257 void    tv_set_message(Tv * tv, char *name)
258 {
259     if (tv == NULL || tv->message_fn == NULL)
260         return;
261 
262     tv->message_fn(tv->message_data, name);
263 }
264 
265 void    tv_message_function_set(Tv * tv, void (*func) ( /* ??? */ ), void *data)
266 {
267     if (tv == NULL)
268         return;
269     tv->message_fn = func;
270     tv->message_data = data;
271     (void) tv_set_activity_message(tv);
272 }
273 
274 void    tv_set_header(Tv * tv, char *name)
275 {
276     if (tv == NULL || tv->header_fn == NULL)
277         return;
278 
279     tv->header_fn(tv->header_data, name);
280 }
281 
282 void    tv_header_function_set(Tv * tv, void (*func) ( /* ??? */ ), void *data)
283 {
284     if (tv == NULL)
285         return;
286     tv->header_fn = func;
287     tv->header_data = data;
288     tv_set_header(tv, tv->label);
289 }
290 
291 Tv     *tv_open(void *tv_screen, char *label)
292 {
293     Tv     *tv = NULL;
294 
295     if (tv_screen)
296     {
297         tv = tv_create(label);
298         tv_install(tv, tv_screen);
299     }
300     return (tv);
301 }
302 
303 static void tv_dummy_calls(void)
304 {                               /* for separate library complilation */
305     Tv     *tv = (Tv *) NULL;
306     double  zoom = 0.0;
307 
308     tv_zoom(tv, zoom);
309     (void) tv_cmap_create(tv);
310     (void) tv_get_im_roi(tv);
311     (void) tv_get_next();
312     tv_init(tv);
313 }
314 

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