next up previous contents
Next: Netlist Modules Up: Component Manipulation Previous: Moving and Deleting Components

Rotating Components

Rotation of components presented a challenge since Tcl/Tk does not directly support the rotation of canvas primitives. Therefore, each primitive which comprises a component had to be rotated individually using rotation matrices represented mathematically by the equations shown in Figure 3.8. The xp and yp variables represent the coordinates of the primitives as determined by the canvas coords command while xc and yc represent the center of rotation, which is simply the center of the component as determined by the cmp_coord array.

   figure1660
Figure 3.8: Rotation Equations for Canvas Primitives

The procedure draw_rotate is the main procedure responsible for rotating a component. This procedure simply iterates over each of the primitive canvas items of a component and invokes the procedure dr_rotate_item which makes use of the transformation equations to rotate each of the primitives. The arc primitive present in the AND and NAND gates had to be treated as a special case by this procedure. As with deleting and moving a component, the wires connected to a component have to be adjusted so as to stay connected to the ports of the component.



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