← Back to team overview

kicad-developers team mailing list archive

Snap to line ends if they are closer than the grid. Howto write GetNearestLineEnd?

 

Hi All,
I would like pcbnew and the module editor to snap to line ends, when they are closer to the mouse than the next grid point. Maybe it's usefull to have a key combination that switches from snap to grid, into snap to line ends.
i don't know how to do this. The function GetNearestGridPosition is used to determine the next grid point, but this function does not know where the line ends are. I would like to write a function something along the lines of this pseudo code:
GetNearestSnapObject
{
    if (GetNearestLineEnd is nearer than GetNearestGridPosition)
        pos=GetNearestLineEnd
    else
        pos=GetNearestGridPosition
    return pos.
}
Maybe it's usefull to snap also only one axis along a line, so you can draw a vertical line, that automatically snaps on the intercept point with a vertical line. Maybe also the center, and the edge of an arc. 
Maybe it's usefull to snap on all objects, perhaps after a key combination is pressed.
Is this a good idea?
Kind regards,
Cedric