Multiboxes, which are synonymous with the glue boxes mentioned in Chapter 2, let the user group together several circuit elements and manipulate them as a single entity. The modules which implement multiboxes are shown in Table 3.11.
|multidel.tcl||Module to delete a multibox and all the circuit elements contained within.|
|multiglue.tcl||Create the multibox on the screen by letting the user stroke out a bounding box around all the circuit elements to be contained within the multibox.|
|multimod.tcl||Module to modify the size of a multibox on the canvas.|
|multimove.tcl||Moves all the circuit elements contained within a multibox.|
|multiunglue.tcl||Removes the multibox from the canvas. This module does not delete the items within the multibox.|
|multiutils.tcl||Miscellaneous utility procedures for the manipulation of multiboxes.|
Multiboxes are displayed as rectangle outlines on the workarea canvas; they are created with the GLUE button on the toolbar. After the user presses this button, a binding is created which calls the procedure multi_create_new when the user clicks the leftmost mouse button on the canvas. This procedure creates an anchor point on the workarea canvas for the multibox. Another binding is then established between the motion of the mouse and the procedure multi_do_set which extends the multibox from the anchor point to the current position of the mouse. When the user releases the mouse button, the creation of the multibox is completed by invoking the procedure multi_stop which deletes the multibox if it had no area.
Resizing the rectangle of an existing multibox is performed by the MODIFY toolbar button. The implementation will identify mouse clicks on either the edges or corners of an existing multibox. If the user clicked on an edge, then the other three edges will act as anchors and the selected edge may be dragged horizontally or vertically. If the user clicked on a corner, then the opposite corner will act as an anchor and the selected corner may be moved diagonally. During modification of multiboxes, the same two procedures described above are reused so as to reduce code duplication.
When the user selects either the MOVE, DELETE or UNGLUE button from the toolbar, the implementation must consolidate all circuit elements enclosed within bounding boxes on the workarea so that each of the multiboxes and their contents may be treated as a single entity. The GUI accomplishes this by creating filled transparent rectangles on top of each of the bounding outline rectangles currently on the workarea canvas. As a result, whenever the mouse pointer moves over a multibox during one of these three operations, the entire multibox outline will be highlighted instead of the individual circuit elements contained within. Hence, the circuit elements contained inside the multibox cannot be directly accessed by the user.
Moving all the circuit elements in a multibox is achieved by tagging all enclosed components and multiboxes with the name multi_tag and by adding all enclosed wire points to a list of points. A binding is then established which binds the motion of the mouse with the movement of all these tagged circuit elements and the wire points in the point list. By moving the points individually, the wires corresponding to these points will also be moved. If a wire straddles a multibox, then one end point will move, whereas the other will remain stationary, thereby creating a rubber banding effect. During the implementation of multibox movement, several issues had to be resolved regarding circuit elements which do not lie entirely inside the selected multibox. For example, if a point attached to a component port lies inside the multibox, but the component itself straddles the outline of the multibox, then the point will not be moved by the GUI.
Deletion of a multibox and its contents is handled by iterating over each of the circuit elements contained inside the selected multibox and then invoking an appropriate delete procedure to remove the element from the display. The unglue feature is trivially implemented by deleting the selected multibox rectangle and its corresponding transparent rectangle from the canvas, leaving the enclosed circuit elements unaltered.