Index: trunk/src/find.h =================================================================== --- trunk/src/find.h (revision 10842) +++ trunk/src/find.h (revision 10843) @@ -31,6 +31,7 @@ #include /* needed to define 'FILE *' */ #include "config.h" +#include "obj_common.h" typedef enum { PCB_FCT_COPPER = 1, /* copper connection */ @@ -80,7 +81,7 @@ void pcb_conn_lookup_uninit(void); void pcb_component_lookup_uninit(void); void pcb_layout_lookup_uninit(void); -void pcb_rat_find_hook(int, void *, void *, void *, pcb_bool, pcb_bool); +void pcb_rat_find_hook(void *ptr1, pcb_any_obj_t *obj, void *ptr3, pcb_bool undo, pcb_bool AndRats); void pcb_save_find_flag(int); void pcb_restore_find_flag(void); int pcb_drc_all(void); Index: trunk/src/find_misc.c =================================================================== --- trunk/src/find_misc.c (revision 10842) +++ trunk/src/find_misc.c (revision 10843) @@ -329,11 +329,13 @@ * find connections for rats nesting * assumes pcb_conn_lookup_init() has already been done */ -void pcb_rat_find_hook(int type, void *ptr1, void *ptr2, void *ptr3, pcb_bool undo, pcb_bool AndRats) +void pcb_rat_find_hook(void *ptr1, pcb_any_obj_t *obj, void *ptr3, pcb_bool undo, pcb_bool AndRats) { + int type; User = undo; DumpList(); - ListStart(type, ptr1, ptr2, ptr3); + type = obj->type == PCB_OBJ_PAD ? PCB_TYPE_PAD : PCB_TYPE_PIN; + ListStart(type, ptr1, obj, ptr3); DoIt(AndRats, pcb_false); User = pcb_false; } Index: trunk/src/netlist.c =================================================================== --- trunk/src/netlist.c (revision 10842) +++ trunk/src/netlist.c (revision 10843) @@ -103,14 +103,14 @@ pcb_connection_t conn; if (!pcb_rat_seek_pad(pin, &conn, pcb_false)) return 1; - switch (conn.type) { - case PCB_TYPE_PIN: - *x = ((pcb_pin_t *) (conn.ptr2))->X; - *y = ((pcb_pin_t *) (conn.ptr2))->Y; + switch (conn.obj->type) { + case PCB_OBJ_PIN: + *x = ((pcb_pin_t *) (conn.obj))->X; + *y = ((pcb_pin_t *) (conn.obj))->Y; return 0; - case PCB_TYPE_PAD: - *x = ((pcb_pad_t *) (conn.ptr2))->Point1.X; - *y = ((pcb_pad_t *) (conn.ptr2))->Point1.Y; + case PCB_OBJ_PAD: + *x = ((pcb_pad_t *) (conn.obj))->Point1.X; + *y = ((pcb_pad_t *) (conn.obj))->Point1.Y; return 0; } return 1; Index: trunk/src/rats.c =================================================================== --- trunk/src/rats.c (revision 10842) +++ trunk/src/rats.c (revision 10843) @@ -115,9 +115,8 @@ padlist_foreach(&element->Pad, &it, pad) { if (PCB_NSTRCMP(PinNum, pad->Number) == 0 && (!Same || !PCB_FLAG_TEST(PCB_FLAG_DRC, pad))) { - conn->type = PCB_TYPE_PAD; conn->ptr1 = element; - conn->ptr2 = pad; + conn->obj = (pcb_any_obj_t *)pad; conn->group = PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, pad) ? Sgrp : Cgrp; if (PCB_FLAG_TEST(PCB_FLAG_EDGE2, pad)) { @@ -134,9 +133,8 @@ padlist_foreach(&element->Pin, &it, pin) { if (!PCB_FLAG_TEST(PCB_FLAG_HOLE, pin) && pin->Number && PCB_NSTRCMP(PinNum, pin->Number) == 0 && (!Same || !PCB_FLAG_TEST(PCB_FLAG_DRC, pin))) { - conn->type = PCB_TYPE_PIN; conn->ptr1 = element; - conn->ptr2 = pin; + conn->obj = (pcb_any_obj_t *)pin; conn->group = Sgrp; /* any layer will do */ conn->X = pin->X; conn->Y = pin->Y; @@ -231,12 +229,12 @@ PCB_ENTRY_LOOP(menu); { if (pcb_rat_seek_pad(entry, &LastPoint, pcb_false)) { - if (PCB_FLAG_TEST(PCB_FLAG_DRC, (pcb_pin_t *) LastPoint.ptr2)) + if (PCB_FLAG_TEST(PCB_FLAG_DRC, (pcb_pin_t *) LastPoint.obj)) pcb_message(PCB_MSG_ERROR, _ ("Error! Element %s pin %s appears multiple times in the netlist file.\n"), PCB_ELEM_NAME_REFDES((pcb_element_t *) LastPoint.ptr1), - (LastPoint.type == - PCB_TYPE_PIN) ? ((pcb_pin_t *) LastPoint.ptr2)->Number : ((pcb_pad_t *) LastPoint.ptr2)->Number); + (LastPoint.obj->type == + PCB_OBJ_PIN) ? ((pcb_pin_t *) LastPoint.obj)->Number : ((pcb_pad_t *) LastPoint.obj)->Number); else { connection = pcb_rat_connection_alloc(net); *connection = LastPoint; @@ -243,11 +241,11 @@ /* indicate expect net */ connection->menu = menu; /* mark as visited */ - PCB_FLAG_SET(PCB_FLAG_DRC, (pcb_pin_t *) LastPoint.ptr2); - if (LastPoint.type == PCB_TYPE_PIN) - ((pcb_pin_t *) LastPoint.ptr2)->Spare = (void *) menu; + PCB_FLAG_SET(PCB_FLAG_DRC, (pcb_pin_t *) LastPoint.obj); + if (LastPoint.obj->type == PCB_OBJ_PIN) + ((pcb_pin_t *) LastPoint.obj)->Spare = (void *) menu; else - ((pcb_pad_t *) LastPoint.ptr2)->Spare = (void *) menu; + ((pcb_pad_t *) LastPoint.obj)->Spare = (void *) menu; } } else @@ -259,11 +257,11 @@ /* indicate expect net */ connection->menu = menu; /* mark as visited */ - PCB_FLAG_SET(PCB_FLAG_DRC, (pcb_pin_t *) LastPoint.ptr2); - if (LastPoint.type == PCB_TYPE_PIN) - ((pcb_pin_t *) LastPoint.ptr2)->Spare = (void *) menu; + PCB_FLAG_SET(PCB_FLAG_DRC, (pcb_pin_t *) LastPoint.obj); + if (LastPoint.obj->type == PCB_OBJ_PIN) + ((pcb_pin_t *) LastPoint.obj)->Spare = (void *) menu; else - ((pcb_pad_t *) LastPoint.ptr2)->Spare = (void *) menu; + ((pcb_pad_t *) LastPoint.obj)->Spare = (void *) menu; } } PCB_END_LOOP; @@ -402,15 +400,15 @@ for (m = 0; Netl->NetN > 0 && m < Netl->NetN; m++) { a = &Netl->Net[m]; pcb_reset_conns(pcb_false); - pcb_rat_find_hook(a->Connection[0].type, a->Connection[0].ptr1, a->Connection[0].ptr2, a->Connection[0].ptr2, pcb_false, AndRats); + pcb_rat_find_hook(a->Connection[0].ptr1, a->Connection[0].obj, a->Connection[0].obj, pcb_false, AndRats); /* now anybody connected to the first point has PCB_FLAG_DRC set */ /* so move those to this subnet */ - PCB_FLAG_CLEAR(PCB_FLAG_DRC, (pcb_pin_t *) a->Connection[0].ptr2); + PCB_FLAG_CLEAR(PCB_FLAG_DRC, (pcb_pin_t *) a->Connection[0].obj); for (n = m + 1; n < Netl->NetN; n++) { b = &Netl->Net[n]; /* There can be only one connection in net b */ - if (PCB_FLAG_TEST(PCB_FLAG_DRC, (pcb_pin_t *) b->Connection[0].ptr2)) { - PCB_FLAG_CLEAR(PCB_FLAG_DRC, (pcb_pin_t *) b->Connection[0].ptr2); + if (PCB_FLAG_TEST(PCB_FLAG_DRC, (pcb_pin_t *) b->Connection[0].obj)) { + PCB_FLAG_CLEAR(PCB_FLAG_DRC, (pcb_pin_t *) b->Connection[0].obj); TransferNet(Netl, b, a); /* back up since new subnet is now at old index */ n--; @@ -427,17 +425,15 @@ conn = pcb_rat_connection_alloc(a); conn->X = line->Point1.X; conn->Y = line->Point1.Y; - conn->type = PCB_TYPE_LINE; conn->ptr1 = layer; - conn->ptr2 = line; + conn->obj = (pcb_any_obj_t *)line; conn->group = pcb_layer_get_group_(layer); conn->menu = NULL; /* agnostic view of where it belongs */ conn = pcb_rat_connection_alloc(a); conn->X = line->Point2.X; conn->Y = line->Point2.Y; - conn->type = PCB_TYPE_LINE; conn->ptr1 = layer; - conn->ptr2 = line; + conn->obj = (pcb_any_obj_t *)line; conn->group = pcb_layer_get_group_(layer); conn->menu = NULL; } @@ -451,9 +447,8 @@ /* make point on a vertex */ conn->X = polygon->Clipped->contours->head.point[0]; conn->Y = polygon->Clipped->contours->head.point[1]; - conn->type = PCB_TYPE_POLYGON; conn->ptr1 = layer; - conn->ptr2 = polygon; + conn->obj = (pcb_any_obj_t *)polygon; conn->group = pcb_layer_get_group_(layer); conn->menu = NULL; /* agnostic view of where it belongs */ } @@ -465,9 +460,8 @@ conn = pcb_rat_connection_alloc(a); conn->X = via->X; conn->Y = via->Y; - conn->type = PCB_TYPE_VIA; conn->ptr1 = via; - conn->ptr2 = via; + conn->obj = (pcb_any_obj_t *)via; conn->group = Sgrp; } } @@ -567,10 +561,10 @@ * not a daisy chain). Further prefer to pick an existing * via in the Net to make that connection. */ - if (conn1->type == PCB_TYPE_POLYGON && - (polygon = (pcb_polygon_t *) conn1->ptr2) && + if (conn1->obj->type == PCB_OBJ_POLYGON && + (polygon = (pcb_polygon_t *) conn1->obj) && !(distance == 0 && - firstpoint && firstpoint->type == PCB_TYPE_VIA) && pcb_poly_is_point_in_p_ignore_holes(conn2->X, conn2->Y, polygon)) { + firstpoint && firstpoint->obj->type == PCB_OBJ_VIA) && pcb_poly_is_point_in_p_ignore_holes(conn2->X, conn2->Y, polygon)) { distance = 0; firstpoint = conn2; secondpoint = conn1; @@ -577,10 +571,10 @@ theSubnet = next; havepoints = pcb_true; } - else if (conn2->type == PCB_TYPE_POLYGON && - (polygon = (pcb_polygon_t *) conn2->ptr2) && + else if (conn2->obj->type == PCB_OBJ_POLYGON && + (polygon = (pcb_polygon_t *) conn2->obj) && !(distance == 0 && - firstpoint && firstpoint->type == PCB_TYPE_VIA) && pcb_poly_is_point_in_p_ignore_holes(conn1->X, conn1->Y, polygon)) { + firstpoint && firstpoint->obj->type == PCB_OBJ_VIA) && pcb_poly_is_point_in_p_ignore_holes(conn1->X, conn1->Y, polygon)) { distance = 0; firstpoint = conn1; secondpoint = conn2; @@ -682,7 +676,7 @@ { PCB_CONNECTION_LOOP(net); { - if (!SelectedOnly || PCB_FLAG_TEST(PCB_FLAG_SELECTED, (pcb_pin_t *) connection->ptr2)) { + if (!SelectedOnly || PCB_FLAG_TEST(PCB_FLAG_SELECTED, (pcb_pin_t *) connection->obj)) { lonesome = pcb_net_new(Nets); onepin = pcb_rat_connection_alloc(lonesome); *onepin = *connection; @@ -767,7 +761,7 @@ Nets = pcb_netlist_new(&result); PCB_CONNECTION_LOOP(net); { - if (!SelectedOnly || PCB_FLAG_TEST(PCB_FLAG_SELECTED, (pcb_pin_t *) connection->ptr2)) { + if (!SelectedOnly || PCB_FLAG_TEST(PCB_FLAG_SELECTED, (pcb_pin_t *) connection->obj)) { lonesome = pcb_net_new(Nets); onepin = pcb_rat_connection_alloc(lonesome); *onepin = *connection; Index: trunk/src/rats.h =================================================================== --- trunk/src/rats.h (revision 10842) +++ trunk/src/rats.h (revision 10843) @@ -43,8 +43,8 @@ struct pcb_connection_s { /* holds a connection (rat) */ pcb_coord_t X, Y; /* coordinate of connection */ - long int type; /* type of object in ptr1 - 3 */ - void *ptr1, *ptr2; /* the object of the connection */ + void *ptr1; /* parent of ptr2??? */ + pcb_any_obj_t *obj; /* the object of the connection */ pcb_layergrp_id_t group; /* the layer group of the connection */ pcb_lib_menu_t *menu; /* the netmenu this *SHOULD* belong too */ }; Index: trunk/src/select.c =================================================================== --- trunk/src/select.c (revision 10842) +++ trunk/src/select.c (revision 10843) @@ -783,7 +783,7 @@ if (menu->Name && menu->Name[0] != '\0' && menu->Name[1] != '\0' && REGEXEC(menu->Name + 2)) { for (i = menu->EntryN, entry = menu->Entry; i; i--, entry++) if (pcb_rat_seek_pad(entry, &conn, pcb_false)) - pcb_rat_find_hook(conn.type, conn.ptr1, conn.ptr2, conn.ptr2, pcb_true, pcb_true); + pcb_rat_find_hook(conn.ptr1, conn.obj, conn.obj, pcb_true, pcb_true); } } PCB_END_LOOP; Index: trunk/src_plugins/autoplace/autoplace.c =================================================================== --- trunk/src_plugins/autoplace/autoplace.c (revision 10842) +++ trunk/src_plugins/autoplace/autoplace.c (revision 10843) @@ -152,17 +152,17 @@ for (i = 0; i < Nets->NetN; i++) { for (j = 0; j < Nets->Net[i].ConnectionN; j++) { pcb_connection_t *c = &(Nets->Net[i].Connection[j]); - switch (c->type) { - case PCB_TYPE_PAD: + switch (c->obj->type) { + case PCB_OBJ_PAD: c->group = PCB_FLAG_TEST(PCB_FLAG_ONSOLDER, (pcb_element_t *) c->ptr1) ? SLayer : CLayer; - c->X = ((pcb_pad_t *) c->ptr2)->Point1.X; - c->Y = ((pcb_pad_t *) c->ptr2)->Point1.Y; + c->X = ((pcb_pad_t *) c->obj)->Point1.X; + c->Y = ((pcb_pad_t *) c->obj)->Point1.Y; break; - case PCB_TYPE_PIN: + case PCB_OBJ_PIN: c->group = SLayer; /* any layer will do */ - c->X = ((pcb_pin_t *) c->ptr2)->X; - c->Y = ((pcb_pin_t *) c->ptr2)->Y; + c->X = ((pcb_pin_t *) c->obj)->X; + c->Y = ((pcb_pin_t *) c->obj)->Y; break; default: pcb_message(PCB_MSG_ERROR, "Odd connection type encountered in " "UpdateXY"); @@ -323,7 +323,7 @@ minx = maxx = n->Connection[0].X; miny = maxy = n->Connection[0].Y; thegroup = n->Connection[0].group; - allpads = (n->Connection[0].type == PCB_TYPE_PAD); + allpads = (n->Connection[0].obj->type == PCB_OBJ_PAD); allsameside = pcb_true; for (j = 1; j < n->ConnectionN; j++) { pcb_connection_t *c = &(n->Connection[j]); @@ -331,7 +331,7 @@ PCB_MAKE_MAX(maxx, c->X); PCB_MAKE_MIN(miny, c->Y); PCB_MAKE_MAX(maxy, c->Y); - if (c->type != PCB_TYPE_PAD) + if (c->obj->type != PCB_OBJ_PAD) allpads = pcb_false; if (c->group != thegroup) allsameside = pcb_false; Index: trunk/src_plugins/autoroute/autoroute.c =================================================================== --- trunk/src_plugins/autoroute/autoroute.c (revision 10842) +++ trunk/src_plugins/autoroute/autoroute.c (revision 10843) @@ -957,9 +957,9 @@ PCB_CONNECTION_LOOP(net); { routebox_t *rb = NULL; - PCB_FLAG_SET(PCB_FLAG_DRC, (pcb_pin_t *) connection->ptr2); - if (connection->type == PCB_TYPE_LINE) { - pcb_line_t *line = (pcb_line_t *) connection->ptr2; + PCB_FLAG_SET(PCB_FLAG_DRC, (pcb_pin_t *) connection->obj); + if (connection->obj->type == PCB_OBJ_LINE) { + pcb_line_t *line = (pcb_line_t *) connection->obj; /* lines are listed at each end, so skip one */ /* this should probably by a macro named "BUMP_LOOP" */ @@ -997,21 +997,21 @@ } } else - switch (connection->type) { - case PCB_TYPE_PAD: - rb = AddPad(layergroupboxes, (pcb_element_t *) connection->ptr1, (pcb_pad_t *) connection->ptr2, rd->styles[j]); + switch (connection->obj->type) { + case PCB_OBJ_PAD: + rb = AddPad(layergroupboxes, (pcb_element_t *) connection->ptr1, (pcb_pad_t *) connection->obj, rd->styles[j]); break; - case PCB_TYPE_PIN: - rb = AddPin(layergroupboxes, (pcb_pin_t *) connection->ptr2, pcb_false, rd->styles[j]); + case PCB_OBJ_PIN: + rb = AddPin(layergroupboxes, (pcb_pin_t *) connection->obj, pcb_false, rd->styles[j]); break; - case PCB_TYPE_VIA: - rb = AddPin(layergroupboxes, (pcb_pin_t *) connection->ptr2, pcb_true, rd->styles[j]); + case PCB_OBJ_VIA: + rb = AddPin(layergroupboxes, (pcb_pin_t *) connection->obj, pcb_true, rd->styles[j]); break; - case PCB_TYPE_POLYGON: + case PCB_OBJ_POLYGON: rb = AddPolygon(layergroupboxes, pcb_layer_id(PCB->Data, (pcb_layer_t *) connection->ptr1), - (struct pcb_polygon_s *) connection->ptr2, rd->styles[j]); + (struct pcb_polygon_s *) connection->obj, rd->styles[j]); break; } assert(rb); Index: trunk/src_plugins/hid_lesstif/netlist.c =================================================================== --- trunk/src_plugins/hid_lesstif/netlist.c (revision 10842) +++ trunk/src_plugins/hid_lesstif/netlist.c (revision 10843) @@ -119,7 +119,7 @@ for (i = net->EntryN, entry = net->Entry; i; i--, entry++) if (pcb_rat_seek_pad(entry, &conn, pcb_false)) - pcb_rat_find_hook(conn.type, conn.ptr1, conn.ptr2, conn.ptr2, pcb_true, pcb_true); + pcb_rat_find_hook(conn.ptr1, conn.obj, conn.obj, pcb_true, pcb_true); pcb_select_connection(PCB, select_flag); pcb_reset_conns(pcb_false); Index: trunk/src_plugins/lib_gtk_common/dlg_netlist.c =================================================================== --- trunk/src_plugins/lib_gtk_common/dlg_netlist.c (revision 10842) +++ trunk/src_plugins/lib_gtk_common/dlg_netlist.c (revision 10843) @@ -211,13 +211,16 @@ static void toggle_pin_selected(pcb_lib_entry_t * entry) { pcb_connection_t conn; + int type; if (!pcb_rat_seek_pad(entry, &conn, pcb_false)) return; - pcb_undo_add_obj_to_flag(conn.type, conn.ptr1, conn.ptr2, conn.ptr2); - PCB_FLAG_TOGGLE(PCB_FLAG_SELECTED, (pcb_any_obj_t *) conn.ptr2); - pcb_draw_obj(conn.type, conn.ptr1, conn.ptr2); + type = conn.obj->type == PCB_OBJ_PAD ? PCB_TYPE_PAD : PCB_TYPE_PIN; + + pcb_undo_add_obj_to_flag(type, conn.ptr1, conn.obj, conn.obj); + PCB_FLAG_TOGGLE(PCB_FLAG_SELECTED, conn.obj); + pcb_draw_obj(type, conn.ptr1, conn.obj); } /** Callback when the user clicks on a PCB node in the right node treeview. @@ -276,10 +279,10 @@ /* And lead the user to the location */ if (pcb_rat_seek_pad(node, &conn, pcb_false)) - switch (conn.type) { - case PCB_TYPE_PIN: + switch (conn.obj->type) { + case PCB_OBJ_PIN: { - pcb_pin_t *pin = (pcb_pin_t *) conn.ptr2; + pcb_pin_t *pin = (pcb_pin_t *) conn.obj; x = pin->X; y = pin->Y; pcb_gui->set_crosshair(x, y, 0); @@ -286,9 +289,9 @@ com->lead_user_to_location(x, y); break; } - case PCB_TYPE_PAD: + case PCB_OBJ_PAD: { - pcb_pad_t *pad = (pcb_pad_t *) conn.ptr2; + pcb_pad_t *pad = (pcb_pad_t *) conn.obj; x = pad->Point1.X + (pad->Point2.X - pad->Point1.X) / 2; y = pad->Point1.Y + (pad->Point2.Y - pad->Point2.Y) / 2; pcb_gui->set_crosshair(x, y, 0); @@ -515,7 +518,7 @@ for (i = selected_net->EntryN, entry = selected_net->Entry; i; i--, entry++) if (pcb_rat_seek_pad(entry, &conn, pcb_false)) - pcb_rat_find_hook(conn.type, conn.ptr1, conn.ptr2, conn.ptr2, pcb_true, pcb_true); + pcb_rat_find_hook(conn.ptr1, conn.obj, conn.obj, pcb_true, pcb_true); pcb_select_connection(PCB, select_flag); pcb_reset_conns(pcb_false); Index: trunk/src_plugins/report/report.c =================================================================== --- trunk/src_plugins/report/report.c (revision 10842) +++ trunk/src_plugins/report/report.c (revision 10843) @@ -766,15 +766,15 @@ } if (pcb_rat_seek_pad(net->Entry, &conn, pcb_false)) { - switch (conn.type) { - case PCB_TYPE_PIN: - x = ((pcb_pin_t *) (conn.ptr2))->X; - y = ((pcb_pin_t *) (conn.ptr2))->Y; + switch (conn.obj->type) { + case PCB_OBJ_PIN: + x = ((pcb_pin_t *) (conn.obj))->X; + y = ((pcb_pin_t *) (conn.obj))->Y; net_found = 1; break; - case PCB_TYPE_PAD: - x = ((pcb_pad_t *) (conn.ptr2))->Point1.X; - y = ((pcb_pad_t *) (conn.ptr2))->Point1.Y; + case PCB_OBJ_PAD: + x = ((pcb_pad_t *) (conn.obj))->Point1.X; + y = ((pcb_pad_t *) (conn.obj))->Point1.Y; net_found = 1; break; } Index: trunk/src_plugins/smartdisperse/smartdisperse.c =================================================================== --- trunk/src_plugins/smartdisperse/smartdisperse.c (revision 10842) +++ trunk/src_plugins/smartdisperse/smartdisperse.c (revision 10843) @@ -101,7 +101,7 @@ static pcb_coord_t padDX(pcb_connection_t * conn) { pcb_element_t *element = (pcb_element_t *) conn->ptr1; - pcb_any_line_t *line = (pcb_any_line_t *) conn->ptr2; + pcb_any_line_t *line = (pcb_any_line_t *) conn->obj; return line->BoundingBox.X1 - (element->BoundingBox.X1 + element->BoundingBox.X2) / 2; } @@ -125,7 +125,7 @@ /* ewww, these are actually arrays */ #define ELEMENT_N(DATA,ELT) ((ELT) - (DATA)->Element) #define VISITED(ELT) (visited[ELEMENT_N(PCB->Data, (ELT))]) -#define IS_ELEMENT(CONN) ((CONN)->type == PCB_TYPE_PAD || (CONN)->type == PCB_TYPE_PIN) +#define IS_ELEMENT(CONN) ((CONN)->obj->type == PCB_OBJ_PAD || (CONN)->obj->type == PCB_OBJ_PIN) #define ARG(n) (argc > (n) ? argv[n] : 0)