Skip to content

Statechart Graph Support

Gary edited this page Aug 27, 2014 · 2 revisions

Table of Contents

Statecharts, or state transition diagrams, show states and transitions between them in a state machine. A child state machine can be embedded inside a state. Statecharts are illustrated in the ATF State Chart Editor Sample, as shown in this figure:

A statechart, like a circuit, specializes a graph. The general graph interface

IGraph<IGraphNode, IGraphEdge<IGraphNode, IEdgeRoute>, IEdgeRoute>

becomes this for a statechart:

IGraph<IState, IGraphEdge<IState, BoundaryRoute>, BoundaryRoute>

The distinguishing items for a statechart are:

  • IState: Interface for states in state-transition diagrams. For details, see IState Interface.
  • BoundaryRoute: Edge route for statecharts. For more information, see BoundaryRoute Class.

Atf.Gui Assembly Graph Support

Most statechart classes and all the interfaces are in this assembly.

Statechart Interfaces

Statecharts can have regular states and pseudo-states. Pseudo-states provide information about actual states.

IComplexState Interface

IState is the interface for states in statechart diagrams that are non-pseudo-states. Its property:

  • Text: Get the state's interior text.
IState implements IHierarchicalGraphNode, the interface for hierarchical nodes in a graph, which contain sub-nodes.

IState Interface

IState is the general interface for states in state-transition diagrams, and covers both states and pseudo-states. Its properties are:

In addition, IState implements IGraphNode, the interface for a node in a graph. For more details, see IGraphNode Interface.

BoundaryRoute Class

BoundaryRoute is an IEdgeRoute implementer for transitions between states. It is distinguished by its Position float property, which indicates the route position on the perimeter of a state. Its range is \[0..4\[,]and]it starts and ends at the top-left, going in a clockwise direction. The range from 0 to 1 is on the right side, from 1 to 2 on the bottom, and so on.

Statechart Enumerations

Two enumerations provide state information.

StateIndicators Enumeration

StateIndicators values enumerate visual indicators for state transition diagrams:

  • Breakpoint: Display a breakpoint indicator on a state.
  • Active: Display an "active" indicator on a state.

StateType Enumeration

StateType identifies the kind of state or pseudostate, which marks or points to states.

  • Normal: A normal state.
  • Start: The start pseudostate, which points to the first state that is active when the state machine starts running.
  • Final: The final pseudostate, which is the last state that a state machine can be in.
  • ShallowHistory: The shallow history pseudostate.
  • DeepHistory: The deep history pseudostate.
  • Conditional: A conditional pseudostate, which indicates a state with conditions to reduce the number of transitions.
History determines which states become active in a destination state's child state machines when the transition is taken to this destination.

Atf.Gui.Winforms Assembly Graph Support

This assembly contains the rendering class for statecharts.

D2dStatechartRenderer Class

D2dStatechartRenderer is the class to handle rendering and hit testing on statechart graphs. It is analogous to the D2dCircuitRenderer that specializes in rendering circuit graphs. D2dStatechartRenderer draws graph nodes as states, and edges as transitions.

D2dStatechartRenderer derives from D2dGraphRenderer, which is described in D2dGraphRenderer Class. D2dStatechartRenderer overrides D2dGraphRenderer's Draw() methods using Direct2D (D2dGraphics class) to draw the statechart. It also overrides the Pick() methods.

D2dStatechartRenderer requires a D2dDiagramTheme in its constructor to specify the rendering theme. For a description of its use in the ATF Fsm Editor Sample, see Document Client in FSM Editor Programming Discussion.

Like the other rendering classes, D2dStatechartRenderer works with an adapter. For example, the ATF State Chart Editor Sample defines its own private class StatechartGraphAdapter derived from D2dGraphAdapter that takes a D2dStatechartRenderer in its constructor. Both D2dGraphNodeEditAdapter and D2dGraphEdgeEditAdapter also require a renderer, which can be a D2dStatechartRenderer. The ATF State Chart Editor Sample shows using a D2dStatechartRenderer with its StatechartGraphAdapter adapter for drawing statecharts, as well as with the adapters D2dGraphNodeEditAdapter and D2dGraphEdgeEditAdapter.

Topics in this section

Clone this wiki locally