Ejemplo n.º 1
0
        public void ZoomToPoint(AxGlobeControl axGlobeControl, double MapX, double MapY)
        {
            try
            {
                IPoint point = new PointClass();
                point.PutCoords(MapX, MapY);    //设置点击的点坐标
                //point = CommonBaseTool.BaseGISTools.getGeoPoint(MapX, MapY);        //转换坐标

                IPoint ptObserver = new PointClass();
                IPoint ptTarget = new PointClass();

                //Observer点
                IClone pClone1 = point as IClone;
                ptObserver = pClone1.Clone() as IPoint;
                ptObserver.Y = ptObserver.Y - 0.08;
                ptObserver.Z = 15.45;
                //Target点
                IClone pClone2 = point as IClone;
                ptTarget = pClone2.Clone() as IPoint;
                ptTarget.Z = -0.01;

                axGlobeControl.GlobeCamera.SetObserverLatLonAlt(ptObserver.Y, ptObserver.X, ptObserver.Z);
                axGlobeControl.GlobeCamera.SetTargetLatLonAlt(ptTarget.Y, ptTarget.X, ptTarget.Z);
                //刷新
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得当前所有图层的list
        /// </summary>
        /// <param name="axGlobeControl">AxGlobeControl</param>
        /// <returns>List<LayerInfo></returns>
        public static List<LayerInfo> getLayerNameList(AxGlobeControl axGlobeControl)
        {
            List<LayerInfo> LayerInfoList = new List<LayerInfo>();
            //判断图层数
            if (axGlobeControl.GlobeDisplay.Scene.LayerCount == 0)
            {
                return LayerInfoList;
            }
            try
            {

                ILayer layer = null;
                LayerInfo pLayerInfo;
                for (int index = 0; index < axGlobeControl.GlobeDisplay.Scene.LayerCount; index++)
                {
                    layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(index);  //取得图层

                    pLayerInfo = new LayerInfo();   //实例化一个图层信息类
                    pLayerInfo.LayerName = "btn_" + layer.Name;
                    pLayerInfo.LayerIndex = index;
                    pLayerInfo.isVisible = layer.Visible;

                    LayerInfoList.Add(pLayerInfo);  //添加到list
                }

                return LayerInfoList;
            }
            catch
            {
                return LayerInfoList;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存影像
        /// </summary>
        /// <param name="axGlobeControl">AxGlobeControl</param>
        public static void SaveSceneAsImage(AxGlobeControl axGlobeControl, string initFoldPath)
        {
            try
            {
                SaveFileDialog sfdImage = new SaveFileDialog();
                sfdImage.Title            = "导出三维场景图像";
                sfdImage.Filter           = "所有文件(*.*)|*.*|Jpeg Files(*.jpg,*.jpeg)|*.jpg,*.jpeg";
                sfdImage.RestoreDirectory = true;
                sfdImage.ValidateNames    = true;
                sfdImage.OverwritePrompt  = true;
                sfdImage.DefaultExt       = "jpg";
                sfdImage.InitialDirectory = initFoldPath;   //初试路径

                if (sfdImage.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                axGlobeControl.GlobeDisplay.ActiveViewer.GetScreenShot(esri3DOutputImageType.JPEG, sfdImage.FileName);
                //保存成功提示
                MessageBox.Show("导出jpg图像成功,图像保存在:" + sfdImage.FileName + "。", "保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                //MessageBox.Show(ex.Message);
                return;
            }
        }
Ejemplo n.º 4
0
 //绕一点旋转查看
 public static void FixedLineOfSight(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeFixedLineOfSightToolClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     _axGlobeControl.CurrentTool = (ITool)pCommand;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 添加数据
 /// </summary>
 //添加图层
 public static void AddLayerToGlobe(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsAddDataCommandClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     pCommand.OnClick();
 }
Ejemplo n.º 6
0
 //全图
 public static void FullExtentGlobe(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeFullExtentCommandClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     pCommand.OnClick();
 }
Ejemplo n.º 7
0
 //逐级缩小
 public static void FixedZoomOut(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeFixedZoomOutCommandClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     pCommand.OnClick();
 }
Ejemplo n.º 8
0
        public void ZoomToPoint(AxGlobeControl axGlobeControl, double MapX, double MapY)
        {
            try
            {
                IPoint point = new PointClass();
                point.PutCoords(MapX, MapY);    //设置点击的点坐标
                //point = CommonBaseTool.BaseGISTools.getGeoPoint(MapX, MapY);        //转换坐标

                IPoint ptObserver = new PointClass();
                IPoint ptTarget   = new PointClass();

                //Observer点
                IClone pClone1 = point as IClone;
                ptObserver   = pClone1.Clone() as IPoint;
                ptObserver.Y = ptObserver.Y - 0.08;
                ptObserver.Z = 15.45;
                //Target点
                IClone pClone2 = point as IClone;
                ptTarget   = pClone2.Clone() as IPoint;
                ptTarget.Z = -0.01;

                axGlobeControl.GlobeCamera.SetObserverLatLonAlt(ptObserver.Y, ptObserver.X, ptObserver.Z);
                axGlobeControl.GlobeCamera.SetTargetLatLonAlt(ptTarget.Y, ptTarget.X, ptTarget.Z);
                //刷新
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }
Ejemplo n.º 9
0
 //信息查询
 public static void Identify(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeIdentifyToolClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     _axGlobeControl.CurrentTool = (ITool)pCommand;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_globeObject">地球控件</param>
        public FactoryArcGlobe(object _globeObject)
        {
            if (_globeObject != null)
            {
                axGlobeControl = _globeObject as AxGlobeControl;
            }
            else
            {
                InitGlobeControl();
            }

            axGlobeControl.OnMouseDown   += new IGlobeControlEvents_Ax_OnMouseDownEventHandler(axGlobeControl_OnMouseDown);
            axGlobeControl.OnMouseMove   += new IGlobeControlEvents_Ax_OnMouseMoveEventHandler(axGlobeControl_OnMouseMove);
            axGlobeControl.OnMouseUp     += new IGlobeControlEvents_Ax_OnMouseUpEventHandler(axGlobeControl_OnMouseUp);
            axGlobeControl.OnDoubleClick += new IGlobeControlEvents_Ax_OnDoubleClickEventHandler(axGlobeControl_OnDoubleClick);
            axGlobeControl.OnKeyDown     += new IGlobeControlEvents_Ax_OnKeyDownEventHandler(axGlobeControl_OnKeyDown);
            axGlobeControl.OnKeyUp       += new IGlobeControlEvents_Ax_OnKeyUpEventHandler(axGlobeControl_OnKeyUp);

            layerMgr   = new LayerManager(axGlobeControl, this);
            pointFac   = new PointFactory(axGlobeControl);
            lineFac    = new LineFactory(axGlobeControl);
            polygonFac = new PolygonFactory(axGlobeControl);
            textFac    = new TextFactory(axGlobeControl);
            pictureFac = new PictureFactory();
            model3dFac = new Model3dFactory(axGlobeControl);
            circleFac  = new CircleFactory(axGlobeControl);

            refreshTimer          = new System.Timers.Timer();
            refreshTimer.Interval = 100;
            refreshTimer.Elapsed += refreshTimer_Elapsed;
        }
Ejemplo n.º 11
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;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 打开地图文件
        /// </summary>
        /// <param name="axGlobeControl"></param>
        /// <param name="InitDirectory"></param>
        public static void Open3DGlobeMap(AxGlobeControl axGlobeControl, string InitDirectory)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.InitialDirectory = InitDirectory;
                ofd.Multiselect      = false;
                ofd.RestoreDirectory = true;
                ofd.Title            = "打开三维地图文档";
                ofd.Filter           = "三维地图(*.3dd)|*.3dd|所有文件(*.*)|*.*";
                ofd.CheckFileExists  = true; //检查文件是否存在

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if (File.Exists(ofd.FileName))               //判断文件是否存在
                    {
                        axGlobeControl.Load3dFile(ofd.FileName); //加载地图
                    }
                }
            }
            catch
            {
                return;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 取得当前所有图层的list
        /// </summary>
        /// <param name="axGlobeControl">AxGlobeControl</param>
        /// <returns>List<LayerInfo></returns>
        public static List <LayerInfo> getLayerNameList(AxGlobeControl axGlobeControl)
        {
            List <LayerInfo> LayerInfoList = new List <LayerInfo>();

            //判断图层数
            if (axGlobeControl.GlobeDisplay.Scene.LayerCount == 0)
            {
                return(LayerInfoList);
            }
            try
            {
                ILayer    layer = null;
                LayerInfo pLayerInfo;
                for (int index = 0; index < axGlobeControl.GlobeDisplay.Scene.LayerCount; index++)
                {
                    layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(index); //取得图层

                    pLayerInfo            = new LayerInfo();                    //实例化一个图层信息类
                    pLayerInfo.LayerName  = "btn_" + layer.Name;
                    pLayerInfo.LayerIndex = index;
                    pLayerInfo.isVisible  = layer.Visible;

                    LayerInfoList.Add(pLayerInfo);  //添加到list
                }

                return(LayerInfoList);
            }
            catch
            {
                return(LayerInfoList);
            }
        }
Ejemplo n.º 14
0
 //左右看
 public static void LookAround(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeLookAroundToolClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     _axGlobeControl.CurrentTool = (ITool)pCommand;
 }
Ejemplo n.º 15
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;
            }
        }
Ejemplo n.º 16
0
        //左右看
        public static void LookAround(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeLookAroundToolClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            _axGlobeControl.CurrentTool = (ITool)pCommand;
        }
Ejemplo n.º 17
0
        //向北看
        public static void LookNorth(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeNorthCommandClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            pCommand.OnClick();
        }
Ejemplo n.º 18
0
        //信息查询
        public static void Identify(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeIdentifyToolClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            _axGlobeControl.CurrentTool = (ITool)pCommand;
        }
Ejemplo n.º 19
0
        //逐级缩小
        public static void FixedZoomOut(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeFixedZoomOutCommandClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            pCommand.OnClick();
        }
Ejemplo n.º 20
0
        //全图
        public static void FullExtentGlobe(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeFullExtentCommandClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            pCommand.OnClick();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 添加数据
        /// </summary>

        //添加图层
        public static void AddLayerToGlobe(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsAddDataCommandClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            pCommand.OnClick();
        }
Ejemplo n.º 22
0
        //绕一点旋转查看
        public static void FixedLineOfSight(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeFixedLineOfSightToolClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            _axGlobeControl.CurrentTool = (ITool)pCommand;
        }
Ejemplo n.º 23
0
        //保存地图
        public static void SaveAsDoc(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsSaveAsDocCommandClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            pCommand.OnClick();
        }
Ejemplo n.º 24
0
        //快速缩放
        public static void ZoomInZoomOut(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeZoomInOutToolClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            _axGlobeControl.CurrentTool = (ITool)pCommand;
        }
Ejemplo n.º 25
0
        //俯视浏览工具
        public static void NavigationMode(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeNavigationModeCommandClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            pCommand.OnClick();
        }
Ejemplo n.º 26
0
        //测距
        public static void MeasureInGlobe(AxGlobeControl _axGlobeControl)
        {
            ICommand pCommand;

            pCommand = new ControlsGlobeMeasureToolClass();
            pCommand.OnCreate(_axGlobeControl.Object);
            _axGlobeControl.CurrentTool = (ITool)pCommand;
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 初始化地图控件
        /// </summary>
        private void InitGlobeControl()
        {
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);      // 绑定ArcGIS

            axGlobeControl          = new AxGlobeControl();
            axGlobeControl.Dock     = System.Windows.Forms.DockStyle.Fill;
            axGlobeControl.Location = new System.Drawing.Point(0, 0);
            axGlobeControl.Name     = "axTOCControl1";
            //axGlobeControl.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axTOCControl1.OcxState")));
            axGlobeControl.Size = new System.Drawing.Size(114, 425);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     circleElement        = null;
     mapControl           = null;
     circleKml            = null;
     kml                  = null;
     layer                = null;
     CommondExecutedEvent = null;
     mapLogic             = null;
     drawn                = false;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     mapLogic             = null;
     mapControl           = null;
     layer                = null;
     pointList            = null;
     polygonElement       = null;
     CommondExecutedEvent = null;
     kml        = null;
     polygonKml = null;
     drawn      = false;
 }
Ejemplo n.º 30
0
        //private static bool SelectedLayer(LayerInfo layerInfo)
        //{
        //    //if(layerInfo.LayerName ="
        //}



        private static ILayer getLayerByName(AxGlobeControl axGlobeControl, string LayerName)
        {
            ILayer layer = null;

            for (int index = 0; index < axGlobeControl.GlobeDisplay.Scene.LayerCount; index++)
            {
                layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(index);
                if (layer.Name == LayerName)
                {
                    return(layer);
                }
            }

            return(layer);
        }
Ejemplo n.º 31
0
        public void InitAnimationByAgaFile(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath, bool _NotFlyByPolyline, int _FlySpeedRating)
        {
            try
            {
                IsFlyByPolyline = _NotFlyByPolyline;
                string FlyFilePath = FlyFoldPath + "\\" + _FlyPathName + ".aga";
                if (!File.Exists(FlyFilePath))    //如果此文件不存在
                {
                    return;
                }
                pAgAnimationUtils = new AGAnimationUtilsClass();
                IBasicScene2 basicScene2 = (IBasicScene2)scene; // Explicit Cast
                pAnimationExtension = basicScene2.AnimationExtension;
                //飞行时长设置
                switch (_FlySpeedRating)
                {
                case 1:
                    FlyDurationTime = 40;
                    break;

                case 2:
                    FlyDurationTime = 30;
                    break;

                case 3:
                    FlyDurationTime = 20;
                    break;

                case 4:
                    FlyDurationTime = 15;
                    break;

                case 5:
                    FlyDurationTime = 10;
                    break;

                default:
                    FlyDurationTime = 20;
                    break;
                }
                pAnimationExtension.AnimationEnvironment.AnimationDuration = FlyDurationTime;

                IAGAnimationContainer pContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer;
                pAgAnimationUtils.LoadAnimationFile(pContainer, FlyFilePath);//值不在预期的范围内;
                animPlayer = (IAGAnimationPlayer)pAgAnimationUtils;
            }
            catch { }
        }
Ejemplo n.º 32
0
        public static void ShowLayerOrNot(AxGlobeControl axGlobeControl, List <LayerInfo> LayerNameList, string layerName, bool isVisible)
        {
            try
            {
                LayerInfo layerInfo = LayerNameList.Find(delegate(LayerInfo li) { return(li.LayerName == layerName); }); //利用委托查找

                ILayer layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(layerInfo.LayerIndex);                        //getLayerByName(axGlobeControl, layerName);  //有名称取得这个图层
                if (layer == null)                                                                                       //如果没有找到图层
                {
                    return;
                }
                layer.Visible = isVisible;                    //设置图层可见性
                axGlobeControl.GlobeDisplay.RefreshViewers(); //刷新
            }
            catch { }
        }
Ejemplo n.º 33
0
        //根据书签的名称定位

        public void BookLightZoom(string bookLightName, AxGlobeControl axGlobeControl)
        {
            try
            {
                ESRI.ArcGIS.Analyst3D.ISceneBookmarks sceneBookmarks = (ESRI.ArcGIS.Analyst3D.ISceneBookmarks)axGlobeControl.Globe;
                IBookmark3D pBookmark3D = null;
                sceneBookmarks.FindBookmark(bookLightName, out pBookmark3D);
                if (pBookmark3D == null)
                {
                    return;
                }
                //缩放到书签
                //pBookmark3D.Apply(m_pGlobe.GlobeDisplay.ActiveViewer as ISceneViewer, true, 3.0); //无动态效果
                ZoomToBookmark(axGlobeControl.Globe.GlobeDisplay, pBookmark3D, 3); //有动态效果
            }
            catch { }
        }
				// Create ArcGIS Engine Controls and set them to be child of each WindowsFormsHost elements
				private void CreateEngineControls ()
				{
					//set Engine controls to the child of each hosts 
					globeControl = new AxGlobeControl ();
					mapHost.Child = globeControl;

					//set Engine controls properties
          globeControl.BackColor = System.Drawing.Color.Black;
					globeControl.OnMouseMove += new IGlobeControlEvents_Ax_OnMouseMoveEventHandler (globeControl_OnMouseMove);
					//style
					globeControl.BorderStyle = 0;
          // set default tool
          Navigate(null, null);
          // listen to events
          GlobeDisplay glbDisplay = globeControl.GlobeDisplay as GlobeDisplay;
          glbDisplay.AfterDraw += new IGlobeDisplayEvents_AfterDrawEventHandler(glbDisplay_AfterDraw);
				}
Ejemplo n.º 35
0
        // Create ArcGIS Engine Controls and set them to be child of each WindowsFormsHost elements
        private void CreateEngineControls()
        {
            //set Engine controls to the child of each hosts
            globeControl  = new AxGlobeControl();
            mapHost.Child = globeControl;

            //set Engine controls properties
            globeControl.BackColor    = System.Drawing.Color.Black;
            globeControl.OnMouseMove += new IGlobeControlEvents_Ax_OnMouseMoveEventHandler(globeControl_OnMouseMove);
            //style
            globeControl.BorderStyle = 0;
            // set default tool
            Navigate(null, null);
            // listen to events
            GlobeDisplay glbDisplay = globeControl.GlobeDisplay as GlobeDisplay;

            glbDisplay.AfterDraw += new IGlobeDisplayEvents_AfterDrawEventHandler(glbDisplay_AfterDraw);
        }
Ejemplo n.º 36
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (flashTimer != null)
     {
         flashTimer.Stop();
         flashTimer.Dispose();
         flashTimer = null;
     }
     layer         = null;
     mapControl    = null;
     pLineSymbol   = null;
     graphcisLayer = null;
     index         = -1;
     isTimer       = false;
     isVisible     = true;
     isHightLight  = false;
     isFlash       = false;
     properties    = null;
 }
Ejemplo n.º 37
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (flashTimer != null)
     {
         flashTimer.Stop();
         flashTimer.Dispose();
         flashTimer = null;
     }
     markerSymbol      = null;
     graphicsLayer     = null;
     index             = -1;
     isFlash           = false;
     isVisible         = true;
     isHightLight      = false;
     isTimer           = false;
     mapControl        = null;
     layer             = null;
     ElementProperties = null;
 }
Ejemplo n.º 38
0
        //按预订的路径飞行
        public bool InitAnimationPlay(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath,
                                      int _FlySpeedRating, bool _IsFlyLoop, bool _IsFlyLookdown)
        {
            bool IsFoundPolyline = true;    //是否能找到对应的Polyline

            try
            {
                scene = _axGlobeControl.GlobeDisplay.Scene;
                globe = _axGlobeControl.Globe;
                IBasicScene2 basicScene = (IBasicScene2)globe;
                pAgAnimationUtils = new AGAnimationUtilsClass();
                //按路径飞行
                ILayer layer = getLayerByName(scene, ANIMATIONPATH_LayerName);
                if (layer == null)
                {
                    IsFoundPolyline = false;
                    return(IsFoundPolyline);
                }
                FlyPathPolyline = getPolylineFromLayer(layer, _FlyPathName);
                if (FlyPathPolyline == null)
                {
                    IsFoundPolyline = false;
                    return(IsFoundPolyline);
                }
                //启用三维线
                IZAware flyPathZAware = (IZAware)FlyPathPolyline;
                flyPathZAware.ZAware = true;

                pAnimationExtension = basicScene.AnimationExtension;
                CreateAnimationFromPath(globe, FlyPathPolyline, FlySpeedRating, IsFlyLoop, IsFlyLookdown);

                //配置飞行
                //InitAnimationParameters();

                //IAGAnimationContainer pContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer;
                //pAgAnimationUtils.LoadAnimationFile(pContainer, FlyFilePath);//值不在预期的范围内;
                animPlayer = (IAGAnimationPlayer)pAgAnimationUtils;
            }
            catch
            { }
            return(IsFoundPolyline);
        }
Ejemplo n.º 39
0
        public void ShowCoordinatesOnMap(AxGlobeControl axGlobeControl)
        {
            try
            {
                ITextSymbol pTextSymbol = new TextSymbolClass();
                //pTextSymbol.Font = new Font("Consolas", 10, FontStyle.Regular);    //设置字体
                pTextSymbol.Size = 12;          //字体大小
                pTextSymbol.Color = BaseGISTools.TransColorToAEColor(Color.White);    //字体颜色

                myTextElement = new TextElementClass(); ;
                myTextElement.Symbol = pTextSymbol; //设置样式
                myTextElement.Text = "这是现实的信息 \n 这是第二行 \n 这是第三行";

                graphicsLayer = axGlobeControl.GlobeDisplay.Scene.BasicGraphicsLayer;
                graphicsContain3D = (IGraphicsContainer3D)graphicsLayer;
                graphicsContain3D.AddElement(myTextElement as IElement);
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }
Ejemplo n.º 40
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 { }
        }
Ejemplo n.º 41
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (flashTimer != null)
     {
         flashTimer.Stop();
         flashTimer.Dispose();
         flashTimer = null;
     }
     mapControl    = null;
     isHightlight  = false;
     isVisible     = true;
     isTimer       = false;
     isFlash       = false;
     index         = -1;
     lockObj       = null;
     fillSymbol    = null;
     graphicsLayer = null;
     layer         = null;
     properties    = null;
 }
Ejemplo n.º 42
0
        public static void FlyByPath(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath,GISFunction.SceneBookmark pSceneBookmark)
        {
            try
            {
                string FlyFilePath = FlyFoldPath + "\\" + _FlyPathName + ".aga";
                if (!File.Exists(FlyFilePath))    //如果此文件不存在
                {
                    return;
                }
                IGlobe globe = _axGlobeControl.Globe;
                IBasicScene2 basicScene = (IBasicScene2)globe;
                basicScene.LoadAnimation(FlyFilePath);

                double duration = 10;
                int numCycles = 1;  //循环次数

                PlayAnimationTrack(duration, numCycles, FlyFilePath, globe, pSceneBookmark);
            }
            catch
            { }
        }
Ejemplo n.º 43
0
        public static void ZoomToPointAnimation(AxGlobeControl axGlobeControl, double MapX, double MapY)
        {
            try
            {
                IPoint point = new PointClass();
                point.PutCoords(MapX, MapY);    //设置点击的点坐标

                //动画缩放到
                IAnimationTrack animaTrack = CreateZoomOverLocationAnimation(axGlobeControl.GlobeDisplay, MapX, MapY, 1000);
                animaTrack.IsEnabled = true;

                IAnimationTracks pTracks = axGlobeControl.Globe as IAnimationTracks;
                //for (int i = 0; i < pTracks.TrackCount; i++)
                //{
                //    IAnimationTrack pTrack = pTracks.Tracks.get_Element(i) as
                //    IAnimationTrack;
                //    pTrack.IsEnabled = true;//设置为true 才可以播放这条轨迹
                //}
                DateTime startTime = DateTime.Now;
                TimeSpan timeSpan;
                double elapsedTime;
                double duration = 7;
                bool play = true;
                do
                {
                    timeSpan = (DateTime.Now).Subtract(startTime);
                    elapsedTime = timeSpan.TotalSeconds;
                    if (elapsedTime > duration)
                    {
                        play = false;
                        elapsedTime = duration;
                    }
                    pTracks.ApplyTracks(axGlobeControl.Globe.GlobeDisplay.ActiveViewer, elapsedTime, duration);
                    axGlobeControl.Globe.GlobeDisplay.RefreshViewers();
                } while (play);

                #region //无动画方式
                //point = CommonBaseTool.BaseGISTools.getGeoPoint(MapX, MapY);        //转换坐标

                //IPoint ptObserver = new PointClass();
                //IPoint ptTarget = new PointClass();

                ////Observer点
                //IClone pClone1 = point as IClone;
                //ptObserver = pClone1.Clone() as IPoint;
                //ptObserver.Y = ptObserver.Y - 0.08;
                //ptObserver.Z = 15.45;
                ////Target点
                //IClone pClone2 = point as IClone;
                //ptTarget = pClone2.Clone() as IPoint;
                //ptTarget.Z = -0.01;

                //axGlobeControl.GlobeCamera.SetObserverLatLonAlt(ptObserver.Y, ptObserver.X, ptObserver.Z);
                //axGlobeControl.GlobeCamera.SetTargetLatLonAlt(ptTarget.Y, ptTarget.X, ptTarget.Z);
                #endregion

                //刷新
                axGlobeControl.GlobeDisplay.RefreshViewers();
            }
            catch { }
        }
Ejemplo n.º 44
0
 //测距
 public static void MeasureInGlobe(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeMeasureToolClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     _axGlobeControl.CurrentTool = (ITool)pCommand;
 }
Ejemplo n.º 45
0
 //向北看
 public static void LookNorth(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeNorthCommandClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     pCommand.OnClick();
 }
Ejemplo n.º 46
0
 //根据书签的名称定位
 public void BookLightZoom(string bookLightName, AxGlobeControl axGlobeControl)
 {
     try
     {
         ESRI.ArcGIS.Analyst3D.ISceneBookmarks sceneBookmarks = (ESRI.ArcGIS.Analyst3D.ISceneBookmarks)axGlobeControl.Globe;
         IBookmark3D pBookmark3D = null;
         sceneBookmarks.FindBookmark(bookLightName, out pBookmark3D);
         if (pBookmark3D == null)
             return;
         //缩放到书签
         //pBookmark3D.Apply(m_pGlobe.GlobeDisplay.ActiveViewer as ISceneViewer, true, 3.0); //无动态效果
         ZoomToBookmark(axGlobeControl.Globe.GlobeDisplay, pBookmark3D, 3); //有动态效果
     }
     catch { }
 }
Ejemplo n.º 47
0
        /// <summary>
        /// 打开地图文件
        /// </summary>
        /// <param name="axGlobeControl"></param>
        /// <param name="InitDirectory"></param>
        public static void Open3DGlobeMap(AxGlobeControl axGlobeControl, string InitDirectory)
        {
            try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.InitialDirectory = InitDirectory;
                ofd.Multiselect = false;
                ofd.RestoreDirectory = true;
                ofd.Title = "打开三维地图文档";
                ofd.Filter = "三维地图(*.3dd)|*.3dd|所有文件(*.*)|*.*";
                ofd.CheckFileExists = true; //检查文件是否存在

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if (File.Exists(ofd.FileName))      //判断文件是否存在
                    {
                        axGlobeControl.Load3dFile(ofd.FileName);    //加载地图
                    }
                }
            }
            catch
            {
                return;
            }
        }
Ejemplo n.º 48
0
        public void InitAnimationByAgaFile(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath, bool _NotFlyByPolyline, int _FlySpeedRating)
        {
            try
            {
                IsFlyByPolyline = _NotFlyByPolyline;
                string FlyFilePath = FlyFoldPath + "\\" + _FlyPathName + ".aga";
                if (!File.Exists(FlyFilePath))    //如果此文件不存在
                {
                    return;
                }
                pAgAnimationUtils = new AGAnimationUtilsClass();
                IBasicScene2 basicScene2 = (IBasicScene2)scene; // Explicit Cast
                pAnimationExtension = basicScene2.AnimationExtension;
                //飞行时长设置
                switch (_FlySpeedRating)
                {
                    case 1:
                        FlyDurationTime = 40;
                        break;
                    case 2:
                        FlyDurationTime = 30;
                        break;
                    case 3:
                        FlyDurationTime = 20;
                        break;
                    case 4:
                        FlyDurationTime = 15;
                        break;
                    case 5:
                        FlyDurationTime = 10;
                        break;
                    default:
                        FlyDurationTime = 20;
                        break;
                }
                pAnimationExtension.AnimationEnvironment.AnimationDuration = FlyDurationTime;

                IAGAnimationContainer pContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer;
                pAgAnimationUtils.LoadAnimationFile(pContainer, FlyFilePath);//值不在预期的范围内;
                animPlayer = (IAGAnimationPlayer)pAgAnimationUtils;
            }
            catch { }
        }
Ejemplo n.º 49
0
        //按预订的路径飞行
        public bool InitAnimationPlay(AxGlobeControl _axGlobeControl, string _FlyPathName, string FlyFoldPath,
            int _FlySpeedRating,bool _IsFlyLoop,bool _IsFlyLookdown)
        {
            bool IsFoundPolyline = true;    //是否能找到对应的Polyline
            try
            {
                scene = _axGlobeControl.GlobeDisplay.Scene;
                globe = _axGlobeControl.Globe;
                IBasicScene2 basicScene = (IBasicScene2)globe;
                pAgAnimationUtils = new AGAnimationUtilsClass();
                //按路径飞行
                ILayer layer = getLayerByName(scene, ANIMATIONPATH_LayerName);
                if (layer == null)
                {
                    IsFoundPolyline = false;
                    return IsFoundPolyline;
                }
                FlyPathPolyline = getPolylineFromLayer(layer, _FlyPathName);
                if (FlyPathPolyline == null)
                {
                    IsFoundPolyline = false;
                    return IsFoundPolyline;
                }
                //启用三维线
                IZAware flyPathZAware = (IZAware)FlyPathPolyline;
                flyPathZAware.ZAware = true;

                pAnimationExtension = basicScene.AnimationExtension;
                CreateAnimationFromPath(globe, FlyPathPolyline, FlySpeedRating, IsFlyLoop, IsFlyLookdown);

                //配置飞行
                //InitAnimationParameters();

                //IAGAnimationContainer pContainer = pAnimationExtension.AnimationTracks.AnimationObjectContainer;
                //pAgAnimationUtils.LoadAnimationFile(pContainer, FlyFilePath);//值不在预期的范围内;
                animPlayer = (IAGAnimationPlayer)pAgAnimationUtils;
            }
            catch
            { }
            return IsFoundPolyline;
        }
Ejemplo n.º 50
0
        private void PlayAnimationFast(int cycles, int iteration, string FlyFilePath, AxGlobeControl axGlobeControl)
        {
            try
            {
                IGlobe globe = axGlobeControl.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 = FlyFilePath;
                    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 " + FlyFilePath + @"\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();
                    }
                }
            }
            catch
            { }
        }
Ejemplo n.º 51
0
 //快速缩放
 public static void ZoomInZoomOut(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeZoomInOutToolClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     _axGlobeControl.CurrentTool = (ITool)pCommand;
 }
Ejemplo n.º 52
0
 //保存地图
 public static void SaveAsDoc(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsSaveAsDocCommandClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     pCommand.OnClick();
 }
Ejemplo n.º 53
0
 //俯视浏览工具
 public static void NavigationMode(AxGlobeControl _axGlobeControl)
 {
     ICommand pCommand;
     pCommand = new ControlsGlobeNavigationModeCommandClass();
     pCommand.OnCreate(_axGlobeControl.Object);
     pCommand.OnClick();
 }
Ejemplo n.º 54
0
        /// <summary>
        /// 保存影像
        /// </summary>
        /// <param name="axGlobeControl">AxGlobeControl</param>
        public static void SaveSceneAsImage(AxGlobeControl axGlobeControl, string initFoldPath)
        {
            try
            {
                SaveFileDialog sfdImage = new SaveFileDialog();
                sfdImage.Title = "导出三维场景图像";
                sfdImage.Filter = "所有文件(*.*)|*.*|Jpeg Files(*.jpg,*.jpeg)|*.jpg,*.jpeg";
                sfdImage.RestoreDirectory = true;
                sfdImage.ValidateNames = true;
                sfdImage.OverwritePrompt = true;
                sfdImage.DefaultExt = "jpg";
                sfdImage.InitialDirectory = initFoldPath;   //初试路径

                if (sfdImage.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                axGlobeControl.GlobeDisplay.ActiveViewer.GetScreenShot(esri3DOutputImageType.JPEG, sfdImage.FileName);
                //保存成功提示
                MessageBox.Show("导出jpg图像成功,图像保存在:" + sfdImage.FileName + "。", "保存成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch
            {
                //MessageBox.Show(ex.Message);
                return;
            }
        }
Ejemplo n.º 55
0
        public static void ShowLayerOrNot(AxGlobeControl axGlobeControl, List<LayerInfo> LayerNameList, string layerName, bool isVisible)
        {
            try
            {
                LayerInfo layerInfo = LayerNameList.Find(delegate(LayerInfo li) { return li.LayerName == layerName; }); //利用委托查找

                ILayer layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(layerInfo.LayerIndex);//getLayerByName(axGlobeControl, layerName);  //有名称取得这个图层
                if (layer == null)  //如果没有找到图层
                {
                    return;
                }
                layer.Visible = isVisible;  //设置图层可见性
                axGlobeControl.GlobeDisplay.RefreshViewers();   //刷新
            }
            catch { }
        }
Ejemplo n.º 56
0
        //private static bool SelectedLayer(LayerInfo layerInfo)
        //{
        //    //if(layerInfo.LayerName ="
        //}
        private static ILayer getLayerByName(AxGlobeControl axGlobeControl, string LayerName)
        {
            ILayer layer = null;
            for (int index = 0; index < axGlobeControl.GlobeDisplay.Scene.LayerCount; index++)
            {
                layer = axGlobeControl.GlobeDisplay.Scene.get_Layer(index);
                if (layer.Name == LayerName)
                {
                    return layer;
                }
            }

            return layer;
        }