예제 #1
0
        /// <summary>
        ///  鼠标滚轮事件,实现地图放大缩小
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GlobleControl_MouseWheel(object sender, MouseEventArgs e)
        {
            System.Drawing.Point sceLoc = axGlobeControl1.PointToScreen(axGlobeControl1.Location);
            System.Drawing.Point pt     = this.PointToScreen(e.Location);

            if (pt.X < sceLoc.X || pt.X > sceLoc.X + axGlobeControl1.Width || pt.Y < sceLoc.Y || pt.Y > sceLoc.Y + axGlobeControl1.Height)
            {
                return;
            }

            double scale = 0.2;

            if (e.Delta > 0)
            {
                scale = -scale;
            }
            IGlobeCamera  globeCamera  = axGlobeControl1.GlobeCamera;
            ICamera       camera       = globeCamera as ICamera;
            IGlobeDisplay globeDisplay = axGlobeControl1.GlobeDisplay;

            if (globeCamera.OrientationMode == esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal)
            {
                double xo, yo, zo;
                globeCamera.GetObserverLatLonAlt(out xo, out yo, out zo);
                zo = zo * (1 + scale);
                globeCamera.SetObserverLatLonAlt(xo, yo, zo);
            }
            else
            {
                camera.ViewingDistance += camera.ViewingDistance * scale;
            }
            axGlobeControl1.GlobeDisplay.RefreshViewers();
        }
예제 #2
0
        /// <summary>
        /// If the user chose to track the element from behind, set the camera behind the element
        /// so that the camera will be placed on the line connecting the previous and the current element's position.
        /// </summary>
        /// <param name="globeCamera"></param>
        /// <param name="newLon"></param>
        /// <param name="newLat"></param>
        /// <param name="newAlt"></param>
        /// <param name="oldLon"></param>
        /// <param name="oldLat"></param>
        /// <param name="oldAlt"></param>
        private void TrackFollowTarget(IGlobeCamera globeCamera, double newLon, double newLat, double newAlt, double oldLon, double oldLat, double oldAlt)
        {
            //make sure that the camera position is not directly above the element. Otherwise it can lead to
            //an ill condition
            if (newLon == oldLon && newLat == oldLat)
            {
                newLon += 0.00001;
                newLat += 0.00001;
            }

            //calculate the azimuth from the previous position to the current position
            double azimuth = Math.Atan2(newLat - oldLat, newLon - oldLon) * (Math.PI / 180.0);

            //the camera new position, right behind the element
            double obsX = newLon - 0.04 * Math.Cos(azimuth * (Math.PI / 180));
            double obsY = newLat - 0.04 * Math.Sin(azimuth * (Math.PI / 180));

            //set the camera position. The camera must be locked in order to prevent a dead-lock caused by the cache manager
            lock (globeCamera)
            {
                globeCamera.SetTargetLatLonAlt(newLat, newLon, newAlt / 1000.0);
                globeCamera.SetObserverLatLonAlt(obsY, obsX, newAlt / 1000.0 + 0.7);
                m_sceneViwer.Camera.Apply();
            }

            //refresh the globe display
            m_globeDisplay.RefreshViewers();
        }
예제 #3
0
        /// <summary>
        /// The real-time feed position updated event handler
        /// </summary>
        /// <param name="position">a GPS position information</param>
        /// <param name="estimate">indicates whether this is an estimated time or real time</param>
        void OnPositionUpdated(ref esriGpsPositionInfo position, bool estimate)
        {
            try
            {
                //add the tracking element to the tracking graphics layer (should happen only once)
                if (-1 == m_trackObjectIndex)
                {
                    int index = AddTrackElement(m_globeGraphicsLayer, position);
                    if (-1 == index)
                    {
                        throw new Exception("could not add tracking object");
                    }

                    //cache the element's index
                    m_trackObjectIndex = index;

                    return;
                }
                //get the element by its index
                IElement elem = ((IGraphicsContainer3D)m_globeGraphicsLayer).get_Element(m_trackObjectIndex);

                //keep the previous location
                double lat, lon, alt;
                ((IPoint)elem.Geometry).QueryCoords(out lon, out lat);
                alt = ((IPoint)elem.Geometry).Z;

                //update the element's position
                IPoint point = elem.Geometry as IPoint;
                point.X       = position.longitude;
                point.Y       = position.latitude;
                point.Z       = alt;
                elem.Geometry = (IGeometry)point;

                //update the element in the graphics layer.
                lock (m_globeGraphicsLayer)
                {
                    m_globeGraphicsLayer.UpdateElementByIndex(m_trackObjectIndex);
                }

                IGlobeCamera globeCamera = m_sceneViwer.Camera as IGlobeCamera;

                //set the camera position in order to track the element
                if (m_bTrackAboveTarget)
                {
                    TrackAboveTarget(globeCamera, point);
                }
                else
                {
                    TrackFollowTarget(globeCamera, point.X, point.Y, point.Z, lon, lat, alt);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
        }
예제 #4
0
        private void GetObserVerLatLong(ISceneViewer pViewer, out double pLatDD, out double pLonDD, out double pAltKms, out double pRoll, out double pIncl)
        {
            IGlobeCamera pCam = (IGlobeCamera)pViewer.Camera;

            pCam.GetObserverLatLonAlt(out pLatDD, out pLonDD, out pAltKms);
            ICamera pIcam = (ICamera)pCam;

            pRoll = pIcam.RollAngle;
            pIncl = pIcam.Inclination;
        }
 public SunPositionTool()
 {
     //get the different members
     m_globe = ArcGlobe.Globe;
     m_globeDisplay = m_globe.GlobeDisplay as IGlobeDisplay3;
     m_globeDisplayRendering = m_globeDisplay as IGlobeDisplayRendering;
     m_globeCamera = m_globeDisplay.ActiveViewer.Camera as IGlobeCamera;
     m_globeViewUtil = m_globeCamera as IGlobeViewUtil;
     m_sceneViewer = m_globeDisplay.ActiveViewer;
 }
예제 #6
0
 public SunPositionTool()
 {
     //get the different members
     m_globe                 = ArcGlobe.Globe;
     m_globeDisplay          = m_globe.GlobeDisplay as IGlobeDisplay3;
     m_globeDisplayRendering = m_globeDisplay as IGlobeDisplayRendering;
     m_globeCamera           = m_globeDisplay.ActiveViewer.Camera as IGlobeCamera;
     m_globeViewUtil         = m_globeCamera as IGlobeViewUtil;
     m_sceneViewer           = m_globeDisplay.ActiveViewer;
 }
예제 #7
0
        //放大至图层方法
        private void ZoomToGlobeLayer(IGlobe globe, int layerindex)
        {
            IGlobeDisplay globeDisplay = globe.GlobeDisplay;
            ISceneViewer  sceneViewer  = globeDisplay.ActiveViewer;
            ICamera       camera       = sceneViewer.Camera;
            IGlobeCamera  globeCamera  = camera as IGlobeCamera;
            IScene        scene        = globe as IScene;
            ILayer        layer        = scene.get_Layer(layerindex);
            IEnvelope     extent       = layer.AreaOfInterest.Envelope;

            globeCamera.SetToZoomToExtents(extent, globe, sceneViewer);
        }
예제 #8
0
 public Fly()
 {
     globe = ArcGlobe.Globe;
     scene = globe as IScene;
     globeDisplay = globe.GlobeDisplay;
     camera = globeDisplay.ActiveViewer.Camera;
     globeCamera = camera as IGlobeCamera;
     theClock = new Microsoft.VisualBasic.Devices.Clock();
     flyCur = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.Fly.cur"));
     moveFlyCur = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.fly1.cur"));
     speed = 0;
 }
예제 #9
0
 public Fly()
 {
     globe        = ArcGlobe.Globe;
     scene        = globe as IScene;
     globeDisplay = globe.GlobeDisplay;
     camera       = globeDisplay.ActiveViewer.Camera;
     globeCamera  = camera as IGlobeCamera;
     theClock     = new Microsoft.VisualBasic.Devices.Clock();
     flyCur       = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.Fly.cur"));
     moveFlyCur   = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream("GlobeFlyTool.fly1.cur"));
     speed        = 0;
 }
예제 #10
0
        /// <summary>
        /// should the user choose to track the element from above, set the camera above the element
        /// </summary>
        /// <param name="globeCamera"></param>
        /// <param name="objectLocation"></param>
        private void TrackAboveTarget(IGlobeCamera globeCamera, IPoint objectLocation)
        {
            //Update the observer as well as the camera position
            //The camera must be locked in order to prevent a dead-lock caused by the cache manager
            lock (globeCamera)
            {
                globeCamera.SetTargetLatLonAlt(objectLocation.Y, objectLocation.X, objectLocation.Z / 1000.0);

                //The camera must nut be located exactly above the target, since it results in poor orientation computation
                //and therefore the camera gets jumpy.
                globeCamera.SetObserverLatLonAlt(objectLocation.Y - 0.000001, objectLocation.X - 0.000001, objectLocation.Z / 1000.0 + 30.0);
                m_sceneViwer.Camera.Apply();
            }
            m_globeDisplay.RefreshViewers();
        }
예제 #11
0
        //重载鼠标滚轮 axGlobeControl1_OnMouseWheel()
        private void axGlobeControl1_OnMouseWheel(object sender, MouseEventArgs e)
        {
            try
            {
                System.Drawing.Point pSceLoc = axGlobeControl1.PointToScreen(axGlobeControl1.Location);
                System.Drawing.Point Pt      = this.PointToScreen(e.Location);
                if (Pt.X < pSceLoc.X || Pt.X > pSceLoc.X + axGlobeControl1.Width || Pt.Y < pSceLoc.Y || Pt.Y > pSceLoc.Y + axGlobeControl1.Height)
                {
                    return;
                }

                double scale = 0.2;
                if (e.Delta < 0)
                {
                    scale = -scale;
                }

                IGlobeCamera  pGlobeCamera  = axGlobeControl1.GlobeCamera;
                ICamera       pCamera       = pGlobeCamera as ICamera;
                IGlobeDisplay pGlobeDisplay = axGlobeControl1.GlobeDisplay;
                if (pGlobeCamera.OrientationMode == esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal)
                {
                    double zt, xo, yo, zo;
                    pGlobeCamera.GetObserverLatLonAlt(out xo, out yo, out zo);
                    pGlobeDisplay.GetSurfaceElevation(xo, yo, true, out zt);
                    IPoint pObserver = new PointClass();
                    pObserver.PutCoords(xo, yo);
                    double zt1 = zt * (CommonBaseTool.BaseGISTools.UnitSacleToMeter(axGlobeControl1.Globe.GlobeUnits));
                    zo = (zo - zt1) * (1 + scale);
                    pGlobeCamera.SetObserverLatLonAlt(xo, yo, zo);
                }
                else
                {
                    pCamera.ViewingDistance += pCamera.ViewingDistance * scale;
                }
                axGlobeControl1.GlobeDisplay.RefreshViewers();
            }
            catch
            {
            }
        }
예제 #12
0
        //将查询到的结果放大
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                IScene    scene   = m_Globe as IScene;
                IEnvelope envelop = new EnvelopeClass();
                envelop.SetEmpty();
                IEnvelope inEnvelope = new EnvelopeClass();
                inEnvelope.SetEmpty();
                IZAware zaware = envelop as IZAware;
                zaware.ZAware = true;
                ISpatialFilter    sf  = new SpatialFilterClass();
                ISpatialReference spr = scene.SpatialReference;

                ILayer            layer       = scene.get_Layer(0);
                IFeatureSelection featuresect = layer as IFeatureSelection;

                IFeatureLayer fl           = layer as IFeatureLayer;
                IFeatureClass fc           = fl.FeatureClass;
                ISelectionSet selectionset = featuresect.SelectionSet;
                string        shapeField   = fc.ShapeFieldName;
                sf.set_OutputSpatialReference(shapeField, spr);
                ICursor cursor;
                selectionset.Search(sf, true, out cursor);

                IFeatureCursor featureCursor = cursor as IFeatureCursor;
                IFeature       feature;
                if ((feature = featureCursor.NextFeature()) != null)
                {
                    IGeometry geometry = feature.Shape;
                    inEnvelope = geometry.Envelope;
                    envelop.Union(inEnvelope);
                }
                IGlobeCamera globecamera = m_SceneView.Camera as IGlobeCamera;
                globecamera.SetToZoomToExtents(envelop, m_Globe, m_SceneView);
                m_SceneView.Redraw(true);
            }
            catch { }
        }
        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);
        }
    /// <summary>
    /// should the user choose to track the element from above, set the camera above the element
    /// </summary>
    /// <param name="globeCamera"></param>
    /// <param name="objectLocation"></param>
    private void TrackAboveTarget(IGlobeCamera globeCamera, IPoint objectLocation)
    {
      //Update the observer as well as the camera position
      //The camera must be locked in order to prevent a dead-lock caused by the cache manager
      lock (globeCamera)
      {

        globeCamera.SetTargetLatLonAlt(objectLocation.Y, objectLocation.X, objectLocation.Z / 1000.0);

        //The camera must nut be located exactly above the target, since it results in poor orientation computation
        //and therefore the camera gets jumpy.
        globeCamera.SetObserverLatLonAlt(objectLocation.Y - 0.000001, objectLocation.X - 0.000001, objectLocation.Z / 1000.0 + 30.0);
        m_sceneViwer.Camera.Apply();
      }
      m_globeDisplay.RefreshViewers();
    }
예제 #15
0
        public static IAnimationTrack CreateZoomOverLocationAnimation(IGlobeDisplay globeDisplay, double doubleX, double doubleY, double doubleAltitide)
        {
            // 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
                IKeyframe keyframe3 = new GlobeCameraKeyframeClass();
                keyframe3.set_PropertyValueInt(0, 0);
                keyframe3.set_PropertyValueDouble(1, doubleY);
                keyframe3.set_PropertyValueDouble(2, doubleX);
                keyframe3.set_PropertyValueDouble(3, -1d *
                                                  unitConverter.ConvertUnits(globeDisplayRendering.GlobeRadius, esriUnits.esriMeters,
                                                                             globe.GlobeUnits)); // (globeDisplayRendering.GlobeRadius / -1000));
                keyframe3.set_PropertyValueDouble(4, doubleY);
                keyframe3.set_PropertyValueDouble(5, doubleX);
                keyframe3.set_PropertyValueDouble(6, doubleAltitide);
                keyframe3.set_PropertyValueDouble(7, 30);
                keyframe3.set_PropertyValueDouble(8, 0);

                #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";
                // 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);
        }
예제 #16
0
        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);
        }
    /// <summary>
    /// If the user chose to track the element from behind, set the camera behind the element 
    /// so that the camera will be placed on the line connecting the previous and the current element's position.
    /// </summary>
    /// <param name="globeCamera"></param>
    /// <param name="newLon"></param>
    /// <param name="newLat"></param>
    /// <param name="newAlt"></param>
    /// <param name="oldLon"></param>
    /// <param name="oldLat"></param>
    /// <param name="oldAlt"></param>
    private void TrackFollowTarget(IGlobeCamera globeCamera, double newLon, double newLat, double newAlt, double oldLon, double oldLat, double oldAlt)
    {
      //make sure that the camera position is not directly above the element. Otherwise it can lead to
      //an ill condition
      if (newLon == oldLon && newLat == oldLat)
      {
        newLon += 0.00001;
        newLat += 0.00001;
      }

      //calculate the azimuth from the previous position to the current position
      double azimuth = Math.Atan2(newLat - oldLat, newLon - oldLon) * (Math.PI / 180.0);

      //the camera new position, right behind the element
      double obsX = newLon - 0.04 * Math.Cos(azimuth * (Math.PI / 180));
      double obsY = newLat - 0.04 * Math.Sin(azimuth * (Math.PI / 180));

      //set the camera position. The camera must be locked in order to prevent a dead-lock caused by the cache manager
      lock (globeCamera)
      {
        globeCamera.SetTargetLatLonAlt(newLat, newLon, newAlt / 1000.0);
        globeCamera.SetObserverLatLonAlt(obsY, obsX, newAlt / 1000.0 + 0.7);
        m_sceneViwer.Camera.Apply();
      }

      //refresh the globe display
      m_globeDisplay.RefreshViewers();
    }