Professional Documents
Culture Documents
Arc Objects is the development platform for the ArcGIS family of applications such as Arc Map, Arc Catalog, and Arc Scene. Arc Objects is a framework that lets you create domain-specific components from other components. Arc Objects provides an infrastructure for application customization that lets you concentrate on serving the specific needs of your clients.
About ArcObjects
ArcObjects is a set of platform-independent software components, written in C++, that provides services to support geographic information system (GIS) applications on the desktop in the form of thick and thin clients and on the server. As previously stated, the language chosen to develop ArcObjects was C++; in addition to this language, ArcObjects makes use of the Microsoft Component Object Model (COM). COM is often thought of as simply specifying how objects are implemented and built in memory and how these objects communicate with one another. While this is true, COM also provides a solid infrastructure at the operating system level to support any system built using COM. On Microsoft Windows operating systems, the COM infrastructure is built directly into the operating system. For operating systems other than Microsoft Windows, this infrastructure must be provided for the ArcObjects system to function.
ArcObjects components
ArcGIS Desktop Use of the object is in one of the ArcGIS Desktop applications. ArcGIS Desktop applications provide a rich user experience, with applications containing many dialog boxes and property pages that allow end users to work effectively with the functionality of the object. Objects that contain properties that are to be modified by users of these applications should have property pages created for these properties. Not all objects require property pages.
Arc Map is used for mapping and editing tasks as well as map-based analysis. Arc Catalog is used for managing your spatial data holdings, defining your geographic data custom schemas, and recording and viewing metadata.
ARCOBJECTS FRAMEWORK
Arc Objects is built using Microsofts Component Object Model (COM) technology. It is possible to extend Arc Objects by writing COM components using any COM-compliant development language. You can extend every part of the Arc Objects architecture in exactly the same way as ESRI developers do.
Type inheritance
Type inheritance defines specialized classes that share properties and methods with the super class and have additional properties and methods.
Line
Primary Line
Secondary Line
This diagram shows that a primary line (creatable class) and secondary line (creatable class) are types of a line (abstract class).
Instantiation
Instantiation specifies that one object from one class has a method with which it creates an object from another class.
Pole Transformer
Customization
Showing and hiding toolbars using the Customize dialog box 1. Click the Tools menu and click Customize. The Customize dialog box appears. You can also double-click any unoccupied area of any toolbar to display the Customize dialog box. 2. If it is not visible, click the Toolbars tab. The presence or absence of a check mark next to the toolbar name indicates its visible state. 3. Check and uncheck the check boxes.
In the Toolbars tab of the Customize dialog box, click New. In the dialog box that appears, specify Chapter One Examples as the name of the new toolbar or use the default setting. Store the toolbar in the document by changing the name of the Save in dropdown list from Normal.mxt to Untitled or the name of the current project. Click OK. The newly created toolbar appears near the top of the application window.
Make sure the toolbar you just created is visible. If it is not visible, display the Customize dialog box. Click the Commands tab of the Customize dialog box. Select the Pan/Zoom category from the Categories list. Scroll to the bottom of the Commands list. Select the Zoom in command and drag it to the toolbar. Release the command when the arrow cursor with a small box below it appears. Continue adding commands from the Pan/Zoom category You may switch to other categories to select commands.
Renaming a toolbar
In the Toolbars tab, click the name of the toolbar whose name you want to change. Click the Rename button. In the dialog box that appears, specify My Own Tools as the new name. Note that you can only rename toolbars youve created. Click OK. If you decide not to rename the toolbar, click Cancel.
Make sure the My Own Tools toolbar is visible. If it is not visible, display the Customize dialog box. Click the Commands tab and choose the Menus category from the Categories list on the lefthand side of the dialog box. In the Commands list at the right-hand side of the dialog box, click Selection. Drag and drop it to the left of the Zoom In button on the My Own Tools toolbar. Click Close in the Customize dialog box. Click Selection on the My Own Tools toolbar and note the menu that appears.
You can save your work to a document or template. Changes saved to a document are specific to the document, whereas changes saved to a template will be reflected in all documents based on the template. Click the File menu and click Save As. Navigate to the Templates folder of the <installation directory>\bin folder. Click the Create New Folder button. Type a new name for the folder and double-click it. Type the template name, click ArcMap Templates (*.mxt) from the Save as type dropdown menu,
Creating a macro
Click the Tools menu, point to Macros, then click Macros. In the Macros dialog, type name in the Macro name text box and click Create. The application creates a new module named Module1 and stubs in the Sub procedure. Enter some code. Switch back to ArcMap by clicking the File menu, clicking Close, and clicking Return to ArcMap. Click the Tools menu, point to Macros, then click Macros.
Click the Tools menu and click Customize. In the Toolbars tab, ensure that the toolbar is visible. Click the Commands tab and select the Macros category. Click the name of project in the Save in dropdown menu. The commands list to the right of the dialog box lists Project.Module1.Name. Drag the macro name to the toolbar you created. The macro appears with a default icon. To change its properties, right-click the icon. In the context menu that appears, click Change Button Image and choose a button from the palette o icons.
Once invoked, a command usually performs some direct action without user intervention. A command is a type of UIControl. Click the Tools menu and click Customize. In the Customize dialog box, click the Commands tab and change the Save in dropdown menu to the name of your project or to Untitled. In the Categories list, select UIControls. Click New UIControl. In the dialog box that appears, choose UIButtonControl as the UIControl Type, then click Create and Edit.
The application adds an entry in the Object Box for the UIButtonControl and stubs in an event procedure for t UIButtonControls Click event. Youll add code to this event to zoom the display to th extents of the dataset. Private Sub UIButtonControl1_Click() Dim pDoc As IMxDocument Set pDoc = ThisDocument pDoc.ActiveView.Extent =pDoc.ActiveView.FullExtent pDoc.ActiveView.Refresh End Sub
1. Click the Tools menu and click Customize. 2. Click the Commands tab and change the Save in combo box to the name of your project or Untitled. 3. Choose UIControls from the Categories list. 4. Click New UIControl. 5. In the dialog box that appears, choose UIToolControl as the UIControl Type, then click Create and Edit.
Right-click any toolbar and click Customize in the context menu that appears. Click the right mouse button to determine whether a context menu is available. Right-click the button whose properties you want to change. In the context menu that appears, click Change Button Image and choose an image. The image you chose appears on the face of the button. Close the Customize dialog box.
DEFINE THE ARCOBJECTS PROGRAMMING TASK 1. Describe the problem in Arc Objects terms. 2. Identify subtasks. 3. Decide where to write the code. 4. Search for a related sample or recommended methodology.
LOCATE THE CORRECT OBJECT MODEL 1. Identify a subtask. 2. Extract keywords. 3. Search for the correct object model diagrams. 4. Review all related documentation.
NAVIGATE THE OBJECT MODEL DIAGRAM 1. Review the structure of the object model diagram.
In general, there are three ways to write Arc Objects code: As a VBA macro in an ArcGIS application As an ActiveX COM component such as a DLL or OCX As a standalone EXE
Advantages Its fast and easy to create, test, and debug macros inside Arc Map and Arc Catalog. The standard ESRI type libraries are already referenced. Important global variables, such as the Application and Document, are available. Its simple to assemble UI forms using VBA and ActiveX components. Its straightforward to integrate VBA code with new Arc Objects UIControls. Its relatively easy to migrate VBA code to VB ActiveX DLL projects.
Standalone Applications
Advantages You can use the ESRI Arc Objects Map control to simplify the embedding of Arc Objects functionality in your application. You can design a highly customized user interface specific to your application. You can quickly create small, lightweight applications. Disadvantages You cannot take advantage of the extensive functionality that ESRI has built into the existing ArcGIS applications such as Arc Map or Arc Catalog. You cannot use Arc Map documents or templates to their fullest capacity.
APPLICATION COCLASS
The Application object directly manages a collection of objects, MxDocument, AppDisplay,SelectionEnvironment. When you first start Arc Map, the Application object is first created, and then it in turn instantiates all of the objects it manages. The IApplication interface provides access to the MxDocument object, the StatusBar object, the Templates object, the currently selected tool, the Visual Basic Editor. The IMxApplication interface provides access to the remainder of the objects the Application automatically creates, including AppDisplay,Paper Co Class, Printer, and SelectionEnvironment.
MXDOCUMENT COCLASS
The Arc Map document is called MxDocument; its role is to control the representation of data. The Arc Map application automatically creates this object when the application first starts. MxDocument specifically creates and manages the following objects: an empty Map, a PageLayout, the TOCCatalogView, the TOCDisplayView. You can obtain a reference to the MxDocument through IApplication::Document.
Views
View is the main application window, or the place where all data is drawn. Arc Map currently has two different views,data view and layout view Objects implement the IActiveView interface to establish themselves as views. The data view corresponds to a Map object, and the layout view corresponds to the PageLayout object. Either of these objects can be set as the documents active view, and only one view is visible at a time.
The following VBA code checks the type of active view: Dim pMxDoc As IMxDocument Set pMxDoc = Application.Document If TypeOf pMxDoc.ActiveView Is IMap Then MsgBox "Active View is a Map" ElseIf TypeOf pMxDoc.ActiveView Is IPageLayout Then MsgBox "Active view is the PageLayout" End If
Application Extensions
The Application object directly manages the life of all application extensions. Application extensions are those extensions registered in the ESRI MxExtension objects; All extensions are automatically created and destroyed in synchronization with an Application object. Use the IExtension interface to query the properties of an extension or implement this interface to create your own custom extension.
Contents views are tabs in the Arc Map table of contents. ArcMap ships with two contents views: display view and source view. The Display tab is the TOCDisplayView object, and the Source tab is the TOCCatalogView object. Developers can add new contents views by creating their own custom object that implements the IContentsView interface.
MAP COCLASS
Every map document contains at least one Map object. Only one Map can have focus at a time, and this Map is called the focus map. IMxDocument provides access to all of the Map objects loaded in the document; IMxDocument::FocusMap returns a reference to the Map currently with focus, and IMxDocument.Maps returns the entire collection of Map objects. MapSurround objects are elements that are related to a Map. Types of map surrounds include
SELECTIONENVIRONMENT COCLASS
Controls properties related to creating and drawing selections. A SelectionEnvironment object is automatically created by the Application object when the application starts. Access to the Application objects SelectionEnvironment is through IMxApplication::SelectionEnvironment.
Display Objects
FEATURE RENDERER A feature renderer is a method for drawing feature layers. Use symbols and colors to visually display features, possibly based o one or more attributes. Types of feature renderers: SimpleRenderer uses the same symbol for each feature. ClassBreaksRenderer allows classes of numeric attribute values to be defined. A different symbol is specified for each class. UniqueValueRenderer uses a different symbol for each unique attribute value. ProportionalSymbolRenderer modifies the size of the symbol in proportion to an attribute from a field. DotDensityRenderer displays a scattering of marker symbols in polygon features, the density of which reflects the value of an attribute. ChartRenderer displays pie, bar, or stacked bar charts that are comprised from one or more attribute fields.
To get to a feature renderer object in Arc Map from a layer, QI to IGeoFeatureLayer and get the Renderer property.
A simple renderer is the default renderer object when a new feature class is loaded.
' Check if the layer is a feature layer If Not TypeOf pLayer Is IGeoFeatureLayer Then Exit Sub Set pGeoFeatureLayer = pLayer ' Check if there is a simple renderer and get a reference to it If Not TypeOf pGeoFeatureLayer.Renderer Is ISimpleRenderer Then Exit Sub Set pSimpleRenderer = pGeoFeatureLayer.Renderer
Color Objects
Objects that support the IColor interface allow precise control over any color used within the ArcObjects model. You can get and set colors using a variety of standard color modelsRGB, CMYK, HSV, HLS, and Grayscale. RGBCOLOR COCLASS To get and set the red,green, and blue components of a color Interface- IRGBColor CMYKCOLOR COCLASS Colors can be specified for output in terms of Cyan, Magenta, Yellow, and Black. Interface- ICMYKColor
Symbol Objects
Types of Symbols
Display Objects
Display Objects
Allow application developers to easily draw graphics on a variety of output devices. Allow you to render shapes stored in real-world coordinates to the screen, the printer, and export files. Use the IDisplay interface to draw points, lines, polygons, rectangles,and text on a device. Access to the display objects DisplayTransformation object is provided by this interface.
DISPLAYTRANSFORMATION COCLASS
Manages the map-to-device transformation Defines how real-world coordinates are mapped to an output space. Maps DisplayTransformation has a SpatialReference object that manages the Maps current coordinate system. A reference to the SpatialReference object is set through IDisplayTransformation::SpatialReference.
IDisplayTransformation
To prepare a transform for use, follow these steps: 1. Set the full map extent with the Bounds property. 2. Set the visible map extent (zoom rectangle) with the VisibleBounds property. 3. Set the output area of the device using the DeviceFrame property. 4. Set the resolution of the output device using the Resolution property.
IRubberBand Interface
geometries on the display using the mouseeither to create whole new geometry objects or to update existing ones. Examples-Dragging an envelope, forming a new polyline, or moving a point. IRubberband interface has two methods TrackExisting Move existing geometries TrackNew Create new geometries
TrackNew method
Private Sub UIToolControl1_MouseDown(ByVal button As Long, _ ByVal shift As Long, ByVal x As Long, ByVal y As Long) Dim pRubberLine As IRubberBand Dim pGeom As IGeometry Dim pMXDoc As IMxDocument Set pMXDoc = ThisDocument Set pRubberLine = New RubberLine Set pGeom=pRubberLine.TrackNew pMXDoc.ActiveView.ScreenDisplay, Nothing) End Sub