public MultipleGlobeViewers() { globe = ArcGlobe.Globe; globeDisplay = globe.GlobeDisplay; globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)globeDisplay.ActiveViewer.Camera; globeDispEvent = (ESRI.ArcGIS.GlobeCore.IGlobeDisplayEvents_Event)globeDisplay; }
void topDownButton_Click(object sender, EventArgs e) { topDownView = true; viewerCaption = theForm.viewerListBox.SelectedItem.ToString(); viewer = (ESRI.ArcGIS.Analyst3D.ISceneViewer)globeDisplay.FindViewer(viewerCaption); viewerGlobeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)viewer.Camera; }
private void btn_Globe_Click(object sender, EventArgs e) { string filePath = @"D:\a_gis工程设计实践课\scene世界地图\world.3dd"; if (axGlobeControl1.Check3dFile(filePath)) { axGlobeControl1.MousePointer = ESRI.ArcGIS.Controls.esriControlsMousePointer.esriPointerHourglass; axGlobeControl1.Load3dFile(filePath); axGlobeControl1.MousePointer = esriControlsMousePointer.esriPointerDefault; } else { MessageBox.Show(filePath + "不是有效的地图文档"); } //定位墓穴点 try { IScene pScene = axGlobeControl1.Globe.GlobeDisplay.Scene; IFeatureLayer pFlyr = null; string name = "云顶天宫"; for (int i = 0; i < pScene.LayerCount; ++i) { if (pScene.get_Layer(i).Name == name)//要定位的图层 { { pFlyr = pScene.get_Layer(i) as IFeatureLayer; break; } } } IFeature pFteature = pFlyr.FeatureClass.GetFeature(0);//定位ObjectID=1384元素 ESRI.ArcGIS.Analyst3D.ICamera camera = axGlobeControl1.Globe.GlobeDisplay.ActiveViewer.Camera; ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera; IMap pMap = axGlobeControl1.Globe as IMap; pMap.SelectFeature(pFlyr, pFteature); ((IActiveView)axGlobeControl1.Globe).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); ZoomToGeometry(axGlobeControl1.Globe, pFteature.Shape, 3, name); } catch { } showGrave(); //展示墓穴点 }
private void buttonX2_Click(object sender, EventArgs e) { ESRI.ArcGIS.Analyst3D.IScene scene = (ESRI.ArcGIS.Analyst3D.IScene)GlobeControl.Globe; // Explicit cast. ESRI.ArcGIS.Geometry.IEnvelope envelope = GlobalValues.element3D.Geometry.Envelope; ESRI.ArcGIS.Analyst3D.ICamera camera = GlobeControl.Globe.GlobeDisplay.ActiveViewer.Camera; ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera) camera; // Explicit cast. ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer = GlobeControl.Globe.GlobeDisplay.ActiveViewer; globeCamera.SetToZoomToExtents(envelope, GlobeControl.Globe, sceneViewer); }
public static void AutoSwitchGlobeCameraOrientationMode(IGlobe pGlobe) { try { ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer = pGlobe.GlobeDisplay.ActiveViewer; ESRI.ArcGIS.Analyst3D.ICamera camera = sceneViewer.Camera; ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera; double xTarget; double yTarget; ESRI.ArcGIS.Geometry.IPoint targetCls = (globeCamera as ICamera).Target; targetCls.QueryCoords(out xTarget, out yTarget); double zTarget = targetCls.Z; // Calculate the current azimuth and inclination of the camera. //azimuth = Math.Atan2(xTarget, yTarget) * 180 / Math.PI; double inclination = (180 / Math.PI) * (Math.Asin(zTarget / Math.Sqrt(xTarget * xTarget + yTarget * yTarget + zTarget * zTarget))) - 10.0; if (inclination > 88 | inclination < -88 | double.IsNaN(inclination)) { double targetLatitude; double targetLongitude; double targetAltitude; globeCamera.GetTargetLatLonAlt(out targetLatitude, out targetLongitude, out targetAltitude); double observerLatitude; double obsLongitude; double obsAltitude; globeCamera.GetObserverLatLonAlt(out observerLatitude, out obsLongitude, out obsAltitude); //// Set the GlobeCamera to global navigation mode. globeCamera.OrientationMode = ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal; globeCamera.NavigationType = ESRI.ArcGIS.GlobeCore.esriGlobeNavigationType.esriGlobeNavigationAttached; globeCamera.SetObserverLatLonAlt(targetLatitude, targetLongitude, obsAltitude); } else { globeCamera.OrientationMode = ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationLocal; globeCamera.NavigationType = ESRI.ArcGIS.GlobeCore.esriGlobeNavigationType.esriGlobeNavigationFree; } } catch { } }
public VisualizeCameraPath() { globe = ArcGlobe.Globe; globeDisplay = globe.GlobeDisplay; globeCamera = globeDisplay.ActiveViewer.Camera as IGlobeCamera; }
public void ZoomToSelectedGlobeFeatures(ESRI.ArcGIS.GlobeCore.IGlobe globe, IEnvelope pEv, string name) { ESRI.ArcGIS.GlobeCore.IGlobeDisplay globeDisplay = globe.GlobeDisplay; ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer = globeDisplay.ActiveViewer; ESRI.ArcGIS.Analyst3D.ICamera camera = sceneViewer.Camera; ESRI.ArcGIS.GlobeCore.IGlobeCamera globeCamera = (ESRI.ArcGIS.GlobeCore.IGlobeCamera)camera; ESRI.ArcGIS.Analyst3D.IScene scene = globeDisplay.Scene; ESRI.ArcGIS.Geometry.IEnvelope envelope = new ESRI.ArcGIS.Geometry.EnvelopeClass(); envelope.SetEmpty(); ESRI.ArcGIS.Geometry.IEnvelope layersExtentEnvelope = new ESRI.ArcGIS.Geometry.EnvelopeClass(); layersExtentEnvelope.SetEmpty(); ESRI.ArcGIS.Geometry.IZAware ZAware = (ESRI.ArcGIS.Geometry.IZAware)envelope; ZAware.ZAware = (true); envelope.Union(pEv); IFeatureLayer pFlyr = null; for (int i = 0; i < scene.LayerCount; ++i) { if (scene.get_Layer(i).Name == name) { pFlyr = scene.get_Layer(i) as IFeatureLayer; break; } } ESRI.ArcGIS.Geodatabase.IGeoDataset geoDataset = (ESRI.ArcGIS.Geodatabase.IGeoDataset)pFlyr; if (geoDataset != null) { ESRI.ArcGIS.Geometry.IEnvelope layerExtent = geoDataset.Extent; layersExtentEnvelope.Union(layerExtent); } System.Double width = envelope.Width; System.Double height = envelope.Height; if (width == 0.0 && height == 0.0) { System.Double dim = 1.0; System.Boolean bEmpty = layersExtentEnvelope.IsEmpty; if (!bEmpty) { System.Double layerWidth = layersExtentEnvelope.Width; System.Double layerHeight = layersExtentEnvelope.Height; System.Double layerDim = System.Math.Max(layerWidth, layerHeight) * 0.05; if (layerDim > 0.0) { dim = System.Math.Min(1.0, layerDim); } } System.Double xMin = envelope.XMin; System.Double yMin = envelope.YMin; ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass(); point.X = xMin; point.Y = yMin; envelope.Width = dim * 0.8; envelope.Height = dim * 0.8; envelope.CenterAt(point); } else if (width == 0.0 || height == 0.0) { System.Double maxDim = System.Math.Max(width, height); envelope.Width = maxDim; envelope.Height = maxDim; } globeCamera.SetToZoomToExtents(envelope, globe, sceneViewer); sceneViewer.Redraw(true); }