Chapter 12. Enhancements

How to enhance OpenCAGE

The model of OpenCAGE consists of several parts. First there is the GIF interface, which is the interface from a graph system to OpenCAGE. It supports at this stage of development nodes (which can be hierarchically connected) and edges between them.

Motivation

  • It is a customer's requirement that OpenCAGE is expandable in a simple way.

  • To show how simple it is to enhance OpenCAGE.

A new Layout

You have to extend the Simple_Layout class and overwrite the methode Apply_Layout with the desired layout function.

See Layouts (the Section called Layouts in Chapter 5) for further informations.

A new, very complex Layout

The class Layout is only an interface which allows you to write a completely new layout without the restrictions of the Simple_Layout.

See Layouts (the Section called Layouts in Chapter 5) for further informations.

A new Node-Type

If you want to add a new node type you don't have to implement anything (at least in OpenCAGE). There are 4 different pixmaps for the different states (normal, selected, marked, marked and selected). In our setup, they are automatically created from the normal pixmap.

  1. Add the new xpm-file of the node into the directory pixmaps/nodes with the name RFG_<type>_NORMAL.xpm.

  2. Edit the Makefile and add it to "NORMAL = ".

  3. Execute make to create the other kinds of pixmaps.

A new Edge-Type

You only have to add a new edge type or change the color of an edge type in the file oc.xml.

A new functionality

Well, this just depends on what you really want to do. If you want to add a new entry to the context menus which manipulates the graph, have a look at the following two sections, Actions (the Section called Actions in Chapter 4) and Command (the Section called Command in Chapter 6).

If you want to add something else, simply read this document as well as the class reference and the Design Patterns [DP95]. You should repeat this if you feel unsure.

A new Action

See Actions (the Section called Actions in Chapter 4) for some background information about actions.

If you want to add a special action which is only supported by your own graph model, simply add a new class, implement it and modifiy your graph model to return the action when appropriate.

If you want to add a more common action, first check if there is already an interface for it in the package OpenCAGE.Actions. If not, create one. Then add a new implementation for your model and modifiy your graph model to return the action when appropriate.

A new Command

See Command (the Section called Command in Chapter 6) for some background information about commands.

To add a new command, you first have to create a new one (plus factory). You can use the omltrip-make-command script which can be found in the src/OpenCAGE directory to create the stubs for the command and the command factory. Give the name of the command as the first parameter. E.g. omltrip-make-command Move creates the stubs for a move command plus factory.

The implementation of the command itself goes into the method Execute. The Can_Execute method of the factory should be also implemented to catch invalid states before a command is created. Can_Execute should be used for fast checks, because it is done at least every time a context menu is shown. If the checks need a longer time, overwrite the Collect_Data method of the command.

The new created command then must be registered with OpenCAGE in the init process. See opencage-init.adb and Initialization of OpenCAGE (the Section called Initialization of OpenCAGE in Chapter 11).

The last step is to add an entry in oc.xml. See Configuration Data (the Section called Configuration Data in Chapter 4). You can include the command in the workbench menus, the workbench iconbar, or the context menus, depending whether the command pertains to a certain graph window or not.

A new Analysis

First, we need an analysis action for the model you are using. See the section about how to add a new Action above. The name of the analysis action should be added as a constant to opencage-general.ads. Then the new analysis action must be registered with OpenCAGE in the init process. See opencage-init.adb and Initialization of OpenCAGE (the Section called Initialization of OpenCAGE in Chapter 11). In this step, the analysis action is associated with a parameter widget using e.g. Register_Simple_Analysis.

After this, the newly created analysis has to be registered with the analysis master (this is allows you to group analyses together). This is done in the configuration file oc.xml.

A new Attribute

Attribute pixmaps are looked up by their name. There is no need to change the implementation.

  1. Add the new xpm-file of the attribute into the directory pixmaps/attributes with the name <attribute-name>.xpm.

  2. Add an entry in oc.xml to specify the position of this attribute.