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

Linux Cross Reference
Tina5/tina-tools/tinatool/tlvision/tlvisSmm_pick.c

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

  1 /**********
  2  *
  3  *
  4  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  5  * University of Manchester, UK.  All rights reserved.
  6  * 
  7  * Redistribution and use in source and binary forms, with or without modification, 
  8  * are permitted provided that the following conditions are met:
  9  * 
 10  *   . Redistributions of source code must retain the above copyright notice, 
 11  *     this list of conditions and the following disclaimer.
 12  *    
 13  *   . Redistributions in binary form must reproduce the above copyright notice,
 14  *     this list of conditions and the following disclaimer in the documentation 
 15  *     and/or other materials provided with the distribution.
 16  * 
 17  *   . Neither the name of the University of Manchester nor the names of its
 18  *     contributors may be used to endorse or promote products derived from this 
 19  *     software without specific prior written permission.
 20  * 
 21  * 
 22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 32  * POSSIBILITY OF SUCH DAMAGE.
 33  **********
 34  *
 35  * Program :   TINA
 36  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlvision/tlvisSmm_pick.c,v $
 37  * Date    :  $Date: 2008/12/02 22:04:19 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: tlvisSmm_pick.c,v 1.3 2008/12/02 22:04:19 paul Exp $
 40  *
 41  * Notes :
 42  *
 43  *
 44  *
 45  *********
 46 */
 47 
 48 #include "tlvisSmm_pick.h"
 49 
 50 #if HAVE_CONFIG_H
 51 #include <config.h>
 52 #endif
 53 
 54 #include <stdio.h>
 55 #include <math.h>
 56 
 57 #include <tina/sys/sysDef.h>
 58 #include <tina/sys/sysPro.h>
 59 #include <tina/math/mathDef.h>
 60 #include <tina/math/mathPro.h>
 61 #include <tina/geometry/geomPro.h>
 62 #include <tina/geometry/geomDef.h>
 63 #include <tina/vision/visDef.h>
 64 #include <tina/vision/visPro.h>
 65 
 66 #include <tinatool/draw/drawDef.h>
 67 #include <tinatool/draw/drawPro.h>
 68 #include <tinatool/tlbase/tlbaseDef.h>
 69 #include <tinatool/tlbase/tlbasePro.h>
 70 #include "tlvisSmm_mouse.h"
 71 #include "tlvisSmm_matcher.h"
 72 
 73 
 74 
 75 static void     pick_direct(Tv * tv, List * picklist)
 76 {
 77         List           *p;
 78 
 79         for (p = picklist; p != NULL; p = p->next)
 80                 if (p->type != POSITIVE)
 81                         geom_negate(p->to, LINE3);
 82 }
 83 
 84 static void    *pick_scene_closest(Tv * tv, Ipos pos, int *type)
 85 {
 86         *type = 0;
 87         return (tv_geom_list_pick_closest(tv, pos, scene_get(), type));
 88 }
 89 
 90 static void    *pick_scene_ml_closest(Tv * tv, Ipos pos, int *type)
 91 {
 92         *type = 0;
 93         return (tv_geom_list_pick_closest(tv, pos, scene_ml_get(), type));
 94 }
 95 
 96 static void     pick_scene_delete(Tv * tv, List * picklist)
 97 {
 98         List           *p;
 99         List           *domain = scene_get();
100 
101         for (p = picklist; p != NULL; p = p->next)
102                 domain = list_rm_ref(domain, p->to, (void (*) ()) NULL);
103 
104         scene_reset(domain);
105 }
106 
107 static void     pick_scene_choose(Tv * tv, List * picklist)
108 {
109         List           *p1;
110         List           *p2;
111         List           *domain = scene_get();
112         Bool            delete;
113 
114         for (p1 = domain; p1 != NULL; p1 = p1->next)
115         {
116                 delete = true;
117                 for (p2 = picklist; p2 != NULL; p2 = p2->next)
118                         if (p1->to == p2->to)
119                                 delete = false;
120                 if (delete)
121                         domain = list_rm_el(domain, p1, (void (*) ()) NULL);
122         }
123 
124         scene_reset(domain);
125 }
126 
127 static void     pick_scene_pwr(Tv * tv, List * picklist)
128 {
129         Pwrte          *p;
130         void           *g1, *g2;
131         int             type1, type2;
132 
133         if (picklist == NULL || picklist->next == NULL)
134                 return;
135 
136         g1 = picklist->to;
137         g2 = picklist->next->to;
138         type1 = picklist->type;
139         type2 = picklist->next->type;
140         p = pwrte_make(g1, type1, g2, type2);
141         pwrte_free(p);
142 }
143 
144 static void     pick_scene_matches(Tv * tv, List * picklist)
145 {
146         void           *geom;
147         int             type;
148         List           *lptr;
149         List           *list = model_get();
150         Tv             *tvm;
151         Tv             *model_tv();
152 
153         if (picklist == NULL)
154                 return;
155 
156         geom = picklist->to;
157         type = picklist->type;
158         list = smm_good_matches(geom, type, list);
159 
160         tv_repaint(tv);
161         tv_save_draw(tv);
162         tv_set_color(tv, blue);
163         geom_draw_directed(tv, geom, type, POSITIVE);
164         tv_reset_draw(tv);
165         tvm = model_tv();
166         tv_repaint(tvm);
167         tv_save_draw(tvm);
168         tv_set_color(tvm, blue);
169         for (lptr = list; lptr != NULL; lptr = lptr->next)
170         {
171                 Match          *m = (Match *) lptr->to;
172 
173                 geom_draw_directed(tvm, m->to2, m->type, POSITIVE);
174         }
175         tv_reset_draw(tvm);
176         list_rm(list, match_free);
177 }
178 
179 Tv_pick         scene_matches(void)
180 {
181         Tv_pick         pick = {Tv_pick_id};
182 
183         pick = pick_define(
184                            PICK_CLOSEST, pick_scene_closest,
185                            PICK_DRAW, geom_draw_directed,
186                            PICK_FUNC, pick_scene_matches,
187                            PICK_NAME, "matches",
188                            NULL);
189         return (pick);
190 }
191 
192 Tv_pick         scene_delete(void)
193 {
194         Tv_pick         pick = {Tv_pick_id};
195 
196         pick = pick_define(
197                            PICK_CLOSEST, pick_scene_closest,
198                            PICK_DRAW, geom_draw_directed,
199                            PICK_FUNC, pick_scene_delete,
200                            PICK_NAME, "delete",
201                            NULL);
202         return (pick);
203 }
204 
205 Tv_pick         scene_choose(void)
206 {
207         Tv_pick         pick = {Tv_pick_id};
208 
209         pick = pick_define(
210                            PICK_CLOSEST, pick_scene_closest,
211                            PICK_DRAW, geom_draw_directed,
212                            PICK_FUNC, pick_scene_choose,
213                            PICK_NAME, "choose",
214                            NULL);
215         return (pick);
216 }
217 
218 Tv_pick         scene_pwr(void)
219 {
220         Tv_pick         pick = {Tv_pick_id};
221 
222         pick = pick_define(
223                            PICK_CLOSEST, pick_scene_closest,
224                            PICK_DRAW, geom_draw_directed,
225                            PICK_FUNC, pick_scene_pwr,
226                            PICK_NAME, "pairs",
227                            NULL);
228         return (pick);
229 }
230 
231 Tv_pick         scene_direct(void)
232 {
233         Tv_pick         pick = {Tv_pick_id};
234 
235         pick = pick_define(
236                            PICK_CLOSEST, directed_scene_closest,
237                            PICK_DRAW, directed_line3_draw,
238                            PICK_FUNC, pick_direct,
239                            PICK_NAME, "direct",
240                            NULL);
241         return (pick);
242 }
243 
244 static void    *pick_model_closest(Tv * tv, Ipos pos, int *type)
245 {
246         void           *geom;
247         *type = 0;
248         geom = tv_geom_list_pick_closest(tv, pos, model_get(), type);
249         geom_format(geom, *type);
250         return (geom);
251 }
252 
253 static void     pick_focus(Tv * tv, List * picklist)
254 {
255         focus_set(list_copy(picklist, (void *(*) ()) NULL, NULL));
256 }
257 
258 static void     pick_group(Tv * tv, List * picklist)
259 {
260         group_set(list_copy(picklist, (void *(*) ()) NULL, NULL));
261 }
262 
263 static void     pick_model_delete(Tv * tv, List * picklist)
264 {
265         List           *p;
266         List           *domain = model_get();
267 
268         for (p = picklist; p != NULL; p = p->next)
269                 domain = list_rm_ref(domain, p->to, (void (*) ()) NULL);
270 
271         model_reset(domain);
272 }
273 
274 static void     pick_model_choose(Tv * tv, List * picklist)
275 {
276         List           *p1;
277         List           *p2;
278         List           *domain = model_get();
279         Bool            delete;
280 
281         for (p1 = domain; p1 != NULL; p1 = p1->next)
282         {
283                 delete = true;
284                 for (p2 = picklist; p2 != NULL; p2 = p2->next)
285                         if (p1->to == p2->to)
286                                 delete = false;
287                 if (delete)
288                         domain = list_rm_el(domain, p1, (void (*) ()) NULL);
289         }
290 
291         model_reset(domain);
292 }
293 
294 static void     pick_model_matches(Tv * tv, List * picklist)
295 {
296         void           *geom;
297         List           *list = scene_get();
298         List           *lptr;
299         Tv             *tvs;
300         Tv             *scene_tv();
301         int             type;
302 
303         if (picklist == NULL)
304                 return;
305 
306         geom = picklist->to;
307         type = picklist->type;
308 
309         list = smm_good_matches(geom, type, list);
310 
311         tv_repaint(tv);
312         tv_save_draw(tv);
313         tv_set_color(tv, blue);
314         geom_draw_directed(tv, geom, type, POSITIVE);
315         tv_reset_draw(tv);
316         tvs = scene_tv();
317         tv_repaint(tvs);
318         tv_save_draw(tvs);
319         tv_set_color(tvs, blue);
320         for (lptr = list; lptr != NULL; lptr = lptr->next)
321         {
322                 Match          *m = (Match *) lptr->to;
323 
324                 geom_draw_directed(tvs, m->to2, m->type, POSITIVE);
325         }
326         tv_reset_draw(tvs);
327         list_rm(list, match_free);
328 }
329 
330 Tv_pick         model_matches(void)
331 {
332         Tv_pick         pick = {Tv_pick_id};
333 
334         pick = pick_define(
335                            PICK_CLOSEST, pick_model_closest,
336                            PICK_DRAW, geom_draw_directed,
337                            PICK_FUNC, pick_model_matches,
338                            PICK_NAME, "matches",
339                            NULL);
340         return (pick);
341 }
342 
343 Tv_pick         model_delete(void)
344 {
345         Tv_pick         pick = {Tv_pick_id};
346 
347         pick = pick_define(
348                            PICK_CLOSEST, pick_model_closest,
349                            PICK_DRAW, geom_draw_directed,
350                            PICK_FUNC, pick_model_delete,
351                            PICK_NAME, "delete",
352                            NULL);
353         return (pick);
354 }
355 
356 Tv_pick         model_choose(void)
357 {
358         Tv_pick         pick = {Tv_pick_id};
359 
360         pick = pick_define(
361                            PICK_CLOSEST, pick_model_closest,
362                            PICK_DRAW, geom_draw_directed,
363                            PICK_FUNC, pick_model_choose,
364                            PICK_NAME, "choose",
365                            NULL);
366         return (pick);
367 }
368 
369 Tv_pick         model_focus(void)
370 {
371         Tv_pick         pick = {Tv_pick_id};
372 
373         pick = pick_define(
374                            PICK_CLOSEST, pick_model_closest,
375                            PICK_DRAW, geom_draw_directed,
376                            PICK_FUNC, pick_focus,
377                            PICK_NAME, "focus",
378                            NULL);
379         return (pick);
380 }
381 
382 Tv_pick         model_group(void)
383 {
384         Tv_pick         pick = {Tv_pick_id};
385 
386         pick = pick_define(
387                            PICK_CLOSEST, pick_model_closest,
388                            PICK_DRAW, geom_draw_directed,
389                            PICK_FUNC, pick_group,
390                            PICK_NAME, "group",
391                            NULL);
392         return (pick);
393 }
394 
395 Tv_pick         model_direct(void)
396 {
397         Tv_pick         pick = {Tv_pick_id};
398 
399         pick = pick_define(
400                            PICK_CLOSEST, directed_model_closest,
401                            PICK_DRAW, directed_line3_draw,
402                            PICK_FUNC, pick_direct,
403                            PICK_NAME, "direct",
404                            NULL);
405         return (pick);
406 }
407 

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