private void btnCreateTour_Click(object sender, EventArgs e) { init(); tour = this.axRenderControl1.ObjectManager.CreateCameraTour(rootId); //初始化节点表格 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; //初始化节点索引 selectPointIndex = -1; cbMode.SelectedIndex = 0; //初始化Time滑动条 this.trackBarTime.Maximum = 0; }
public void AddUCFrameEdit(ICameraTour tour) { this.ucFrameEdit1 = new UCFrameEdit(tour); this.ucFrameEdit1.Dock = DockStyle.Fill; this.Controls.Clear(); this.Controls.Add(this.ucFrameEdit1); }
private void init() { if (tour != null) { this.axRenderControl1.ObjectManager.DeleteObject(tour.Guid); tour = null; } }
private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { tour = (ICameraTour)this.dataGridView1.Rows[e.RowIndex].Cells[1].Value; if (tour != null && tour.WaypointsNumber > 0) { tour.Play(); this.btnPause.Enabled = true; this.btnStop.Enabled = true; } }
// 注册输出视频事件 public void AdviseEvent(ICameraTour tour, System.Collections.ArrayList list, string fileName, int vindex, string fileType, int fps, TreeList treelist, TreeListNode lastNodeInGroup) { this.UnAdviseEvent(); d3.RcVideoExportBegin += new Gvitech.CityMaker.Controls._IRenderControlEvents_RcVideoExportBeginEventHandler(this.AxRenderControl_RcVideoExportBegin); d3.RcVideoExporting += new Gvitech.CityMaker.Controls._IRenderControlEvents_RcVideoExportingEventHandler(this.AxRenderControl_RcVideoExporting); d3.RcVideoExportEnd += new Gvitech.CityMaker.Controls._IRenderControlEvents_RcVideoExportEndEventHandler(this.AxRenderControl_RcVideoExportEnd); this._tour = tour; this._groupNodeToPlay = list; this._fileName = fileName; this._vindex = vindex; this._fileType = fileType; this._fps = fps; this._treelist = treelist; this._lastNodeInGroup = lastNodeInGroup; }
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); }
// 输出视频结束 private void AxRenderControl_RcVideoExportEnd(object sender, _IRenderControlEvents_RcVideoExportEndEvent e) { if (e.isAborted) { XtraMessageBox.Show("输出取消!", "提示"); this._dlg.Close(); this.UnAdviseEvent(); return; } if (this._groupNodeToPlay == null) { this.time = e.time; this.time /= 1000.0; this.time = System.Math.Round(this.time, 2); XtraMessageBox.Show("输出完成,用时" + this.time + "秒。", "提示"); this._dlg.Close(); this.UnAdviseEvent(); return; } this._dlg.Close(); this.time += e.time; this.time /= 1000.0; this._groupNodeToPlay.RemoveAt(0); if (this._groupNodeToPlay.Count > 0) { TreeListNode treeListNode = this._groupNodeToPlay[0] as TreeListNode; ICameraTour cameraTour = treeListNode.GetValue("tl_Object") as ICameraTour; this._vindex++; cameraTour.ExportVideo(this._fileName + "_" + this._vindex.ToString() + this._fileType, this._fps); this._treelist.SetFocusedNode(treeListNode); return; } if (this._groupNodeToPlay.Count == 0) { this._treelist.SetFocusedNode(this._lastNodeInGroup); this.time = System.Math.Round(this.time, 2); XtraMessageBox.Show("输出完成,用时" + this.time + "秒。", "提示"); this._dlg.Close(); this.UnAdviseEvent(); } }
void init() { // 初始化RenderControl控件 IPropertySet ps = new PropertySet(); ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL); this.axRenderControl1.Initialize(true, ps); this.axRenderControl1.Camera.FlyTime = 1; rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID; // 注册出图事件 this.axRenderControl1.RcPictureExportBegin += new _IRenderControlEvents_RcPictureExportBeginEventHandler(axRenderControl1_RcPictureExportBegin); this.axRenderControl1.RcPictureExporting += new _IRenderControlEvents_RcPictureExportingEventHandler(axRenderControl1_RcPictureExporting); this.axRenderControl1.RcPictureExportEnd += new _IRenderControlEvents_RcPictureExportEndEventHandler(axRenderControl1_RcPictureExportEnd); // 注册相机“返回”和“前进”事件 this.axRenderControl1.RcCameraUndoRedoStatusChanged += new _IRenderControlEvents_RcCameraUndoRedoStatusChangedEventHandler(axRenderControl1_RcCameraUndoRedoStatusChanged); _rcCameraUndoRedo = new _IRenderControlEvents_RcCameraUndoRedoStatusChangedEventHandler(axRenderControl1_RcCameraUndoRedoStatusChanged); // 设置天空盒 if (System.IO.Directory.Exists(strMediaPath)) { string tmpSkyboxPath = strMediaPath + @"\skybox"; ISkyBox skybox = this.axRenderControl1.ObjectManager.GetSkyBox(0); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg"); skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg"); } else { MessageBox.Show("请不要随意更改SDK目录名"); return; } // 加载FDB场景 try { IConnectionInfo ci = new ConnectionInfo(); ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x; string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB"); ci.Database = tmpFDBPath; IDataSourceFactory dsFactory = new DataSourceFactory(); IDataSource ds = dsFactory.OpenDataSource(ci); string[] setnames = (string[])ds.GetFeatureDatasetNames(); if (setnames.Length == 0) { return; } IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]); string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable); if (fcnames.Length == 0) { return; } fcMap = new Hashtable(fcnames.Length); foreach (string name in fcnames) { IFeatureClass fc = dataset.OpenFeatureClass(name); // 找到空间列字段 List <string> geoNames = new List <string>(); IFieldInfoCollection fieldinfos = fc.GetFields(); for (int i = 0; i < fieldinfos.Count; i++) { IFieldInfo fieldinfo = fieldinfos.Get(i); if (null == fieldinfo) { continue; } IGeometryDef geometryDef = fieldinfo.GeometryDef; if (null == geometryDef) { continue; } geoNames.Add(fieldinfo.Name); } fcMap.Add(fc, geoNames); } } catch (COMException ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return; } // CreateFeautureLayer bool hasfly = false; foreach (IFeatureClass fc in fcMap.Keys) { List <string> geoNames = (List <string>)fcMap[fc]; foreach (string geoName in geoNames) { if (!geoName.Equals("Geometry")) { continue; } IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer( fc, geoName, null, null, rootId); if (!hasfly) { IFieldInfoCollection fieldinfos = fc.GetFields(); IFieldInfo fieldinfo = fieldinfos.Get(fieldinfos.IndexOf(geoName)); IGeometryDef geometryDef = fieldinfo.GeometryDef; env = geometryDef.Envelope; if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 && env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0)) { continue; } IEulerAngle angle = new EulerAngle(); angle.Set(0, -20, 0); this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle); } hasfly = true; } } // 加载动画导航 BindingSource bindingSource1 = new BindingSource(); { string tmpXMLPath = (strMediaPath + @"\xml\CameraTour_1.xml"); tour = this.axRenderControl1.ObjectManager.CreateCameraTour(rootId); if (File.Exists(tmpXMLPath)) { StreamReader sr = new StreamReader(tmpXMLPath); string xmlstring = ""; string line = sr.ReadLine(); while (!string.IsNullOrEmpty(line)) { xmlstring += line; line = sr.ReadLine(); } sr.Close(); tour.FromXml(xmlstring); } bindingSource1.Add(new Knight("CameraTour_1", tour)); } { string tmpXMLPath = (strMediaPath + @"\xml\CameraTour_2.xml"); tour = this.axRenderControl1.ObjectManager.CreateCameraTour(rootId); if (File.Exists(tmpXMLPath)) { StreamReader sr = new StreamReader(tmpXMLPath); string xmlstring = ""; string line = sr.ReadLine(); while (!string.IsNullOrEmpty(line)) { xmlstring += line; line = sr.ReadLine(); } sr.Close(); tour.FromXml(xmlstring); } bindingSource1.Add(new Knight("CameraTour_2", tour)); } dataGridView1.DataSource = bindingSource1; dataGridView1.Columns[1].Visible = false; this.btnPause.Enabled = false; this.btnStop.Enabled = false; this.toolStripComboBoxWeather.SelectedIndex = 0; { this.helpProvider1.SetShowHelp(this.axRenderControl1, true); this.helpProvider1.SetHelpString(this.axRenderControl1, ""); this.helpProvider1.HelpNamespace = "HelloWorld.html"; } }
public ProgressDialog(ICameraTour tour) { this.InitializeComponent(); this._tour = tour; }
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()); } } } }