//放大至书签 private void ZoomToBookmark3D(string bookmarkName) { IBookmark3D bookmark = new Bookmark3DClass(); m_SceneBookmarks.FindBookmark(bookmarkName, out bookmark); bookmark.Apply(m_SceneView, false, 0); m_SceneView.Redraw(true); }
public override void OnKeyDown(int int_0, int int_1) { if (this.bool_0 && int_0 == 27) { ISceneViewer activeViewer = this._plugin.ActiveViewer; activeViewer.Redraw(true); this.bool_0 = false; } }
public override void OnClick() { ICamera camera = this._plugin.Camera; double viewFieldAngle = camera.ViewFieldAngle; camera.ViewFieldAngle = viewFieldAngle * 0.9; ISceneViewer activeViewer = this._plugin.ActiveViewer; activeViewer.Redraw(false); }
/// <summary> /// 定位 /// </summary> /// <param name="lngLat"></param> /// <param name="zoomLevel"></param> public void ZoomToPosition(Core.Model.MapLngLat lngLat, int?zoomLevel = null) { ISceneViewer m_ActiveView = mapControl.Globe.GlobeDisplay.ActiveViewer; IEnvelope enve = new EnvelopeClass(); enve.PutCoords(lngLat.Lng, lngLat.Lat, lngLat.Lng, lngLat.Lat); enve.ZMin = lngLat.Alt * 10; enve.ZMax = lngLat.Alt * 10; mapControl.GlobeCamera.SetToZoomToExtents(enve, mapControl.Globe, m_ActiveView); m_ActiveView.Redraw(false); }
private void cmdFullExtent_Click(object sender, System.EventArgs e) { IGlobeCamera camera = (IGlobeCamera)m_Camera; //Make sure that the camera is using global coordinates camera.OrientationMode = esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal; //Point the camera at 0,0 in lat,long - this is the default target IPoint target = new PointClass(); target.PutCoords(0.0, 0.0); target.Z = 0.0; m_Camera.Target = target; //Reset the camera to its default values m_Camera.Azimuth = 140; m_Camera.Inclination = 45; m_Camera.ViewingDistance = 4.0; m_Camera.ViewFieldAngle = 30.0; m_Camera.RollAngle = 0.0; m_Camera.RecalcUp(); m_ActiveView.Redraw(false); }
public override void OnClick() { //Get scene viewer's camera ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera; //Widen the field of view double dAngle; dAngle = pCamera.ViewFieldAngle; pCamera.ViewFieldAngle = dAngle * 0.9; //Redraw the scene viewer ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer; pSceneViewer.Redraw(false); }
public override void OnKeyDown(int keyCode, int Shift) { if (m_bInUse == true) { if (keyCode == 27) //If ESC was pressed { //Redraw the scene viewer ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer; pSceneViewer.Redraw(true); ReleaseCapture(m_pSceneHookHelper.ActiveViewer.hWnd); m_bInUse = false; } } }
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { m_bDrawPoint = true; //move the light-source according to the mouse coordinate double lat, lon, alt; lat = lon = alt = 0; m_globeViewUtil.WindowToGeographic(m_globeDisplay, m_sceneViewer, arg.X, arg.Y, false, out lon, out lat, out alt); m_globeDisplayRendering.SetSunPosition(lat, lon); //Refresh the display so that the AfterDraw will get called m_sceneViewer.Redraw(false); }
public void DrawRectangle(IEnvelope pEnvelope) { //Get the scene viewer ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer; //Redraw the rectangle pSceneViewer.Redraw(true); //GDI+ call to fill a rectangle with a hollow brush myGraphics.FillRectangle(m_brush, (int)pEnvelope.XMin, (int)pEnvelope.YMin, (int)pEnvelope.Width, (int)pEnvelope.Height); //GDI+ call to draw a rectangle with a specified pen myGraphics.DrawRectangle(m_pen, (int)pEnvelope.XMin, (int)pEnvelope.YMin, (int)pEnvelope.Width, (int)pEnvelope.Height); }
/// <summary> /// 定位 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnPosition_Click(object sender, EventArgs e) { try { ISceneViewer m_ActiveView = globe.GlobeDisplay.ActiveViewer; IEnvelope enve = new EnvelopeClass(); double newLng = Convert.ToDouble(countLong); double newLat = Convert.ToDouble(countLat); enve.PutCoords(newLng, newLat, newLng + 2, newLat + 2); enve.ZMin = 0; enve.ZMax = 0; globe.GlobeCamera.SetToZoomToExtents(enve, globe.Globe, m_ActiveView); m_ActiveView.Redraw(false); } catch (Exception ex) { Log4Allen.WriteLog(typeof(frmLngLatCalculate), ex.Message); } }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { if (!m_bInUse) { return; } //Differences between previous and current mouse coordinates long dx, dy; dx = X - m_lMouseX; dy = Y - m_lMouseY; if (dx == 0 && dy == 0) { return; } //Get the scene viewer's camera ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera; //Zoom camera if (dy < 0) { pCamera.Zoom(1.1); } else if (dy > 0) { pCamera.Zoom(0.9); } //Set mouse coordinates for the next OnMouseMove event m_lMouseX = X; m_lMouseY = Y; //Redraw the scene viewer ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer; pSceneViewer.Redraw(true); }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { if (!m_bInUse) { return; } if (X - m_lMouseX == 0 && Y - m_lMouseY == 0) { return; } //Create point with previous mouse coordinates IPoint pStartPoint; pStartPoint = new PointClass(); pStartPoint.PutCoords((double)m_lMouseX, (double)m_lMouseY); //Create point with a new mouse coordinates IPoint pEndPoint; pEndPoint = new PointClass(); pEndPoint.PutCoords((double)X, (double)Y); //Set mouse coordinates for the next OnMouseMove event m_lMouseX = X; m_lMouseY = Y; //Get scene viewer's camera ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera; //Pan the camera pCamera.Pan(pStartPoint, pEndPoint); //Redraw the scene viewer ISceneViewer pSceneViewer = m_pSceneHookHelper.ActiveViewer; pSceneViewer.Redraw(false); }
public override void OnMouseUp(int Button, int Shift, int X, int Y) { if (!m_bInUse) { return; } try { if (GetCapture(m_pSceneHookHelper.ActiveViewer.hWnd) != 0) { ReleaseCapture(m_pSceneHookHelper.ActiveViewer.hWnd); } //Get the scene viewer's camera ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera; //Get the scene graph ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph; //Create envelope IEnvelope pEnvelope; CreateEnvelope(X, Y, out pEnvelope); IPoint pPoint; object pOwner, pObject; if (pEnvelope.Width == 0 || pEnvelope.Height == 0) { //Translate screen coordinates into a 3D point pSceneGraph.Locate(pSceneGraph.ActiveViewer, X, Y, esriScenePickMode.esriScenePickAll, true, out pPoint, out pOwner, out pObject); //Set camera target and zoom in pCamera.Target = pPoint; pCamera.Zoom(1.3333333333333); } else { //Get dimension of the scene viewer window Rectangle rect; rect = new Rectangle(); if (GetWindowRect(m_pSceneHookHelper.ActiveViewer.hWnd, ref rect) == 0) { return; } //If perspective (3D) view if (pCamera.ProjectionType == esri3DProjectionType.esriPerspectiveProjection) { double dWidth, dHeight; dWidth = Math.Abs(rect.Right - rect.Left) * (Math.Abs(rect.Right - rect.Left) / pEnvelope.Width); dHeight = Math.Abs(rect.Top - rect.Bottom) * (Math.Abs(rect.Top - rect.Bottom) / pEnvelope.Height); pPoint = new PointClass(); pPoint.PutCoords(pEnvelope.XMin + (pEnvelope.Width / 2), pEnvelope.YMin + (pEnvelope.Height / 2)); //Redimension envelope based on scene viewer dimensions pEnvelope.XMin = pPoint.X - (dWidth / 2); pEnvelope.YMin = pPoint.Y - (dHeight / 2); pEnvelope.Width = dWidth; pEnvelope.Height = dHeight; //Zoom camera to the envelope pCamera.ZoomToRect(pEnvelope); } else { //Translate screen coordinates into a 3D point pSceneGraph.Locate(pSceneGraph.ActiveViewer, (int)(pEnvelope.XMin + (pEnvelope.Width / 2)), (int)(pEnvelope.YMin + (pEnvelope.Height / 2)), esriScenePickMode.esriScenePickAll, true, out pPoint, out pOwner, out pObject); //Set camera target pCamera.Target = pPoint; double dx, dy; dx = pEnvelope.Width; dy = pEnvelope.Height; //Determine zoom factor if (dx > 0 && dy > 0) { dx = Math.Abs(rect.Right - rect.Left) / dx; dy = Math.Abs(rect.Top - rect.Bottom) / dy; if (dx < dy) { pCamera.Zoom(dx); } else { pCamera.Zoom(dy); } } else { pCamera.Zoom(1.3333333333333); } } } } finally { //Redraw the scene viewer ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer; pSceneViewer.Redraw(true); m_bInUse = false; } }
public void Flight() { //Get IMessageDispatcher interface IMessageDispatcher pMessageDispatcher; pMessageDispatcher = new MessageDispatcherClass(); //Set the ESC key to be seen as a cancel action pMessageDispatcher.CancelOnClick = false; pMessageDispatcher.CancelOnEscPress = true; //Get the scene graph ISceneGraph pSceneGraph = (ISceneGraph)m_pSceneHookHelper.SceneGraph; //Get the scene viewer ISceneViewer pSceneViewer = (ISceneViewer)m_pSceneHookHelper.ActiveViewer; //Get the camera ICamera pCamera = (ICamera)m_pSceneHookHelper.Camera; bCancel = false; do { //Get the elapsed time double dlastFrameDuration, dMeanFrameRate; pSceneGraph.GetDrawingTimeInfo(out dlastFrameDuration, out dMeanFrameRate); if (dlastFrameDuration < 0.01) { dlastFrameDuration = 0.01; } if (dlastFrameDuration > 1) { dlastFrameDuration = 1; } //Windows API call to get windows client coordinates Rectangle rect = new Rectangle(); if (GetClientRect(m_pSceneHookHelper.ActiveViewer.hWnd, ref rect) == 0) { return; } //Get normal vectors double dXMouseNormal, dYMouseNormal; dXMouseNormal = 2 * ((double)m_lMouseX / (double)rect.Right) - 1; dYMouseNormal = 2 * ((double)m_lMouseY / (double)rect.Bottom) - 1; //Set elevation and azimuth in radians for normal rotation m_dElevation = m_dElevation - (dlastFrameDuration * dYMouseNormal * Math.Abs(dYMouseNormal)); m_dAzimut = m_dAzimut - (dlastFrameDuration * dXMouseNormal * Math.Abs(dXMouseNormal)); if (m_dElevation > 0.45 * 3.141592) { m_dElevation = 0.45 * 3.141592; } if (m_dElevation < -0.45 * 3.141592) { m_dElevation = -0.45 * 3.141592; } if (m_dAzimut < 0) { m_dAzimut = m_dAzimut + (2 * 3.141592); } if (m_dAzimut > 2 * 3.141592) { m_dAzimut = m_dAzimut - (2 * 3.141592); } double dx, dy, dz; dx = Math.Cos(m_dElevation) * Math.Cos(m_dAzimut); dy = Math.Cos(m_dElevation) * Math.Sin(m_dAzimut); dz = Math.Sin(m_dElevation); //Change the viewing directions (target) m_pPointTgt.X = m_pPointObs.X + (m_dDistance * dx); m_pPointTgt.Y = m_pPointObs.Y + (m_dDistance * dy); m_pPointTgt.Z = m_pPointObs.Z + (m_dDistance * dz); //Move the camera in the viewing directions m_pPointObs.X = m_pPointObs.X + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dx); m_pPointObs.Y = m_pPointObs.Y + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dy); m_pPointTgt.X = m_pPointTgt.X + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dx); m_pPointTgt.Y = m_pPointTgt.Y + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dy); m_pPointObs.Z = m_pPointObs.Z + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dz); m_pPointTgt.Z = m_pPointTgt.Z + (dlastFrameDuration * (2 ^ m_iSpeed) * m_dMotion * dz); pCamera.Observer = m_pPointObs; pCamera.Target = m_pPointTgt; //Set the angle of the camera about the line of sight between the observer and target pCamera.RollAngle = 10 * dXMouseNormal * Math.Abs(dXMouseNormal); //Redraw the scene viewer pSceneViewer.Redraw(true); object objCancel; //Dispatch any waiting messages: OnMouseMove / OnMouseUp / OnKeyUp events //object objCancel = bCancel as object; pMessageDispatcher.Dispatch(m_pSceneHookHelper.ActiveViewer.hWnd, false, out objCancel); //End flight if ESC key pressed if (bCancel == true) { EndFlight(); } }while(m_bInUse == true && bCancel == false); bCancel = false; }
public override void OnMouseUp(int int_0, int int_1, int int_2, int int_3) { if (this.bool_0) { try { ICamera camera = this._plugin.Camera; ISceneGraph sceneGraph = this._plugin.SceneGraph; IEnvelope envelope; this.CreateEnvelope(int_2, int_3, out envelope); if (envelope.Width == 0.0 || envelope.Height == 0.0) { IPoint point; object obj; object obj2; sceneGraph.Locate(sceneGraph.ActiveViewer, int_2, int_3, esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2); if (point != null) { camera.Target = point; } camera.Zoom(0.75); } else if (camera.ProjectionType == esri3DProjectionType.esriPerspectiveProjection) { camera.ZoomToRect(envelope); } else { IPoint point; object obj; object obj2; sceneGraph.Locate(sceneGraph.ActiveViewer, (int)(envelope.XMin + envelope.Width / 2.0), (int)(envelope.YMin + envelope.Height / 2.0), esriScenePickMode.esriScenePickAll, true, out point, out obj, out obj2); if (point != null) { camera.Target = point; } System.Drawing.Rectangle rectangle = default(System.Drawing.Rectangle); if (ToolSceneZoomIn.GetWindowRect(this._plugin.ActiveViewer.hWnd, ref rectangle) == 0) { return; } double num = envelope.Width; double num2 = envelope.Height; if (num > 0.0 && num2 > 0.0) { num /= (double)Math.Abs(rectangle.Right - rectangle.Left); num2 /= (double)Math.Abs(rectangle.Top - rectangle.Bottom); if (num > num2) { camera.Zoom(num); } else { camera.Zoom(num2); } } else { camera.Zoom(0.75); } } } catch { } ISceneViewer activeViewer = this._plugin.ActiveViewer; activeViewer.Redraw(true); if (this.graphics_0 != null) { this.graphics_0.Dispose(); this.graphics_0 = null; } this.bool_0 = false; } }
public void Flight() { IMessageDispatcher messageDispatcher = new MessageDispatcher(); messageDispatcher.CancelOnClick = false; messageDispatcher.CancelOnEscPress = true; ISceneGraph sceneGraph = this._plugin.SceneGraph; ISceneViewer activeViewer = this._plugin.ActiveViewer; ICamera camera = this._plugin.Camera; this.bool_1 = false; do { double num; double num2; sceneGraph.GetDrawingTimeInfo(out num, out num2); if (num < 0.01) { num = 0.01; } if (num > 1.0) { num = 1.0; } System.Drawing.Rectangle rectangle = default(System.Drawing.Rectangle); if (ToolSceneFly.GetClientRect(this._plugin.ActiveViewer.hWnd, ref rectangle) == 0) { return; } double num3 = 2.0 * ((double)this.long_0 / (double)rectangle.Right) - 1.0; double num4 = 2.0 * ((double)this.long_1 / (double)rectangle.Bottom) - 1.0; this.double_2 -= num * num4 * Math.Abs(num4); this.double_3 -= num * num3 * Math.Abs(num3); if (this.double_2 > 1.4137164000000002) { this.double_2 = 1.4137164000000002; } if (this.double_2 < -1.4137164000000002) { this.double_2 = -1.4137164000000002; } if (this.double_3 < 0.0) { this.double_3 += 6.283184; } if (this.double_3 > 6.283184) { this.double_3 -= 6.283184; } double num5 = Math.Cos(this.double_2) * Math.Cos(this.double_3); double num6 = Math.Cos(this.double_2) * Math.Sin(this.double_3); double num7 = Math.Sin(this.double_2); this.ipoint_1.X = this.ipoint_0.X + this.double_1 * num5; this.ipoint_1.Y = this.ipoint_0.Y + this.double_1 * num6; this.ipoint_1.Z = this.ipoint_0.Z + this.double_1 * num7; this.ipoint_0.X = this.ipoint_0.X + num * (double)(2 ^ this.int_0) * this.double_0 * num5; this.ipoint_0.Y = this.ipoint_0.Y + num * (double)(2 ^ this.int_0) * this.double_0 * num6; this.ipoint_1.X = this.ipoint_1.X + num * (double)(2 ^ this.int_0) * this.double_0 * num5; this.ipoint_1.Y = this.ipoint_1.Y + num * (double)(2 ^ this.int_0) * this.double_0 * num6; this.ipoint_0.Z = this.ipoint_0.Z + num * (double)(2 ^ this.int_0) * this.double_0 * num7; this.ipoint_1.Z = this.ipoint_1.Z + num * (double)(2 ^ this.int_0) * this.double_0 * num7; camera.Observer = this.ipoint_0; camera.Target = this.ipoint_1; camera.RollAngle = 10.0 * num3 * Math.Abs(num3); activeViewer.Redraw(true); object obj; messageDispatcher.Dispatch(this._plugin.ActiveViewer.hWnd, false, out obj); if (this.bool_1) { this.EndFlight(); } }while (this.bool_0 && !this.bool_1); this.bool_1 = false; }