public void UpdateRootNode(bool add) { this.mRootNode = null; if (this.mDGraph.NodeCount > 0) { int i, count = this.mDGraph.NodeCount; for (i = 0; i < count; i++) { this.mRootNode = this.mDGraph.NodeAt(i) as DGRootNode; if (this.mRootNode != null) { break; } } if (this.mRootNode != null && i > 0) { // TODO: Swap root node and this.mDGraph.NodeAt(0) } } if (this.mRootNode == null && add) { DecisionGraph dg = this.mState.DecisionGraph; if (dg != null) { this.mRootNode = new DGRootNode(dg, this); this.mDGraph.InsertNode(0, this.mRootNode); this.mRootNode.SetParent(this); } } }
public void AddRootDGEdges() { if (this.mRootNode == null) { DecisionGraph dg = this.mState.DecisionGraph; if (dg != null) { this.mRootNode = new DGRootNode(dg, this); this.mDGraph.InsertNode(0, this.mRootNode); this.mRootNode.SetParent(this); } } if (this.mRootNode != null) { DGNode node; DGEdge edge; List <DGEdge> edges = this.mRootNode.EntryAnchor.Edges; for (int i = this.mDGraph.NodeCount - 1; i > 0; i--) { node = this.mDGraph.NodeAt(i); if (node.EntryAnchor.Edges.Count == 0) { edge = new DGEdge(this.mRootNode, node, true); edges.Add(edge); node.EntryAnchor.Edges.Add(edge); this.mDGraph.AddEdge(edge); edge.SetParent(this); } } } }
private void InitDecisionGraph() { this.mDGraph = new Digraph <DGNode, DGEdge>(); DecisionGraph dg = this.mState.DecisionGraph; if (dg != null) { int i; DGNode dst; //DGEdge edge; //AnchorPoint ap; DecisionGraphNode dgn; DecisionGraphNode[] dgns; this.mRootNode = new DGRootNode(dg, this); this.mDGraph.AddNode(this.mRootNode); this.mRootNode.SetParent(this); if (dg.DecisionMakerCount > 0) { dgns = dg.DecisionMakers; //ap = root.DecisionMakerAnchor; for (i = 0; i < dgns.Length; i++) { dgn = dgns[i]; if (dgn != null) { dst = this.InitDGN(this.mRootNode, dgn); dst.SetCategory(DGNode.DGFlag.DecisionMaker); /*edge = new DGEdge(root, dst); * ap.Edges.Add(edge); * dst.EntryAnchor.Edges.Add(edge); * this.mDecisionGraph.AddEdge(edge); * edge.SetParent(this);/* */ } } } if (dg.EntryPointCount > 0) { dgns = dg.EntryPoints; //ap = root.EntryAnchor; for (i = 0; i < dgns.Length; i++) { dgn = dgns[i]; if (dgn != null) { dst = this.InitDGN(this.mRootNode, dgn); dst.SetCategory(DGNode.DGFlag.EntryPoint); /*edge = new DGEdge(root, dst); * ap.Edges.Add(edge); * dst.EntryAnchor.Edges.Add(edge); * this.mDecisionGraph.AddEdge(edge); * edge.SetParent(this);/* */ } } } this.AddRootDGEdges(); } }
public DGRootNode(DecisionGraph dg, StateNode state) : base(null, state) { if (dg == null) { throw new ArgumentNullException("dg"); } this.mDecisionGraph = dg; this.mEntryAnchor.SetPosition(sRad, 0); this.mEntryAnchor.SetDirection(1, 0); this.UpdateVisualization(); }
private void UpdateDecisionGraph() { DecisionGraph dg = this.mState.State.DecisionGraph; if (dg != null && this.mDGN != null) { dg.Remove(this.mDGN); if ((DGFlag.EntryPoint & this.mCategory) == DGFlag.EntryPoint) { dg.AddEntryPoint(this.mDGN); } if ((DGFlag.DecisionMaker & this.mCategory) == DGFlag.DecisionMaker) { dg.AddDecisionMaker(this.mDGN); } } }
private void SetValue(DGFlag value) { DecisionGraph dg = this.mNode.mState.State.DecisionGraph; if (dg != null && this.mNode.mDGN != null) { dg.Remove(this.mNode.mDGN); if ((DGFlag.EntryPoint & value) == DGFlag.EntryPoint) { dg.AddEntryPoint(this.mNode.mDGN); } if ((DGFlag.DecisionMaker & value) == DGFlag.DecisionMaker) { dg.AddDecisionMaker(this.mNode.mDGN); } } this.mNode.mCategory = value; }