next up previous contents
Next: Component Manipulation Up: Component Modules Previous: Component Creation

Component Representation Arrays

The associative array draw_params is used to store various attributes related to a component. It is indexed by a component tag and a component attribute. The attributes currently supported are canvas, colour, width and orient. For example, if the orientation of the component with tag comp_nand_8 is currently 180 degrees, then the value of the array element draw_params(comp_nand_8,orient) will be 180. The canvas attribute indicates in which canvas the component resides. This attribute exists for future extensibility of the GUI, in which multiple views of a circuit over several different canvases may be possible. The colour attribute stores the colour to be used when drawing the primitives; by default, they are black. The width attribute indicates the outline thickness to be used when drawing the primitives which make up the component; by default the widths are set to one pixel. The default values for the initial colour and width of a component can be changed using the option database. The orient attribute, as alluded to above, stores the current rotation of the component. Currently, the orientation of a component must be one of 0, 90, 180 or 270. The purpose of the draw_params associative array is to cut down on the number of global variables required by the draw.tcl module and to reduce the number of parameters which must be passed among procedures.

Another array, cmp_coord is used to store the location of the component on the canvas. It too, is indexed by the unique tag name of the component and contains the canvas coordinates of the center of the component. In retrospect, the cmp_coord array could have been merged with the draw_params array, so as to limit pollution of the global namespace.

Donald Craig
Mon Jul 8 12:05:35 NDT 1996