第七章 元素.ppt.convertor

上传人:第*** 文档编号:33575336 上传时间:2018-02-15 格式:DOC 页数:12 大小:27.98KB
返回 下载 相关 举报
第七章 元素.ppt.convertor_第1页
第1页 / 共12页
第七章 元素.ppt.convertor_第2页
第2页 / 共12页
第七章 元素.ppt.convertor_第3页
第3页 / 共12页
第七章 元素.ppt.convertor_第4页
第4页 / 共12页
第七章 元素.ppt.convertor_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《第七章 元素.ppt.convertor》由会员分享,可在线阅读,更多相关《第七章 元素.ppt.convertor(12页珍藏版)》请在金锄头文库上搜索。

1、元素一、 图形元素(Graphics Element)模型二、 框架元素(Frame Element)模型三 、MapSurround 对象模型1概述在 ArcGIS 中,显示在地图上的图形分为两种:要素(Feature) :储存在数据库(或文件)中的数据;元素(Element):以图像的形式存在工程文件(.MXD)中。2概述Element 是一个非常庞大复杂的对象集合,分为两大部分:图形元素(Graphic Element)和框架元素(Frame Element ) 。在 Map 或 PageLayout 对象中可以通过 IGraphicsContainer 接口来管理这些元素,使用这个接口

2、定义的方法可以添加、删除和更新位于 Map 或 PageLayout 上的元素。IElement 是所有图形元素和框架元素类都实现的接口,IElement :Geometry 属性定义了元素的形状和位置。Element 是一个抽象类,在编程中使用其子类进行实例化。3一、Graphics Element 对象模型图形元素(GraphicElement) 实现了 IGraphicsElement 接口,这个接口仅定义了一个 SpatialReference 属性,用于设置这些图形元素的空间参考。图形元素(GraphicElement) 还实现 ITransform2D 接口,这个接口定义的方法和属

3、性可以让图形元素移动、旋转和缩放。图形元素包括 MarkerElement, LineElement,FiIIShapeElement ,TextElement,DataGraphElement ,PictureElement 和 GroupElement 等对象,它们都是作为图形的形式而存在,在视图上是可见的。4一、Graphics Element 对象模型MarkerElement 和 LineElementMarkerElement 和 LineElement 是最简单的图形元素,它们在数据视图(DataView)或者布局视图(Pagelayout view)上表现为点和线的形式。要将图

4、形元素显示在视图上,一般的步骤是这样的:1.产生一个新的元素对象;2.确定元素显示时使用的 Symbol(符号)和 Geometry(几何形体对象); 3.使用 IGraphicsContainer.AddElement 把元素添加到视图中去;4.刷新视图,让添加的元素可以显示出来。以 LineElement 为例,添加它到视图需要使用两个接口:IElement 和ILineElement,前者用于确定线元素的 Geometry ,后者用于确定Symbol。设置 Symbol 和 Geometry 属性时需要注意对象的类型,Symbol 属性只能有线符号设置, Geometry 属性只能使用

5、Line 或者Polyline 进行设置。MarkerElement 也是一样,使用的是 Marker 类型的Symbol 和点作为它的 Geometry。5一、Graphics Element 对象模型MarkerElement 和 LineElementIMap pMap;IActiveView pActiveView;/获得控件的 Map 对象pMap=axMapControll .Map;pActiveView=pMap as IActiveView;/创建 Point 对象IPoint pPt;pPt=new PointClass();pPt.PutCoords(e.mapX, e.

6、mapY);/设置 MarkerElement 的 Symbol 属性ISimpleMarkerSymbol pMarkerSymbol;pMarkerSymbol=new SimpIeMarkerSymboIClass();/设置符号颜色pMarkerSymboLColor=getRGB(11,200, 145);/设置符号大小pMarkerSymboI.Size=2;/设置符号样式pMarkerSymboLStyle=esriSimpIeMarkerStyle.esriSMSDiamond;6一、Graphics Element 对象模型MarkerElement 和 LineElemen

7、t/创建 MarkerElement 对象IMarkerElement pMarkerElement;pMarkerElement=new MarkerElementClass();/获取 IElement 对象,用于设置元素的 Geometry 属性IElement pElement;pElement=pMarkerElement as IElement;pElement.Geometry=pPt;/设置元素的 Symbol 属性pMarkerElement.Symbol=pMarkerSymbol;IGraphicsContainer pGraphicsContainer;pGraphic

8、sContainer=pMap as IGraphicsContainer;/将元素添加到 Map 对象中pGraphicsContainer.AddElement(pMarkerElement as IElement, 0);/刷新地图pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null)7一、Graphics Element 对象模型FiIIShapeElement 对象FiIIshapeElement 是一个抽象类,它的子类有 CircIeElement, EllipseElement,Poly

9、gonElement 和 RectangleElement。这些对象的共同特点是它们的 Geometry 属性都是二维的封闭图形,分别表现为圆形元素、椭圆形元素、多边形元素和矩形元素。IFiIIShapeElement 是所有 FiIIShapeElement 类都实现的接口,它定义了用于显示图形元素的 Symbol 属性,这个 Symbol 属性必须设置为IFillsymbol 对象。 创建 FiIIShapeElement 对象和把 FiIIShapeElement 对象添加到MapControl 或 PageLayout 的方法与点、线元素基本相同。8一、Graphics Element

10、 对象模型FiIIShapeElement 对象IMap pMap;IActiveView pActiveView;/获得控件的 Map 对象pMap=axMapControll .Map;pActiveView=pMap as IActiveView;IPolygon pPolygon=axMapControll.TrackPolygon() as IPolygon;/创建 SimpIeFillSymbol 对象ISimpIeFiIISymbol pSimpIeFillsym;pSimpIeFillsym=new SimpIeFiIISymboIClass();pSimpIeFiIIsym.

11、Style=esriSimpIeFiIIStyle.esriSFSDiagonalCross;pSimpIeFiIIsym.Color=getRGB(102, 200, 103);9一、Graphics Element 对象模型FiIIShapeElement 对象/创建 PolygonElement 对象IFiIIShapeElement pPolygonEle;pPolygonEle=new PolygonElementClass();pPolygonEle.Symbol=pSimpIeFillsym; IElement pEle;pEle=pPolygonEle as (Element;

12、pEle.Geometry=pPolygon;/将元素添加到 Map 对象中IGraphicsContainer pGraphicsContainer;pGraphicsContainer=pMap as IGraphicsContainer;pGraphicsContainer.AddElement(pEle, 0); /刷新地图pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null)10一、Graphics Element 对象模型PictureElement 对象在 ArcMap 制作地图的时,用

13、户可以向 PageLayout 中插入位图图片,通过这种方式可以制作更加漂亮的地图以输出使用。这种图片其实也是一种图形元素,即 PictureElement对象。PictureElement 是一个抽象类,它的两个了类 BmpPictureElement 和EmfPictureElement,它们分别用于往布局视图中插入 BMP 文件和 EMF文件。IPictureElement 是这两个子类都实现的接口,使用它可以用于操作一个图片元素。IPictureElement.Filter 属性是供 OpenFileDialog 使用的过滤器;IPictureElement.MaintainAspec

14、tRatio 属性可以决定调整图片尺寸时是否保持其长宽比例;IPictureElement.PictureDescription 可以添加图片的附加描述信息;IPictureElement.SavePicturelnDocument 属性则确定这张图片是否会被保存到 MXD 文件上。IPictureElement.ImportPictureFromFile 用于取得一张图片文件。11一、Graphics Element 对象模型PlctureElement 对象IPageLayout pPageLayout;pPageLayout=axPageLayoutControll .PageLayou

15、t;IGraphicsContainer pGraphicsContainer;pGraphicsContainer=pPageLayout as IGraphicsContainer;IActiveView pActIveView=pPageLayout as IActiveView;/新建 BmpPictureElement 对象IPictureElement pBmpPicEle=new BmpPictureElementClass();/设置使用的位图文件pBmpPicEle.ImportPictureFromFile( C:My Documentssim.bmp);/图片在缩放时保持

16、长宽比例pBmpPicEle.MaintainAspectRatio=true;IEnvelope pEnv=axPageLayoutControll.TrackRectangle();IElement pEle=pBmpPicEle as IElement;/设置 Geometry 属性pEle.Geometry=pEnv;pGraphicsContainer.AddElement(pEle, 0);pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null)12一、Graphics Element 对象模型PlctureElement 对象13一、Graphics Element 对象模型TextElement 对象地图为了显示图形的附加信息,一般都是需要采用文字标注来完成。地图标注有两种形式:一种是保存在地理数据库中以标注类的形式存在,另一种是使用文字元素。TextElement 对象实现了

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号