next up previous contents
Next: Finishing Up Up: Using the Editor Previous: Rigi Views

Scripting

You can program the editor by writing scripts using the Rigi Command Library (RCL) to automate tasks, customize features, and integrate capabilities. There is an RCL command corresponding to each menu command. These commands (and others) can be assembled into procedures.

Return to the Children window with the ListADT, ElementADT, and Control subsystem nodes.

For scripting experiments, make a test window of leaf nodes by performing a projection of the subsystems with infinite depth:

  1. Select the three subsystem nodes.
  2. Choose Settings from the Options menu.
  3. Adjust the Projection Depth slider to the value -1.
  4. Choose Projection from the Navigate menu.

    A Projection window appears, containing the lowest level nodes in the subsystem hierarchy; the structure of the hierarchy is not modified after producing a projection.

    tex2html_wrap4958

You can produce custom layouts. To enter an RCL command:

  1. Place the pointer to the command entry field and click.

    tex2html_wrap4960

  2. Type rcl_select_type Module.

    Press the enter key after typing each script command.

    The rcl_select_type command selects nodes by their type (here, it is Module).

  3. Type rcl_cursor_set 100 10.

    The rcl_cursor_set command moves a cursor to location (x,y) = (100,10) on the canvas. This is equivalent to clicking the mouse at that location (usually as a prelude for arrangement operations).

  4. Type rcl_group_vertically.

    The rcl_group_vertically command corresponds to choosing Vertical from the Layout menu; the selected nodes are arranged in a vertical line along the left side of the canvas.

    tex2html_wrap_inline4844 Note: RCL is case sensitive.

    tex2html_wrap4962

As each command is entered, it is put into a scrollable command history list located below the menubar.

tex2html_wrap4964

Clicking on a command in the list automatically places it into the command entry field. Double-clicking on a command in the list runs it right away (and appends this command to the bottom of the list).

Now, using the current commands in the command history list, retrieve and edit them as appropriate to lay out the two remaining Data nodes in a vertical line to the right of the Module nodes.

Using a separate text editor, you can write script files that can be loaded into rigiedit. For example, type the following into a file called myscript.rcl in your home directory:

 
proc columns {} { 
    rcl_select_all  
    foreach nodeID [rcl_select_get_list] {  
        set nodeTypes([rcl_get_node_type $nodeID]) 1  
    }  
    set numNodeTypes [array size nodeTypes]  
    if {$numNodeTypes == 0} {  
        return  
    }  
    set xDelta [expr [rcl_win_canvas_width] / $numNodeTypes]  
    set xPos [expr $xDelta / 2]  
  
    foreach nodeType [array names nodeTypes] {  
        rcl_select_type $nodeType  
        rcl_cursor_set $xPos 0  
        rcl_group_vertically  
        incr xPos $xDelta  
    }  
    rcl_scale_to_window  
    rcl_select_none  
}

This script arranges the nodes in the active window into columns by their node type.

To load the myscript.rcl into rigiedit and run the layout algorithm:

  1. Type source tex2html_wrap_inline4954 /myscript.rcl in the command entry field.

    tex2html_wrap4966

  2. Type columns.

    tex2html_wrap4968

To use script commands to access external tools such as graph layout programs:

  1. Type rcl_filter_arctype data 0 then rcl_filter_apply 0 arc in the command entry field.

    These two commands hide the data arcs in the active window (the Projection window).

  2. Type sugiyama call 0.

    The call arcs of the graph in the current window are presented in a layered, tree-like form using the Sugiyama directed graph layout algorithm. The sugiyama command takes an arc type as the first parameter and a window number as the second parameter (zero meaning the current window). The window number is shown in the title bar of a window, following the type.

    tex2html_wrap4970

    tex2html_wrap_inline4854 Tip: This technique is a quick way of producing call graphs for a program.


next up previous contents
Next: Finishing Up Up: Using the Editor Previous: Rigi Views

James Uhl
Wed Jul 10 14:13:22 PDT 1996