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 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);
        }
 void getListOfSecondaryViewers()
 {
     ESRI.ArcGIS.esriSystem.IArray viewers = globeDisplay.GetAllViewers();
     if (viewers.Count < 2)
     {
         return;
     }
     for (int i = 0; i < viewers.Count; i++)
     {
         ESRI.ArcGIS.Analyst3D.ISceneViewer viewerElement = (ESRI.ArcGIS.Analyst3D.ISceneViewer)viewers.get_Element(i);
         if (viewerElement.Caption != "Globe view")
         {
             theForm.viewerListBox.Items.Add(viewerElement.Caption);
         }
     }
 }
예제 #4
0
 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 { }
 }
예제 #5
0
파일: Form3.cs 프로젝트: 16Lovia/GISDiary
        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);
        }
 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;
 }