Stateflow    

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.

  1. As B moves on top of A, the transition stays curved but its front end slides down to B's lower left-hand corner.
  2. As B continues to move to the left over A, the transition's front end hops around B's lower left-hand corner.
  3. 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. Stateflow chooses to connect the junction to state A through the junction's left side. Since the junction is below A, only a curved connection is possible.
  1. 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.

  1. Stateflow connects the junction 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.
  2. 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.
  3. At the location left of state A, Stateflow chooses to connect to state B through its right connection point. Since the junction is above B, only a curved connection is possible.
  4. 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.

You can bow a smart transition between two junctions to any degree by placing the mouse cursor on any point in the transition (except the attachment points) and click-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 Stateflow only uses the component perpendicular to the line connecting the two junctions.

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.


  Setting Smart Behavior in Transitions What Nonsmart Transitions Do