Nevron .NET Vision Documentation
Snapping

Snapping refers to the ability of drawing views to snap coordinates, points and angles so that it is easier for the user to resize and align drawing content. The snapping functionality of each drawing view is encapsulated in the NSnapManager class, an instance of which can be obtained from the SnapManager property of the NDrawingView class.

Snapping can in general be divided into four categories:

Snap targets, snap strength and snap priority

The objects to which a coordinate or point can be snapped is called snap target. The possible snap targets are enumerated by the SnapTargetsMask enumeration. This mask is internally used by the snap manager and is exposed to the user via a NSnapTargets attribute. The snap manager exposes one primary snap targets via it's SnapTo property. These snap targets define the possible targets to which a point or coordinate can in general be snapped.

In an environment, where a coordinate or point can be snapped to multiple targets, there are two parameters, which determine the target to which the object eventually snaps to. They are:

Coordinate Snapping

Coordinate snapping is decoupled, which means that a point X coordinate can be snapped to one target, while it's Y coordinate can be snapped to another target. Currently there are three types of objects, which can perform coordinate snapping:

When a coordinate needs to be snapped, the manager first tries to snap it to guidelines, then to grid and finally to rulers. Coordinate snapping is used by both points and bounds snapping.

Bounds Snapping

Bounds snapping occurs when the user drags an element inside the drawing view. When performing bounds snapping the manager tries to find, which of the following coordinates, best snaps to the respective X and Y coordinate snappers:

Bounds snapping also obeys to the snap priorities of coordinate snappers - for example: If the left side is closest to a grid line, but the right side can be snapped to a guideline, it is the right bounds side which will be snapped, since guidelines are with higher priority for snapping than the grid. Bounds snapping takes into account the primary SnapTo setting of the snap manager.

Points Snapping

Points snapping occurs when the user drags an element handle. When performing points snapping the manager first tries to snap the point to another point (for example plug to port). If it cannot snap the point to another point, then it snaps it's X and Y coordinates.

The targets to which each individual point snaps to, is controlled by the respective "SnapTo" setting (for example plug points are snapped to the targets specified by the SnapShapePlugsTo setting). The individual "SnapTo" settings of all points are intersected with primary SnapTo setting, which means that if you globally prohibit snapping to guidelines, no point will be snapped to guidelines even if it's individual "SnapTo" settings allow it.

Angle Snapping
Angle snapping occurs when the user drags a rotator handle. When performing rotation snapping, the manager snaps the rotation angle to an exact product of the RotationStep parameter. This is performed if the actual angle to which the user rotated the object is inside the allowed RotationDeviation (i.e. the rotation deviation is the amount of acceptable mistake the user can make).
Related Examples
Windows Forms: Drawing View - Snapping
See Also

 

 


©2017. Nevron Software LLC.

Send Feedback