Beispiel #1
0
            public void ProcessNode(Node node)
            {
                for (int i = _processedNodes; i < AddedNodes.Count; i++)
                {
                    if (AddedNodes[i] != node)
                    {
                        continue;
                    }

                    bool isChanged = false;

                    while (i > _processedNodes)
                    {
                        // This only happens if we weren't in topo order
                        if (Debugger.IsAttached)
                        {
                            Debugger.Break();
                        }

                        AddedNodes.Swap(i - 1, i);
                        i--;
                        isChanged = true;
                    }

                    // Signal that these rows have changed
                    if (isChanged)
                    {
                        Updated?.Invoke();
                    }

                    _processedNodes++;
                    break;
                }
            }
Beispiel #2
0
 public void Clear()
 {
     AddedNodes.Clear();
     _junctions.Clear();
     Nodes.Clear();
     _lanes.Clear();
     Count = 0;
 }
 public static void AddDCTextures(NetInfo netInfo)
 {
     try {
         var node = NodeInfoUtil.CreateDCNode(netInfo.m_nodes[0], netInfo);
         if (node == null)
         {
             return;
         }
         netInfo.m_nodes                  = NodeInfoUtil.AddNode(netInfo.m_nodes, node);
         netInfo.m_connectGroup          |= node.m_connectGroup;
         netInfo.m_nodeConnectGroups     |= node.m_connectGroup;
         netInfo.m_requireDirectRenderers = true;
         AddedNodes.Add(node);
     }
     catch (Exception e) {
         Log.Error(e.ToString());
     }
 }
Beispiel #4
0
 public static void AddDCTextures(NetInfo netInfo, float voffset /* = ASPHALT_HEIGHT*/)
 {
     try {
         var nodes = NodeInfoUtil.CreateDCNodes(netInfo.m_nodes[0], netInfo, voffset);
         if (nodes == null)
         {
             return;
         }
         foreach (var node in nodes)
         {
             netInfo.m_nodes                  = NodeInfoUtil.AddNode(netInfo.m_nodes, node);
             netInfo.m_connectGroup          |= node.m_connectGroup;
             netInfo.m_nodeConnectGroups     |= node.m_connectGroup;
             netInfo.m_requireDirectRenderers = true;
             AddedNodes.Add(node);
         }
     } catch (Exception e) {
         Log.Error(e.ToString());
     }
 }
Beispiel #5
0
 private bool HasNode(INode n)
 {
     return(AddedNodes.Contains(n));
 }
Beispiel #6
0
            public void Add(GitRevision revision, DataTypes types)
            {
                var parentIds = revision.ParentGuids;

                // If we haven't seen this node yet, create a new junction.
                if (!GetNode(revision.Guid, out var node) && (parentIds == null || parentIds.Count == 0))
                {
                    _junctions.Add(new Junction(node, node));
                }

                Count++;
                node.Data      = revision;
                node.DataTypes = types;
                node.Index     = AddedNodes.Count;
                AddedNodes.Add(node);

                foreach (string parentId in parentIds)
                {
                    GetNode(parentId, out var parent);

                    if (parent.Index < node.Index)
                    {
                        // TODO: We might be able to recover from this with some work, but
                        // since we build the graph async it might be tough to figure out.
                        Debug.WriteLine("The nodes must be added such that all children are added before their parents");
                        continue;
                    }

                    if (node.Descendants.Count == 1 && node.Ancestors.Count <= 1 &&
                        node.Descendants[0].Oldest == node &&
                        parent.Ancestors.Count == 0

                        // If this is true, the current revision is in the middle of a branch
                        // and is about to start a new branch. This will also mean that the last
                        // revisions are non-relative. Make sure a new junction is added and this
                        // is the start of a new branch (and color!)
                        && !types.HasFlag(DataTypes.Active))
                    {
                        // The node isn't a junction point. Just the parent to the node's
                        // (only) ancestor junction.
                        node.Descendants[0].Add(parent);
                    }
                    else if (node.Ancestors.Count == 1 && node.Ancestors[0].Youngest != node)
                    {
                        // The node is in the middle of a junction. We need to split it.
                        _junctions.Add(node.Ancestors[0].SplitIntoJunctionWith(node));

                        // The node is a junction point. We are a new junction
                        _junctions.Add(new Junction(node, parent));
                    }
                    else if (parent.Descendants.Count == 1 && parent.Descendants[0].Oldest != parent)
                    {
                        // The parent is in the middle of a junction. We need to split it.
                        _junctions.Add(parent.Descendants[0].SplitIntoJunctionWith(parent));

                        // The node is a junction point. We are a new junction
                        _junctions.Add(new Junction(node, parent));
                    }
                    else
                    {
                        // The node is a junction point. We are a new junction
                        _junctions.Add(new Junction(node, parent));
                    }
                }

                bool isRelative = types.HasFlag(DataTypes.Active);

                if (!isRelative && node.Descendants.Any(d => d.IsRelative))
                {
                    isRelative = true;
                }

                bool isRebuild = false;

                foreach (var ancestor in node.Ancestors)
                {
                    ancestor.IsRelative = isRelative || ancestor.IsRelative;

                    // Uh, oh, we've already processed this lane. We'll have to update some rows.
                    var parent = ancestor.TryGetParent(node);
                    if (parent != null && parent.InLane != int.MaxValue)
                    {
                        int resetTo = ancestor.Oldest.Descendants.Aggregate(ancestor.Oldest.InLane, (current, dd) => Math.Min(current, dd.Youngest.InLane));
                        Debug.WriteLine("We have to start over at lane {0} because of {1}", resetTo, node);
                        isRebuild = true;
                        break;
                    }
                }

                if (isRebuild)
                {
                    // TODO: It would be nice if we didn't have to start completely over...but it wouldn't
                    // be easy since we don't keep around all of the necessary lane state for each step.
                    int lastLane = _lanes.Count - 1;
                    _lanes.Clear();
                    _lanes.CacheTo(lastLane);

                    // We need to signal the DvcsGraph object that it needs to redraw everything.
                    Updated?.Invoke();
                }
                else
                {
                    _lanes.Update(node);
                }
            }
Beispiel #7
0
 public bool IsAddedNode(PSMComponent component)
 {
     return(AddedNodes.Contains(component));
 }