Beispiel #1
0
        // 添加ListView项
        private void ListView_AddItem(PosNode node)
        {
            var item = new ListViewItem(new[] { "" });

            item.Tag       = node.Id;
            item.BackColor = node.Color;
            item.Checked   = true;
            listView1.Items.Insert(0, item);
            int    id   = node.Id;
            string desc = node.Id.ToString();

            if (id == 0)
            {
                desc = "里程计";
            }
            else if (id < 1000)
            {
                switch (id % 10)
                {
                case 0:
                    desc = id / 10 + "原始";
                    break;

                case 1:
                    desc = id / 10 + "滤波";
                    break;

                case 2:
                    desc = id / 10 + "Kalman";
                    break;

                case 3:
                    desc = id / 10 + "融合";
                    break;

                default:
                    break;
                }
            }
            else if (id > 1000000)
            {
                desc = id / 1000000 + "(" + id % 1000000 / 10000 + "," +
                       id % 10000 / 100 + "," + id % 100 + ")";
            }
            item     = new ListViewItem(new[] { desc });
            item.Tag = node.Id;
            listView2.Items.Insert(0, item);
            MapBox_Resize(null, null);
        }
Beispiel #2
0
        /// <summary>
        ///     更新定位
        /// </summary>
        public void UpdatePos(List <Node> nodeList)
        {
            Invoke(new Action <List <Node> >(nodes =>
            {
                foreach (var node in nodes)
                {
                    PosNode posNode = null;
                    foreach (var pos in posList)
                    {
                        if (pos.Id == node.Id)
                        {
                            posNode = pos;
                            break;
                        }
                    }

                    if (posNode == null) // 无则新建
                    {
                        posNode = new PosNode(node);
                        posList.Add(posNode);
                        ListView_AddItem(posNode);
                    }
                    else // 有则更新
                    {
                        // 轨迹录点
                        if (record)
                        {
                            posNode.PosList.Add(new Node(posNode));
                            for (var i = posNode.PosList.Count - 2; i >= 0; i--)
                            {
                                if (posNode.PosList[i].Tag >= 0)
                                {
                                    if (posNode.PosList[i].distance(posNode) < MinSpacing)
                                    {
                                        posNode.PosList.Last().Tag -= 101;
                                    }
                                    break;
                                }
                            }
                        }

                        // 更新
                        posNode.Set(node.X, node.Y, node.Tag, node.Yaw);
                    }
                }
            }), nodeList);
            Invalidate();
        }