This page attempts to document the snapping system in pcb.
The snapping system is what takes the location of the cursor (the arrow representing the position of the mouse on the screen) and translates it into the coordinates on the board where actions take place. For example, the snapping system currently restricts the position of the crosshair to the closest grid point to the cursor. If you move the cursor near a pin or a pad, the snapping system positions the crosshair at the center of that pin or pad.
The snapping system in pcb is always active, and cannot be disabled. The snapping order… will be documented the next time I edit this page!
In pcb 4.0.2, snapping is implemented in crosshair.c, towards the end of the file. It is entirely integrated with the crosshair.
First, there is a structure that holds the information about where the crosshair is currently snapped. There is a series of functions that implement snapping.