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

Linux Cross Reference
Tina4/src/tools/edge/order_mouse.c

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

  1 /**@(#)
  2 **/
  3 #include <tina/sys.h>
  4 #include <tina/sysfuncs.h>
  5 #include <tina/math.h>
  6 #include <tina/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 #include <tina/tv.h>
 10 #include <tina/tvfuncs.h>
 11 #include <tina/toolsfuncs.h>
 12 
 13 
 14 static Parcam *pcam;
 15 static Vec2 left1 = {Vec2_id};
 16 static Vec2 left2 = {Vec2_id};
 17 static Vec2 right1 = {Vec2_id};
 18 static Vec2 right2 = {Vec2_id};
 19 static int raster;
 20 static Tv *tvl;
 21 static Tv *tvr;
 22 
 23 static  order_match(void)
 24 {
 25     stest_order_match(raster);
 26 }
 27 
 28 static void new_order(Vec2 p)
 29 {
 30     Vec2    q = {Vec2_id};
 31     Vec2    v = {Vec2_id};
 32     Imrect *im;
 33     float   width;
 34 
 35     q = p;
 36     raster = vec2_y(p);         /* the rectified y coordinate */
 37     v = vec2(1.0, 0.0);         /* along the x axis of pcam */
 38     im = left_image();
 39     width = (im == NULL) ? tvl->width : im->width;
 40     rectify_pos_and_dir(pcam->derect1, &q, &v);
 41     left1 = vec2_sum(q, vec2_times((0 - vec2_x(q)) / vec2_x(v), v));
 42     left2 = vec2_sum(q, vec2_times((width - vec2_x(q)) / vec2_x(v), v));
 43     q = p;
 44     im = right_image();
 45     v = vec2(1.0, 0.0);         /* along the x axis of pcam */
 46     width = (im == NULL) ? tvr->width : im->width;
 47     rectify_pos_and_dir(pcam->derect2, &q, &v);
 48     right1 = vec2_sum(q, vec2_times((0 - vec2_x(q)) / vec2_x(v), v));
 49     right2 = vec2_sum(q, vec2_times((width - vec2_x(q)) / vec2_x(v), v));
 50 }
 51 
 52 static void order_left_down(Tv * tv, Ipos pos)
 53 {
 54     pcam = pcam_get();
 55     tvl = tv;
 56     tvr = right_tv();
 57 
 58     if (pcam == NULL)
 59         return;
 60 
 61     new_order(rectify_pos(pcam->rect1, tv_backproj2(tv, pos)));
 62     tv_set_overlay(tvl);        /* also calls tv_save_draw */
 63     tv_set_overlay(tvr);        /* also calls tv_save_draw */
 64     tv_line2(tvl, left1, left2);
 65     tv_line2(tvr, right1, right2);
 66 }
 67 
 68 static void order_left_drag(Tv * tv, Ipos pos)
 69 {
 70     if (pcam == NULL)
 71         return;
 72 
 73     tv_line2(tvl, left1, left2);
 74     tv_line2(tvr, right1, right2);
 75     new_order(rectify_pos(pcam->rect1, tv_backproj2(tv, pos)));
 76     tv_line2(tvl, left1, left2);
 77     tv_line2(tvr, right1, right2);
 78 }
 79 
 80 static void order_left_up(Tv * tv, Ipos pos)
 81 {
 82     if (pcam == NULL)
 83         return;
 84 
 85     tv_line2(tvl, left1, left2);
 86     tv_line2(tvr, right1, right2);
 87     new_order(rectify_pos(pcam->rect1, tv_backproj2(tv, pos)));
 88     tv_reset_draw(tvl);
 89     tv_reset_draw(tvr);
 90     tv_set_color(tvl, cyan);
 91     tv_set_color(tvr, cyan);
 92     tv_line2(tvl, left1, left2);
 93     tv_line2(tvr, right1, right2);
 94 }
 95 
 96 static void order_right_down(Tv * tv, Ipos pos)
 97 {
 98     pcam = pcam_get();
 99     tvl = left_tv();
100     tvr = tv;
101 
102     if (pcam == NULL)
103         return;
104 
105     new_order(rectify_pos(pcam->rect2, tv_backproj2(tv, pos)));
106     tv_set_overlay(tvl);        /* also calls tv_save_draw */
107     tv_set_overlay(tvr);        /* also calls tv_save_draw */
108     tv_line2(tvl, left1, left2);
109     tv_line2(tvr, right1, right2);
110 }
111 
112 static void order_right_drag(Tv * tv, Ipos pos)
113 {
114     if (pcam == NULL)
115         return;
116 
117     tv_line2(tvl, left1, left2);
118     tv_line2(tvr, right1, right2);
119     new_order(rectify_pos(pcam->rect2, tv_backproj2(tv, pos)));
120     tv_line2(tvl, left1, left2);
121     tv_line2(tvr, right1, right2);
122 }
123 
124 static void order_right_up(Tv * tv, Ipos pos)
125 {
126     if (pcam == NULL)
127         return;
128 
129     tv_line2(tvl, left1, left2);
130     tv_line2(tvr, right1, right2);
131     new_order(rectify_pos(pcam->rect2, tv_backproj2(tv, pos)));
132     tv_reset_draw(tvl);
133     tv_reset_draw(tvr);
134     tv_set_color(tvl, cyan);
135     tv_set_color(tvr, cyan);
136     tv_line2(tvl, left1, left2);
137     tv_line2(tvr, right1, right2);
138 }
139 
140 Tv_mouse left_order_mouse(void)
141 {
142     return (mouse_define(LEFT_DOWN, order_left_down,
143                          LEFT_DRAG, order_left_drag,
144                          LEFT_UP, order_left_up,
145                          MIDDLE_UP, order_match, NULL));
146 }
147 
148 Tv_mouse right_order_mouse(void)
149 {
150     return (mouse_define(LEFT_DOWN, order_right_down,
151                          LEFT_DRAG, order_right_drag,
152                          LEFT_UP, order_right_up,
153                          MIDDLE_UP, order_match, NULL));
154 }
155 

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