2.1 other stone-ArcMap plug-in mechanism

Source: Internet
Author: User
Plug-ins we are preparing to design GIS Application Framework Nbgis ESRI Of ArcMap The software is a simulated object, so it is necessary for readers to understand ArcMap Program.

ArcMapNot based on. NetProgram developed by the Mechanism, which usesC ++Developed, despite this, except for plug-in recognition. NetFramework andComThe plug-in framework is different, and other steps are very similar. You can design a plug-inGISThe Application Framework process provides reference.

The core of the plug-in architecture is the communication between the framework Host Program and the plug-in object. That is, how the Host Program recognizes plug-in objects and establishes event associations with plug-in objects. This process includes the following points:

How does the Host Program identify plug-in objects?

ArcMapIsComThe application of the mechanism, andMS Office SystemSimilarly, when it is installed on a hard disk,ArcMapAll dynamic link librariesDLLFile registration information will be written to different "component directories" in the Registry "(Component categories.

Arcmap.exeWhen the program startsArcMapRelatedComponent categoriesFind information about the relevant plug-in objects and initialize them based on the information.

The plug-in referred to in this book refers to the ability to form a user interface (User Interface,UI) And can interact with users inArcMapAs a command button (Icommand), A tool button (Itool), A toolbar (Itoolbardef), A menu bar (Imenudef) Or a floating form (Idockablewindow). For exampleFigure2 limit 2As shown in.UIAll objects are generated based on the attributes of the plug-in objects.UILayer representation.

 


Figure2 ‑ 2 ArcMapProgram Interface

After the Host Program obtains the corresponding plug-in object information, it dynamically createsUIObject.

Plug-inUIHow can an object be initialized?

When the host ProgramArcmap.exeAfter obtaining information about the plug-in object from the registry and generating the plug-in object in the memory (note that the plug-in object is stillUITo generate plug-ins Based on the plug-in objects.UIObject.

plug-in UI object initialization includes three aspects: first, the host Program carries the UI information generation actual UI layer object, take icommand as an example, the Host Program obtains the icon and tooltip , name , Category , message , in the UI Generate a UI command command object for interaction, see figure 2 rows 2 .

The second is that the Host Program will create two public variables that will carry the information and interaction methods of the Host Program.ArcMapModerateApplicationAndThisdocumentTwo objects.Arcmap.exeSetApplicationObject plug-inUIThe object's initialization function is passed to the plug-inUIObject. The initialization function is as follows:

Private sub icommand_oncreate (byval hook as object)

'HookThe parameter is a pointArcMapHost Program pointer

'M_pappIs a variable for the plug-in to use the host Program. The plug-in can use this variable to obtain information about the main program.

Set m_papp = hook

End sub

In this way, the communication bridge between the host Program and the plug-in object is established.

Third, the host program adds a plug-in objectUIThe interaction channel between the object and the plug-in object is established. The host program implements this through the "event mechanism" when the userUIClick a plug-in on the pageUIThe host program can call the correct plug-in object through the function pointer and callback function to complete specific operations.

How plug-in objects generate theirUIObject?

The plug-in objects are differentUIFormat appears on the host Program. This is the plug-inUIObject initialization. BecauseArcMapThe visualization components in are dividedIcommand,Itool,Itoolbardef,ImenudefAndIdockablewindowWhen the host Program obtains information about a plug-in component, it generates differentUILayer components.

If you write an extensionDLL, Which includesIcommandType andItoolbardefType, andIcommandTypeUIObjects are placed inItoolbardefOfUIDuring parsing, the host Program will generateIcommandObjectUIObject andItoolbardefOfUIObject, and thenIcommandOfUIObject associatedItoolbardefInUIThe effect on the layer is a tool bar with command buttons.

TheseUIThe Host Program is responsible for the process of layer parsing and generation. Plug-In developers do not need to consider this issue.

Plug-inUIHow do I interact with the plug-in when an object is triggered?

Plug-in objectUIHow Objects interact with plug-in objects when triggered by users is perhaps the most interesting part of the plug-in framework. InComBy binding function pointers and callback functions, the host Program will know which object's function needs to be called when a button is pressed to implement the functions required for the event. In. NET FrameworkEvent Association is called a "delegate"(Delegate)In the following sections, we will explain the principle and application of the delegation mechanism.

Figure2 limit 3ShownArcmap.exeThe whole process of starting and loading the plug-in:

 


Figure2 ‑ 3 ArcMapStartup Process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.