public int[] ReorderRails(IntervalTree tree, int[] rails, double selectionStart, double selectionEnd)
        {
            List <KeyValuePair <int, double> > railTimes = new List <KeyValuePair <int, double> >(rails.Length);

            long selectionStartUs = (long)(selectionStart * 1000000.0);
            long selectionEndUs   = (long)(selectionEnd * 1000000.0);

            foreach (int railId in rails)
            {
                double t = double.MaxValue;

                bool railIntersectsSelection = false;

                foreach (var iv in tree.RangeEnum(railId, selectionStartUs, selectionEndUs))
                {
                    railIntersectsSelection = true;
                    break;
                }

                if (railIntersectsSelection)
                {
                    foreach (var iv in tree.RangeEnum(railId, selectionStartUs, tree.MaxTimeUs))
                    {
                        StreamingInterval siv = iv as StreamingInterval;
                        if ((siv.Stage & StreamingStage.IO) != 0)
                        {
                            t = Math.Min(t, iv.Start);
                            break;
                        }
                    }
                }

                railTimes.Add(new KeyValuePair <int, double>(railId, t));
            }

            railTimes.Sort(new KeyValuePair_SecondComparer <int, double>());
            return(railTimes.Select((x) => x.Key).ToArray <int>());
        }
示例#2
0
        void PopulateIntervalTreeView(CheckboxTreeView treeView, IntervalTree tree)
        {
            lock (tree)
            {
                foreach (RailGroup rg in tree.Groups)
                {
                    TreeNode node = null;

                    string name = rg.Name;

                    if (!m_pathsInIntervalTree.ContainsKey(name))
                    {
                        TreeNodeCollection nodes = treeView.Nodes;

                        foreach (string location in name.PathLocations())
                        {
                            if (nodes.ContainsKey(location))
                            {
                                node = nodes[location];
                            }
                            else
                            {
                                node         = new TreeNode(location);
                                node.Name    = location;
                                node.Checked = true;
                                node.Tag     = rg;
                                nodes.Add(node);
                            }

                            nodes = node.Nodes;
                        }

                        m_pathsInIntervalTree.Add(name, node);
                    }
                    else
                    {
                        node = m_pathsInIntervalTree[name];
                    }

                    foreach (int railId in rg.Rails)
                    {
                        string   railName = tree.GetRailName(railId);
                        TreeNode railNode = node;

                        if (!m_pathsInIntervalTree.ContainsKey(railName))
                        {
                            TreeNodeCollection nodes = railNode.Nodes;

                            foreach (string location in railName.PathLocations())
                            {
                                if (nodes.ContainsKey(location))
                                {
                                    railNode = nodes[location];
                                }
                                else
                                {
                                    railNode         = new TreeNode(location);
                                    railNode.Name    = location;
                                    railNode.Checked = true;
                                    railNode.Tag     = new KeyValuePair <RailGroup, int>(rg, railId);
                                    nodes.Add(railNode);
                                }

                                nodes = railNode.Nodes;
                            }

                            m_pathsInIntervalTree.Add(railName, railNode);

                            /*
                             * TreeNode leafNode = new TreeNode(location);
                             * leafNode.Name = location;
                             * leafNode.Checked = true;
                             * leafNode.Tag = new KeyValuePair<RailGroup, int>(rg, railId);
                             * node.Nodes.Add(leafNode);
                             * m_pathsInIntervalTree.Add(location, leafNode);
                             */
                        }
                    }
                }
            }
        }
 public int[] ReorderRails(IntervalTree tree, int[] rails, double selectionStart, double selectionEnd)
 {
     return(rails);
 }