/// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            //Instantiate the hook helper
            if (null == m_globeHookHelper)
            {
                m_globeHookHelper = new GlobeHookHelperClass();
            }

            //set the hook
            m_globeHookHelper.Hook = hook;

            //get the relevant members
            IGlobe globe = m_globeHookHelper.Globe;

            m_scene         = globe as IScene;
            m_globeDsp      = m_globeHookHelper.GlobeDisplay;
            m_globeViewUtil = m_globeHookHelper.Camera as IGlobeViewUtil;

            //connect to the ZipCodes featureclass
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            path = System.IO.Path.Combine(path, @"ArcGIS\data\USZipCodeData");
            if (!Directory.Exists(path))
            {
                throw new Exception(string.Format("Fix code to point to your sample data: {0} was not found", path));
            }

            IWorkspaceFactory wf = new ShapefileWorkspaceFactoryClass() as IWorkspaceFactory;
            IWorkspace        ws = wf.OpenFromFile(path, 0);
            IFeatureWorkspace fw = ws as IFeatureWorkspace;

            m_featureClass = fw.OpenFeatureClass("US_ZipCodes");
        }
Esempio n. 2
0
        private void ChangeIllumination(IRgbColor prgb)
        {
            IGlobeDisplayRendering pglbDispRend = (IGlobeDisplayRendering)axGlobeControl1.GlobeDisplay;

            double platitude = 0; double plongitude = 0;
            Single pSunred; Single pSungreen; Single pSunblue; Single pAmbientLght;

            if ((pglbDispRend.IsSunEnabled == true) & (chkSun.Checked == true))
            {
                //get the Default position and color...
                pglbDispRend.GetSunPosition(out platitude, out plongitude);
                pglbDispRend.GetSunColor(out pSunred, out pSungreen, out pSunblue);
                //Set AmbientLght
                string sVal = TxtAmbient.Text;
                if (Convert.ToSingle(sVal) > 1)
                {
                    sVal = "1";
                }
                if (Convert.ToSingle(sVal) < 0)
                {
                    sVal = "0";
                }
                pglbDispRend.AmbientLight = Convert.ToSingle(sVal);
                //update textbox
                TxtAmbient.Text = sVal;
                pAmbientLght    = pglbDispRend.AmbientLight;
                IColor        pIcolor  = prgb;
                IGlobeDisplay pglbDisp = EnableSetSun(pAmbientLght, platitude, plongitude, pIcolor);
                axGlobeControl1.GlobeDisplay = pglbDisp;
                axGlobeControl1.GlobeDisplay.RefreshViewers();
            }
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        public void getGlobeCoodinates(AxGlobeControl axGlobeControl, int x, int y, out double X, out double Y, out double Z)
        {
            //string coordInfo = "坐标信息";
            try
            {
                //获取点击坐标的X、Y
                IPoint        globePoint   = new PointClass();
                IGlobeDisplay globeDisplay = axGlobeControl.GlobeDisplay;
                ISceneViewer  sceneViewer  = globeDisplay.ActiveViewer;
                System.Object owner        = System.Type.Missing;
                System.Object object1      = System.Type.Missing;
                globeDisplay.Locate(sceneViewer, x, y, false, false, out globePoint, out owner, out object1);

                //coordInfo = globePoint.X.ToString("F8") + "," + globePoint.Y.ToString("F8") + "," + globePoint.Z.ToString("F4");
                X = globePoint.X;
                Y = globePoint.Y;
                Z = globePoint.Z;
                //return coordInfo;
            }
            catch
            {
                X = 0;
                Y = 0;
                Z = 0;
                //return coordInfo;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 设置图层栅格化
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="bRasterize">是否栅格化</param>
        public void SetRasterize(string layerName, bool bRasterize)
        {
            if (!layerDic.ContainsKey(layerName))
            {
                return;
            }

            ILayer pLayer = layerDic[layerName];

            Dosomething((Action) delegate()
            {
                IScene m_scene = globeControl.Globe as IScene;                                      // 提供数据给成员控制场景
                m_scene.ActiveGraphicsLayer = pLayer;                                               // 活动的图层,如果没有则创建一个
                IGlobeGraphicsLayer pGL     = pLayer as IGlobeGraphicsLayer;                        //提供数据给地图图形图层

                IGlobeDisplay m_globeDisplay           = globeControl.Globe.GlobeDisplay;           // 提供数据给成员操作地图显示
                IGlobeDisplayLayers pGlobeLayer        = m_globeDisplay as IGlobeDisplayLayers;     // 提供数据给成员操作地图显示图层
                IGlobeLayerProperties pGlobeLayerProps = pGlobeLayer.FindGlobeProperties(pLayer);   // 提供数据给成员操纵图层属性,返回图层的属性
                IGlobeGraphicsElementProperties pGEP   = new GlobeGraphicsElementPropertiesClass(); // 图层的其他属性
                pGEP.DrapeElement = true;
                pGEP.DrapeZOffset = 10;
                pGEP.Rasterize    = bRasterize;                  //是否栅格化
                pGlobeLayerProps.ApplyDisplayProperties(pLayer); //应用属性到此图层
            }, true);
        }
Esempio n. 6
0
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            //initialize the hook-helper
            if (m_globeHookHelper == null)
            {
                m_globeHookHelper = new GlobeHookHelper();
            }

            //set the hook
            m_globeHookHelper.Hook = hook;


            //get the ArcGIS path from the registry
            RegistryKey key  = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\ArcObjectsSDK10.2");
            string      path = Convert.ToString(key.GetValue("InstallDir"));

            //set the path to the featureclass used by the GPS simulator
            m_shapefileName = System.IO.Path.Combine(path, "Samples\\data\\USAMajorHighways\\usa_major_highways.shp");

            //get the GlobeDisplsy from the hook helper
            m_globeDisplay = m_globeHookHelper.GlobeDisplay;

            //initialize the real-time manager
            if (null == m_realTimeFeedManager)
            {
                m_realTimeFeedManager = new RealTimeFeedManagerClass();
            }

            //use the built in simulator of the real-time manager
            m_realTimeFeedManager.RealTimeFeed = m_realTimeFeedManager.RealTimeFeedSimulator as IRealTimeFeed;

            m_realTimeFeed = m_realTimeFeedManager.RealTimeFeed;
        }
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            //Instantiate the hook helper
            if (null == m_globeHookHelper)
            {
                m_globeHookHelper = new GlobeHookHelperClass();
            }

            //set the hook
            m_globeHookHelper.Hook = hook;

            //get the relevant members
            IGlobe globe = m_globeHookHelper.Globe;

            m_scene         = globe as IScene;
            m_globeDsp      = m_globeHookHelper.GlobeDisplay;
            m_globeViewUtil = m_globeHookHelper.Camera as IGlobeViewUtil;

            //connect to the ZipCodes featureclass
            //get the ArcGIS path from the registry
            String      versionNumber = RuntimeManager.ActiveRuntime.Version;
            RegistryKey key           = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\ArcObjectsSdk" + versionNumber);
            string      path          = Convert.ToString(key.GetValue("InstallDir"));

            path = System.IO.Path.Combine(path, @"Samples\data\USZipCodeData");

            IWorkspaceFactory wf = new ShapefileWorkspaceFactoryClass() as IWorkspaceFactory;
            IWorkspace        ws = wf.OpenFromFile(path, 0);
            IFeatureWorkspace fw = ws as IFeatureWorkspace;

            m_featureClass = fw.OpenFeatureClass("US_ZipCodes");
        }
Esempio n. 8
0
        public static double GetGlobeElevation(IGlobeDisplay globeDisplay, double longitude, double latitude, bool maxResolution)
        {
            IUnitConverter unitConverter = new UnitConverterClass();

            double doubleZ = 0;

            globeDisplay.GetSurfaceElevation(longitude, latitude, maxResolution, out doubleZ);
            return(unitConverter.ConvertUnits(doubleZ, esriUnits.esriMeters, globeDisplay.Globe.GlobeUnits));
        }
Esempio n. 9
0
        /// <summary>
        /// 地理坐标转化为屏幕坐标
        /// </summary>
        /// <param name="lon">经度</param>
        /// <param name="lat">纬度</param>
        /// <param name="alt">高度</param>
        /// <returns></returns>
        public System.Drawing.Point GeographyToScenePoint(double lon, double lat, double alt = 0)
        {
            int            x, y;
            IGlobeViewUtil globeViewUtil = mapControl.GlobeCamera as IGlobeViewUtil;
            IGlobeDisplay  pGlobeDisplay = mapControl.GlobeDisplay;

            globeViewUtil.GeocentricToWindow(lon, lat, alt, out x, out y);
            System.Drawing.Point point = new System.Drawing.Point(x, y);
            return(point);
        }
Esempio n. 10
0
        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 { }
        }
Esempio n. 11
0
        /// <summary>
        /// 屏幕坐标转地理坐标
        /// </summary>
        /// <param name="x">屏幕X</param>
        /// <param name="y">屏幕Y</param>
        /// <returns></returns>
        public MapLngLat SceneToGeographyPoint(int x, int y)
        {
            double         dLat, dLon, dAlt;
            IGlobeDisplay  pGlobeDisplay  = mapControl.GlobeDisplay;
            ISceneViewer   pViewer        = mapControl.GlobeDisplay.ActiveViewer;
            IGlobeViewUtil pGlobeViewUtil = mapControl.GlobeCamera as IGlobeViewUtil;

            pGlobeViewUtil.WindowToGeographic(pGlobeDisplay, pViewer, x, y, true, out dLon, out dLat, out dAlt);
            Core.Model.MapLngLat lnglat = new Core.Model.MapLngLat(dLon, dLat, dAlt);
            return(lnglat);
        }
Esempio n. 12
0
        private void GetGeographicCoordinates(IGlobe globe, int screenX, int screenY, ref double longitude, ref double latitude, ref double altitudeInKilometers)
        {
            IGlobeDisplay globeDisplay = globe.GlobeDisplay;

            ISceneViewer sceneViewer = globeDisplay.ActiveViewer;

            ICamera camera = globeDisplay.ActiveViewer.Camera;

            IGlobeViewUtil globeViewUtil = camera as IGlobeViewUtil;

            globeViewUtil.WindowToGeographic(globeDisplay, sceneViewer, screenX, screenY, true, out longitude, out latitude, out altitudeInKilometers);
        }
Esempio n. 13
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;
 }
Esempio n. 14
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);
        }
Esempio n. 15
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;
 }
Esempio n. 16
0
        /// <summary>
        /// 添加新的场景
        /// </summary>
        /// <param name="sceneName">场景名称</param>
        private void AddNewBookmarkScene(string sceneName, IGlobeDisplay _GlobeDisplay, ISceneBookmarks _SceneBookmarks)
        {
            try
            {
                //sBookName = sBookName + "|创建日期:" + DateTime.Today.ToShortDateString() + ",时间:" + DateTime.Now.ToLongTimeString();

                ICamera camera = _GlobeDisplay.ActiveViewer.Camera;

                IBookmark3D p3DBookmark = new ESRI.ArcGIS.Analyst3D.Bookmark3D();
                p3DBookmark.Name = sceneName;
                p3DBookmark.Capture(camera);
                _SceneBookmarks.AddBookmark(p3DBookmark);
            }
            catch { }
        }
Esempio n. 17
0
        private void Form1_Load(object sender, EventArgs e)
        {
            m_Globe         = axGlobeControl1.Globe;
            m_GlobeDisplay  = m_Globe.GlobeDisplay;
            m_SceneView     = m_GlobeDisplay.ActiveViewer;
            m_GlobeViewUtil = axGlobeControl1.GlobeCamera as IGlobeViewUtil;

            IGlobeDisplayEvents_Event m_GlobeDisplayEvents = axGlobeControl1.Globe.GlobeDisplay as IGlobeDisplayEvents_Event;

            //将三维视图重绘事件委托给m_GlobeDisplayEvents_AfterDraw方法
            m_GlobeDisplayEvents.AfterDraw += new IGlobeDisplayEvents_AfterDrawEventHandler(m_GlobeDisplayEvents_AfterDraw);

            axMapControl1.Extent    = axMapControl1.FullExtent;
            comboBox1.SelectedIndex = 0;
        }
Esempio n. 18
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (null == m_weatherLayer)
            {
                return;
            }

            object owner;
            object obj;

            IPoint        hitPoint;
            IGlobeDisplay globedisplay = ((IGlobe)m_scene).GlobeDisplay;

            ISceneViewer sceneViewer = globedisplay.ActiveViewer;

            globedisplay.Locate(sceneViewer, X, Y, false, false, out hitPoint, out owner, out obj);

            if (obj != null)
            {
                if (!(obj is IPropertySet))
                {
                    return;
                }

                IPropertySet propset = obj as IPropertySet;

                if (!(owner is RSSWeatherLayer3DClass))
                {
                    return;
                }

                if (propset == null)
                {
                    return;
                }

                //get the zip code
                object o       = propset.GetProperty("ZIPCODE");
                long   zipcode = Convert.ToInt64(o);
                m_weatherLayer.Select(zipcode, Shift != 1);
            }
            else
            {
                m_weatherLayer.Select(-1L, true);
            }
        }
Esempio n. 19
0
        public void AddDrapeLayerToGlobeElevationSurface(IGlobeDisplay globeDisplay, ILayer layer, System.String elevationRasterFilePath)
        {
            ChangeProp(layer);

            IGlobeDisplayLayers globeDisplayLayers = (IGlobeDisplayLayers)globeDisplay; // Explicit cast

            IFeatureLayer pFeatureLayer = (IFeatureLayer)layer;

            pFeatureLayer.Cached = true;

            // Create elevation raster layer
            IRasterLayer elevationRasterLayer = new RasterLayer();

            elevationRasterLayer.CreateFromFilePath(elevationRasterFilePath);

            // Create and add the GlobeLayerProperties extension with the Type set to ElevationData
            IGlobeLayerProperties globeLayerProperties = new GlobeLayerProperties();

            globeLayerProperties.Type = esriGlobeDataType.esriGlobeDataElevation;
            ILayerExtensions layerExtension = (ILayerExtensions)elevationRasterLayer; // Explicit cast

            layerExtension.AddExtension(globeLayerProperties);

            // Set the base option for layer to be esriGlobeLayerBaseLayer and its base layer to be ElevationLayer
            IGlobeLayerProperties  drapeLayerGlobeLayerProperties  = globeDisplayLayers.FindGlobeProperties(layer);
            IGlobeHeightProperties drapeLayerGlobeHeightProperties = drapeLayerGlobeLayerProperties.HeightProperties;

            //
            drapeLayerGlobeHeightProperties.BaseLayer  = elevationRasterLayer;
            drapeLayerGlobeHeightProperties.BaseOption = esriGlobeLayerBaseOption.esriGlobeLayerBaseLayer;
            drapeLayerGlobeHeightProperties.ElevationExpressionString = "[Elevation] * 1000";
            // drapeLayerGlobeHeightProperties.ExtrusionType =  ESRI.ArcGIS.Analyst3D.esriExtrusionType.esriExtrusionBase;
            //drapeLayerGlobeHeightProperties.ExtrusionExpressionString = "Elevation * 1000";
            // Apply the height properties of the layer
            globeDisplayLayers.ApplyHeightProperties(layer);
            drapeLayerGlobeHeightProperties.Apply(m_Globe, layer);
            // globeDisplay.RefreshViewers();

            globeDisplayLayers.RefreshLayer(layer);
            IActiveView pacv = (IActiveView)m_Globe;

            pacv.PartialRefresh(esriViewDrawPhase.esriViewGeography, pFeatureLayer, null);
        }
Esempio n. 20
0
        private string strBtnAhead = "btn_";    //给书签名称自动加上“btn_"
        //private string DatFilePath = "";        //书签保存位置

        public SceneBookmark(AxGlobeControl _axGlobeControl, ButtonItem _btnItem, EventHandler _btnItem_Click)
        {
            try
            {
                this.axGlobeControl    = _axGlobeControl;
                this.btnItem           = _btnItem;
                this.btnItemClickEvent = _btnItem_Click;

                pGlobeDisplay   = this.axGlobeControl.GlobeDisplay;
                pScene          = pGlobeDisplay.Scene;
                pSceneBookmarks = pScene as ISceneBookmarks;

                BookmarkCount = pSceneBookmarks.BookmarkCount;      //bookmark的个数

                //DatFilePath = Application.StartupPath + "\\Data\\Bookmark.dat"; //书签的保存位置

                //LoadBookmarkDatFile(DatFilePath, pSceneBookmarks);  //加载场景书签【有错误,停用】
            }
            catch { }
        }
Esempio n. 21
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
            {
            }
        }
Esempio n. 22
0
        public void RefreshMaps(IMap pMap)
        {
            if (m_Mapglobe == null)
            {
                return;
            }
            m_GlobeDisplay = m_Globe.GlobeDisplay;
            for (int i = 0; i < pMap.LayerCount; i++)
            {
                //  m_Mapglobe.AddLayer(pMap.get_Layer(i));
                if (pMap.get_Layer(i) is IFeatureLayer)
                {
                    AddVectorDataToGlobe(m_Globe, esriGlobeLayerType.esriGlobeLayerTypeDraped, pMap.get_Layer(i));
                }
                //AddDrapeLayerToGlobeElevationSurface(m_GlobeDisplay, pMap.get_Layer(i), @"C:\Users\mgh\Desktop\AirPlane2\AirPlane\AirPlane\bin\Debug\GlobeData\wsiearth.tif");
                //Hieght(pMap.get_Layer(i));
            }

            // ChangeRasterize();
            // ChangeHeightProperties();
        }
Esempio n. 23
0
        /// <summary>
        /// Occurs when this command is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            //initialize the hook-helper
            if (m_globeHookHelper == null)
            {
                m_globeHookHelper = new GlobeHookHelper();
            }

            //set the hook
            m_globeHookHelper.Hook = hook;


            //set the path to the featureclass used by the GPS simulator
            string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            m_shapefileName = System.IO.Path.Combine(path, @"ArcGIS\data\USAMajorHighways\usa_major_highways.shp");
            System.Diagnostics.Debug.WriteLine(string.Format("File path for data root: {0}", m_shapefileName));
            if (!File.Exists(m_shapefileName))
            {
                throw new Exception(string.Format("Fix code to point to your sample data: {0} was not found", m_shapefileName));
            }

            //get the GlobeDisplsy from the hook helper
            m_globeDisplay = m_globeHookHelper.GlobeDisplay;

            //initialize the real-time manager
            if (null == m_realTimeFeedManager)
            {
                m_realTimeFeedManager = new RealTimeFeedManagerClass();
            }

            //use the built in simulator of the real-time manager
            m_realTimeFeedManager.RealTimeFeed = m_realTimeFeedManager.RealTimeFeedSimulator as IRealTimeFeed;

            m_realTimeFeed = m_realTimeFeedManager.RealTimeFeed;
        }
		/// <summary>
		/// Occurs when this command is created
		/// </summary>
		/// <param name="hook">Instance of the application</param>
		public override void OnCreate(object hook)
		{
      //Instantiate the hook helper
      if (null == m_globeHookHelper)
        m_globeHookHelper = new GlobeHookHelperClass();
      
      //set the hook
      m_globeHookHelper.Hook = hook;

      //get the relevant members
      IGlobe globe = m_globeHookHelper.Globe;
      m_scene = globe as IScene;
      m_globeDsp = m_globeHookHelper.GlobeDisplay;
			m_globeViewUtil = m_globeHookHelper.Camera as IGlobeViewUtil;

			//connect to the ZipCodes featureclass
      //get the ArcGIS path from the registry
      String versionNumber = RuntimeManager.ActiveRuntime.Version;
      RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\ArcObjectsSdk" + versionNumber);
      string path = Convert.ToString(key.GetValue("InstallDir"));
      path = System.IO.Path.Combine(path, @"Samples\data\USZipCodeData");

			IWorkspaceFactory wf = new ShapefileWorkspaceFactoryClass() as IWorkspaceFactory;
      IWorkspace ws = wf.OpenFromFile(path, 0);
			IFeatureWorkspace fw = ws as IFeatureWorkspace;
			m_featureClass = fw.OpenFeatureClass("US_ZipCodes");
		}
Esempio n. 25
0
        private void PlayAnimationFast(int cycles, int iteration)
        {
            IGlobe           globe        = axGlobeControl1.Globe;
            IGlobeDisplay    globeDisplay = globe.GlobeDisplay;
            Scene            scene        = (Scene)globeDisplay.Scene;
            IAnimationTracks sceneTracks  = (IAnimationTracks)scene;

            IArray trackCamArray = new ArrayClass();
            IArray trackGlbArray = new ArrayClass();
            IArray trackLyrArray = new ArrayClass();

            string sError;

            if (sceneTracks.TrackCount == 0)
            {
                sError = m_AnimFilePath;
                if (sError == "")
                {
                    sError = "To get a Sample animation file, Developer Kit Samples need to be installed!";
                    System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + sError);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("The current document doesn't contain animation file." + 0x000A + "Load " + m_AnimFilePath + @"\AnimationSample.aga for sample.");
                }
                return;
            }

            IAnimationTrack track;
            IAnimationTrack trackLayer;
            IAnimationTrack trackGlobe = null;
            IAnimationType  animType;
            IAnimationType  animLayer;
            IAnimationType  animGlobeCam = null;
            IKeyframe       kFGlbCam;
            IKeyframe       kFGlbLayer;
            int             k;

            int[] count = new int[1000];

            //get each track from the scene and store tracks of the same kind in an Array
            for (int i = 0; i <= sceneTracks.TrackCount - 1; i++)
            {
                track    = (IAnimationTrack)sceneTracks.Tracks.get_Element(i);
                k        = i;
                animType = track.AnimationType;

                if (animType.CLSID.Value.ToString() == "{7CCBA704-3933-4D7A-8E89-4DFEE88AA937}")
                {
                    //GlobeLayer
                    trackLayer = new AnimationTrackClass();
                    trackLayer = track;
                    trackLayer.AnimationType = animType;
                    kFGlbLayer = new GlobeLayerKeyframeClass();
                    animLayer  = animType;
                    //Store the keyframe count of each track in an array
                    count[i] = trackLayer.KeyframeCount;
                    trackLyrArray.Add(trackLayer);
                }
                else if (animType.CLSID.Value.ToString() == "{D4565495-E2F9-4D89-A8A7-D0B69FD7A424}")
                {
                    //Globe Camera type
                    trackGlobe = new AnimationTrackClass();
                    trackGlobe = track;
                    trackGlobe.AnimationType = animType;
                    kFGlbCam     = new GlobeCameraKeyframeClass();
                    animGlobeCam = animType;
                    //Store the keyframe count of each track in an array
                    count[i] = trackGlobe.KeyframeCount;
                    trackGlbArray.Add(trackGlobe);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Animation Type " + animType.Name + " Not Supported. Check if the animation File is Valid!");
                    return;
                }
            }

            int larger = Greatest(ref count);

            //if nothing gets passed by the argument it takes the max no of keyframes
            if (iteration == 0)
            {
                iteration = larger;
            }

            IAnimationTrack trackCamera;
            IAnimationType  animCam = null;
            IKeyframe       kFBkmark;
            double          time = 0;
            int             keyFrameLayerCount; int keyFrameCameraCount; int keyFrameCount;

            for (int i = 1; i <= cycles; i++)                    //no of cycles...
            {
                for (int start = 0; start <= iteration; start++) //no of iterations...
                {
                    for (int j = 0; j <= trackCamArray.Count - 1; j++)
                    {
                        trackCamera = (IAnimationTrack)trackCamArray.get_Element(j);
                        if (trackCamera != null)
                        {
                            if (time >= trackCamera.BeginTime)
                            {
                                keyFrameCameraCount = trackGlobe.KeyframeCount;
                                kFBkmark            = trackCamera.get_Keyframe(keyFrameCameraCount - keyFrameCameraCount);
                                //reset object
                                animCam.ResetObject(scene, kFBkmark);
                                //interpolate by using track
                                trackCamera.InterpolateObjectProperties(scene, time);
                                keyFrameCameraCount = keyFrameCameraCount - 1;
                            }
                        }
                    }

                    for (k = 0; k <= trackGlbArray.Count - 1; k++)
                    {
                        trackGlobe = (IAnimationTrack)trackGlbArray.get_Element(k);
                        if (trackGlobe != null)
                        {
                            if (time >= trackGlobe.BeginTime)
                            {
                                keyFrameCount = trackGlobe.KeyframeCount;
                                kFGlbCam      = trackGlobe.get_Keyframe(trackGlobe.KeyframeCount - keyFrameCount);
                                //reset object
                                animGlobeCam.ResetObject(scene, kFGlbCam);
                                //interpolate by using track
                                trackGlobe.InterpolateObjectProperties(scene, time);
                                keyFrameCount = keyFrameCount - 1;
                            }
                        }
                    }

                    for (int t = 0; t <= trackLyrArray.Count - 1; t++)
                    {
                        trackLayer = (IAnimationTrack)trackLyrArray.get_Element(t);
                        if (trackLayer != null)
                        {
                            if (time >= trackLayer.BeginTime)
                            {
                                keyFrameLayerCount = trackLayer.KeyframeCount;
                                kFGlbLayer         = trackLayer.get_Keyframe(trackLayer.KeyframeCount - keyFrameLayerCount);
                                //interpolate by using track
                                trackLayer.InterpolateObjectProperties(scene, time);
                                keyFrameLayerCount = keyFrameLayerCount - 1;
                            }
                        }
                    }

                    //reset interpolation Point
                    time = start / iteration;
                    //refresh the globeviewer(s)
                    globeDisplay.RefreshViewers();
                }
            }
        }
Esempio n. 26
0
        ///<summary> 由路径来创建一个Camera动画.这条路径有图层提供一条三维线要素</summary>
        ///
        ///<param name="globe">IGlobe接口</param>
        ///<param name="layer">一个包含PolyLine的ILayer接口</param>
        ///<param name="featureID">包含路径的要素ID.Example: 123</param>
        ///
        ///<remarks></remarks>
        public void CreateAnimationFromPath(string path, string SaveFilePath)
        {
            IGlobe        pGlobe       = axGlobeControl1.Globe;
            IGlobeDisplay globeDisplay = pGlobe.GlobeDisplay;
            IScene        scene        = globeDisplay.Scene;

            // 获取动画扩展
            IBasicScene2        basicScene2        = scene as IBasicScene2;
            IAnimationExtension animationExtension = basicScene2.AnimationExtension;

            //获取路径

            //读取shp文件

            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();


            string pFolder   = System.IO.Path.GetDirectoryName(path);
            string pFileName = System.IO.Path.GetFileName(path);

            //2打开shapeFile工作空间
            IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(pFolder, 0);
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;

            //3、打开要素类
            IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(pFileName);

            //4、创建要素图层
            IFeatureLayer pFLayer = new FeatureLayerClass();

            //5、关联图层和要素类
            pFLayer.FeatureClass = pFeatureClass;
            pFLayer.Name         = pFeatureClass.AliasName;
            int b = pFeatureClass.ObjectClassID;

            ILayer        pLayer       = pFLayer;
            IFeatureLayer featureLayer = pLayer as IFeatureLayer;
            IFeatureClass featureClass = featureLayer.FeatureClass;
            //int pFeatureID = pFeatureClass.FeatureClassID;
            int       pFeatureID = 0;
            IFeature  feature    = featureClass.GetFeature(pFeatureID);
            IGeometry geometry   = feature.Shape;

            //创建AGAnimationUtils和AGImportPathOptions对象
            ESRI.ArcGIS.Animation.IAGAnimationUtils    agAnimationUtils    = new AGAnimationUtilsClass();
            ESRI.ArcGIS.Animation.IAGImportPathOptions agImportPathOptions = new AGImportPathOptionsClass();

            // 设置AGImportPathOptions的属性
            agImportPathOptions.BasicMap        = (IBasicMap)pGlobe;
            agImportPathOptions.AnimationTracks = (IAGAnimationTracks)pGlobe;
            agImportPathOptions.AnimationType   = new AnimationTypeGlobeCameraClass();
            agImportPathOptions.AnimatedObject  = pGlobe.GlobeDisplay.ActiveViewer.Camera; //动画对象
            agImportPathOptions.PathGeometry    = geometry;                                //动画轨迹
            agImportPathOptions.ConversionType  = ESRI.ArcGIS.Animation.esriFlyFromPathType.esriFlyFromPathObsAndTarget;
            agImportPathOptions.LookaheadFactor = 0.05;
            agImportPathOptions.RollFactor      = 0;

            agImportPathOptions.AnimationEnvironment = animationExtension.AnimationEnvironment;
            IAGAnimationContainer AGAnimationContainer = animationExtension.AnimationTracks.AnimationObjectContainer;

            //创建
            agAnimationUtils.CreateFlybyFromPath(AGAnimationContainer, agImportPathOptions);

            //播放

            //获取AGAnimationEnvironment对象
            IBasicScene2            basicscene  = pGlobe as IBasicScene2;
            IAnimationExtension     animationEx = basicscene.AnimationExtension;
            IAGAnimationEnvironment agAnimationEnv;

            agAnimationEnv = animationEx.AnimationEnvironment;
            agAnimationEnv.AnimationDuration = Convert.ToDouble("30");                              //持续时间
            agAnimationEnv.PlayType          = esriAnimationPlayType.esriAnimationPlayTypeDuration; //播放模式

            agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayOnceForward;

            agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayOnceReverse;
            //agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayLoopForward;
            //agAnimationEnv.PlayMode = esriAnimationPlayMode.esriAnimationPlayLoopReverse;


            IAGAnimationPlayer agAnimationPlayer = agAnimationUtils as IAGAnimationPlayer;

            agAnimationPlayer.PlayAnimation(pGlobe as IAGAnimationTracks, agAnimationEnv, null);



            //保存


            if (System.IO.File.Exists(SaveFilePath))
            {
                System.IO.File.Delete(SaveFilePath);
                agAnimationUtils.SaveAnimationFile(AGAnimationContainer, SaveFilePath, esriArcGISVersion.esriArcGISVersion10);
            }
        }
Esempio n. 27
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);
        }
Esempio n. 28
0
        public static double GetGlobeElevation(IGlobeDisplay globeDisplay, double longitude, double latitude, bool maxResolution)
        {
            IUnitConverter unitConverter = new UnitConverterClass();

            double doubleZ = 0;
            globeDisplay.GetSurfaceElevation(longitude, latitude, maxResolution, out doubleZ);
            return unitConverter.ConvertUnits(doubleZ, esriUnits.esriMeters, globeDisplay.Globe.GlobeUnits);
        }
Esempio n. 29
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;
        }
Esempio n. 30
0
        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 { }
        }
		private void Form1_Load(object sender, System.EventArgs e)
		{
      // Get the SDK location
      string sGlbData = RuntimeManager.ActiveRuntime.Path.ToString();
      sGlbData = Directory.GetParent(sGlbData).ToString();
      // first time removes the directory separator
      sGlbData = Directory.GetParent(sGlbData).ToString();
      sGlbData = sGlbData + "\\DeveloperKit" + RuntimeManager.ActiveRuntime.Version + "\\Samples\\data\\Globe\\World Imagery.3dd";
      if (axGlobeControl1.Check3dFile(sGlbData)) axGlobeControl1.Load3dFile(sGlbData);

			//Enable north arrow, HUD and GlobeTips.
			bool bChkArrow = axGlobeControl1.GlobeViewer.NorthArrowEnabled;
			bool bHUD = axGlobeControl1.GlobeViewer.HUDEnabled;
			ChkHUD.Checked = bHUD;
			ChkArrow.Checked = bChkArrow;
			//get the state of globetips from the loaded doc.....
			m_penumTips = axGlobeControl1.GlobeViewer.GlobeDisplay.Globe.ShowGlobeTips;
			//if no tip value (not set) in the loaded doc set it to default..
			if (m_penumTips <= 0)
			{
				m_penumTips = esriGlobeTipsType.esriGlobeTipsTypeLatLon;
			}
			cmbTipType.Items.Insert(0, "esriGlobeTipsTypeNone");
			cmbTipType.Items.Insert(1, "esriGlobeTipsTypeLatLon");
			cmbTipType.Items.Insert(2, "esriGlobeTipsTypeElevation");
			cmbTipType.Items.Insert(3, "esriGlobeTipsTypeLatLonElevation");

			ChkTip.Checked = true;//tip value of the doc...
			//set the list...
			cmbTipType.SelectedIndex = (int) m_penumTips;

			//populate tip type values..
			axGlobeControl1.TipStyle = esriTipStyle.esriTipStyleSolid;
			axGlobeControl1.TipDelay = 500; //default..
			axGlobeControl1.GlobeViewer.GlobeDisplay.Globe.ShowGlobeTips = m_penumTips;
			axGlobeControl1.GlobeDisplay.RefreshViewers();

			//Get current sun property..
			IGlobeDisplayRendering pglbDispRend = (IGlobeDisplayRendering)axGlobeControl1.GlobeDisplay;
			bool bsun = pglbDispRend.IsSunEnabled;
			if (bsun == true) chkSun.Checked = true; //checked
			//Get Ambient light...
			TxtAmbient.Text = pglbDispRend.AmbientLight.ToString();
			//Listen to events..
      m_globeDisplay = axGlobeControl1.GlobeDisplay;
      globeDisplayEvents = (IGlobeDisplayEvents_Event)m_globeDisplay;
      globeDisplayEvents.AfterDraw += new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
      //globeDisplayEvents += new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
			//afterDrawE = new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
			//((IGlobeDisplayEvents_Event)axGlobeControl1.GlobeDisplay).AfterDraw+=afterDrawE;


     
      
      //globeDisplayEvents.AfterDraw += new (globeDisplayEvents_AfterDraw);
		}
Esempio n. 32
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>
    /// This is where the actual drawing takes place.
    /// </summary>
    /// <param name="pGlobeViewer"></param>
    public override void DrawImmediate(IGlobeViewer pGlobeViewer)
    {
      //make sure that the layer is valid, visible and that the main table exists 
      if (!m_bVisible || !m_bValid | null == m_table)
        return;

      
      //get the OpenGL rendering mode
      uint mode;
      unsafe
      {
        int m;
        GL.glGetIntegerv(GL.GL_RENDER_MODE, &m);
        mode = (uint)m;
          //GL.glGetIntegerv(GL.GL_RENDER_MODE, out mode);
        
      }

      //get the OpenGL matrices (required for the viewport filtering and the billboard orientation)
      GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, m_modelViewMatrix);
      GL.glGetIntegerv(GL.GL_VIEWPORT, m_viewport);
      GL.glGetDoublev(GL.GL_PROJECTION_MATRIX, m_projMatrix);

      //populate the billboard matrix
      m_billboardMatrix[0] = m_modelViewMatrix[0];
      m_billboardMatrix[1] = m_modelViewMatrix[4];
      m_billboardMatrix[2] = m_modelViewMatrix[8];
      m_billboardMatrix[3] = 0;

      m_billboardMatrix[4] = m_modelViewMatrix[1];
      m_billboardMatrix[5] = m_modelViewMatrix[5];
      m_billboardMatrix[6] = m_modelViewMatrix[9];
      m_billboardMatrix[7] = 0;

      m_billboardMatrix[8] = m_modelViewMatrix[2];
      m_billboardMatrix[9] = m_modelViewMatrix[6];
      m_billboardMatrix[10] = m_modelViewMatrix[10];
      m_billboardMatrix[11] = 0;

      m_billboardMatrix[12] = 0;
      m_billboardMatrix[13] = 0;
      m_billboardMatrix[14] = 0;
      m_billboardMatrix[15] = 1;

      ISceneViewer sceneViewer = pGlobeViewer.GlobeDisplay.ActiveViewer;

      //only once, create display lists and do initializations
      if (!m_bDisplayListCreated)
      {
        CreateDisplayLists();
        m_globeDisplay = pGlobeViewer.GlobeDisplay;
      }

      //get the globeViewUtil which allow to convert between the different globe coordinate systems
      m_globeViewUtil = sceneViewer.Camera as IGlobeViewUtil;
      IGlobeViewUtil globeViewUtil = sceneViewer.Camera as IGlobeViewUtil;
      IGlobeAdvancedOptions advOpt = m_globeDisplay.AdvancedOptions;

      //the ClipNear value is required for the viewport filtering (since we don't
      //want to draw an item which is beyond the clipping planes).
      double clipNear = advOpt.ClipNear;

      double dblObsX, dblObsY, dblObsZ, dMagnitude;
      ICamera camera = pGlobeViewer.GlobeDisplay.ActiveViewer.Camera;
      
      //query the camera location in geocentric coordinate (OpenGL coord system)
      camera.Observer.QueryCoords(out dblObsX, out dblObsY);
      dblObsZ = camera.Observer.Z;

      double lat, lon, X = 0.0, Y = 0.0, Z = 0.0;

      //iterate through all the records of the layer, test whether the item is within the 
      //viewport are and draw it onto the globe.
      foreach (DataRow rec in m_table.Rows)
      {

        lat = Convert.ToDouble(rec[3]);
        lon = Convert.ToDouble(rec[4]);
        X = Convert.ToDouble(rec[5]);
        Y = Convert.ToDouble(rec[6]);
        Z = Convert.ToDouble(rec[7]);

        #region get the OGL geocentric coordinates X,Y,Z
        if (X == 0.0 && Y == 0.0 && Z == 0.0)
        {
          //calculate the geocentric coordinates
          globeViewUtil.GeographicToGeocentric(lon, lat, 1000.0, out X, out Y, out Z);

          //write the calculated geocentric coordinate to the table
          lock (m_table)
          {
            rec[5] = X;
            rec[6] = Y;
            rec[7] = Z;
            rec.AcceptChanges();
          }
        }
        #endregion

        //make sure that the item is inside the viewport, otherwise no need to draw it
        if (!InsideViewport(X, Y, Z, clipNear, mode))
          continue;

        //get the distance from the camera to the drawn item.
        //This distance will determine whether to draw the item as a dot or as
        //a full icon.
        m_vector3D.SetComponents(dblObsX - X, dblObsY - Y, dblObsZ - Z);
        dMagnitude = m_vector3D.Magnitude;

        //call the drawing method
        DrawItem(rec, dMagnitude);
      }
    }
    /// <summary>
    /// Occurs when this command is created
    /// </summary>
    /// <param name="hook">Instance of the application</param>
    public override void OnCreate(object hook)
    {
      //initialize the hook-helper
      if (m_globeHookHelper == null)
        m_globeHookHelper = new GlobeHookHelper();

      //set the hook
      m_globeHookHelper.Hook = hook;

      
      //get the ArcGIS path from the registry
      RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ESRI\ArcObjectsSDK10.2");
      string path = Convert.ToString(key.GetValue("InstallDir"));

      //set the path to the featureclass used by the GPS simulator
      m_shapefileName = System.IO.Path.Combine(path, "Samples\\data\\USAMajorHighways\\usa_major_highways.shp");

      //get the GlobeDisplsy from the hook helper
      m_globeDisplay = m_globeHookHelper.GlobeDisplay;

      //initialize the real-time manager
      if (null == m_realTimeFeedManager)
        m_realTimeFeedManager = new RealTimeFeedManagerClass();

      //use the built in simulator of the real-time manager
      m_realTimeFeedManager.RealTimeFeed = m_realTimeFeedManager.RealTimeFeedSimulator as IRealTimeFeed;

      m_realTimeFeed = m_realTimeFeedManager.RealTimeFeed;
    }
Esempio n. 35
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            // Get the SDK location
            string sGlbData = RuntimeManager.ActiveRuntime.Path.ToString();

            sGlbData = Directory.GetParent(sGlbData).ToString();
            // first time removes the directory separator
            sGlbData = Directory.GetParent(sGlbData).ToString();
            sGlbData = sGlbData + "\\DeveloperKit" + RuntimeManager.ActiveRuntime.Version + "\\Samples\\data\\Globe\\World Imagery.3dd";
            if (axGlobeControl1.Check3dFile(sGlbData))
            {
                axGlobeControl1.Load3dFile(sGlbData);
            }

            //Enable north arrow, HUD and GlobeTips.
            bool bChkArrow = axGlobeControl1.GlobeViewer.NorthArrowEnabled;
            bool bHUD      = axGlobeControl1.GlobeViewer.HUDEnabled;

            ChkHUD.Checked   = bHUD;
            ChkArrow.Checked = bChkArrow;
            //get the state of globetips from the loaded doc.....
            m_penumTips = axGlobeControl1.GlobeViewer.GlobeDisplay.Globe.ShowGlobeTips;
            //if no tip value (not set) in the loaded doc set it to default..
            if (m_penumTips <= 0)
            {
                m_penumTips = esriGlobeTipsType.esriGlobeTipsTypeLatLon;
            }
            cmbTipType.Items.Insert(0, "esriGlobeTipsTypeNone");
            cmbTipType.Items.Insert(1, "esriGlobeTipsTypeLatLon");
            cmbTipType.Items.Insert(2, "esriGlobeTipsTypeElevation");
            cmbTipType.Items.Insert(3, "esriGlobeTipsTypeLatLonElevation");

            ChkTip.Checked = true;            //tip value of the doc...
            //set the list...
            cmbTipType.SelectedIndex = (int)m_penumTips;

            //populate tip type values..
            axGlobeControl1.TipStyle = esriTipStyle.esriTipStyleSolid;
            axGlobeControl1.TipDelay = 500;             //default..
            axGlobeControl1.GlobeViewer.GlobeDisplay.Globe.ShowGlobeTips = m_penumTips;
            axGlobeControl1.GlobeDisplay.RefreshViewers();

            //Get current sun property..
            IGlobeDisplayRendering pglbDispRend = (IGlobeDisplayRendering)axGlobeControl1.GlobeDisplay;
            bool bsun = pglbDispRend.IsSunEnabled;

            if (bsun == true)
            {
                chkSun.Checked = true;                           //checked
            }
            //Get Ambient light...
            TxtAmbient.Text = pglbDispRend.AmbientLight.ToString();
            //Listen to events..
            m_globeDisplay                = axGlobeControl1.GlobeDisplay;
            globeDisplayEvents            = (IGlobeDisplayEvents_Event)m_globeDisplay;
            globeDisplayEvents.AfterDraw += new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
            //globeDisplayEvents += new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
            //afterDrawE = new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
            //((IGlobeDisplayEvents_Event)axGlobeControl1.GlobeDisplay).AfterDraw+=afterDrawE;



            //globeDisplayEvents.AfterDraw += new (globeDisplayEvents_AfterDraw);
        }
Esempio n. 36
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            //relative file path to the sample data from project location
            string sGlbData = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            sGlbData = Path.Combine(sGlbData, @"ArcGIS\data\Globe\World Imagery.3dd");
            var filePath = new DirectoryInfo(sGlbData);

            System.Diagnostics.Debug.WriteLine(string.Format("File path for data root: {0} [{1}]", filePath.FullName, Directory.GetCurrentDirectory()));
            if (!File.Exists(sGlbData))
            {
                throw new Exception(string.Format("Fix code to point to your sample data: {0} [{1}] was not found", filePath.FullName, Directory.GetCurrentDirectory()));
            }

            if (axGlobeControl1.Check3dFile(sGlbData))
            {
                axGlobeControl1.Load3dFile(sGlbData);
            }

            //Enable north arrow, HUD and GlobeTips.
            bool bChkArrow = axGlobeControl1.GlobeViewer.NorthArrowEnabled;
            bool bHUD      = axGlobeControl1.GlobeViewer.HUDEnabled;

            ChkHUD.Checked   = bHUD;
            ChkArrow.Checked = bChkArrow;
            //get the state of globetips from the loaded doc.....
            m_penumTips = axGlobeControl1.GlobeViewer.GlobeDisplay.Globe.ShowGlobeTips;
            //if no tip value (not set) in the loaded doc set it to default..
            if (m_penumTips <= 0)
            {
                m_penumTips = esriGlobeTipsType.esriGlobeTipsTypeLatLon;
            }
            cmbTipType.Items.Insert(0, "esriGlobeTipsTypeNone");
            cmbTipType.Items.Insert(1, "esriGlobeTipsTypeLatLon");
            cmbTipType.Items.Insert(2, "esriGlobeTipsTypeElevation");
            cmbTipType.Items.Insert(3, "esriGlobeTipsTypeLatLonElevation");

            ChkTip.Checked = true;            //tip value of the doc...
            //set the list...
            cmbTipType.SelectedIndex = (int)m_penumTips;

            //populate tip type values..
            axGlobeControl1.TipStyle = esriTipStyle.esriTipStyleSolid;
            axGlobeControl1.TipDelay = 500;             //default..
            axGlobeControl1.GlobeViewer.GlobeDisplay.Globe.ShowGlobeTips = m_penumTips;
            axGlobeControl1.GlobeDisplay.RefreshViewers();

            //Get current sun property..
            IGlobeDisplayRendering pglbDispRend = (IGlobeDisplayRendering)axGlobeControl1.GlobeDisplay;
            bool bsun = pglbDispRend.IsSunEnabled;

            if (bsun == true)
            {
                chkSun.Checked = true;                           //checked
            }
            //Get Ambient light...
            TxtAmbient.Text = pglbDispRend.AmbientLight.ToString();
            //Listen to events..
            m_globeDisplay                = axGlobeControl1.GlobeDisplay;
            globeDisplayEvents            = (IGlobeDisplayEvents_Event)m_globeDisplay;
            globeDisplayEvents.AfterDraw += new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
            //globeDisplayEvents += new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
            //afterDrawE = new IGlobeDisplayEvents_AfterDrawEventHandler(OnAfterDraw);
            //((IGlobeDisplayEvents_Event)axGlobeControl1.GlobeDisplay).AfterDraw+=afterDrawE;



            //globeDisplayEvents.AfterDraw += new (globeDisplayEvents_AfterDraw);
        }
Esempio n. 37
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);
        }