Skip to content

ATF Graph Interfaces

Gary edited this page Aug 27, 2014 · 1 revision

Table of Contents

Graph support in ATF includes a variety of interfaces for general graphs, circuits, and statecharts. These interfaces reside in the Sce.Atf.Controls.Adaptable.Graphs namespace and Atf.Gui assembly.

IGraph and Related Interfaces

In ATF, the interface for a graph is IGraph<IGraphNode, IGraphEdge<IGraphNode, IEdgeRoute>, IEdgeRoute>:

public interface IGraph<out TNode, out TEdge, out TEdgeRoute>
    where TNode : class, IGraphNode
    where TEdge : class, IGraphEdge<TNode, TEdgeRoute>
    where TEdgeRoute : class, IEdgeRoute

Graph objects, such as circuits, implement IGraph.

IGraph references several other interfaces:

  • IGraphNode: Interface for a node in a graph; nodes are connected by edges.
  • IGraphEdge<IGraphNode, IEdgeRoute>: Interface for routed edges in a graph. Routed edges connect nodes and have a defined source and destination route from and to the nodes.
  • IEdgeRoute: Interface for edge routes, which contain information on source and destination nodes for graph edges.
Note that all the type parameters in IGraph are covariant, so that more derived types can be used than the ones specified. (As of C# 4.0, generic interfaces support covariance for type parameters marked with the out modifier. This modifier ensures that the marked type parameter is only used in an output position, for example, the return type of a method.) Other types of graphs use IGraph interfaces with parameters that are derived from the parameters specified in IGraph's declaration, as shown in Types of Graphs. For instance, the Sce.Atf.Controls.Adaptable.Graphs.Circuit class for circuit graphs implements IGraph this way:
public abstract class Circuit : DomNodeAdapter, IGraph<Element, Wire, ICircuitPin>, ...

In this circuit interface, Element is an element like an AND gate, Wire is a wire connecting elements, and ICircuitPin is a pin on an element. These classes and interface derive from or implement the interfaces in the general IGraph interface:

  • Element implements ICircuitElement which implements IGraphNode.
  • Wire implements IGraphEdge<Element, ICircuitPin>.
  • ICircuitPin implements IEdgeRoute.
The IGraph interface contains the following properties:
  • Nodes: Get the nodes in the graph as IEnumerable<IGraphNode> — or something derived from that, because the parameter is covariant.
  • Edges: Get the edges in the graph as IEnumerable<IGraphEdge<IGraphNode, IEdgeRoute>> — or something derived from that.
IGraph also offers these extension methods:
  • GetEdges(): Get the edges that connect to the given node.
  • GetNodes(): Get the nodes that connect to the given node.
  • GetInputEdges(): Get the "incoming" edges that connect to the given node. These are the edges whose ToNode matches the given node. For a description of the ToNode property, see IGraphEdge Interface.
  • GetOutputEdges(): Get the "outgoing" edges that connect to the given node. These are the edges whose FromNode matches the given node. For a description of the FromNode property, see IGraphEdge Interface.
  • GetInputNodes(): Get the "incoming" nodes that connect to the given node by an incoming edge. An incoming edge is an edge whose ToNode matches the given node.
  • GetOutputNodes(): Get the "outgoing" nodes that connect to the given node by an outgoing edge. An outgoing edge is an edge whose FromNode matches the given node.

IGraphNode Interface

IGraphNode is the interface for a node in a graph. Nodes take a variety of forms, depending on the type of graph. In a circuit, for instance, a node is an element that contains pins that are connected to other pins on elements. IGraphNode contains these properties:

  • Name: Get the node name.
  • Bounds: Get the bounding rectangle for the node in world space (or local space if a hierarchy is involved, as with sub-circuits).

IGraphEdge Interface

IGraphEdge is the interface for edges in a graph and has two forms. The first form is IGraphEdge<IGraphNode>:

public interface IGraphEdge<out TNode>
    where TNode : class, IGraphNode

This interface has the properties:

  • FromNode: Get the edge's source node as an IGraphNode — or something derived from IGraphNode, because the parameter is covariant.
  • ToNode: Get the edge's destination node as an IGraphNode — or something derived from that, because the parameter is covariant.
The second form is IGraphEdge<out IGraphNode, out IEdgeRoute>:
public interface IGraphEdge<out TNode, out TEdgeRoute> : IGraphEdge<TNode>
    where TNode : class, IGraphNode
    where TEdgeRoute : class, IEdgeRoute

This interface includes the properties:

  • FromRoute: Get the IEdgeRoute for the source node.
  • ToRoute: Get the IEdgeRoute for the destination node.
Note that this form of the interface derives from the first one, so it includes both the source and destination nodes as well as the nodes' IEdgeRoute properties.

IEdgeRoute Interface

IEdgeRoute indicates whether nodes allow multiple input or output edges with these Boolean properties:

  • AllowFanIn: Get whether this node can accept multiple edges as inputs.
  • AllowFanOut: Get whether this node can accept multiple edges as outputs.

Other Graph Interfaces

This table lists the other graph interfaces and their derivation. It includes Interfaces for general, circuit, and statechart graphs.

Interface Derives from Description
ICircuitContainer Interface for container of circuit items. The container should support element addition, removal, and insertion. For details, see ICircuitContainer Interface.
ICircuitElement IGraphNode Interface for circuit elements, which have a Type property defining their pins and appearance.
ICircuitElementType Interface for circuit element types, containing properties to define the appearance, inputs, and outputs of an element. For instance, the Image property gets an element image.
ICircuitGroupPin<out TElement>
where TElement : class, ICircuitElement
ICircuitPin Interface for group pins, which are virtual pins that expose real pins of elements inside the group to other circuit elements outside the group. Contains properties to get pin information: connections, bounds, and CircuitGroupPinInfo to specify behavior or appearance of ICircuitGroupPin.
ICircuitGroupType<TElement, TWire, TPin>
where TElement : class, IGraphNode
where TWire : class, IGraphEdge<TElement, TPin>
where TPin : class, IEdgeRoute
IHierarchicalGraphNode<TElement, TWire, TPin>,
ICircuitElementType
Interface for hierarchical circuit group element types. For more information on this interface, see Group Class.
ICircuitPin IEdgeRoute Interface for pins, which are the sources and destinations for wires between circuit elements. Its properties get the name, type, and pin index.
IComplexState<TNode, TEdge>
where TNode : class, IState
where TEdge : class, IGraphEdge<TNode, BoundaryRoute>
IHierarchicalGraphNode<TNode, TEdge, BoundaryRoute> Interface for states in statechart diagrams that are non-pseudo-states. For more information, see Statechart Interfaces.
IEdgeStyleProvider Provide information about an edge's shape and appearance in an EdgeStyle enumeration or EdgeStyleData. For more information, see EdgeStyleData Class.
IEditableGraph<in TNode, TEdge, in TEdgeRoute>
where TNode : class, IGraphNode
where TEdge : class, IGraphEdge<TNode, TEdgeRoute>
where TEdgeRoute : class, IEdgeRoute
Interface for a graph that can be edited by a control.Contains methods to change node connections.
IEditableGraphContainer<in TNode, TEdge, in TEdgeRoute>
where TNode : class, IGraphNode
where TEdge : class, IGraphEdge<TNode, TEdgeRoute>
where TEdgeRoute : class, IEdgeRoute
IEditableGraph<TNode, TEdge, TEdgeRoute> Interface for container of graph objects. Its methods allow moving items in and out of the container and resizing it. For information on its use, see CircuitEditingContext Class.
IGraphAdapter<TNode, TEdge, TEdgeRoute>
where TNode : class, IGraphNode
where TEdge : class, IGraphEdge<TNode, TEdgeRoute>
where TEdgeRoute : class, IEdgeRoute
Interface for graph adapters, which manage rendering and picking for a graph in the adapted control. This is currently unused.
IGraphNodeOptionsProvider Interface for IGraphNode that can provide additional options for controlling the display and other aspects of a graph node.
IHierarchicalCircuitElementType<TElement, TWire, TPin>
where TElement : class, ICircuitElement
where TWire : class, IGraphEdge<TElement, TPin>
where TPin : class, ICircuitPin
IHierarchicalGraphNode<TElement, TWire, TPin>,
ICircuitElementType
Interface for a hierarchical circuit element type. Currently unused.
IHierarchicalGraphNode<out TNode, TEdge, TEdgeRoute>
where TNode : class, IGraphNode
where TEdge : class, IGraphEdge<TNode, TEdgeRoute>
where TEdgeRoute : class, IEdgeRoute
IGraphNode Interface for hierarchical nodes in a graph, which contain sub-nodes. For more information on this interface, see Group Class.
IState IGraphNode Interface for states in state-transition diagrams, such as statecharts. For more information, see Statechart Interfaces.

Topics in this section

Clone this wiki locally