《理解对象模型图(OMD).ppt》由会员分享,可在线阅读,更多相关《理解对象模型图(OMD).ppt(17页珍藏版)》请在三一办公上搜索。
1、AO/AE编程基础(1),1.2 理解对象模型图(OMD),6-2,Lesson overview,ArcObject 的对象模型图 阅读一个对象的模型图类的类型类的相互关系接口、属性、方法的图标 根据OMD图表编写程序,6-3,OMDs help you write codeShow interfaces,methods,and properties for each classShow relationships between classes在几个图表中拥有超过 1,500 个类超过 1,600 个接口,ArcObject object model diagrams,6-4,在哪里可以找
2、到ArcGIS OMD图表,Start Programs ArcGIS ArcObjects Developer Help简单的、详细的类图PDF files电子书籍光盘中软件安装的目录中,6-5,Relationship symbols,继承组成用来创建对应关系 1:N联合,*,_,蛋,鸟,翅膀,羽毛,2,Abstract,Class,Class,Class,小鸡,CoClass,巢,CoClass,*,6-6,类和他们相应的对象,ArcMap objects,MxDocument,Map,Layer,*,*,FeatureLayer,Application,6-7,Not creatabl
3、e or instantiableCan never have instances of an abstract classDefine general interfaces for subclassesSubclasses inherit interfacesOMD symbol:2D shaded rectangle,抽象类(没有阴影),6-8,实例化类(Class),Noncreatable classCannot create with the New keywordObtain instances from other objectsOMD Symbol:3D Rectangle w
4、ith no shade,Dim pNewRow As IRowSet pNewRow=pTable.CreateRow,生 成,6-9,Creatable:Use the New keywordDim pMap As IMapSet pMap=New MapInstantiable:Obtain from other objectsDim pMap As IMapSet pMap=pMxDocument.FocusMapOMD symbol:Shaded 3D rectangle,可创建的类(CoClass),6-10,Where to begin?Getting into the OMD,
5、特殊的全局变量Application:IApplication interface of the Application objectThisDocument:IDocument interface of the MxDocument object阅读 ArcMap 或 ArcCatalog OMD图表的入口,Application,ThisDocument,6-11,Property and method symbols,Property哑铃形状的图标Method,6-12,Property Put:Most ArcObjects propertiesProperty holds a val
6、ue or a copy of an objectDo not use Set keyword Property Put by Reference:Some ArcObjects propertiesProperty holds a reference to an objectMust use the Set keyword如果引用对象发生了变化,对象的属性将同步受到影像,Setting properties,pLayer.Name=Port Moresby No Set keyword,Set pLayer.FeatureClass=pMoresbyData Must use Set!,6-
7、13,Return a valueName:String Return an object referenceDocument:IDocumentStatusBar:IStatusBar,Getting properties,返回一个值Dim strName As String Dim pDoc As IDocumentDim pBar As IStatusBarstrName=Application.NameMsgBox strName返回一个引用Set pDoc=Application.DocumentSet pBar=Application.StatusBar pBar.Message(
8、0)pDoc.Title,6-14,棒棒糖类型的图标(),Finding interfaces,这些接口也是有效的。但是详细的属性和方法必须在其它地方浏览。(e.g.,Object Browser).,该接口被本类使用.所有的属性和放都列表在类图中.,继承接口是有效的,6-15,FeatureLayer on Map Layer OMD,概念上,这是一个对象模型事实上,被分别在几张图表里存放虫洞表现了图表与图表间的连接关系,Wormholes,Element on ArcMap OMD,虫洞,6-16,Example:MxDocument Map layer,Get the FocusMap(
9、active data frame)from MxDocumentMxDocument may have several Maps(*)Get a layer from the the MapMany types of layers(),Dim pMxDoc As IMxDocumentSet pMxDoc=ThisDocumentDim pMap As IMapSet pMap=pMxDoc.FocusMapDim pLayer As ILayerSet pLayer=pMap.Layer(1)Is pLayer a FeatureLayer?If TypeOf pLayer Is IFeatureLayer ThenMsgBox Yes!,its a feature layerEnd If,MxDocument,Map,FeatureLayer,Layer,*,*,Others,A,6-17,Exercise 2 overview,Interpret the ArcObject object model diagramsWrite code to change the ArcMap captionWork with the MxDocument and its MapsUse the TypeOf keyword to test an object reference,