Share via


Controlling How Shapes Flip and Rotate

Will users flip and rotate your shapes? In some cases, you can design your shapes to accommodate these actions; in others, you might want to prevent them from doing so.

When you design a shape, you need to anticipate how the user will flip or rotate the shape and then design appropriate behavior. The Shape Transform section records a shape's orientation with respect to its parent. When a user flips or rotates a shape, its Shape Transform section reflects the actual transformation that occurs.

In this section…

How Flipping Affects a Shape

How Rotating Affects a Shape

Designing Shapes that Flip and Rotate

Preventing Shapes from Flipping and Rotating

How Flipping Affects a Shape

When a shape is flipped, the value of its FlipX or FlipY cell changes to TRUE. The parent coordinates of the shape's origin change, but the location of the shape's pin doesn't change with respect to either its local or parent coordinates. In the following figure, the shape is rotated to show more clearly the interaction of the FlipX and FlipY cells.

Local coordinates of a rotated shape as FlipX and FlipY values are changed

Local coordinates of a rotated shape as FlipX and FlipY values are changed.

  1. FlipX = FALSE, FlipY = FALSE, Angle = 30 deg.
  1. FlipX = FALSE, FlipY = TRUE, Angle = 30 deg.
  1. FlipX = TRUE, FlipY = FALSE, Angle = 30 deg.
  1. FlipX = TRUE, FlipY = TRUE, Angle = 30 deg.

If you are designing shapes that users can flip, you need to be aware of the different behaviors that result depending on the method that was used. To flip a shape, users can do the following:

  • Click Flip Vertical or Flip Horizontal on the Action toolbar or Shape menu.
  • Set the value of the FlipX or FlipY cell in the Shape Transform section.

Depending on which of the previous methods a user employs to flip a shape, two different shape transformations can result:

  • When a user clicks Flip Horizontal on the Action toolbar or Shape menu, the shape appears to flip about a vertical line in the page coordinate system that passes through the shape's pin. The value of the FlipX cell is toggled between true and false. If the shape has been rotated, the value of the Angle cell becomes �angle, a different shape transformation, as the following figure shows.
  • When a user edits the values of the FlipX cell in the Shape Transform section, setting the value of the FlipX cell to true flips the shape horizontally by reversing the direction of the shape's local x-coordinate axis. The value of the Angle cell doesn't change.

The Flip Horizontal command both flips and rotates the shape.

The Flip Horizontal command both flips and rotates the shape.

  1. Original shape
  1. Effect of the Flip Horizontal command
  1. Effect of setting only FlipX = true
  1. Page coordinate system

Using Flip Vertical on the Action toolbar or Shape menu has the effect of toggling the value of the FlipY cell and changing the value of the Angle cell to �angle.

TOP

How Rotating Affects a Shape

To rotate a shape, a user can drag a shape handle with the Rotation tool or use the Size & Position window, which includes an editable Angle field (click Size & Position Window on the View menu). When a shape is rotated, the value in the shape's Angle cell describes the rotation of the shape's local coordinate system with respect to the parent coordinate system.

A shape rotates about its pin: The parent coordinates of a shape's origin change as the shape is rotated, but the location of the shape's pin does not change with respect to either its local or parent coordinates.

Note If page rotation is enabled, a user can rotate the views of a drawing page by dragging its corner with the Rotation tool. Although this causes existing shapes and guides to appear rotated as well, they are not—they maintain the same position and angle with respect to the origin of the page. Rotating a page doesn't affect the page's appearance when printed or the appearance of the rulers and grid in the drawing window.

To enable (or disable) page rotation in Microsoft® Visio®, click Options on the Tools menu, click the General tab, and select (or clear) Enable page rotation.

A page does not display a Shape Transform section in a ShapeSheet® window, so you are unable to view or edit its Angle cell as you can for a shape. However, you can access it using Automation through the PageSheet property. For details about accessing formulas through Automation, see Chapter 17, Automating Formulas.

TOP

Designing Shapes that Flip and Rotate

If you expect users to flip and rotate your shape, you can design the shape to work at different angles and orientations. For example, you can change the way a shape flips or rotates by moving its local pin. In the following figure, when a user flips the transistor symbol vertically, the horizontal lead stays in position. When the shape is flipped horizontally, the vertical lead stays in position. This behavior makes the transistor flip appropriately in electrical schematics with cascaded transistors.

The transistor shape unflipped, flipped vertically, and then flipped horizontally

The transistor shape unflipped, flipped vertically, and then flipped horizontally

  1. The local pin is aligned with the vertical leads and with the horizontal leads.
  1. The horizontal lead doesn't move.
  1. The vertical lead doesn't move.

You can use the Rotation tool to drag the shape's pin to a new location. Doing this changes the values of PinX and PinY, but the LocPinX and LocPinY formulas also change to counteract the pin movement so that the shape doesn't jump on the page. You can also move the pin by changing only the formulas in the LocPinX and LocPinY cells. This changes the relationship between the local pin and the parent pin, so the shape also moves on the drawing page. For example, the transistor shape offsets the local pin with the following formulas:

  • LocPinX = Width * 0.75
  • LocPinY = Height * 0.5

Some shapes, such as the transistor shape shown in the following illustration, are commonly rotated by multiples of 90 degrees. If you design such a shape so that its alignment box coincides with the grid and its pin and any connection points lie on grid points, the shape will snap into alignment more quickly when a user flips or rotates it.

A transistor symbol designed to rotate in multiples of 90 degrees

A transistor symbol designed to rotate in multiples of 90 degrees

  1. The alignment box is a multiple of the grid, and the pin is also on a grid point.
  1. When the shape is rotated, the connection points always fall on grid lines.

For details about working with alignment boxes and the grid, see Chapter 11, Arranging Shapes in Drawings.

TOP

Preventing Shapes from Flipping and Rotating

You can prevent users from rotating a shape by guarding the formula in its Angle cell:

The shape can still be flipped, but users will not be able to use the Rotation tool or RotateLeft, Rotate Right, or Rotate Text command on the Shape menu to rotate it unless they edit its Angle formula in a ShapeSheet window. This technique is easy but not ideal, because the shape still displays rotation handles when the Rotation tool is active, and the RotateLeft, Rotate Right, and Rotate Text commands are not dimmed on the menu—they simply don't do anything, which might confuse some users.

A better technique is to lock the shape against rotation by selecting Rotation in the Protection dialog box (on the Format menu, click Protection) or setting the LockRotate cell (in the Protection section) to a value other than zero. When the Rotation tool is active, padlocks appear on the shape's rotation handles, giving users a visual clue that is not provided when you guard the value of the Angle cell.

However, the lock doesn't prevent the shape from being flipped by means of the Flip Vertical and Flip Horizontal commands. To prevent a shape from being flipped, guard the formulas in its FlipX and FlipY cells:

  • FlipX = GUARD(FALSE)
  • FlipY = GUARD(FALSE)

There is no equivalent option in the Protection dialog box.