GlobeControl 做鹰眼图

news/2024/7/5 5:17:42


之前在网上看的都是mapcontrol做鹰眼的例子,还一个是globe作为主视图,mapcontrol作为鹰眼的例子,自己根据鹰眼的原理,写了一个,大致说下我的思路:
1、添加mapcontrol的OnExtentUpdated方法
2、在globecontrol上添加IglobeGraphicsLayer图层,然后根据map的更新范围,在globe画红线框
3、重新设置观察者的坐标为map更新范围pEnv的中心点,然后全局显示globe
但是现在红线框能画上,不能让globe全局显示,之前用IGlobeCamera 的方法SetToZoomToExtents将globe放大到局部了,不能实现鹰眼的效果,后来用SetObserverLatLonAlt设置pEnv的中心点为观察者点,但是也达不到想要的效果,请大神指点下!!谢谢!以下是我的代码:
            IEnvelope pEnv = (IEnvelope)e.newEnvelope;
            IZAware pZaware = pEnv as IZAware;
            pZaware.ZAware = true;
            IActiveView pActiveView = m_Globe as IActiveView;
            if (pEnv.XMax>180)//判断地图是否超出范围,如果超出直接设置最大值或者最小值
            {
                pEnv.XMax = 179;//这里不能设置为180,因为地图时间范围是179.99999,没有180,画红框时不准确,因此设置为179,可能也有点误差
            }
            if (pEnv.XMin <-180)
            {
                pEnv.XMin = -179;
            }
            if (pEnv.YMax >90)
            {
                pEnv.YMax = 89;
            }
            if (pEnv.YMin <-90)
            {
                pEnv.YMin = -89;
            }
            //axGlobeControl1.GlobeCamera.SetToZoomToExtents(pEnv, m_Globe, m_SceneViewer);
            //在globe上添加一个图层
            (globeGraphicsLayer as IGraphicsContainer3D).DeleteAllElements();
            pGlobeElementPropers.DrapeElement = true;
            pGlobeElementPropers.DrapeQuality = true;
            pGlobeElementPropers.DrapeZOffset = 15000;
            
            IElement pLineElement = new LineElementClass();
            ISimpleLine3DSymbol pSimpleLineSymbol = new SimpleLine3DSymbolClass();
            pSimpleLineSymbol.Style = esriSimple3DLineStyle.esriS3DLSStrip;
            pSimpleLineSymbol.ResolutionQuality = 1;
            IColor pRgbColor = new RgbColorClass();
            pRgbColor.RGB = 255;
            ILineSymbol pLineSymbol = pSimpleLineSymbol as ILineSymbol;
            pLineSymbol.Color = pRgbColor;
            pLineSymbol.Width = 5;
            //设置geometry
            IPolyline pPolyLine = new PolylineClass();
            ISegment pSegment = new LineClass();
            ISegmentCollection pSegmentCollection = new PathClass();
            object Missing = Type.Missing;

            IPoint fromPoint = new PointClass();
            fromPoint.PutCoords(pEnv.XMin, pEnv.YMin);
            pSegment.FromPoint = fromPoint;
            IPoint toPoint = new PointClass();
            toPoint.PutCoords(pEnv.XMax, pEnv.YMin);
            pSegment.ToPoint = toPoint;
            pSegmentCollection.AddSegment(pSegment, ref Missing, ref Missing);


            ISegment pSegment2 = new LineClass();
            IPoint fromPoint2 = new PointClass();
            IPoint toPoint2 = new PointClass();
            fromPoint2.PutCoords(pEnv.XMax, pEnv.YMin);
            pSegment2.FromPoint = fromPoint2;
            toPoint2.PutCoords(pEnv.XMax, pEnv.YMax);
            pSegment2.ToPoint = toPoint2;
            pSegmentCollection.AddSegment(pSegment2, ref Missing, ref Missing);

            ISegment pSegment3 = new LineClass();
            IPoint fromPoint3 = new PointClass();
            IPoint toPoint3 = new PointClass();
            fromPoint3.PutCoords(pEnv.XMax, pEnv.YMax);
            pSegment3.FromPoint = fromPoint3;
            toPoint3.PutCoords(pEnv.XMin, pEnv.YMax);
            pSegment3.ToPoint = toPoint3;
            pSegmentCollection.AddSegment(pSegment3, ref Missing, ref Missing);

            ISegment pSegment4 = new LineClass();
            IPoint fromPoint4 = new PointClass();
            IPoint toPoint4 = new PointClass();
            fromPoint4.PutCoords(pEnv.XMin, pEnv.YMax);
            pSegment4.FromPoint = fromPoint4;
            toPoint4.PutCoords(pEnv.XMin, pEnv.YMin);
            pSegment4.ToPoint = toPoint4;
            pSegmentCollection.AddSegment(pSegment4, ref Missing, ref Missing);


            IGeometryCollection pGeometryCollection = new PolylineClass();
            pGeometryCollection.AddGeometry(pSegmentCollection as IGeometry, ref Missing, ref Missing);

            pPolyLine = pGeometryCollection as IPolyline;

            pLineElement.Geometry = pPolyLine;
            //添加到graphics layer上
            ILineElement pLineElement_2 = pLineElement as ILineElement;
            pLineElement_2.Symbol = pLineSymbol;
            
            globeGraphicsLayer.AddElement(pLineElement, pGlobeElementPropers, out index0);

            //
            double lon, lat, alt;
            ICamera pCamera = m_Globe.GlobeDisplay.ActiveViewer.Camera;
            IGlobeCamera pGlobeCamera = pCamera as IGlobeCamera;
            pGlobeCamera.OrientationMode = esriGlobeCameraOrientationMode.esriGlobeCameraOrientationGlobal;
            IPoint pTarge = new PointClass();
            pTarge.PutCoords(0.0,0.0);
            pTarge.Z = 0;
            pCamera.Target = pTarge;
            lon=(pEnv.XMin + pEnv.XMax) / 2.0;
            lat=(pEnv.YMax + pEnv.YMin) / 2.0;
            alt=Math.Max(pEnv.Width, pEnv.Height)* 1000 * 0.0553;
            //m_globeViewUtil.WindowToGeographic(m_GlobeDisplay, m_SceneViewer, (int)((pEnv.XMin + pEnv.XMax) / 2), (int)((pEnv.YMax + pEnv.YMin) / 2), true, out lon, out lat, out alt);
            //axGlobeControl1.GlobeCamera.GetObserverLatLonAlt(out lat, out lon, out alt);
            //axGlobeControl1.GlobeCamera.SetObserverLatLonAlt((pEnv.XMin + pEnv.XMax) / 2, (pEnv.YMax + pEnv.YMin) / 2, 100);
            
            //ICommand pCommand = new ControlsGlobeFullExtentCommandClass();
            //pCommand.OnCreate(axGlobeControl1.Object);
            //pCommand.OnClick();
            axGlobeControl1.GlobeCamera.SetObserverLatLonAlt(lat, lon, alt);
            //axGlobeControl1.GlobeCamera.SetToZoomToExtents(pActiveView.FullExtent, m_Globe, m_SceneViewer);
            //ESRI.ArcGIS.Geometry.ISpatialReference spatialReference = pScene.SpatialReference;
            //if (pEnv.Width < 0.005 && pEnv.Height < 0.005)
            //    pEnv.Expand(0.005, 0.005, false);
            //else
            //    pEnv.Expand(0.0005, 0.0005, false);

            //double centerPointX = (pEnv.XMax + pEnv.XMin) / 2;
            //double cneterPointY = (pEnv.YMax + pEnv.YMin) / 2;
            //ESRI.ArcGIS.Geometry.IPoint centerPoint = new ESRI.ArcGIS.Geometry.PointClass();
            //centerPoint.SpatialReference = spatialReference;
            //centerPoint.X = centerPointX;
            //centerPoint.Y = cneterPointY;
            //pEnv.CenterAt(centerPoint);
            //axGlobeControl1.GlobeCamera.SetToZoomToExtents(pEnv, m_Globe, m_SceneViewer);
            m_SceneViewer.Redraw(true);
            axGlobeControl1.Globe.GlobeDisplay.RefreshViewers();

http://www.niftyadmin.cn/n/4223541.html

相关文章

1.5.1 Python函数初识

一、为什么要使用函数&#xff1f; 1,避免代码重用 2,提高代码的可读性 二、函数的定义与调用 1,函数定义: def func(): 函数注释print&#xff08;函数体&#xff09;return 返回值 复制代码 定义&#xff1a;def关键字开头&#xff0c;空格之后接函数名和圆括号&#xff0c;…

k8s介绍性文章索引

2019独角兽企业重金招聘Python工程师标准>>> containered替代了docker engine吗&#xff1f; - Kubernetes Containerd集成进入GA阶段转载于:https://my.oschina.net/u/2475751/blog/3003690

关于自定义异常的层次

纵观众多的开源框架&#xff0c;甚至是jdk自身&#xff0c;异常几乎总是按一定的类层次结构组织起来。那种认为一个系统只需要提供一个异常基类&#xff0c;其余所有异常都是只需要继承这一个基类的观点是武断和片面的。我们至少可以从两个方面来认识异常层次的重要性&#xff…

nexus学习 二、nexus 说明

nexus 说明 component name的说明 maven-central&#xff1a;maven中央仓库&#xff0c;默认从https://repo1.maven.org/maven2/拉取jarmaven-releases&#xff1a;私库发行版jarmaven-snapshots&#xff1a;私库快照&#xff08;调试版本&#xff09;jarmaven-public&#x…

在C#中实现打印功能(C#中PrintDialog,PrintDocument的使用)实用的类

http://www.cnblogs.com/sunbin/archive/2010/06/02/1749663.html 在C#中使用PrintDialog可以很方便的实现程序的打印功能。 其步骤如下&#xff1a; 创建一个PrintDialog的实例。如下&#xff1a; System.Windows.Forms.PrintDialog PrintDialog1new PrintDialog ();创建一…

js BOM浏览器对象模型

BOM即Browser Object Model&#xff0c;浏览器对象模型&#xff0c;表示浏览器窗口&#xff0c;所有js全局对象、函数以及变量均是window 对象的成员。 对于不同的浏览器&#xff0c;表示宽度和高度的方法不同&#xff1a; 对于IE9及以上、Chrome、Firefox、Opera以及Safari&am…

nexus学习 三、web界面功能介绍

一、Browse Server Content 1.1 Search ​ 这个就是类似Maven仓库上的搜索功能&#xff0c;就是从私服上查找是否有哪些包。 注意&#xff1a; 在Search这级是支持模糊搜索的&#xff0c;如图所示: 如果进入具体的目录&#xff0c;好像不支持模糊搜索&#xff1b; 1.2 B…

山石4.0使用手册

https://wenku.baidu.com/view/7091ad270066f5335a812154.html转载于:https://www.cnblogs.com/xinghen1216/p/10297366.html