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

Linux Cross Reference
Tina6/tina-tools/tinatool/tlvision/tlvisSmm_mouse.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_mouse.c,v $
 37  * Date    :  $Date: 2003/10/01 16:02:47 $
 38  * Version :  $Revision: 1.2 $
 39  * CVS Id  :  $Id: tlvisSmm_mouse.c,v 1.2 2003/10/01 16:02:47 tony Exp $
 40  *
 41  * Notes :
 42  *
 43  *
 44  *
 45  *********
 46 */
 47 
 48 #include "tlvisSmm_mouse.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/geom_LinePro.h>
 62 #include <tina/geometry/geom_LineDef.h>
 63 #include <tina/geometry/geom_GenPro.h>
 64 #include <tina/geometry/geom_GenDef.h>
 65 #include <tina/vision/visDef.h>
 66 #include <tina/vision/visPro.h>
 67 
 68 #include <tinatool/wdgts/wdgtsDef.h>
 69 #include <tinatool/wdgts/wdgtsPro.h>
 70 #include <tinatool/gphx/gphxDef.h>
 71 #include <tinatool/gphx/gphxPro.h>
 72 #include <tinatool/draw/drawDef.h>
 73 #include <tinatool/draw/drawPro.h>
 74 
 75 #include "tlvisSmm_matcher.h"
 76 #include "tlvisSmm_view.h"
 77 
 78 static void    *model_picked = NULL;
 79 static int      model_type;
 80 static void    *scene_picked = NULL;
 81 static int      scene_type;
 82 
 83 void            directed_line3_draw(Tv * tv, void *picked, int type)
 84 {
 85         geom_draw_directed(tv, picked, LINE3, type);
 86 }
 87 
 88 void           *directed_model_closest(Tv * tv, Ipos pos, int *type)
 89 {
 90         Line3          *line;
 91         List           *list;
 92         List           *model_get();
 93         Ipos            tv_proj3();
 94 
 95         list = model_get();
 96 
 97         *type = LINE3;
 98         line = (Line3 *) tv_geom_list_pick_closest(tv, pos, list, type);
 99         if (line != NULL)
100         {
101                 Ipos            p1 = {Ipos_id};
102                 Ipos            p2 = {Ipos_id};
103 
104                 p1 = tv_proj3(tv, line->p1);
105                 p2 = tv_proj3(tv, line->p2);
106 
107                 if (ipos_sqrmod(ipos_diff(pos, p2)) < ipos_sqrmod(ipos_diff(pos, p1)))
108                         *type = POSITIVE;
109                 else
110                         *type = NEGATIVE;
111         }
112         return (line);
113 }
114 
115 void           *directed_scene_closest(Tv * tv, Ipos pos, int *type)
116 {
117         Line3          *line;
118         List           *list;
119         List           *scene_get();
120         Ipos            tv_proj3();
121 
122         list = scene_get();
123 
124         *type = LINE3;
125         line = (Line3 *) tv_geom_list_pick_closest(tv, pos, list, type);
126         if (line != NULL)
127         {
128                 Ipos            p1 = {Ipos_id};
129                 Ipos            p2 = {Ipos_id};
130 
131                 p1 = tv_proj3(tv, line->p1);
132                 p2 = tv_proj3(tv, line->p2);
133 
134                 if (ipos_sqrmod(ipos_diff(pos, p2)) < ipos_sqrmod(ipos_diff(pos, p1)))
135                         *type = POSITIVE;
136                 else
137                         *type = NEGATIVE;
138         }
139         return (line);
140 }
141 
142 static   void       model_left_down(Tv * tv, Ipos pos)
143 {
144         model_picked = directed_model_closest(tv, pos, &model_type);
145         tv_set_overlay(tv);
146         directed_line3_draw(tv, model_picked, model_type);
147 }
148 
149 static   void       model_left_drag(Tv * tv, Ipos pos)
150 {
151         directed_line3_draw(tv, model_picked, model_type);
152         model_picked = directed_model_closest(tv, pos, &model_type);
153         directed_line3_draw(tv, model_picked, model_type);
154 }
155 
156 /* ARGSUSED quieten lint */
157 static   void       model_left_up(Tv * tv, Ipos pos)
158 
159 /* unused */
160 {
161         tv_reset_draw(tv);
162         tv_set_color(tv, green);
163         tv_save_draw(tv);
164         directed_line3_draw(tv, model_picked, model_type);
165         geom_format(model_picked, model_type);
166         tv_reset_draw(tv);
167         if (model_type == NEGATIVE)
168                 model_picked = line3_negative((Line3 *) model_picked);
169         else
170                 model_picked = line3_copy((Line3 *) model_picked);
171         if (model_picked && scene_picked)
172         {
173                 matcher_add_match(model_picked, scene_picked, LINE3);
174                 model_picked = scene_picked = NULL;
175                 tv_repaint((Tv *) model_tv());
176                 tv_repaint((Tv *) scene_tv());
177                 matches_draw();
178         }
179 }
180 
181 static  void        scene_left_down(Tv * tv, Ipos pos)
182 {
183         scene_picked = directed_scene_closest(tv, pos, &scene_type);
184         tv_set_overlay(tv);
185         directed_line3_draw(tv, scene_picked, scene_type);
186 }
187 
188 static  void        scene_left_drag(Tv * tv, Ipos pos)
189 {
190         directed_line3_draw(tv, scene_picked, scene_type);
191         scene_picked = directed_scene_closest(tv, pos, &scene_type);
192         directed_line3_draw(tv, scene_picked, scene_type);
193 }
194 
195 /* ARGSUSED quieten lint */
196 static   void       scene_left_up(Tv * tv, Ipos pos)
197 
198 /* unused */
199 {
200         tv_reset_draw(tv);
201         tv_save_draw(tv);
202         tv_set_color(tv, green);
203         directed_line3_draw(tv, scene_picked, scene_type);
204         tv_reset_draw(tv);
205         if (scene_type == NEGATIVE)
206                 scene_picked = line3_negative((Line3 *) scene_picked);
207         else
208                 scene_picked = line3_copy((Line3 *) scene_picked);
209         if (model_picked && scene_picked)
210         {
211                 matcher_add_match(model_picked, scene_picked, LINE3);
212                 model_picked = scene_picked = NULL;
213                 tv_repaint((Tv *) model_tv());
214                 tv_repaint((Tv *) scene_tv());
215                 matches_draw();
216         }
217 }
218 
219 Tv_mouse        matcher_model_mouse(void)
220 {
221         return (mouse_define(LEFT_DOWN, model_left_down,
222                              LEFT_DRAG, model_left_drag,
223                              LEFT_UP, model_left_up, NULL));
224 }
225 
226 Tv_mouse        matcher_scene_mouse(void)
227 {
228         return (mouse_define(LEFT_DOWN, scene_left_down,
229                              LEFT_DRAG, scene_left_drag,
230                              LEFT_UP, scene_left_up, NULL));
231 }
232 

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