Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 5243) +++ trunk/src/crosshair.c (revision 5244) @@ -42,6 +42,7 @@ #include "vtonpoint.h" #include "find.h" #include "undo.h" +#include "event.h" #include "action_helper.h" #include "obj_line_draw.h" @@ -62,7 +63,6 @@ static void XORDrawElement(pcb_element_t *, pcb_coord_t, pcb_coord_t); static void XORDrawBuffer(pcb_buffer_t *); static void XORDrawInsertPointObject(void); -static void XORDrawAttachedLine(pcb_coord_t, pcb_coord_t, pcb_coord_t, pcb_coord_t, pcb_coord_t); static void XORDrawAttachedArc(pcb_coord_t); static void thindraw_moved_pv(pcb_pin_t * pv, pcb_coord_t x, pcb_coord_t y) @@ -186,7 +186,7 @@ /*----------------------------------------------------------- * Draws the outline of a line */ -static void XORDrawAttachedLine(pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, pcb_coord_t thick) +void XORDrawAttachedLine(pcb_coord_t x1, pcb_coord_t y1, pcb_coord_t x2, pcb_coord_t y2, pcb_coord_t thick) { pcb_coord_t dx, dy, ox, oy; double h; @@ -360,8 +360,6 @@ */ static void XORDrawMoveOrCopy(void) { - pcb_rubberband_t *ptr; - pcb_cardinal_t i; pcb_coord_t dx = pcb_crosshair.X - pcb_crosshair.AttachedObject.X, dy = pcb_crosshair.Y - pcb_crosshair.AttachedObject.Y; switch (pcb_crosshair.AttachedObject.Type) { @@ -457,34 +455,7 @@ break; } - /* draw the attached rubberband lines too */ - i = pcb_crosshair.AttachedObject.RubberbandN; - ptr = pcb_crosshair.AttachedObject.Rubberband; - while (i) { - pcb_point_t *point1, *point2; - - if (PCB_FLAG_TEST(PCB_FLAG_VIA, ptr->Line)) { - /* this is a rat going to a polygon. do not draw for rubberband */ ; - } - else if (PCB_FLAG_TEST(PCB_FLAG_RUBBEREND, ptr->Line)) { - /* 'point1' is always the fix-point */ - if (ptr->MovedPoint == &ptr->Line->Point1) { - point1 = &ptr->Line->Point2; - point2 = &ptr->Line->Point1; - } - else { - point1 = &ptr->Line->Point1; - point2 = &ptr->Line->Point2; - } - XORDrawAttachedLine(point1->X, point1->Y, point2->X + dx, point2->Y + dy, ptr->Line->Thickness); - } - else if (ptr->MovedPoint == &ptr->Line->Point1) - XORDrawAttachedLine(ptr->Line->Point1.X + dx, - ptr->Line->Point1.Y + dy, ptr->Line->Point2.X + dx, ptr->Line->Point2.Y + dy, ptr->Line->Thickness); - - ptr++; - i--; - } + pcb_event(PCB_EVENT_RUBBER_MOVE_DRAW, "cc", dx, dy); } /* --------------------------------------------------------------------------- Index: trunk/src/crosshair.h =================================================================== --- trunk/src/crosshair.h (revision 5243) +++ trunk/src/crosshair.h (revision 5244) @@ -124,4 +124,8 @@ void pcb_crosshair_set_mode(int Mode); void pcb_crosshair_set_local_ref(pcb_coord_t X, pcb_coord_t Y, pcb_bool Showing); + +/*** utility for plugins ***/ +void XORDrawAttachedLine(pcb_coord_t, pcb_coord_t, pcb_coord_t, pcb_coord_t, pcb_coord_t); + #endif Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 5243) +++ trunk/src/event.h (revision 5244) @@ -36,6 +36,7 @@ PCB_EVENT_RUBBER_RESET, /* rubber band: reset attached */ PCB_EVENT_RUBBER_REMOVE_ELEMENT, /* rubber band: removed an element with rubber bands attached */ PCB_EVENT_RUBBER_MOVE, /* rubber band: object moved */ + PCB_EVENT_RUBBER_MOVE_DRAW, /* rubber band: draw crosshiar-attached rubber band objects after a move or copy */ PCB_EVENT_last /* not a real event */ } pcb_event_id_t; Index: trunk/src/rubberband.c =================================================================== --- trunk/src/rubberband.c (revision 5243) +++ trunk/src/rubberband.c (revision 5244) @@ -584,6 +584,44 @@ } } +static void rbe_draw(void *user_data, int argc, pcb_event_arg_t argv[]) +{ + pcb_rubberband_t *ptr; + pcb_cardinal_t i; + pcb_coord_t dx = argv[1].d.c, dy = argv[2].d.c; + + + /* draw the attached rubberband lines too */ + i = pcb_crosshair.AttachedObject.RubberbandN; + ptr = pcb_crosshair.AttachedObject.Rubberband; + while (i) { + pcb_point_t *point1, *point2; + + if (PCB_FLAG_TEST(PCB_FLAG_VIA, ptr->Line)) { + /* this is a rat going to a polygon. do not draw for rubberband */ ; + } + else if (PCB_FLAG_TEST(PCB_FLAG_RUBBEREND, ptr->Line)) { + /* 'point1' is always the fix-point */ + if (ptr->MovedPoint == &ptr->Line->Point1) { + point1 = &ptr->Line->Point2; + point2 = &ptr->Line->Point1; + } + else { + point1 = &ptr->Line->Point1; + point2 = &ptr->Line->Point2; + } + XORDrawAttachedLine(point1->X, point1->Y, point2->X + dx, point2->Y + dy, ptr->Line->Thickness); + } + else if (ptr->MovedPoint == &ptr->Line->Point1) + XORDrawAttachedLine(ptr->Line->Point1.X + dx, + ptr->Line->Point1.Y + dy, ptr->Line->Point2.X + dx, ptr->Line->Point2.Y + dy, ptr->Line->Thickness); + + ptr++; + i--; + } + +} + static const char *rubber_cookie = "old rubberband"; void pcb_rubberband_init(void) @@ -592,4 +630,5 @@ pcb_event_bind(PCB_EVENT_RUBBER_RESET, rbe_reset, ctx, rubber_cookie); pcb_event_bind(PCB_EVENT_RUBBER_REMOVE_ELEMENT, rbe_remove_element, 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); }