Automated User Interface for Annotations
Note: |
This topic is for Document/Medical only. |
The annotation example program that ships with LEADTOOLS is implemented using high-level automated features. This topic describes which parts of the example program are automated and which parts are not.
Behavior That Is Not Automated
When the main window is created, the example program creates the annotation toolbar using the L_AnnCreateToolbar function and initializes a tool-tracking variable by calling the L_AnnGetToolBarChecked function.
When a child window is created, if annotation data is present, the window is set to the container of the child window using L_AnnSetWnd. If annotation data is not present, a container is created for the child window. Next, the user mode is set using L_AnnSetUserMode. An automation object is then created, associated with the container, and activated using L_AnnCreate, L_AnnSetAutoContainer and L_AnnSetActiveState. This allows you to interact with the annotations, and is required to create the automated mode for annotations. Finally, parameters are set to control the translation of annotations added to the container, undo depth, and the hyperlink menu item.
When a child window is closed, the program disables and destroys the annotation objects using the L_AnnSetActiveState and L_AnnDestroy functions.
The pull-down menus in the example program let you control the automation, but the menu items, themselves, are not automated. (Only the pop-up menus, invoked with the right mouse button, are automated.) The pull-down menu options that affect annotations do the following:
File > Open lets you load an image file. If the image file has an associated annotation file (with the same file name, but with a file extension of ANN), this menu option also loads the annotation file using the L_AnnLoad function. If there is no associated annotation file, the program creates an annotation container that is the same size as the bitmap. This is done with the L_AnnCreateContainer function. The program also creates and assigns an automation object using the L_AnnCreate and L_AnnSetAutoContainer functions. (The automation object lets you control the default properties.)
File > Save lets you save the image file as you normally would, but it also saves an annotation file, giving it the same name as the image file, but with a file extension of ANN.
File > Print lets you print the image as you normally would, but it also prints the annotations using the L_AnnPrint function.
Edit > User Mode sets the automated user mode to design mode or run mode using the L_AnnSetUserMode function.
Edit > Tool changes the selected tool in the toolbar using the L_AnnSetToolBarChecked function.
View > Normal, Zoom, and Fit Image to Window change the display rectangle for painting the image, then change the scaling factors of the root annotation container to match the displayed image. The program uses the L_AnnSetScalarX and L_AnnSetScalarY functions to do this. (To handle scrolling, the program uses the L_AnnSetOffsetX and L_AnnSetOffsetY functions.)
Behavior That Is Automated
The toolbar created by the L_AnnCreateToolbar function appears as follows:
In design mode, you can select tools from the toolbar and draw them over the image in the window. You can then use the right mouse button to get a pop-up menu that is tailored to each object type. The pop-up menu appears as shown in this example.
The popup menu is context sensitive. It lists only the properties that can be changed on the selected object or objects. If you use the popup menu to change a property, the value that you specify is applied to the current selection, and it becomes the default for the next object.
The following topics describe the automated annotation features for particular objects and tools: