The GO Factory has four snap modes: snap to hangers, grid, lines and intersections, and a flag which determines whether to create geometric dependencies or just modify the click position (irrelevant for snap to grid). The snap modes are independent on one another and can be combined or switched on and off arbitrarily (even during a GO Factory operation).
When several snap modes are switched on, the closest suitable snap position is chosen. If, for example, snap to grid and to lines are switched on, then a point which is either on a line or a grid point is chosen. Or, if there is no such near object within the snap tolerance, the clicked position is kept unchanged and a mouse-click is created. The grid has the lowest priority of all (if there are several objects with equal distance).
The snap tolerance is stored in each View window and recomputed according
to the current zoom. The top-level View window sets its tolerance
into the global
factory.snap_tolerance. The bitmask of snap
modes is stored in
The snap functions are:
void snap_point( struct geom_point * pos, struct dist_pass_result * dpr, struct geom_transform2 * grid, struct obj_tlo * tlo, real maxdist ); void snap_to_go( struct geom_point * pos, struct dist_pass_result * dpr, struct obj_tlo * tlo, real maxdist ); void snap_to_anchor( struct geom_point * pos, struct dist_pass_result * dpr, struct obj_tlo * tlo, real maxdist );
snap_point function snaps the
pos point according to
the current snap settings and updates the value of
pos. If the
pointer is not
NULL, it copies the dist pass result into it.
The distance pass algorithm is described in Center pass algorithm.
grid is a transformation matrix determining the grid points. The
nearest grid point is computed in this way:
snap_to_go function seeks a nearby GO regardless to the current
snap settings. This is used for selection purposes, for example.
snap_to_anchor seeks a nearby anchor – again, regardless to the current