Index: trunk/src/event.c =================================================================== --- trunk/src/event.c (revision 23640) +++ trunk/src/event.c (revision 23641) @@ -53,7 +53,6 @@ "pcbev_new_pstk", "pcbev_busy", "pcbev_rubber_reset", - "pcbev_rubber_remove_subc", "pcbev_rubber_move", "pcbev_rubber_move_draw", "pcbev_rubber_rotate90", Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 23640) +++ trunk/src/event.h (revision 23641) @@ -54,7 +54,6 @@ PCB_EVENT_BUSY, /* called before CPU-intensive task begins */ PCB_EVENT_RUBBER_RESET, /* rubber band: reset attached */ - PCB_EVENT_RUBBER_REMOVE_SUBC, /* rubber band: removed a subc with rubber bands attached */ PCB_EVENT_RUBBER_MOVE, /* rubber band: object moved */ PCB_EVENT_RUBBER_MOVE_DRAW, /* rubber band: draw crosshair-attached rubber band objects after a move or copy */ PCB_EVENT_RUBBER_ROTATE90, /* rubber band: crosshair object rotated by 90 degrees */ Index: trunk/src/obj_rat.c =================================================================== --- trunk/src/obj_rat.c (revision 23640) +++ trunk/src/obj_rat.c (revision 23641) @@ -29,6 +29,7 @@ #include "board.h" #include "data.h" +#include "data_it.h" #include "conf_core.h" #include "hid_inlines.h" #include "undo.h" @@ -504,3 +505,31 @@ else pcb_line_invalidate_draw(NULL, (pcb_line_t *) Rat); } + +void pcb_rat_update_obj_removed(pcb_board_t *pcb, pcb_any_obj_t *obj) +{ + pcb_rat_t *rat; + gdl_iterator_t it; + + if (obj->type == PCB_OBJ_SUBC) { + pcb_subc_t *subc = (pcb_subc_t *)obj; + pcb_any_obj_t *o; + pcb_data_it_t it2; + + /* subcircuit means checking against each part object; + this is O(R*P), where R is the number of rat lines and P is the + number of subc parts - maybe an rtree based approach would be better */ + for(o = pcb_data_first(&it2, subc->data, PCB_OBJ_CLASS_REAL); o != NULL; o = pcb_data_next(&it2)) + pcb_rat_update_obj_removed(pcb, o); + return; + } + + ratlist_foreach(&pcb->Data->Rat, &it, rat) { + if ((pcb_rat_anchor_guess(rat, 0, 1) == obj) || (pcb_rat_anchor_guess(rat, 1, 1) == obj)) { + if (PCB->RatOn) + pcb_rat_invalidate_erase(rat); + pcb_undo_move_obj_to_remove(PCB_OBJ_RAT, rat, rat, rat); + } + } +} + Index: trunk/src/obj_rat.h =================================================================== --- trunk/src/obj_rat.h (revision 23640) +++ trunk/src/obj_rat.h (revision 23641) @@ -61,7 +61,10 @@ /* Call pcb_rat_anchor_guess() on all rats of data, with update=true */ void pcb_rat_all_anchor_guess(pcb_data_t *data); +/* Minimal update rats after object removal: remove connected rats */ +void pcb_rat_update_obj_removed(pcb_board_t *pcb, pcb_any_obj_t *obj); + #define PCB_RAT_LOOP(top) do { \ pcb_rat_t *line; \ gdl_iterator_t __it__; \ Index: trunk/src/tool_remove.c =================================================================== --- trunk/src/tool_remove.c (revision 23640) +++ trunk/src/tool_remove.c (revision 23641) @@ -61,13 +61,14 @@ pcb_message(PCB_MSG_WARNING, "Can not remove the subcircuit being edited in the footprint edit mode\n"); return; } - pcb_event(PCB_EVENT_RUBBER_REMOVE_SUBC, "ppp", ptr1, ptr2, ptr3); } + obj = ptr2; + pcb_rat_update_obj_removed(PCB, obj); + /* preserve original parent over the board layer pcb_search_screen operated on - this is essential for undo: it needs to put back the object to the original layer (e.g. inside a subc) instead of on the board layer */ - obj = ptr2; if (obj->parent_type == PCB_PARENT_LAYER) ptr1 = obj->parent.layer; else if (obj->parent_type == PCB_PARENT_DATA) Index: trunk/src_plugins/rubberband_orig/rubberband.c =================================================================== --- trunk/src_plugins/rubberband_orig/rubberband.c (revision 23640) +++ trunk/src_plugins/rubberband_orig/rubberband.c (revision 23641) @@ -1014,25 +1014,6 @@ rbnd->arcs.used = 0; } -static void rbe_remove_subc(void *user_data, int argc, pcb_event_arg_t argv[]) -{ - rubber_ctx_t *rbnd = user_data; - pcb_rb_line_t *ptr; - void *ptr1 = argv[1].d.p, *ptr2 = argv[2].d.p, *ptr3 = argv[3].d.p; - int i, type = PCB_OBJ_SUBC; - - rbnd->lines.used = 0; - pcb_rubber_band_lookup_rat_lines(rbnd, type, ptr1, ptr2, ptr3); - ptr = rbnd->lines.array; - for(i = 0; i < rbnd->lines.used; i++) { - if (PCB->RatOn) - pcb_rat_invalidate_erase((pcb_rat_t *) ptr->Line); - - pcb_undo_move_obj_to_remove(PCB_OBJ_RAT, ptr->Line, ptr->Line, ptr->Line); - ptr++; - } -} - static void rbe_move(void *user_data, int argc, pcb_event_arg_t argv[]) { rubber_ctx_t *rbnd = user_data; @@ -1476,7 +1457,6 @@ void *ctx = &rubber_band_state; PCB_API_CHK_VER; pcb_event_bind(PCB_EVENT_RUBBER_RESET, rbe_reset, ctx, rubber_cookie); - pcb_event_bind(PCB_EVENT_RUBBER_REMOVE_SUBC, rbe_remove_subc, ctx, rubber_cookie); pcb_event_bind(PCB_EVENT_RUBBER_MOVE, rbe_move, ctx, rubber_cookie); pcb_event_bind(PCB_EVENT_RUBBER_MOVE_DRAW, rbe_draw, ctx, rubber_cookie); pcb_event_bind(PCB_EVENT_RUBBER_ROTATE90, rbe_rotate90, ctx, rubber_cookie);