Extending Transitions with Smart Behavior

About Smart Behavior Transitions

Transitions with smart behavior — known as smart transitions — attach their ends to the surfaces of Stateflow objects and, therefore, maintain their shapes and uniqueness when you rearrange chart objects.

Setting Smart Behavior in Transitions

Transitions are automatically created with smart behavior, on the assumption that this behavior is desirable in most circumstances. You can disable or enable smart behavior in existing transitions with the following procedure:

  1. Right-click a transition.

    On the resulting menu, observe the selection titled Smart. If a check mark appears in front of Smart, the transition has smart behavior.

  2. If Smart is not checked, select it to enable smart behavior.

    To disable smart transition behavior, select Smart if it is already checked.

See the following sections for a comparison of behavior between smart and nonsmart transitions:

What Smart Transitions Do

The following topics discuss some of the behaviors of smart transitions:

Smart Transitions Slide Around Surfaces

In the following example, state B is attached to state A by a smart transition. The example shows state B being dragged counterclockwise around the upper right corner of state A. When this occurs, state B turns to its selection color and the transition turns to a very light shade of gray, a sure sign of smart behavior. Dragging direction is shown by the arrows.

1

2

3

4

5

6

Note the following step-by-step behavior for the preceding example:

  1. The first capture shows states A and B at the beginning of movement.

  2. As B moves upward, the transition's back end slides upward on A, maintaining the transition straight.

  3. As B moves around A's corner, the back end of the transition suddenly hops around A's upper right-hand corner. The transition is now curved from A's top surface to B's left side, maintaining perpendicularity with each attached state side.

  4. As B moves on top of A, the transition stays curved but its front end slides down to B's lower left-hand corner.

  5. As B continues to move to the left over A, the transition's front end hops around B's lower left-hand corner.

  6. Finally, as B moves directly over A, the transition's front end slides onto B's bottom edge.

As B continues to circle A, steps 1 through 6 repeat for each of A's remaining sides.

Smart Transitions Slide and Maintain Shape

While transitions with smart behavior allow their ends to slide around the surfaces of their connected objects, they also attempt to maintain their original shape during moving. In the following example, a pair of transitions with smart behavior slide during a resizing to maintain their original shape.

1

2

3

In the following example, the ends of a pair of transitions with smart behavior emanate from a junction and terminate in a state. As the junction is dragged around the state, the ends slide around the state and maintain the same relative spacing between each other. Direction is indicated by the arrows.

1

2

3

Smart Transitions Connect States to Junctions at 90 Degree Angles

Straight-line connections to states must be in one of four directions: left, right, up, or down. To maintain their straightness, smart transitions from junctions always seek to connect to a state through equivalent locations on the junction (left, right, top, bottom). In the following example, a junction is connected to two states, A and B. Watch the behavior of two straight smart transitions as the junction is moved to different locations.

1

2

3

4

5

6

  1. The junction starts with two straight smart transition connections to states A and B.

  2. The junction connects to state A through its left side. Since the junction is below A, only a curved connection is possible.

    State B could be connected by a straight line through the junction's left side, but this is already occupied by the connection to A. Therefore, B is connected through the junction's bottom, and must be curved.

  3. The junction connects to B by a straight transition through the junction's top connection. No straight-line connection to A is possible, therefore the junction is connected to state A with a curved transition through its left side.

  4. At this location (under A, to the left of B), straight-line transitions to A and B are possible from the junction's top and right connection points, respectively.

  5. At the location left of state A, the junction connects to state B through its right connection point. Since the junction is above B, only a curved connection is possible.

  6. Above A, a straight-line transition to state A is possible through the junction's bottom connector. A straight-line connection to state B is not possible, so the junction is connected to state B through a curved transition from its right connection.

Smart Transitions Snap to an Invisible Grid

Junctions that are connected to other junctions with smart transitions will snap to an invisible grid consisting of horizontal and vertical lines that pass through the center of each junction. The following example depicts this behavior.

1

2

3

Here, the invisible grid is depicted for each of the three junctions by dashed vertical and horizontal lines. Each junction is connected to each other through nonlinear smart transitions:

  1. In the first scene, the snap grid for each junction does not overlap. The arrow indicates that junction A is being moved toward the vertical snap line for junction B.

  2. When A is within a very small distance of B's snap line, A snaps into position directly above B and centered in its vertical snap line. The arrow indicates that A is now being moved toward the horizontal snap line for junction C.

  3. When A is within a very small distance of C's horizontal snap line, A snaps into position directly to the side of C and centered in its horizontal snap line.

Smart Transitions Bow Symmetrically

Transitions with smart behavior bow symmetrically between junctions. In the following examples, transitions with smart behavior are drawn between two junctions:

1

2

3

  1. In the first case, a transition originates at the junction on the left and terminates on the left side of the right junction. This results in a straight line.

  2. In the second case, a transition originates at the junction on the left and terminates on the top of the right junction. This results in a transition line bowed up.

  3. In the third case, a transition originates at the junction on the left and terminates on the right side of the right junction. This results in a transition line bowed up even more.

    Bowed smart transitions maintain symmetry by maintaining equality between transition entry and exit angles as shown below.

You can bow a smart transition between two junctions to any degree by placing your pointer on any point in the transition (except the attachment points) and clicking and dragging in a direction perpendicular to a straight line connecting the two junctions. You can move the mouse in any direction to bow the transition but only the component perpendicular to the straight line applies.

Disabling smart behavior for a transition allows you to distort the transition asymmetrically (see section Nonsmart Transitions Distort Asymmetrically). However, if you enable smart behavior again, the transition automatically returns to its prior symmetric bowed shape.

What Nonsmart Transitions Do

The following topics describe some of the behavior exhibited by transitions without smart behavior.

You can disable and enable smart behavior in transitions. See the section Setting Smart Behavior in Transitions.

Nonsmart Transitions Anchor Connection Points

Contrast the example in the section Smart Transitions Slide Around Surfaces with the example shown below.

1

2

3

4

5

6

A nonsmart transition connects state A to state B. The pointer is then placed over state B and clicked and dragged to new locations counterclockwise around A. When this occurs, state B turns to its highlight color but the transition remains unchanged, a sure sign of a nonsmart transition.

As B is moved around A, the transition changes into a distorted curve that maintains the original attachment points. These remain unchanged in position, although the angle of attachment is always perpendicular to the side of the state.

Nonsmart Transitions Distort Asymmetrically

Simply by clicking and dragging on different locations along a transition without smart behavior, you can reshape it into an asymmetric curve suited to your individual preferences. This is illustrated in the following example:

1

2

3

For this example, use the following procedure:

  1. Drag a horizontal transition between two junctions.

  2. Right-click the transition and select Smart from the resulting shortcut menu to disable smart behavior.

  3. Place your pointer anywhere on the transition.

  4. Click and drag your pointer up and to the left.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS