CDOps.mesa (part of ChipNDale)
Copyright © 1983, 1986, 1987 by Xerox Corporation. All rights reserved.
Created by: Christian Jacobi, February 24, 1984 2:03 pm
Last edited by: Christian Jacobi, April 10, 1987 6:00:30 pm PDT
DIRECTORY
CD,
Rope USING [ROPE];
CDOps: CEDAR DEFINITIONS =
BEGIN
Simple operation on ChipNDale designs.
All procedures do not queue; proper synchronization with CDSequencer by the caller is assumed. (Except CreateDesign, Redraw, or ImmediateRedraw, and the printing procs, which can be called anytime)
--Basics
CreateDesign: PROC [technology: CD.Technology] RETURNS [design: CD.Design];
--Creates a new, empty design; does not open a viewer yet.
--Caller is supposed to set mutability after design is built.
--Caller holds the synchronization lock until mutability is initialized and a viewer is opened
SetMutability: PROC [design: CD.Design, mutability: CD.Mutability ← editable];
--After the call, the design might be changed by interactive commands
ResetDesign: PROC [design: CD.Design];
--Makes design empty
RenameDesign: PROC [design: CD.Design, name: Rope.ROPE] RETURNS [done: BOOL];
--Renames a design; This procedure can fail; not all ropes are legal names!
RealTopCell: PROC [design: CD.Design] RETURNS [dummyCell: CD.Object];
--Returns dummy cell which represents the top level of the design.
--Do not reposition dummyCell; dummyCell can be changed without
-- calling CDDirectory.PropagateChange.
--Do not include dummyCell in directory
PushedTopCell: PROC [design: CD.Design] RETURNS [dummyCell: CD.Object];
--Returns dummy cell which represents the pushed in cell of the design;
--- (The level where all the interactive edits happen)
--Do not reposition dummyCell; represents can be changed without
-- calling CDDirectory.PropagateChange
--Do not include dummyCell in directory
MakeImmutable: PROC [ob: CD.Object] RETURNS [done: BOOL];
-- Tries to make an object immutable by making all its children immutable first,
-- and then setting the objects own immutable bit.
-- Very important: To make an object immutable is an operation which changes the
-- object! It must be called only while owning the designs lock [of the design
-- owning ob] with CDSequencer. [Because a parallel editing process can not check
-- the immutable-bit atomicly with performing a change to the object].
-- However, this change is not propagated.
--Undelete
FlushRemember: PROC [design: CD.Design];
--Makes design forget its undelete cache
GetRemembered: PROC [design: CD.Design] RETURNS [CD.InstanceList];
--Returns instances in the undelete cache
--the returned instances are removed from the cache
Remember: PROC [design: CD.Design, what: REF];
--Rememembers either an instance or an InstanceList for a short time in the undelete cache.
--Printing
LambdaRope: PROC [n: CD.Number, lambda: CD.Number] RETURNS [Rope.ROPE];
--For printing purposes
InstRope: PROC [inst: CD.Instance, design: CD.Design←NIL, verbosity: INT𡤁] RETURNS [Rope.ROPE];
--For printing purposes
LayerRope: PROC [layer: CD.Layer] RETURNS [Rope.ROPE];
--For printing purposes
ToRope: PROC [x: REF, whenFailed: REFNIL] RETURNS [Rope.ROPE];
--Tries hard to make rope; for printing purposes
--Drawing
DrawDesign: PROC [design: CD.Design, pr: CD.DrawRef];
--Draws a design into a device
--No shortcuts, usefull for abstract devices
--Drawing into viewers
QuickDrawDesign: PROC [design: CD.Design, pr: CD.DrawRef];
--Draw a design into a device, using the quick draw procedures
--Shortcuts are taken; suits the implementation of viewers
ImmediateRedraw: PROC [design: CD.Design, r: CD.Rect𡤊ll, eraseFirst: BOOLTRUE];
--Refreshes the the area r in all viewers without extra delay [drawing is forked]
Redraw: PROC [design: CD.Design, r: CD.Rect𡤊ll, eraseFirst: BOOLTRUE];
--Refreshes the the area r in all viewers
--Is delayed until the current command is finished
--Efficiency hint:
-- if a lot of small rectangles need to be redrawn, it can be more efficient
-- to call a redraw of a big rectangle first.
all: PRIVATE CD.Rect = [FIRST[CD.Number], FIRST[CD.Number], LAST[CD.Number], LAST[CD.Number]];
DoTheDelayedRedraws: PROC [design: CD.Design];
--Forwards all Redraw requests which have not yet been drawn to the viewers.
--Should be called from the command sequencer
RedrawInstance: PROC [design: CD.Design, inst: CD.Instance←NIL, erase: BOOLTRUE];
--Redraws the instance (delayed)
--Handling instances on a design basis
SetInstList: PROC [design: CD.Design, instList: CD.InstanceList ← NIL] = INLINE {
--Sets instance list of the currently pushed in cell of the design
design^.actual.first.specific.contents ← instList
};
InstList: PROC [design: CD.Design] RETURNS [CD.InstanceList] = INLINE {
--Returns instance list of the currently pushed in cell of the design
RETURN[design^.actual.first.specific.contents]
};
IncludeInstance: PROC [design: CD.Design, inst: CD.Instance, draw: BOOL TRUE];
--Includes instance into design [pushed cell]
IncludeInstanceList: PROC [design: CD.Design, il: CD.InstanceList, draw: BOOL TRUE];
--Includes instances into design [pushed cell]
RemoveInstance: PROC [design: CD.Design, inst: CD.Instance, draw: BOOL TRUE];
--Removes instance from design [pushed cell]
ReOrderInstance: PROC [design: CD.Design, inst: CD.Instance];
--Puts instance at the end [pushed cell]
--Used to make next selection finding different instance
IncludeObject: PROC [design: CD.Design, ob: CD.Object, trans: CD.Transformation←[[0,0], original]] RETURNS [CD.Instance];
--Conveniance: Includes object into design [pushed cell]
--Side effect: Sets selection according to internal selection mode
FitObjectI: PROC [ob: CD.Object, location: CD.Position ← [0, 0], orientation: CD.Orientation ← CD.Orientation[original]] RETURNS [trans: CD.Transformation];
--Conveniance: Returns a transformation such that the oriented objects interest rect
--will have its lower left corner at location
IncludeObjectI: PROC [design: CD.Design, ob: CD.Object, location: CD.Position ← [0, 0], orientation: CD.Orientation ← CD.Orientation[original]] RETURNS [CD.Instance];
--Conveniance: Includes object into design [pushed cell]
--Fancy coordinate transformation:
-- fits oriented objects lower left corner of interest rect to location
--Side effect: Sets selection according to internal selection mode
SelectedInstance: PROC [design: CD.Design] RETURNS [first: CD.Instance, multiple: BOOL];
--first: returns ref to any selected instance if there is one or more, otherwise NIL.
--multiple: more than one instance is selected
TheInstance: PROC [design: CD.Design, text: Rope.ROPENIL] RETURNS [inst: CD.Instance];
-- Finds the single selected instance of a design
-- if returned instance is nil, all messages are made and caller might return quietly
-- if returned instance is not nil; text line is written.
GetGrid: PROC [design: CD.Design, hint: REFNIL] RETURNS [CD.Number];
--Returns a grid number
--Interesting, because it returns a grid without explicitely importing viewer modules
PlaceInst: PROC [design: CD.Design, ob: CD.Object, hint: REFNIL] RETURNS [inst: CD.Instance];
--Places ob down, somewhere into design and returns the instance made
--Makes a guess for a good position
--hint: hint to find gridding information
-- use NIL, ViewerClasses.Viewer, or CDSequencer.Command
BoundingBox: PROC [design: CD.Design, onlySelected: BOOLFALSE] RETURNS [CD.Rect];
--Bounding box of whole design
--Empty for empty design
DeselectAll: PROC [design: CD.Design, setSelection: BOOLFALSE];
--Set or clear selection of all instances
END.