ArcGlobe滚轮缩放功能

globe没有mousewheel事件, 

public partial class Form1 : Form
    {
        //TOC菜单
        IFeatureLayer pTocFeatureLayer = null;            //点击的要素图层
        private FormAtrribute frmAttribute = null;        //图层属性窗体
        //private ILayer pMoveLayer;                        //需要调整显示顺序的图层
        //private int toIndex;                              //存放拖动图层移动到的索引号 
    
        public Form1()
        {
            InitializeComponent();

            / /向Arcglobe中添加鼠标滚轮放大缩小功能
            this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.axGlobeControl1_OnMouseWheel);

        }

 

 

 

private void axGlobeControl1_OnMouseWheel(object sender, MouseEventArgs e)
        {
            //将axGlobeControl1相对于软件的坐标,变换成屏幕坐标
            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;

            ESRI.ArcGIS.GlobeCore.IGlobeCamera pGlobeCamera = axGlobeControl1.GlobeCamera;
            ESRI.ArcGIS.Analyst3D.ICamera pCamera = pGlobeCamera as ESRI.ArcGIS.Analyst3D.ICamera;
            ESRI.ArcGIS.GlobeCore.IGlobeDisplay pGlobeDisplay = axGlobeControl1.GlobeDisplay;          
           // if (pGlobeCamera.OrientationMode == esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal)
            if (pGlobeCamera.OrientationMode == ESRI.ArcGIS.GlobeCore.esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal)

            {
                double xo, yo, zo;
                pGlobeCamera.GetObserverLatLonAlt(out xo, out yo, out zo);
                zo = zo * (1 + scale);
                pGlobeCamera.SetObserverLatLonAlt(xo, yo, zo);
            }
            else
            {
                pCamera.ViewingDistance += pCamera.ViewingDistance * scale;
            }
            axGlobeControl1.GlobeDisplay.RefreshViewers();

        }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值