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

Linux Cross Reference
Tina6/tina-tools/tinatool/draw/drawTv_pick.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_pick.c,v $
 36  * Date    :  $Date: 2003/10/01 16:02:47 $
 37  * Version :  $Revision: 1.2 $
 38  * CVS Id  :  $Id: drawTv_pick.c,v 1.2 2003/10/01 16:02:47 tony Exp $
 39  *
 40  * Author  : Legacy TINA
 41  *
 42  * Notes :
 43  *
 44  *********
 45 */
 46 
 47 #include "drawTv_pick.h"
 48 
 49 #if HAVE_CONFIG_H
 50   #include <config.h>
 51 #endif
 52 
 53 #include <stdio.h>
 54 #include <string.h>
 55 #include <math.h>
 56 
 57 #if HAVE_STDARG_H
 58 #  include <stdarg.h>
 59 #  define VA_START(a, f)                va_start(a, f)
 60 #else
 61 #  if HAVE_VARARGS_H
 62 #    include <varargs.h>
 63 #    define VA_START(a, f)  va_start(a)
 64 #  endif
 65 #endif /* HAVE_STDARG_H */
 66 #ifndef VA_START
 67   error no variadic api available
 68 #endif
 69 
 70 #include <tina/sys/sysDef.h>
 71 #include <tina/sys/sysPro.h>
 72 #include <tina/math/mathDef.h>
 73 #include <tina/math/mathPro.h>
 74 #include <tinatool/draw/draw_TvDef.h>
 75 #include <tinatool/draw/draw_TvPro.h>
 76 
 77 void    tv_set_pick(Tv * tv, Tv_pick pick)
 78 {
 79     if (tv == NULL)
 80         return;
 81 
 82     list_rm(tv->pick.picklist, tv->pick.free);
 83     /* tv_repaint(tv);  */
 84 
 85     tv->pick = pick;
 86     if (tv->tv_screen != NULL && tv->activity == PICK)
 87         (void) tv_set_activity_message(tv);
 88 }
 89 
 90 void    tv_set_pick_reset(Tv * tv, void (*reset) ( /* ??? */ ))
 91 {
 92     if (tv->pick_reset != reset)
 93     {
 94         (*tv->pick_reset) ();
 95         tv->pick_reset = reset;
 96     }
 97 }
 98 
 99 void    tv_pick_proc(Tv * tv, int state, Ipos pos)
100 {
101     static void *picked;
102     static int type;
103     Tv_pick *pick = &tv->pick;
104     List   *ref_addtostart();
105 
106     switch (state)
107     {
108     case LEFT_DOWN:
109         tv_set_overlay(tv);     /* also calls tv_save_draw */
110         picked = (*pick->closest) (tv, pos, &type);
111         (*pick->draw) (tv, picked, type);
112         break;
113     case LEFT_DRAG:
114         (*pick->draw) (tv, picked, type);
115         picked = (*pick->closest) (tv, pos, &type);
116         (*pick->draw) (tv, picked, type);
117         break;
118     case LEFT_UP:
119         (*pick->draw) (tv, picked, type);
120         if (picked != NULL)
121             pick->picklist = ref_addtostart(pick->picklist, picked, type);
122         tv_reset_draw(tv);
123         tv_save_draw(tv);
124         tv_color_set(tv, green);
125         (*pick->draw) (tv, picked, type);
126         tv_reset_draw(tv);
127         break;
128     case MIDDLE_DOWN:
129         (*pick->func) (tv, pick->picklist);
130         list_rm(pick->picklist, pick->free);
131         pick->picklist = NULL;
132         if (pick->do_repaint)
133             tv_repaint(tv);
134         break;
135     case RIGHT_DOWN:
136         list_rm(pick->picklist, pick->free);
137         pick->picklist = NULL;
138         if (pick->do_repaint)
139             tv_repaint(tv);
140         break;
141     }
142 }
143 
144 static void *null_closest(void)
145 {
146     return (NULL);
147 }
148 
149 Tv_pick null_pick(void)
150 {
151     Tv_pick pick = {Tv_pick_id};
152 
153     (void) strcpy(pick.name, "null");
154     pick.picklist = NULL;
155     pick.closest = null_closest;
156     pick.highlight = null_function;
157     pick.draw = null_function;
158     pick.func = null_function;
159     pick.free = null_function;
160     pick.do_repaint = true;
161     return (pick);
162 }
163 
164 
165 Tv_pick 
166 #if HAVE_STDARG_H
167 pick_define(int case_flag, ...)
168 #else
169 pick_define(case_flag, va_alist)
170         int case_flag;
171   va_dcl
172 #endif /* HAVE_STDARG_H */
173 {
174     Tv_pick pick = {Tv_pick_id};
175     va_list ap;
176 
177     VA_START(ap, case_flag);
178 
179     pick = null_pick();
180     pick.picklist = NULL;
181     while (case_flag)
182     {
183         switch (case_flag)
184         {
185         case PICK_NAME:
186             (void) strcpy(pick.name, (char *) va_arg(ap, char *));
187             break;
188         case PICK_CLOSEST:
189             pick.closest = (void *((*) ())) va_arg(ap, void *);
190             break;
191         case PICK_HIGHLIGHT:
192             pick.highlight = (void (*) ()) va_arg(ap, void *);
193             break;
194         case PICK_DRAW:
195             pick.draw = (void (*) ()) va_arg(ap, void *);
196             break;
197         case PICK_FUNC:
198             pick.func = (void (*) ()) va_arg(ap, void *);
199             break;
200         case PICK_FREE:
201             pick.free = (void (*) ()) va_arg(ap, void *);
202             break;
203         case PICK_REPAINT:
204             pick.do_repaint = (Bool) va_arg(ap, int);
205             break;
206         }
207         case_flag = (int) va_arg(ap, int);
208     }
209     va_end(ap);
210     return (pick);
211 }
212 

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