CDCells.mesa (a ChipNDale module)
Copyright (C) 1983, 1985, 1986 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, 23-Aug-83
Last edited by: Christian Jacobi, November 3, 1986 5:54:39 pm PST
DIRECTORY
CD USING [Design, Instance, InstanceList, InstanceSequence, Object, ObjectClass, Rect, Transformation];
CDCells: CEDAR DEFINITIONS =
BEGIN
-- Procedures for creating designs by programs
-- Cell creation
-- The newly created cells are not included into any design or directory.
-- Use CDDirectory.Include to include cell to a design's directory.
-- Use CDCells.Include.. to include instances or objects into existing cells.
-- Use CDDirectory to give names to cells.
CreateEmptyCell:
PROC []
RETURNS [
CD.Object];
-- Creates a new empty cell.
CreateCell:
PROC [il:
CD.InstanceList←
NIL, sq:
CD.InstanceSequence←
NIL, ir:
CD.Rect←[0,0,-1,-1]]
RETURNS [
CD.Object];
-- Creates a new cell using il and sq.
-- Warning: il and sq are directly used;
-- Caller must not use those instances, list or sequence elsewhere.
CreateCellXTransformed:
PROC [il:
CD.InstanceList←
NIL, sq:
CD.InstanceSequence←
NIL, ir:
CD.Rect←[0,0,-1,-1], cTrans:
CD.Transformation←[]]
RETURNS [
CD.Object];
-- Creates a new cell, using a de-transformed copy of il, sq and ir
-- Cell modifications
IncludeMode:
TYPE = {doit, dontNotify, dontResize};
--A mode parameter for cell modifications
-- doit: normal, but slow case: operation will be completed
-- dontNotify: speed up hack.
-- Does not propagate a change cell event.
-- Does not cause redrawing of the design.
-- dontResize: [also implies dontNotify] speed up hack.
-- Does not call ResizeCell to recompute the draw size; Coordinate system
-- invariants can be violated. Caller must promises to call ResizeCell
-- himself to reestablish coordinate system invariants.
--For designs, neither re-sizing nor notifying is done.
IncludeOb:
PROC [design:
CD.Design ←
NIL,
cell:
CD.Object ←
NIL,
ob:
CD.Object,
trans:
CD.Transformation ← [],
mode: IncludeMode ← doit]
RETURNS [newInst:
CD.Instance, resize:
BOOL];
--design (NIL: allowed in case cell really is not yet part of a design)
--cell (NIL: include into design)
--ob: the object to be included in cell
--trans: transformation of ob inside cell
--mode: see above
--newInst: the new created instance;
-- if cell is not repositioned, newInst is in coordinate system of unrepositioned cell
--resize: Resize was called or should be called, depending of mode
IncludeInstance:
PROC [design:
CD.Design ←
NIL,
cell:
CD.Object ←
NIL,
inst:
CD.Instance,
mode: IncludeMode ← doit]
RETURNS [resize:
BOOL];
--design (NIL: allowed, if cell really is not yet part of a design)
--cell (NIL: include into design)
--inst: instance to include in cell
--mode: see above
--resize: Resize was called or should be called, depending of mode
RemoveInstance:
PROC [design:
CD.Design ←
NIL,
cell:
CD.Object←
NIL,
inst:
CD.Instance,
mode: IncludeMode ← doit]
RETURNS [resize:
BOOL];
--design (NIL: allowed, if cell really is not yet part of a design)
--cell (NIL: remove from design)
--inst: instance to be removed from cell
--mode: see above
--resize: Resize was called or should be called, depending of mode
SetInterestRect:
PROC [design:
CD.Design, cell:
CD.Object, r:
CD.Rect ← [0, 0, -1, -1], mode: IncludeMode ← doit];
--Set the interest rect of a cell
--Defaulting r means to use a reasonable default for the interest rect
--design (NIL: allowed, if cell really is not yet part of a design, or, mode=dontResize)
ResizeCell:
PROC [design:
CD.Design, cell:
CD.Object]
RETURNS [didResize:
BOOL];
--Make sure bbox and ir [if defaulted] of a cell are correct
--If necessary, propagates size change all over in design,
--but does not notify change event.
--design (NIL: allowed, if cell really is not yet part of a design).
SetSimplificationTreshhold:
PROC [cell:
CD.Object, val:
REAL←-1, inPixels:
BOOL←
TRUE];
--If inPixels: The cell will be simplified if its height on the screen is smaller than val pixels
--val -1: tries a fair guess for val
SetBorderMode:
PROC [cell:
CD.Object, draw:
BOOL];
--Sets border drawing mode for cell
-- miscellanious
IsCell:
PROC [ob:
CD.Object]
RETURNS [
BOOL] =
INLINE {
RETURN [ ob.class = pCellClass ]
};
IsEmpty:
PROC [cell:
CD.Object]
RETURNS [
BOOL];
--Returns whether the cell is empty
--Empty cell are not allowed, but it still is usefull to have a check
CountInstances:
PROC [cell:
CD.Object]
RETURNS [
INT];
--Returns the number of instances of a cell
IsPushedIn:
PROC [design:
CD.Design]
RETURNS [yes:
BOOL];
--Returns whether the design is pushed into a cell
IsDummyCell:
PROC [cell:
CD.Object]
RETURNS [
BOOL];
--Returns whether cell is a (mutable) copy of a pushed in cell; then, it could
--have been (or can be) changed without call of CDDirectory.PropagateChange
ToSequenceMode:
PROC [cell:
CD.Object];
--Tries to move as many instances from the list to the sequence as possible
InstEnumerator:
TYPE =
PROC [inst:
CD.Instance]
RETURNS [quit:
BOOL←
FALSE];
EnumerateInstances:
PROC [cell:
CD.Object, proc: InstEnumerator]
RETURNS [quit:
BOOL];
--Enumerates the instances of the cell in unspecified order.
--If the cell is changed while the enumeration, the changed and maybe other instances
--might not be enumerated correctly.
--Applies proc to each instance until proc returns TRUE or no more instances.
--Returns TRUE if some call returned TRUE
pCellClass: PRIVATE READONLY CD.ObjectClass;
END.