/// <summary> /// 删除某一个场景 /// </summary> /// <param name="SceneName">场景名称</param> private void DeleteBookmarkScene(string SceneName) { try { if (BookmarksNamesList.Count == 0) { return; } IBookmark3D p3DBookmark = null; pSceneBookmarks.FindBookmark(SceneName, out p3DBookmark); //查询场景 if (p3DBookmark == null) //如果场景不存在 { return; } DialogResult dr = MessageBox.Show("是否删除书签", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DialogResult.No == dr) { return; } pSceneBookmarks.RemoveBookmark(p3DBookmark); //删除场景 pGlobeDisplay.RefreshViewers(); //pScene.SceneGraph.RefreshViewers(); } catch { } }
private void lstBookmarks_SelectedIndexChanged(object sender, System.EventArgs e) { //Get a bookmark corresponding to list and apply it to the SceneViewer IBookmark3D bookmark = (IBookmark3D)m_Bookmarks.get_Element(lstBookmarks.SelectedIndex); //Switch to new bookmark location bookmark.Apply(axSceneControl1.SceneViewer, false, 0); }
public void DeleteBookmark(string markName) { ISceneBookmarks2 sceneBookmarks = globe as ISceneBookmarks2; IBookmark3D bookmark3D = null; sceneBookmarks.FindBookmark(markName, out bookmark3D); if (bookmark3D != null) { sceneBookmarks.RemoveBookmark(bookmark3D); } }
public static void ZoomToBookmark(IGlobeDisplay globeDisplay, IBookmark3D pBookmark3D, double doubleDuration) { try { //创建动画轨迹并添加 IAnimationTrack pAnimationTrack = CreateZoomOverLocationAnimation(globeDisplay, pBookmark3D); //播放轨迹 IGlobe globe = globeDisplay.Globe; IAnimationTracks animationTracks = (IAnimationTracks)globe; //// Add Track //animationTracks.AddTrack(pAnimationTrack); // Only enable the track with the parsed name for (int i = 0; i <= animationTracks.TrackCount - 1; i++) { IAnimationTrack animationTrackTest = (IAnimationTrack)animationTracks.Tracks.get_Element(i); if (animationTrackTest.Name == pAnimationTrack.Name) { animationTrackTest.IsEnabled = true; } else { animationTrackTest.IsEnabled = false; } } // Play Track System.DateTime dateTimeStart = DateTime.Now; double doubleElapsed = 0; while (doubleElapsed <= doubleDuration) { // Animation Viewer animationTracks.ApplyTracks(globe.GlobeDisplay.ActiveViewer, doubleElapsed, doubleDuration); globe.GlobeDisplay.ActiveViewer.Redraw(true); // Get Elapsed Time System.TimeSpan timeSpanElapsed = DateTime.Now.Subtract(dateTimeStart); doubleElapsed = timeSpanElapsed.TotalSeconds; } // Display Last Frame (if slow viewer) animationTracks.ApplyTracks(globe.GlobeDisplay.ActiveViewer, 1d, 1d); #region 根据当前摄像机姿态决定应该为Global模式还是Local模式 AutoSwitchGlobeCameraOrientationMode(globe); #endregion globe.GlobeDisplay.ActiveViewer.Redraw(true); // Remove Track animationTracks.RemoveTrack(pAnimationTrack); } catch { } }
public void Move2Bookmark(string markName) { ISceneBookmarks2 sceneBookmarks = globe as ISceneBookmarks2; IBookmark3D bookmark3D = null; sceneBookmarks.FindBookmark(markName, out bookmark3D); if (bookmark3D != null) { bookmark3D.Apply(globe.GlobeDisplay.ActiveViewer, true, 0); globe.GlobeDisplay.RefreshViewers(); } }
private void frmManageBookMarker_Load(object sender, EventArgs e) { if (this.ibasicMap_0 is ISceneBookmarks) { IArray bookmarks = (this.ibasicMap_0 as ISceneBookmarks).Bookmarks; for (int i = 0; i < bookmarks.Count; i++) { IBookmark3D bookmark3D = bookmarks.get_Element(i) as IBookmark3D; this.listView1.Items.Add(bookmark3D.Name).Tag = bookmark3D; } } }
/// <summary> /// 使书签在listBox中显示方法 /// </summary> /// <param name="sceneBookmarks"></param> private void ShowAllBookmarkNameToList(ISceneBookmarks sceneBookmarks) { //创建 IArray bookmarkArray = sceneBookmarks.Bookmarks; for (int i = 0; i < bookmarkArray.Count; i++) { System.Object oo = bookmarkArray.get_Element(i); IBookmark3D bookmark = oo as IBookmark3D; // listBox1.Items.Add(bookmark.Name); } }
/// <summary> /// 书签创建关键帧 /// </summary> /// <param name="_pGlobe"></param> /// <param name="_pBook3D"></param> /// <returns></returns> public static IAGKeyframe CreateKeyframefromBook(IGlobe _pGlobe, IBookmark3D _pBook3D) { IScene _pScene = _pGlobe.GlobeDisplay.Scene; IAGAnimationContainer pAGAnimationContainer = _pScene as IAGAnimationContainer; IAGAnimationTracks pAGAnimationTracks = _pGlobe as IAGAnimationTracks; IAGAnimationUtils pAGAutils = new AGAnimationUtilsClass(); ESRI.ArcGIS.Animation.IAGAnimationType pAGType = new AnimationTypeGlobeCameraClass(); IAGKeyframe pGlobeKey = new GlobeCameraKeyframeClass(); pAGAutils.KeyframeFromBookmark(pAGAnimationContainer, _pBook3D as ISpatialBookmark, out pGlobeKey); return pGlobeKey; }
/// <summary> /// 书签创建关键帧 /// </summary> /// <param name="_pGlobe"></param> /// <param name="_pBook3D"></param> /// <returns></returns> public static IAGKeyframe CreateKeyframefromBook(IGlobe _pGlobe, IBookmark3D _pBook3D) { IScene _pScene = _pGlobe.GlobeDisplay.Scene; IAGAnimationContainer pAGAnimationContainer = _pScene as IAGAnimationContainer; IAGAnimationTracks pAGAnimationTracks = _pGlobe as IAGAnimationTracks; IAGAnimationUtils pAGAutils = new AGAnimationUtilsClass(); ESRI.ArcGIS.Animation.IAGAnimationType pAGType = new AnimationTypeGlobeCameraClass(); IAGKeyframe pGlobeKey = new GlobeCameraKeyframeClass(); pAGAutils.KeyframeFromBookmark(pAGAnimationContainer, _pBook3D as ISpatialBookmark, out pGlobeKey); return(pGlobeKey); }
//根据书签的名称定位 public void BookLightZoom(string bookLightName, AxGlobeControl axGlobeControl) { try { ESRI.ArcGIS.Analyst3D.ISceneBookmarks sceneBookmarks = (ESRI.ArcGIS.Analyst3D.ISceneBookmarks)axGlobeControl.Globe; IBookmark3D pBookmark3D = null; sceneBookmarks.FindBookmark(bookLightName, out pBookmark3D); if (pBookmark3D == null) { return; } //缩放到书签 //pBookmark3D.Apply(m_pGlobe.GlobeDisplay.ActiveViewer as ISceneViewer, true, 3.0); //无动态效果 ZoomToBookmark(axGlobeControl.Globe.GlobeDisplay, pBookmark3D, 3); //有动态效果 } catch { } }
private void btnOK_Click(object sender, EventArgs e) { if (this.ibasicMap_0 is ISceneBookmarks) { IBookmark3D bookmark3D = null; bool flag = false; IArray bookmarks = (this.ibasicMap_0 as ISceneBookmarks).Bookmarks; for (int i = 0; i < bookmarks.Count; i++) { bookmark3D = (bookmarks.get_Element(i) as IBookmark3D); if (bookmark3D.Name == this.txtBookMarker.Text) { flag = true; break; } } if (flag) { if (System.Windows.Forms.MessageBox.Show("书签已存在,是否替换!", "书签", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { bookmark3D.Capture((this.ibasicMap_0 as IScene).SceneGraph.ActiveViewer.Camera); base.DialogResult = System.Windows.Forms.DialogResult.OK; base.Close(); } } else { frmBookMark.nIndex++; bookmark3D = new Bookmark3D(); bookmark3D.Name = this.txtBookMarker.Text; bookmark3D.Capture((this.ibasicMap_0 as IScene).SceneGraph.ActiveViewer.Camera); (this.ibasicMap_0 as ISceneBookmarks).AddBookmark(bookmark3D); base.DialogResult = System.Windows.Forms.DialogResult.OK; base.Close(); } } }
private List <string> getBookmarksNames(ISceneBookmarks _SceneBookmarks) { List <string> bookmarksNames = new List <string>(); try { if (_SceneBookmarks.BookmarkCount == 0) { return(bookmarksNames); } for (int index = 0; index < BookmarkCount; index++) { IBookmark3D pBookmark3D = _SceneBookmarks.Bookmarks.get_Element(index) as IBookmark3D; bookmarksNames.Add(strBtnAhead + pBookmark3D.Name); } return(bookmarksNames); } catch { return(bookmarksNames); } }
public static IAnimationTrack CreateZoomOverLocationAnimation(IGlobeDisplay globeDisplay, IBookmark3D pBookmark3D) { // Set Mouse Cursor //IMouseCursor mouseCursor = new MouseCursorClass(); //mouseCursor.SetCursor(2); // QI to GlobeDisplayRendering Interface IGlobeDisplayRendering globeDisplayRendering = (IGlobeDisplayRendering)globeDisplay; // Get Elevation Multiplication Factor IUnitConverter unitConverter = new UnitConverterClass(); // Get GlobeDisplay and Camera IGlobe globe = globeDisplay.Globe; IAnimationTracks animationTracks = (IAnimationTracks)globe; IGlobeCamera globeCamera = (IGlobeCamera)globeDisplay.ActiveViewer.Camera; // Create New Animation Track IAnimationTrack animationTrack = new AnimationTrackClass(); try { IAnimationType animationType = new AnimationTypeGlobeCameraClass(); animationTrack.AnimationType = animationType; // Create First KeyFrame At Current Location IKeyframe keyframe1 = new GlobeCameraKeyframeClass(); keyframe1.CaptureProperties((IScene)globe, globeCamera); animationTrack.InsertKeyframe(keyframe1, animationTrack.KeyframeCount); //// Create Last KeyFrame Over Desired Location //pBookmark3D.Apply(globeDisplay.ActiveViewer as ISceneViewer, false, 0); //IKeyframe keyframe3 = new GlobeCameraKeyframeClass(); //keyframe3.CaptureProperties((IScene)globe, globeCamera); IKeyframe keyframe3 = CreateKeyframefromBook(globeDisplay.Globe, pBookmark3D) as IKeyframe; #region 获取第一帧和第三帧的参数 double dX1_Tar, dY1_Tar, dZ1_Tar, dX1_Obs, dY1_Obs, dZ1_Obs; GetParametersFromKeyFrame(keyframe1, out dX1_Tar, out dY1_Tar, out dZ1_Tar, out dX1_Obs, out dY1_Obs, out dZ1_Obs); double dX3_Tar, dY3_Tar, dZ3_Tar, dX3_Obs, dY3_Obs, dZ3_Obs; GetParametersFromKeyFrame(keyframe3, out dX3_Tar, out dY3_Tar, out dZ3_Tar, out dX3_Obs, out dY3_Obs, out dZ3_Obs); #endregion //=========================================== 创建中间帧 =========================================== //IKeyframe keyframe2 = CreateMiddleKeyframe(globeDisplay.Globe, dX1_Tar, dY1_Tar, dZ1_Tar, dX1_Obs, dY1_Obs, dZ1_Obs, // dX3_Tar, dY3_Tar, dZ3_Tar, dX3_Obs, dY3_Obs, dZ3_Obs); //头晕、高血压、糖尿病患者调用该函数请慎重! //=========================================== 创建中间帧 =========================================== //animationTrack.InsertKeyframe(keyframe2, animationTrack.KeyframeCount); animationTrack.InsertKeyframe(keyframe3, animationTrack.KeyframeCount); // Set The Animation Track Name animationTrack.Name = "Zoom Over Location From Bookmark"; // Set Track Attachments animationTrack.AttachObject(globeCamera); animationTrack.ApplyToAllViewers = true; // Add The New Track To The Scene animationTracks.AddTrack(animationTrack); // Return The Newly Create Aninmation Track } catch { } return animationTrack; }
public static IAnimationTrack CreateZoomOverLocationAnimation(IGlobeDisplay globeDisplay, IBookmark3D pBookmark3D) { // Set Mouse Cursor //IMouseCursor mouseCursor = new MouseCursorClass(); //mouseCursor.SetCursor(2); // QI to GlobeDisplayRendering Interface IGlobeDisplayRendering globeDisplayRendering = (IGlobeDisplayRendering)globeDisplay; // Get Elevation Multiplication Factor IUnitConverter unitConverter = new UnitConverterClass(); // Get GlobeDisplay and Camera IGlobe globe = globeDisplay.Globe; IAnimationTracks animationTracks = (IAnimationTracks)globe; IGlobeCamera globeCamera = (IGlobeCamera)globeDisplay.ActiveViewer.Camera; // Create New Animation Track IAnimationTrack animationTrack = new AnimationTrackClass(); try { IAnimationType animationType = new AnimationTypeGlobeCameraClass(); animationTrack.AnimationType = animationType; // Create First KeyFrame At Current Location IKeyframe keyframe1 = new GlobeCameraKeyframeClass(); keyframe1.CaptureProperties((IScene)globe, globeCamera); animationTrack.InsertKeyframe(keyframe1, animationTrack.KeyframeCount); //// Create Last KeyFrame Over Desired Location //pBookmark3D.Apply(globeDisplay.ActiveViewer as ISceneViewer, false, 0); //IKeyframe keyframe3 = new GlobeCameraKeyframeClass(); //keyframe3.CaptureProperties((IScene)globe, globeCamera); IKeyframe keyframe3 = CreateKeyframefromBook(globeDisplay.Globe, pBookmark3D) as IKeyframe; #region 获取第一帧和第三帧的参数 double dX1_Tar, dY1_Tar, dZ1_Tar, dX1_Obs, dY1_Obs, dZ1_Obs; GetParametersFromKeyFrame(keyframe1, out dX1_Tar, out dY1_Tar, out dZ1_Tar, out dX1_Obs, out dY1_Obs, out dZ1_Obs); double dX3_Tar, dY3_Tar, dZ3_Tar, dX3_Obs, dY3_Obs, dZ3_Obs; GetParametersFromKeyFrame(keyframe3, out dX3_Tar, out dY3_Tar, out dZ3_Tar, out dX3_Obs, out dY3_Obs, out dZ3_Obs); #endregion //=========================================== 创建中间帧 =========================================== //IKeyframe keyframe2 = CreateMiddleKeyframe(globeDisplay.Globe, dX1_Tar, dY1_Tar, dZ1_Tar, dX1_Obs, dY1_Obs, dZ1_Obs, // dX3_Tar, dY3_Tar, dZ3_Tar, dX3_Obs, dY3_Obs, dZ3_Obs); //头晕、高血压、糖尿病患者调用该函数请慎重! //=========================================== 创建中间帧 =========================================== //animationTrack.InsertKeyframe(keyframe2, animationTrack.KeyframeCount); animationTrack.InsertKeyframe(keyframe3, animationTrack.KeyframeCount); // Set The Animation Track Name animationTrack.Name = "Zoom Over Location From Bookmark"; // Set Track Attachments animationTrack.AttachObject(globeCamera); animationTrack.ApplyToAllViewers = true; // Add The New Track To The Scene animationTracks.AddTrack(animationTrack); // Return The Newly Create Aninmation Track } catch { } return(animationTrack); }