コード例 #1
0
        public override void DoubleClick(Action <string> showMsg)
        {
            IShortBranchTreeGenerator graph = new DigraphBuilder();

            graph.buildRoutes();
            if (pro.VccToCF == null)
            {
                pro.VccToCF = graph.getVccToCFBranch();
            }
            showMsg("加载总正至测试点部分图纸...\r\n");
            Messenger.Default.Send <BranchView>(
                pro.VccToCF
                , "ShowGraph");
        }
コード例 #2
0
        public override void DoubleClick(Action <string> showMsg)
        {
            IShortBranchTreeGenerator graph = new DigraphBuilder();

            graph.buildRoutes();
            if (pro.CompleteBr == null)
            {
                pro.CompleteBr = graph.getAllBranch();
            }
            showMsg("加载布线总图...\r\n");
            Messenger.Default.Send <BranchView>(
                pro.CompleteBr
                , "ShowGraph");
        }
コード例 #3
0
        private void setSearchSource(ISet <ShortBranchNode> brs)
        {
            ISet <ShortBranchNode> total = DigraphBuilder.expandBranch(brs);

            foreach (ShortBranchNode node in total)
            {
                foreach (TNodeUI ui in node.Uis)
                {
                    cptNames.Add(ui.Info.getName());
                    allCpts.Add(ui);
                }
            }
            SearchList.ItemsSource = cptNames;
        }
コード例 #4
0
        /// <summary>
        /// 添加电路图中的元件,并设置其位置
        /// </summary>
        private void drawGraph(ISet <ShortBranchNode> brs, bool left, bool right)
        {
            //绘制并联电路的封闭垂线
            if (view.Type)
            {
                ISet <ShortBranchNode> total = DigraphBuilder.expandBranch(brs);
                foreach (ShortBranchNode node in view.LabelToBranch.Values)
                {
                    if (node == null || node.EndName == "GND" || node.EndName == "DC110V")
                    {
                        continue;
                    }
                    var filterNodes = total.Where(p => node.EndName == p.EndName).ToList();
                    if (filterNodes.Count == 0 || filterNodes.Count == 1)
                    {
                        continue;
                    }
                    double max = filterNodes.Max(p => p.Uis[p.Uis.Count - 1].Pos.Y);
                    double min = filterNodes.Min(p => p.Uis[p.Uis.Count - 1].Pos.Y);
                    INotifyComponentChanged info   = node.Nodes.First().Uis[node.Nodes.First().Uis.Count - 1].Info;
                    INotifyComponentChanged cpinfo = info.clone();
                    view.Observer.addListener(cpinfo);
                    VerticalLine line = new VerticalLine(cpinfo);
                    line.setLineLength((max - min) * 60);
                    ShortBranchNode brnode = filterNodes.FirstOrDefault(p => p.Uis[p.Uis.Count - 1].Pos.Y == min);
                    Canvas.SetLeft(line, DigraphBuilder.START_POS.X + brnode.Uis[brnode.Uis.Count - 1].Pos.X * 150 + 150);
                    Canvas.SetTop(line, DigraphBuilder.START_POS.Y + brnode.Uis[0].Pos.Y * 60 + 37.5);
                    map.Children.Add(line);
                }
            }

            //总正垂线
            if (left)
            {
                Line line = new Line();
                line.Stroke          = Brushes.Black;
                line.StrokeThickness = 1;
                line.X1 = 0; line.Y1 = 0;
                line.X2 = 0; line.Y2 = (brs.Last().Uis[0].Pos.Y - brs.First().Uis[0].Pos.Y) * 60;
                Canvas.SetLeft(line, DigraphBuilder.START_POS.X + brs.First().Uis[0].Pos.X * 150);
                Canvas.SetTop(line, DigraphBuilder.START_POS.Y + brs.First().Uis[0].Pos.Y * 60 + 37.5);
                map.Children.Add(line);
            }

            /*核心元器件*/
            List <TNodeUI>         uis = new List <TNodeUI>();
            double                 widthMax = 0, heightMax = 0;
            double                 miny = double.MaxValue, maxy = double.MinValue, maxx = double.MinValue;
            ISet <ShortBranchNode> branchs = new HashSet <ShortBranchNode>(brs);

            while (branchs.Count != 0)
            {
                ISet <ShortBranchNode> temp = new HashSet <ShortBranchNode>();
                foreach (ShortBranchNode brNode in branchs)
                {
                    foreach (ShortBranchNode child in brNode.Nodes)
                    {
                        temp.Add(child);
                    }
                    if (brNode.Nodes.Count == 0)
                    {
                        if (brNode.Uis[0].Pos.Y < miny)
                        {
                            miny = brNode.Uis[0].Pos.Y;
                        }
                        if (brNode.Uis[0].Pos.Y > maxy)
                        {
                            maxy = brNode.Uis[0].Pos.Y;
                        }
                        if (brNode.Uis.Last().Pos.X > maxx)
                        {
                            maxx = brNode.Uis.Last().Pos.X;
                        }
                        if (brNode.EndName == "GND")
                        {
                            uis.Add(brNode.Uis.Last());
                        }
                    }
                    foreach (TNodeUI ui in brNode.Uis)
                    {
                        UIElement ele = BranchFactory.convert(ui);
                        map.Children.Add(ele);
                        ElectricAnalysis.Graph.Point realPos = ui.RealPos;
                        Canvas.SetLeft(ele, realPos.X);
                        Canvas.SetTop(ele, realPos.Y);
                        if (DigraphBuilder.START_POS.X + ui.Pos.X * 150 > widthMax)
                        {
                            widthMax = DigraphBuilder.START_POS.X + ui.Pos.X * 150;
                        }
                        if (DigraphBuilder.START_POS.Y + ui.Pos.Y * 60 > heightMax)
                        {
                            heightMax = DigraphBuilder.START_POS.Y + ui.Pos.Y * 60;
                        }
                    }
                    //绘垂线
                    if (brNode.Nodes.Count > 1)
                    {
                        INotifyComponentChanged cpinfo = brNode.Uis[brNode.Uis.Count - 1].Info.clone();
                        view.Observer.addListener(cpinfo);
                        VerticalLine line = new VerticalLine(cpinfo);
                        line.setLineLength((brNode.Nodes.Last().Uis[0].Pos.Y - brNode.Nodes.First().Uis[0].Pos.Y) * 60);
                        Canvas.SetLeft(line, DigraphBuilder.START_POS.X + brNode.Nodes.First().Uis[0].Pos.X * 150);
                        Canvas.SetTop(line, DigraphBuilder.START_POS.Y + brNode.Nodes.First().Uis[0].Pos.Y * 60 + 37.5);
                        map.Children.Add(line);
                    }
                }
                branchs = temp;
            }
            outerBd.Width  = widthMax + 250;
            outerBd.Height = heightMax + 150;

            //总负垂线
            if (right)
            {
                Line line = new Line();
                line.Stroke          = Brushes.Black;
                line.StrokeThickness = 1;
                line.X1 = 0; line.Y1 = 0;
                line.X2 = 0; line.Y2 = (maxy - miny) * 60;
                Canvas.SetLeft(line, widthMax + 150);
                Canvas.SetTop(line, DigraphBuilder.START_POS.Y + brs.First().Uis[0].Pos.Y * 60 + 37.5);
                map.Children.Add(line);
                foreach (TNodeUI ui in uis)
                {
                    for (double i = ui.Pos.X + 1; i <= maxx; i++)
                    {
                        BlankLine bk = new BlankLine(ui.Info);
                        map.Children.Add(bk);
                        Canvas.SetLeft(bk, DigraphBuilder.START_POS.X + i * 150);
                        Canvas.SetTop(bk, DigraphBuilder.START_POS.Y + ui.Pos.Y * 60);
                    }
                }
            }
        }
コード例 #5
0
        public static void testNodesCount()
        {
            var          brs   = DigraphBuilder.expandBranch(AppProject.GetInstance().CompleteBr.Nodes);
            ISet <TNode> nodes = new HashSet <TNode>();

            foreach (var br in brs)
            {
                br.Uis.ForEach(p =>
                {
                    nodes.Add(p.Info.getHeadNode());
                    if (p.Info.getTailNode() != null)
                    {
                        nodes.Add(p.Info.getTailNode());
                    }
                });
            }
            Console.Write(string.Format("总图包含节点数:{0},总结点数为:{1}\r\n", nodes.Count, AppProject.GetInstance().Nodes.Count));
            nodes.Clear();
            brs = DigraphBuilder.expandBranch(AppProject.GetInstance().VccToGnd.Nodes);
            foreach (var br in brs)
            {
                br.Uis.ForEach(p =>
                {
                    nodes.Add(p.Info.getHeadNode());
                    if (p.Info.getTailNode() != null)
                    {
                        nodes.Add(p.Info.getTailNode());
                    }
                });
            }
            brs = DigraphBuilder.expandBranch(AppProject.GetInstance().GndToCF.Nodes);
            foreach (var br in brs)
            {
                br.Uis.ForEach(p =>
                {
                    nodes.Add(p.Info.getHeadNode());
                    if (p.Info.getTailNode() != null)
                    {
                        nodes.Add(p.Info.getTailNode());
                    }
                });
            }
            Console.Write(string.Format("两个子图包含节点数:{0}\r\n", nodes.Count));
            HashSet <TNode> tnodes = new HashSet <TNode>();

            foreach (ShortBranch br in AppProject.GetInstance().Shorts)
            {
                br.Branch.ForEach(p => tnodes.Add(p));
            }
            Console.Write(string.Format("所有短支路中包含节点数为:{0}\r\n", tnodes.Count));
            nodes.Clear();
            foreach (var list in AppProject.GetInstance().Equals.Values)
            {
                foreach (var one in list)
                {
                    nodes.Add(one);
                }
            }
            Console.Write(string.Format("所有等电位点包含的节点数为:{0}\r\n", nodes.Count));

            foreach (var nd in tnodes)
            {
                nodes.Remove(nd);
            }
            foreach (var nd in nodes)
            {
                if (nd.TNType != TerminalType.Block && nd.TNType != TerminalType.RE && !nd.PartType.Contains("设备连接") && !nd.PartType.Contains("端子排") && !nd.PartType.Contains("接口连接"))
                {
                }
            }
        }