Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 7679) +++ trunk/src/crosshair.c (revision 7680) @@ -393,16 +393,32 @@ case PCB_TYPE_LINE: { - pcb_line_t *line = (pcb_line_t *) pcb_crosshair.AttachedObject.Ptr2; + /* We move a local copy of the line -the real line hasn't moved, + * only the preview. + */ + int moved = 0; + pcb_line_t line; + memcpy(&line, (pcb_line_t *) pcb_crosshair.AttachedObject.Ptr2, sizeof(line)); - XORDrawAttachedLine(line->Point1.X + dx, line->Point1.Y + dy, line->Point2.X + dx, line->Point2.Y + dy, line->Thickness); + pcb_event(PCB_EVENT_RUBBER_CONSTRAIN_MAIN_LINE, "pp", &line, &moved); + if (!moved) + { + line.Point1.X += dx; + line.Point1.Y += dy; + line.Point2.X += dx; + line.Point2.Y += dy; + } + + XORDrawAttachedLine(line.Point1.X, line.Point1.Y, + line.Point2.X, line.Point2.Y, line.Thickness); + /* Draw the DRC outline if it is enabled */ if (conf_core.editor.show_drc) { pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.cross); - XORDrawAttachedLine(line->Point1.X + dx, line->Point1.Y + dy, - line->Point2.X + dx, line->Point2.Y + dy, - line->Thickness + 2 * (PCB->Bloat + 1) ); + XORDrawAttachedLine(line.Point1.X, line.Point1.Y, + line.Point2.X, line.Point2.Y, + line.Thickness + 2 * (PCB->Bloat + 1) ); pcb_gui->set_color(pcb_crosshair.GC, conf_core.appearance.color.crosshair); } break; Index: trunk/src/event.h =================================================================== --- trunk/src/event.h (revision 7679) +++ trunk/src/event.h (revision 7680) @@ -51,6 +51,7 @@ PCB_EVENT_RUBBER_LOOKUP_LINES, /* rubber band: attach rubber banded line objects to crosshair */ PCB_EVENT_RUBBER_LOOKUP_RATS, /* rubber band: attach rubber banded rat lines objects to crosshair */ PCB_EVENT_RUBBER_FIT_CROSSHAIR, /* rubber band: fit crosshair and modify lines to keep orientation */ + PCB_EVENT_RUBBER_CONSTRAIN_MAIN_LINE, /* rubber band: adapt main line to keep rubberband lines direction */ PCB_EVENT_GUI_SYNC, /* sync GUI state (e.g. after a menu clicked) */ Index: trunk/src_plugins/rubberband_orig/rubberband.c =================================================================== --- trunk/src_plugins/rubberband_orig/rubberband.c (revision 7679) +++ trunk/src_plugins/rubberband_orig/rubberband.c (revision 7680) @@ -991,6 +991,28 @@ } } +static void rbe_constrain_main_line(void *user_data, int argc, pcb_event_arg_t argv[]) +{ + rubber_ctx_t *rbnd = user_data; + pcb_line_t *main_line = argv[1].d.p; + int *moved = argv[2].d.p; + + *moved = 0; + + if (rbnd->RubberbandN != 2) + return; + + if (rbnd->Rubberband[0].delta_is_valid) { + main_line->Point1.X += rbnd->Rubberband[0].DX; + main_line->Point1.Y += rbnd->Rubberband[0].DY; + *moved = 1; + } + if (rbnd->Rubberband[1].delta_is_valid) { + main_line->Point2.X += rbnd->Rubberband[1].DX; + main_line->Point2.Y += rbnd->Rubberband[1].DY; + *moved = 1; + } +} static const char *rubber_cookie = "old rubberband"; @@ -1011,6 +1033,7 @@ pcb_event_bind(PCB_EVENT_RUBBER_LOOKUP_LINES, rbe_lookup_lines, ctx, rubber_cookie); pcb_event_bind(PCB_EVENT_RUBBER_LOOKUP_RATS, rbe_lookup_rats, ctx, rubber_cookie); pcb_event_bind(PCB_EVENT_RUBBER_FIT_CROSSHAIR, rbe_fit_crosshair, ctx, rubber_cookie); + pcb_event_bind(PCB_EVENT_RUBBER_CONSTRAIN_MAIN_LINE, rbe_constrain_main_line, ctx, rubber_cookie); return rb_uninit; }