Controlling How Shapes Connect

The behavior that allows part of a shape to stay connected to another shape is called glue. You can specify the part of a shape to which another shape can be glued by defining a connection point.

You can glue the begin or end points of a one-dimensional (1-D) shape to a guide, guide point, shape vertex, selection handle, or connection point. You can also glue the begin or end point of a 1-D shape to the pin (a shape's center of rotation) of a 1-D or 2-D shape to create walking glue (also known as dynamic glue). If you've enabled users to glue shapes to vertices or handles, Microsoft® Visio® automatically creates an inward connection point on a shape when you glue another shape to its vertices or handles.

When an endpoint of a 1-D shape is glued to another shape, you can move the glued-to shape, and the glued endpoint stays attached, stretching the 1-D shape as the unglued endpoint stays anchored. When a 2-D shape is glued to another shape and you move the glued-to shape, the 2-D shape moves with it.

In this section...

Defining a Connector's Glue Behavior

Specifying What Can be Glued

Understanding Connection Points

Adding Connection Points to a Shape

Naming Connection Points

Designing Shapes for the Dynamic Connector

Defining a Connector's Glue Behavior

You can choose the type of glue behavior a 1-D connector shape uses, static or dynamic:

  • If the endpoint of a 1-D shape remains fixed to a particular connection point, it is said to use static glue. Static glue is point-to-point glue: The connection is always between the same two points, no matter how the shapes move. The default behavior for a shape you draw or any shape that is not placeable or routable is static glue.
  • If the 1-D shape's endpoint "walks" from connection point to connection point (or from side to side) to improve the visibility of the connection as the other shape moves, it is said to use dynamic glue. This is how routable connectors glue placeable shapes. You can think of dynamic glue as shape-to-shape glue: It connects two shapes between the shortest route allowed by a particular routing style, simplifying a drawing.

When you create a connector, you can set it to use dynamic glue so that its endpoints can move from one connection point to another as a user moves the shapes to which the connector is glued. Visio redraws the connector so it connects the shapes at their two closest connection points.

If the connector's endpoint is glued with static glue, the selection handle displays the default begin point Aa200985.IC_BeginPoint(en-us,office.10).gif or end point Aa200985.IC_EndPoint(en-us,office.10).gif symbol in dark red. If the connector's endpoint is glued with dynamic glue, its selection handle is solid red.

A connector defined to use dynamic glue can create a connection with static or dynamic glue.

A connector defined to use dynamic glue can create a connection with static or dynamic glue.

  1. Drag an endpoint to connect with static glue.
  1. Drag an endpoint to the middle of a shape or press CTRL and drag an endpoint to connect with dynamic glue.

To define static or dynamic glue for a connector

  1. Select the shape, and then click Show Shapesheet on the Window menu.
  1. If the Glue Info section is not displayed, click Sections on the View menu. In the ViewSections dialog box, select Glue info, and then click OK.
  1. In the Glue Info section of the ShapeSheet spreadsheet, enter 0 in the GlueType cell to specify static glue, or enter 2 to specify dynamic glue.

By default, dynamic glue connects via the shortest route allowed by a particular routing style between two connection points or midshape selection handles. You can set a preference so that a shape with dynamic glue walks to a side, top, or bottom connection point when the glued endpoint is moved. To do this, set the WalkPreference cell in the Glue Info section. Routable connectors ignore the setting of the WalkPreference cell; their routing behavior is controlled by the value of the ShapeRouteStyle cell. For details about WalkPreference and ShapeRouteStyle settings, see the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).

Note When a user glues a 1-D connector with dynamic glue to another shape, Visio generates a formula that refers to the EventXFMod cell of the other shape. When that shape is changed, Visio recalculates any formula that refers to its EventXFMod cell, including the formula in the BegTrigger and EndTrigger cells. These two cells contain formulas generated for a 1-D shape by Visio when the 1-D shape is glued to other shapes. Other formulas for the 1-D connector refer to the BegTrigger and EndTrigger cells and move the begin or end point of the connector or alter its shape as needed.

TOP

Specifying What Can be Glued

You can specify the parts of a shape to which another shape can be glued on a page in the Snap & Glue dialog box. For example, most Visio templates enable users to glue 1-D shapes only to guides, guide points, and connection points. On the Tools menu, click Snap & Glue and select additional Glue to options that are appropriate for your drawing or template.

Although 1-D shapes are usually used to connect 2-D shapes, you can glue the following parts of 2-D shapes:

  • An entire side of a shape (shape geometry) to a guide or a guide point
  • An edge of the alignment box to a guide
  • A selection handle to a guide point
  • A control handle to a connection point
  • An outward or inward/outward connection point to an inward or inward/outward connection point on another shape

TOP

Understanding Connection Points

When you design a shape, you indicate locations where it can glue or be glued by adding connection points to the shape. As you create masters, consider which points users will most likely need and avoid creating additional points, because they can make a shape respond less efficiently.

A connection point's type influences whether other shapes can be glued to it or whether the shape that has the connection point can be glued to other shapes:

  • Other shapes can be glued to an inward connection point. Inward connection points behave like connection points in versions of Visio products earlier than Visio 2000. An inward connection point attracts endpoints of 1-D shapes and outward or inward/outward connection points of other shapes. Diagrams such as flowcharts and organization charts that consist of 2-D shapes and 1-D connectors need only inward connection points on 2-D shapes.
  • A shape with an outward connection point can be glued to an inward connection point on another shape. An outward connection point is attracted to inward and inward/outward connection points of other shapes. Office layout diagrams and CAD diagrams that consist almost exclusively of 2-D shapes can take advantage of outward connection points.
  • An inward/outward connection point behaves like an inward connection point when you glue the endpoint of a 1-D shape or a shape with an outward connection point to it. It behaves like an outward connection point when you glue it to another shape. Inward/outward connection points are useful for shapes that might be glued together in any order. For example, if wall segment shapes have an inward/outward connection point at each end, either end of one wall segment shape could be glued to either end of another wall segment shape, in any order. If such a shape had an outward connection point on one end and an inward connection point on the other, you would be forced to glue an outward end to an inward end, which would be less convenient.

Note Beginning with Visio 2000, Visio imports connection points created in earlier versions of Visio as inward connection points with no preferred direction. Any scratch formulas in the A, B, C, and D cells of such rows are imported without change.

The following illustration shows a paving tile shape that has all three kinds of connection points.

A paving tile shape with inward, outward, and inward/outward connection points

A paving tile shape with inward, outward, and inward/outward connection points

  1. Outward connection point
  1. Inward/outward connection point
  1. Inward connection point
  1. An inward/outward connection point snaps to the closest inward or inward/outward connection point

To glue outward and inward/outward connection points, the Connection Points check box must be selected under Glue to in the Snap & Glue dialog box on the user's system. When a user drags a shape with outward or inward/outward connection points, the shape snaps to the nearest inward or inward/outward connection point. If a shape has more than one outward connection point, Visio snaps the connection point closest to the mouse pointer.

A connection point can have a direction, or vector, which determines whether shapes rotate when they are glued together. Initially, if a connection point is placed on a shape's geometry, its vector is perpendicular to the segment in which the connection point is placed. Otherwise, the connection point has a vector of 0 (that is, no direction). When an outward connection point is glued to an inward (or inward/outward) connection point and both connection points have a non-zero vector, Visio aligns the vectors of both, rotating the shape as needed. If either connection point has a vector of 0, the shapes are not rotated.

A connection point�s vector determines how a shape rotates when it is glued.

A connection point's vector determines how a shape rotates when it is glued.

  1. Perpendicular vector (the default)
  1. Angled vector
  1. To change a connection point's vector, select the connection point and drag the green direction handle to the angle you want.
  1. No vector
  1. To prevent a shape from rotating when it is glued, drag the direction handle onto the connection point. The green direction handle turns gray, which indicates that the connection point has no vector.

When a shape with an outward connection point is glued, Visio generates formulas in its PinX, PinY, and Angle cells representing that shape's connection with the shape to which it is glued. For example, these are the formulas generated for one of the shapes glued along a perpendicular vector. Circle1 is the name of the shape to which it is glued; references to the EventXFMod cell of the circle shape and the page ensure that the glued shape moves or rotates as needed to preserve the connection. The following LOCTOPAR and ANGLETOPAR formulas convert local coordinates of the glued shape to the coordinate system of the shape to which it is glued (Circle1).

  • PinX = LOCTOPAR(PNT(Circle1!Connections.X2+-0.3536 in.,
  •         Circle1!Connections.Y2+0.3536 in.),
  •         Circle1!EventXFMod,ThePage!EventXFMod)
  • PinY = LOCTOPAR(PNT(Circle1!Connections.X2+-0.3536 in.,
  •         Circle1!Connections.Y2+0.3536 in.),
  •         Circle1!EventXFMod,ThePage!EventXFMod)
  • Angle = ANGLETOPAR(-45 deg.,Circle1!EventXFMod,EventXFMod)

Compare the following PinX and PinY formulas of a shape with a vector of 0. If the inward or outward connection points don't have a direction vector, Visio doesn't generate an Angle formula.

  • PinX = PNTX(LOCTOPAR(PNT(Circle3!Connections.X2,Circle3!Connections.Y2),
  •         Circle3!EventXFMod,ThePage!EventXFMod))+-0.5 in.
  • PinY = PNTY(LOCTOPAR(PNT(Circle3!Connections.X2,Circle3!Connections.Y2),
  •         Circle3!EventXFMod,ThePage!EventXFMod))+0 in.

TOP

Adding Connection Points to a Shape

Microsoft Visio automatically creates an inward connection point at the vertex or selection handle of a shape when a connector is glued at that position, so you must manually add connection points only when you need an inward connection point in a nonstandard location, or when you need an outward or inward/outward connection point.

You can add a connection point to a shape by using the Connection Point tool. To add outward connection points or change a connection point's type, on the Tools menu, click Options, click the Advanced tab, and then ensure Run in developer mode is selected under Developer Settings.

To create a connection point

  1. Select the shape.
  1. Click the Connection Point tool.
  1. Do one of the following:
  • To create an inward connection point, hold down CTRL, and then click where you want to add the connection point.
  • To create an outward connection point, hold down CTRL+ALT, and then click where you want to add the connection point.
  • To create an inward/outward connection point, select an existing connection point, right-click, and click Inward & Outward on the shortcut menu.

When you add a connection point, Visio adds the Connection Points section to the ShapeSheet window with a row describing the point's x- and y-local coordinates, the x- and y-coordinates of its direction, and its type (inward, outward, or inward/outward). By changing the formulas for a connection point's coordinates, you can control how the location of the connection point changes when a shape is resized.

If you add a connection point to a shape's geometry, Visio orients the direction vector perpendicularly to the segment in which the connection point was added—inward for an inward connection point, outward for an outward connection point, or both inward and outward for an inward/outward connection point.

Tip If the Glue To setting for Shape geometry is selected in the Snap & Glue dialog box (Tools menu) and the user drags a shape with an outward connection point to another shape, Visio automatically creates an inward connection point with the appropriate vector and glues the shapes together. If the shapes are dragged apart, breaking the glue, Visio automatically deletes the connection point it created.

To prevent other shapes from being glued to a shape's geometry, set the NoSnap cell in the shape's corresponding Geometry section to TRUE. This disables snapping to geometry, gluing to geometry, nudging 1-D shapes to geometry, 2-D snap and glue, and snapping to shape extensions. For example, you might do this to prevent a window shape from connecting to an electrical outlet, or a chair from connecting to another chair. Setting NoSnap causes shapes to rotate less as the user drags them across potential snap points, and filters out geometry extensions that aren't useful.

TOP

Naming Connection Points

You can rename the Connections Points row to create a more meaningful reference for the value contained in the X or Y cell of the same row. The cell name you enter must be unique within the section. When you create a name for one cell in this section, Microsoft Visio names all the cells in the section with the default name, Connections.Row_n. If no rows in the section are named, the name cell is blank.

For example, to rename the cell for the first row, enter Custom in the formula bar to create the cell name Connections.Custom. Visio creates the name Connections.Row_2 for the cell in the second row. To refer to the X cell of the first row, use Connections.Custom.X1 or Connections.X1. To refer to the Y cell of the first row, use Connections.Custom.Y1 or Connections.Y1. To refer to the X cell of the second row, use Connections.Row_2.X or Connections.X2, and to refer to its Y cell, use Connections.Row_2.Y or Connections.Y2.

TOP

Designing Shapes for the Dynamic Connector

The dynamic connector can extend inside a shape's bounding box to intersect the shape's geometry. (A shape's bounding box is the smallest nonrotated rectangle that encloses the shape's alignment box.)

Dynamic intersection with shape geometry

Dynamic intersection with shape geometry

  1. Dynamic intersection enabled
  1. Dynamic intersection disabled
  1. Dynamic intersection enabled for a shape with geometry outside of its alignment box. The dynamic connector "finds" the outermost geometry on the side to which it is glued.

The dynamic connector can also extend into groups to intersect the geometry of a shape in a group.

Note In versions earlier than Visio 2000, the dynamic connector did not extend into the shape's bounding box or into groups.

Dynamic intersection with shapes in groups

Dynamic intersection with shapes in groups

  1. Dynamic intersection enabled
  1. Dynamic intersection disabled

Dynamic intersection is enabled for shapes by default. However, dynamic intersection causes the Visio engine to perform complex calculations that can affect shape performance when a connector is dynamically glued to a shape, especially in shapes that have multiple or complex geometries, or in groups that contain many shapes.

Dynamic intersection for a shape is controlled by the ShapeFixedCode cell in its Shape Layout section. ShapeFixedCode contains an 8-bit integer in which each bit controls a different dynamic connection behavior. To disable dynamic intersection for a shape, set the value of its ShapeFixedCode cell to its current value plus 128. To reenable dynamic intersection for that shape, subtract 128 from the current value of its ShapeFixedCode cell. For details about setting ShapeFixedCode to other values, see the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).

To develop usable shapes that perform well with the dynamic connector, consider the following suggestions:

  • Design the shape so that all of its geometry is within its alignment box. This yields the best-looking results when a dynamic connector is glued to the shape.
  • Provide connection points on the shape if you want the dynamic connector to glue to specific locations. If a shape has a connection point on the side that the dynamic connector "walks" to, the connector glues to the connection point rather than the shape's geometry, thus avoiding the potentially time-consuming calculations involved in dynamic intersection.
  • If you want to prevent the dynamic connector from intersecting a shape's geometry under any circumstances, disable dynamic intersection by setting the shape's ShapeFixedCode cell. This is especially recommended for shapes enclosed within other shapes, as often occurs in groups.