コード例 #1
0
        /// <summary>
        /// 双击行头,相机飞入节点所在位置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (tour != null)
            {
                selectPointIndex = e.RowIndex;
                double            speed;
                gviCameraTourMode mode;

                int pointIndex = Convert.ToInt32(dt.Rows[selectPointIndex][0]);
                tour.GetWaypoint(pointIndex, out position, out angle, out speed, out mode);

                this.axRenderControl1.Camera.FlyTime = 0;
                this.axRenderControl1.Camera.SetCamera(position, angle, gviSetCameraFlags.gviSetCameraNoFlags);
            }
        }
コード例 #2
0
        private void LoadDynamicObjectAndLineFromFile()
        {
            ICameraTour tour     = null;
            string      tourPath = (strMediaPath + @"\xml\CameraTour_2.xml");

            if (File.Exists(tourPath))
            {
                StreamReader sr        = new StreamReader(tourPath);
                string       xmlstring = sr.ReadToEnd();
                sr.Close();
                tour = this.axRenderControl1.ObjectManager.CreateCameraTour(rootId);
                tour.FromXml(xmlstring);
            }
            if (tour == null)
            {
                MessageBox.Show("xml文件读取失败");
            }

            dynamicObject.CrsWKT = tour.CrsWKT;
            point.SpatialCRS     = new CRSFactory().CreateFromWKT(tour.CrsWKT) as ISpatialCRS;
            line.SpatialCRS      = new CRSFactory().CreateFromWKT(tour.CrsWKT) as ISpatialCRS;

            for (int i = 0; i < tour.WaypointsNumber; i++)
            {
                double            duration;
                gviCameraTourMode mode;
                tour.GetWaypoint(i, out position, out angle, out duration, out mode);
                dynamicObject.AddWaypoint(position, 10);

                point.Position = position;
                if (line.PointCount == 0)
                {
                    line.StartPoint = point;
                }
                else
                {
                    line.AddPointAfter(i - 1, point);
                }
            }

            ICurveSymbol cur = new CurveSymbol();

            cur.Color = System.Drawing.Color.Yellow;
            cur.Width = -2;
            rline     = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, cur, rootId);
        }
コード例 #3
0
        private void btnImportFromXML_Click(object sender, EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            od.Filter = "XML文件|*.xml";
            if (System.IO.Directory.Exists(strMediaPath))
            {
                od.InitialDirectory = strMediaPath + @"\xml";
            }
            od.RestoreDirectory = true;
            if (od.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(od.FileName))
                {
                    StreamReader sr        = new StreamReader(od.FileName);
                    string       xmlstring = sr.ReadToEnd();
                    sr.Close();
                    tour = null;
                    tour = this.axRenderControl1.ObjectManager.CreateCameraTour(rootId);
                    tour.FromXml(xmlstring);

                    if (tour.WaypointsNumber > 0)
                    {
                        //初始化节点表格
                        dt = new DataTable();
                        DataColumn dc0 = new DataColumn("index", typeof(int));
                        DataColumn dc1 = new DataColumn("x", typeof(double));
                        DataColumn dc2 = new DataColumn("y", typeof(double));
                        DataColumn dc3 = new DataColumn("z", typeof(double));
                        DataColumn dc4 = new DataColumn("heading", typeof(double));
                        DataColumn dc5 = new DataColumn("tilt", typeof(double));
                        DataColumn dc6 = new DataColumn("roll", typeof(double));
                        DataColumn dc7 = new DataColumn("duration", typeof(double));
                        DataColumn dc8 = new DataColumn("mode", typeof(string));
                        dt.Columns.AddRange(new DataColumn[] { dc0, dc1, dc2, dc3, dc4, dc5, dc6, dc7, dc8 });
                        this.dataGridView1.DataSource = dt;

                        for (int i = 0; i < tour.WaypointsNumber; i++)
                        {
                            double            duration;
                            gviCameraTourMode mode;
                            tour.GetWaypoint(i, out position, out angle, out duration, out mode);

                            //将值写入表格
                            DataRow dr = dt.NewRow();
                            dr[0] = i;
                            dr[1] = position.X;
                            dr[2] = position.Y;
                            dr[3] = position.Z;
                            dr[4] = angle.Heading;
                            dr[5] = angle.Tilt;
                            dr[6] = angle.Roll;
                            dr[7] = duration;
                            dr[8] = getModeString(mode);
                            dt.Rows.Add(dr);
                        }
                        this.dataGridView1.Update();

                        //更新Time滑动条最大值
                        decimal mathRound = Math.Round((decimal)tour.TotalTime, 2);
                        this.trackBarTime.Maximum = int.Parse(((double)mathRound * 100.0).ToString());
                    }
                }
            }
        }