6 #include "libgeda_priv.h"
8 /* Omit TEXT objects as that requires fonts. */
9 char const *grips_test_data
[] = {
11 "N 45800 47300 46400 47300 4",
12 "L 46500 46600 46500 47200 3 0 0 0 -1 -1",
13 "U 46400 46500 45800 46500 10 0",
14 "P 45700 46600 45700 47200 1 0 0",
17 "V 46100 46900 300 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1",
18 "A 46100 46900 200 135 225 3 0 0 0 -1 -1",
19 "B 45500 46300 1100 1700 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1",
20 "H 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1 7",
31 const GRIP all_grips
[] = {
32 { .x
= 45800, .y
= 47300, .whichone
= GRIP_1
},
33 { .x
= 46400, .y
= 47300, .whichone
= GRIP_2
},
34 { .x
= 46500, .y
= 46600, .whichone
= GRIP_1
},
35 { .x
= 46500, .y
= 47200, .whichone
= GRIP_2
},
36 { .x
= 46400, .y
= 46500, .whichone
= GRIP_1
},
37 { .x
= 45800, .y
= 46500, .whichone
= GRIP_2
},
38 { .x
= 45700, .y
= 46600, .whichone
= GRIP_1
},
39 { .x
= 45700, .y
= 47200, .whichone
= GRIP_2
},
40 { .x
= 46100, .y
= 46900, .whichone
= GRIP_CIRCLE_CENTER
},
41 { .x
= 46400, .y
= 46600, .whichone
= GRIP_CIRCLE_RADIUS
},
42 { .x
= 45800, .y
= 46900, .whichone
= GRIP_CIRCLE_RADIUS_LEFT
},
43 { .x
= 46400, .y
= 46900, .whichone
= GRIP_CIRCLE_RADIUS_RIGHT
},
44 { .x
= 46100, .y
= 47200, .whichone
= GRIP_CIRCLE_RADIUS_TOP
},
45 { .x
= 46100, .y
= 46600, .whichone
= GRIP_CIRCLE_RADIUS_BOTTOM
},
46 { .x
= 46100, .y
= 46900, .whichone
= GRIP_ARC_CENTER
},
47 { .x
= 46100, .y
= 46900, .whichone
= GRIP_ARC_RADIUS
},
48 { .x
= 45958, .y
= 47041, .whichone
= GRIP_START_ANGLE
},
49 { .x
= 46300, .y
= 46900, .whichone
= GRIP_END_ANGLE
},
50 { .x
= 45500, .y
= 48000, .whichone
= GRIP_UPPER_LEFT
},
51 { .x
= 46600, .y
= 46300, .whichone
= GRIP_LOWER_RIGHT
},
52 { .x
= 46600, .y
= 48000, .whichone
= GRIP_UPPER_RIGHT
},
53 { .x
= 45500, .y
= 46300, .whichone
= GRIP_LOWER_LEFT
},
54 { .x
= 45800, .y
= 47400, .whichone
= GRIP_FIRST_OPAQUE
+ 0*3 + 2 },
55 { .x
= 45800, .y
= 47500, .whichone
= GRIP_FIRST_OPAQUE
+ 1*3 + 2 },
56 { .x
= 45900, .y
= 47600, .whichone
= GRIP_FIRST_OPAQUE
+ 2*3 + 2 },
57 { .x
= 46200, .y
= 47600, .whichone
= GRIP_FIRST_OPAQUE
+ 3*3 + 2 },
58 { .x
= 46300, .y
= 47700, .whichone
= GRIP_FIRST_OPAQUE
+ 4*3 + 2 },
59 { .x
= 46300, .y
= 47800, .whichone
= GRIP_FIRST_OPAQUE
+ 5*3 + 2 },
60 { .x
= 0, .y
= 0, .whichone
= GRIP_NONE
} /* Sentinel. */
63 static enum visit_result
update_object(OBJECT
*o
, void *userdata
)
65 PAGE
*page
= userdata
;
67 /* This would also be a place to emit page signals. */
68 s_conn_update_object(page
, o
);
73 static enum visit_result
get_grip(OBJECT
*o
, void *userdata
)
77 *l
= s_basic_get_all_grips(o
, *l
);
95 toplevel
= s_toplevel_new();
96 page
= s_page_new(toplevel
, "test");
97 s_toplevel_goto_page(toplevel
, page
);
99 buf
= g_strjoinv("\n", grips_test_data
);
100 o_read_buffer(toplevel
, toplevel
->page_current
->object_tail
,
101 buf
, strlen(buf
), "test");
104 s_visit_page(page
, &update_object
, page
, VISIT_LINEAR
, 1);
105 s_visit_page(page
, &get_grip
, &grips
, VISIT_LINEAR
, 1);
107 grips
= g_list_reverse(grips
);
109 for (cursor
= grips
, i
= 0; cursor
; cursor
= cursor
->next
, i
++) {
111 if (all_grips
[i
].whichone
== GRIP_NONE
) {
112 /* More grips than expected! */
116 if (all_grips
[i
].whichone
!= g
->whichone
||
117 all_grips
[i
].x
!= g
->x
||
118 all_grips
[i
].y
!= g
->y
) {
119 /* Grip data is wrong. */
124 if (all_grips
[i
].whichone
!= GRIP_NONE
) {
125 /* Not enough grips from the objects. */