示例#1
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();
        }