예제 #1
0
        public BranchView getVccToGndBranch()
        {
            #region 将树状结构的节点放到一维集合中
            BranchView             rst   = getNodes(vccNodes[0].Equal, label => label == "GND");
            ISet <ShortBranchNode> brs   = rst.Nodes;
            ShortBranchNode        head  = brs.First().Parent;
            ISet <ShortBranchNode> total = expandBranch(brs);
            rst.Type = true;
            #endregion

            #region 过滤出所有总正到总负的通路
            filterNodes(total, name => name != "GND");
            #endregion

            #region 为短支路树计算位置信息
            ISet <ShortBranchNode> data = new HashSet <ShortBranchNode>(total.Where(p => p.Parent == head).ToList());
            CalculatePosition(data, 0, 0);
            if (rst.Type)
            {
                alignBranchNode(total, rst);
            }
            rst.Nodes = data;
            #endregion
            rst.GraphType = GraphType.VccToGndGraph;
            rst.GraphName = "总正至总负布线图";
            return(rst);
        }
예제 #2
0
 private void alignBranchNode(ISet <ShortBranchNode> expandNodes, BranchView view)
 {
     foreach (ShortBranchNode node in view.LabelToBranch.Values)
     {
         if (node == null)
         {
             continue;
         }
         var filterNodes = expandNodes.Where(p => node.EndName == p.EndName).ToList();
         if (filterNodes.Count == 0 || filterNodes.Count == 1)
         {
             continue;
         }
         double maxWidth = double.MinValue;
         foreach (ShortBranchNode br in filterNodes)
         {
             if (br.Uis[br.Uis.Count - 1].Pos.X > maxWidth)
             {
                 maxWidth = br.Uis[br.Uis.Count - 1].Pos.X;
             }
         }
         foreach (ShortBranchNode br in filterNodes)
         {
             double start = br.Uis[br.Uis.Count - 1].Pos.X;
             TNode  head  = br.Uis[br.Uis.Count - 1].Info.getHeadNode();
             TNode  tail  = br.Uis[br.Uis.Count - 1].Info.getTailNode();
             for (double x = start; x < maxWidth; x++)
             {
                 INotifyComponentChanged info = new ComponentViewModel(Tuple.Create <TNode, TNode>(head, tail), ComponentType.Blank);
                 TNodeUI ui = new TNodeUI(info, false, view.Observer);
                 ui.Pos = new Point(x + 1, br.Uis[br.Uis.Count - 1].Pos.Y);
                 br.Uis.Add(ui);
             }
             moveRight(br.Nodes, maxWidth - start);
         }
         double maxy = filterNodes.Max(p => p.Uis[p.Uis.Count - 1].Pos.Y);
         double miny = filterNodes.Min(p => p.Uis[p.Uis.Count - 1].Pos.Y);
         TNode  tm   = AppProject.GetInstance().Equals[node.EndName].First();
         INotifyComponentChanged _info = new ComponentViewModel(Tuple.Create <TNode, TNode>(tm, null), ComponentType.Blank);
         TNodeUI nui = new TNodeUI(_info, false, view.Observer);
         nui.Pos = new Point(node.Uis[node.Uis.Count - 1].Pos.X + 1, node.Uis[node.Uis.Count - 1].Pos.Y);
         List <TNodeUI> uis = new List <TNodeUI>()
         {
             nui
         };
         ShortBranchNode nnode = new ShortBranchNode(uis, node, node.EndName);
         foreach (ShortBranchNode nd in node.Nodes)
         {
             nnode.Nodes.Add(nd);
         }
         moveRight(node.Nodes, 1);
         node.Nodes.Clear();
         node.Nodes.Add(nnode);
     }
 }
예제 #3
0
        public BranchView getAllBranch()
        {
            BranchView rst = getNodes(vccNodes[0].Equal, label => false);

            CalculatePosition(rst.Nodes, 0, 0);
            if (rst.Type)
            {
                alignBranchNode(expandBranch(rst.Nodes), rst);
            }
            rst.GraphType = GraphType.CompleteGraph;
            rst.GraphName = "布线总图";
            return(rst);
        }
예제 #4
0
        public BranchView getCFToGndBranch()
        {
            #region 将树状结构的节点放到一维集合中
            BranchView             rst   = getNodes(gndNodes[0].Equal, label => label == "DC110V");
            ISet <ShortBranchNode> brs   = rst.Nodes;
            ShortBranchNode        head  = brs.First().Parent;
            ISet <ShortBranchNode> total = expandBranch(brs);
            #endregion

            #region 过滤出所有总负到测试点的通路
            AppProject    pro    = AppProject.GetInstance();
            ISet <string> remain = new HashSet <string>();
            foreach (ShortBranchNode node in total)
            {
                if (node.Nodes.Count == 0)
                {
                    bool mark = false;
                    foreach (TNode tnode in pro.Equals[node.EndName])
                    {
                        if (tnode.PartType.StartsWith("接口连接器"))
                        {
                            mark = true;
                            break;
                        }
                    }
                    if (mark)
                    {
                        ShortBranchNode tp = node;
                        while (tp != null)
                        {
                            remain.Add(tp.EndName);
                            tp = tp.Parent;
                        }
                    }
                }
            }
            //先把叶节点中末端是测试点的标注出来
            bool next = true;
            while (next)
            {
                next = false;
                List <ShortBranchNode> temp = new List <ShortBranchNode>();
                foreach (ShortBranchNode node in total)
                {
                    if (node.Nodes.Count == 0)
                    {
                        bool mark = false;
                        foreach (TNode tnode in pro.Equals[node.EndName])
                        {
                            if (tnode.PartType.StartsWith("接口连接器"))
                            {
                                mark = true;
                                if (!node.Uis[node.Uis.Count - 1].Info.isCFNode())
                                {
                                    INotifyComponentChanged info = new ComponentViewModel(Tuple.Create <TNode, TNode>(tnode, null), ComponentType.Terminal);
                                    node.Uis.Add(new TNodeUI(info, false, rst.Observer));
                                }
                                break;
                            }
                        }
                        if (!mark)
                        {
                            if (!remain.Contains(node.EndName))
                            {
                                node.remove();
                                temp.Add(node);
                                next = true;
                            }
                            else
                            {
                                ShortBranchNode tp = node;
                                while (tp != null)
                                {
                                    remain.Add(tp.EndName);
                                    tp = tp.Parent;
                                }
                            }
                        }
                    }
                }
                foreach (ShortBranchNode node in temp)
                {
                    total.Remove(node);
                }
            }
            rst.Nodes = removeRedundentRoute(rst.Nodes, total);//去除冗余的支路
            #endregion

            #region 为短支路树计算位置信息
            ISet <ShortBranchNode> data = new HashSet <ShortBranchNode>(total.Where(p => p.Parent == head).ToList());
            CalculatePosition(data, 0, 0);
            if (rst.Type)
            {
                alignBranchNode(total, rst);
            }
            rst.Nodes = data;
            #endregion
            rst.GraphType = GraphType.CFToGndGraph;
            rst.GraphName = "测试点至总负布线图";
            return(rst);
        }