Nevron Open Vision Documentation
Snap and Glue

 
About Snap and Glue

Snapping refers to the ability of drawing objects to attract coordinates, points and angles so that it is easier for the user to resize and align drawing content. Snapping can in general be divided into four categories:

Snapping of X and Y coordinates (coordinates snapping)
Snapping of bounds
Snapping of points
Snapping of rotation angles

Gluing refers to the ability of certain drawing objects to be glued to the drawing objects they were snapped to.

The snap and glue functionality of each drawing is encapsulated in the NSnapAndGlue class, an instance of which can be obtained from the SnapAndGlue property of the NDrawing class. 

Snapping

The objects to which a coordinate or point can be snapped is called snap target.

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:

  1. Ports - points can be snapped to ports, if SnapToPorts is true.
  2. Geometries  - points can be snapped to geometries and geometry vertices, if SnapToGeometries is true.
  3. Shapes - only end-points can be snapped to shapes, if SnapToShapes is true.
  4. Guidelines  -  coordinates and points and can be snapped to guidelines, if SnapToGuidelines is true.
  5. Grid -  coordinates and points and can be snapped to guidelines, if SnapToGrid is true.
  6. Rulers -  coordinates and points and can be snapped to rulers subdivisions, if SnapToRulers is true.

NOV diagram snaps coordinates, points, bounds and angles. Following is more information about each type of 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:

    Guidelines - snaps to guideline coordinate
    Rulers - snaps to rulers ticks
    Grid - snaps to visible grid lines (major lines or major and minor lines)

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 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 left, center and right are snapped to X coordinate snappers
    Bounds top, middle and center are snapped to 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.

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 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 RotationTolerance (i.e. the rotation tolerance is the amount of acceptable mistake the user can make).

Glue

Glue refers to the ability of certain drawing elements to remain glued to the objects to which they snapped when moved. This mostly refers to begin and end points of 1D shapes and the shape control points.

Visually (when moved) the begin and end points of each 1D shape and the control points of shapes can be glued to:

1. Ports - the glue is established, if the respective point is snapped to port and the GlueToPorts property is set to true.

2. Geometry - the glue is established, if the respective point is snapped to a geometry contour location and the GlueToGeometry property is set to true. It is important to note that both end-points and control points are actually glued to a relative location inside the snapped geometry shape box.

3. Shape - the glue is established, if the respective point is snapped to a geometry contour location and the GlueToShapes property is set to true. When end-points are glued, they take into account the target shape DefaultShapeGlue property to determine the type of glue to establish. Control points are always glued to a relative location inside the snapped shape box.

 

 

Send Feedback