• ArcEngine下GlobeControl与MapControl的二三维联动


    实现思路:2D—>3D,将当前MapControl的可视范围设置为GlobeControl中Extent属性的值;3D--->2D,获取当前GlobeControl的target和observer的Camera的BLH以及当前的图形显示范围,并将其设置为Mapcontrol的显示范围。中心点可取observer、target或者二者的中心点均可。全部代码如下:

       #region 二三维切换及联动
    
            //3D视图
            private void tabItem_3D_Click (object sender,EventArgs e)
            {
                axToolbarControl_Map.Visible = false;
                axToolbarControl_Globe.Visible = true;
                axTOCControl_Globe.Visible = true;
                axTOCControl_Map.Visible = false;
    
                statusStripXYZ.Visible = true;
                statusStripXY.Visible = false;
    
                //2D—>3D联动
                IActiveView avtiveView = m_globeControl.Globe as IActiveView;
                avtiveView.Extent = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds;
                avtiveView.Refresh();
    
    
            }
            //2D视图
            private void tabItem_2D_Click (object sender,EventArgs e)
            {
                axToolbarControl_Globe.Visible = false;
                axToolbarControl_Map.Visible = true;
                axTOCControl_Globe.Visible = false;
                axTOCControl_Map.Visible = true;
                statusStripXYZ.Visible = false;
                statusStripXY.Visible = true;
    
                Synchronization_3DTo2D();
    
            }
            //3D—>2D
            private void Synchronization_3DTo2D ()
            {
                IScene scene = m_globeControl.Globe.GlobeDisplay.Scene;
                ISceneViewer sceneViewer = m_globeControl.GlobeDisplay.ActiveViewer;
                IGlobeCamera globeCamera = sceneViewer.Camera as IGlobeCamera;
                IGlobeViewUtil globeViewUtil = globeCamera as IGlobeViewUtil;
    
                IEnvelope pEnv = new EnvelopeClass();
                globeViewUtil.QueryVisibleGeographicExtent(pEnv);//得到GlobeControl的Extent
                if(pEnv == null)
                {
                    return;
                }
    
                IPoint observerPoint = new PointClass();
                IPoint targetPoint = new PointClass();
                //获取Target和observer的坐标
                GetObserverTarget(out observerPoint,out targetPoint);
                IPoint point = new PointClass();
                (point as IZAware).ZAware = true;
                point.X = (observerPoint.X + targetPoint.X) / 2;
                point.Y = (observerPoint.Y + targetPoint.Y) / 2;
                point.Z = (observerPoint.Z + targetPoint.Z) / 2;
               
                pEnv.CenterAt(point);
    
                axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = pEnv;
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,null,null);
    
    
            }
            //获取target和observer的坐标
            private void GetObserverTarget (out IPoint ObserverPoint,out IPoint TargetPoint)
            {
                IGlobeDisplay m_GlobeDisplay = m_globeControl.Globe.GlobeDisplay;
                ISceneViewer pSceneViewer = m_GlobeDisplay.ActiveViewer;
                ICamera pCamera = pSceneViewer.Camera;
                IGlobeCamera pGlobeCamera = m_GlobeDisplay.ActiveViewer.Camera as IGlobeCamera;
    
                
                ObserverPoint = null;
                TargetPoint = null;
                
                //获取observer的BLH
                double obsLat,obsLon,obsAltKms; 
                pGlobeCamera.GetObserverLatLonAlt(out obsLat,out obsLon,out obsAltKms);
               
                //获取target的BLH
                double tgtLat,tgtLon,tgtAltKms;
                pGlobeCamera.GetTargetLatLonAlt(out tgtLat,out tgtLon,out tgtAltKms);
                
                ObserverPoint = new PointClass();
                (ObserverPoint as IZAware).ZAware = true;
                ObserverPoint.PutCoords(obsLon,obsLat);
                ObserverPoint.Z = obsAltKms;
    
                TargetPoint = new PointClass();
                (TargetPoint as IZAware).ZAware = true;
                TargetPoint.PutCoords(tgtLon,tgtLat);
                TargetPoint.Z = tgtAltKms;
            }
            #endregion
          

  • 相关阅读:
    20160421
    20160420笔记
    第一个随笔
    搬家
    OO第十五次作业
    OO第三次博客作业
    OO5-7次作业总结
    从入门到不放弃——OO第一次作业总结
    第八次团队作业——系统设计和任务分配
    第七次作业-团队选题报告和需求规格说明书
  • 原文地址:https://www.cnblogs.com/giser-whu/p/3707032.html
Copyright © 2020-2023  润新知