Beispiel #1
0
 /// <summary>
 /// 加载MotionPath
 /// </summary>
 private void LoadMotionPath()
 {
     motionPath        = CommonUnity.RenderHelper.ObjectManager.CreateMotionPath(rootId);
     motionPath.CrsWKT = datasetCRS.AsWKT();
     //为MotionPath添加第一个点
     position.SetCoords(firstX, firstY, firstZ, 0, 0);
     angle.Set(firstH, firstP, firstR);
     scale.Set(firstSX, firstSY, firstSZ);
     motionPath.AddWaypoint2(position, angle, scale, firtWhen);
     //为MotionPath添加第二个点
     position.SetCoords(secondX, secondY, secondZ, 0, 0);
     angle.Set(secondH, secondP, secondR);
     scale.Set(secondSX, secondSY, secondSZ);
     motionPath.AddWaypoint2(position, angle, scale, secondWhen);
     //为MotionPath添加第三个点
     position.SetCoords(thirdX, thirdY, thirdZ, 0, 0);
     angle.Set(thirdH, thirdP, thirdR);
     scale.Set(thirdSX, thirdSY, thirdSZ);
     motionPath.AddWaypoint2(position, angle, scale, thirdWhen);
     //为MotionPath添加第四个点
     position.SetCoords(fourthX, fourthY, fourthZ, 0, 0);
     angle.Set(fourthH, fourthP, fourthR);
     scale.Set(fourthSX, fourthSY, fourthSZ);
     motionPath.AddWaypoint2(position, angle, scale, fourthWhen);
 }
Beispiel #2
0
        private void ToolStripMenuItemCreateRenderPolyline_Click(object sender, EventArgs e)
        {
            motionPath = this.axRenderControl1.ObjectManager.CreateMotionPath(rootId);

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(Application.StartupPath + @"\MotionPath.xml");
            string wkt = xmlDoc.SelectSingleNode("root/WKT").InnerText;

            motionPath.CrsWKT = wkt;
            IPoint point = new GeometryFactory().CreatePoint(gviVertexAttribute.gviVertexAttributeZ);

            point.SpatialCRS = new CRSFactory().CreateFromWKT(wkt) as ISpatialCRS;
            IPolyline line = new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;

            line.SpatialCRS = new CRSFactory().CreateFromWKT(wkt) as ISpatialCRS;

            XmlNodeList nodes = xmlDoc.SelectNodes("root/Waypoint");
            int         i     = 0;

            foreach (XmlNode node in nodes)
            {
                double x = double.Parse(node.SelectSingleNode("X").InnerText);
                double y = double.Parse(node.SelectSingleNode("Y").InnerText);
                double z = double.Parse(node.SelectSingleNode("Z").InnerText);
                position.Set(x, y, z);
                point.Position = position;
                if (line.PointCount == 0)
                {
                    line.StartPoint = point;
                }
                else
                {
                    line.AddPointAfter(i - 1, point);
                }
                i++;

                double heading = double.Parse(node.SelectSingleNode("Heading").InnerText);
                double tilt    = double.Parse(node.SelectSingleNode("Tilt").InnerText);
                double roll    = double.Parse(node.SelectSingleNode("Roll").InnerText);
                double when    = double.Parse(node.SelectSingleNode("When").InnerText);
                angle.Set(heading, tilt, roll);
                scale.Set(1, 1, 1);
                motionPath.AddWaypoint2(point, angle, scale, when);
            }

            IRenderPolyline rpl = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, null, selectedId);

            rpl.Name = "RenderPolyline";
            TreeNode treeNode = new TreeNode("RenderPolyline", 1, 1);

            treeNode.Tag     = rpl.Guid;
            treeNode.Checked = true;
            selectedNode.Nodes.Add(treeNode);
            this.treeView1.UpdateView();
        }
Beispiel #3
0
        private void LoadMotionPathAndLineFromFile()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(Application.StartupPath + @"MotionPath.xml");
            wkt = xmlDoc.SelectSingleNode("root/WKT").InnerText;
            // 指定坐标系与xml里的相同
            motionPath.CrsWKT = xmlDoc.SelectSingleNode("root/WKT").InnerText;
            point.SpatialCRS  = new CRSFactory().CreateFromWKT(motionPath.CrsWKT) as ISpatialCRS;
            line.SpatialCRS   = new CRSFactory().CreateFromWKT(motionPath.CrsWKT) as ISpatialCRS;

            XmlNodeList nodes = xmlDoc.SelectNodes("root/Waypoint");
            int         i     = 0;

            foreach (XmlNode node in nodes)
            {
                double x       = double.Parse(node.SelectSingleNode("X").InnerText);
                double y       = double.Parse(node.SelectSingleNode("Y").InnerText);
                double z       = double.Parse(node.SelectSingleNode("Z").InnerText);
                double heading = double.Parse(node.SelectSingleNode("Heading").InnerText);
                double tilt    = double.Parse(node.SelectSingleNode("Tilt").InnerText);
                double roll    = double.Parse(node.SelectSingleNode("Roll").InnerText);
                double when    = double.Parse(node.SelectSingleNode("When").InnerText);
                position.Set(x, y, z);
                point.Position = position;
                if (line.PointCount == 0)
                {
                    line.StartPoint = point;
                }
                else
                {
                    line.AddPointAfter(i - 1, point);
                }
                i++;
                angle.Set(heading, tilt, roll);
                scale.Set(1, 1, 1);
                motionPath.AddWaypoint2(point, angle, scale, when);
                this.axRenderControl1.ObjectManager.CreateRenderPoint(point, null, rootId);
            }

            ICurveSymbol cur = new CurveSymbol();

            cur.Color = System.Drawing.Color.Red;
            cur.Width = -2;
            rline     = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, cur, rootId);
        }