Index: trunk/src/crosshair.c =================================================================== --- trunk/src/crosshair.c (revision 16502) +++ trunk/src/crosshair.c (revision 16503) @@ -782,15 +782,7 @@ line = (pcb_line_t *) ptr2; - /* Allow snapping to off-grid lines when drawing new lines (on - * the same layer), and when moving a line end-point - * (but don't snap to the same line) - */ - if ((conf_core.editor.mode != PCB_MODE_LINE || CURRENT != ptr1) && - (conf_core.editor.mode != PCB_MODE_MOVE || - pcb_crosshair.AttachedObject.Ptr1 != ptr1 || - pcb_crosshair.AttachedObject.Type != PCB_OBJ_LINE_POINT - || pcb_crosshair.AttachedObject.Ptr2 == line)) + if (!pcb_tool_should_snap_offgrid_line(ptr1, line)) return; dx = line->Point2.X - line->Point1.X; Index: trunk/src/tool.c =================================================================== --- trunk/src/tool.c (revision 16502) +++ trunk/src/tool.c (revision 16503) @@ -30,6 +30,7 @@ #include "board.h" #include "conf_core.h" +#include "data.h" #include "error.h" #include "event.h" #include "grid.h" @@ -261,7 +262,23 @@ pcb_notify_crosshair_change(pcb_true); } +pcb_bool pcb_tool_should_snap_offgrid_line(pcb_layer_t *layer, pcb_line_t *line) +{ + /* Allow snapping to off-grid lines when drawing new lines (on + * the same layer), and when moving a line end-point + * (but don't snap to the same line) + */ + if ((conf_core.editor.mode == PCB_MODE_LINE && CURRENT == layer) || + (conf_core.editor.mode == PCB_MODE_MOVE + && pcb_crosshair.AttachedObject.Type == PCB_OBJ_LINE_POINT + && pcb_crosshair.AttachedObject.Ptr1 == layer + && pcb_crosshair.AttachedObject.Ptr2 != line)) + return pcb_true; + else + return pcb_false; +} + #warning tool TODO: move this out to a tool plugin #include "tool_arc.h" Index: trunk/src/tool.h =================================================================== --- trunk/src/tool.h (revision 16502) +++ trunk/src/tool.h (revision 16503) @@ -120,6 +120,7 @@ void pcb_tool_attach_for_copy(pcb_coord_t PlaceX, pcb_coord_t PlaceY, pcb_bool do_rubberband); void pcb_tool_notify_block(void); /* create first or second corner of a marked block (when clicked) */ +pcb_bool pcb_tool_should_snap_offgrid_line(pcb_layer_t *layer, pcb_line_t *line); /**** Low level, for internal use ****/