PWConditionalImpl.mesa
Copyright © 1984 by Xerox Corporation. All rights reversed.
Created by: Monier
Last Edited by: Serlet, May 2, 1985 1:49:52 am PDT
Last Edited by Monier, February 1, 1985 2:46:50 pm PST
This module deals with parametrized cells, i.e. cells containing conditional objects. The objects are named with the property $PWCond and their presence in the final cell is specified by the user code.
DIRECTORY
CD,
CDCells,
CDProperties USING [CopyProps, CopyVal, FetchProcs, GetPropFromApplication, RegisterProperty],
PWBasics,
PWConditional,
Rope;
PWConditionalImpl: CEDAR PROGRAM
IMPORTS CD, CDCells, CDProperties, PWBasics, Rope
EXPORTS PWConditional =
BEGIN
OPEN PWConditional;
-- Add or remove (depending on the default) the named objects into a copy of the cell
Inst: PUBLIC PROC [design: CD.Design, obj: CD.ObPtr, conds: LIST OF Rope.ROPE, removeNamed: BOOLTRUE] RETURNS [newObj: CD.ObPtr] =
BEGIN
location: CD.Position;
Copies the application, and inserts it in the applications of newObj, at the position location (in IR coordonnates).
Insert: PROC [appl: CD.ApplicationPtr] =
BEGIN
newAppl: CD.ApplicationPtr ← PWBasics.IncludeApplication[newObj, appl.ob, location, appl.orientation];
newAppl.properties ← CDProperties.CopyProps[appl.properties];
END;
-- Get the cell with everything in it
newObj ← CDCells.CreateEmptyCell[];
-- Check every application for the property $PWCond.
FOR appls: CD.ApplicationList ← NARROW [obj.specificRef, CD.CellPtr].contents, appls.rest WHILE appls # NIL DO
ref: REF ← CDProperties.GetPropFromApplication[appls.first, $PWCond];
location ← PWBasics.GetLocation[appls.first, obj]; -- a utiliser!!!!
IF ref = NIL THEN Insert[appls.first]
ELSE WITH ref SELECT FROM
prop: Rope.ROPE =>
BEGIN  -- it is a conditionnal object; see if it is listed
listed: BOOLFALSE;
FOR list: LIST OF Rope.ROPE ← conds, list.rest WHILE list # NIL DO
IF Rope.Equal[list.first, prop] THEN listed ← TRUE;
ENDLOOP;
We remove an object if it is listed and removeNamed=TRUE or if removeNamed=FALSE and it is not listed
IF listed # removeNamed THEN Insert[appls.first];
END;
ENDCASE => Insert[appls.first];
ENDLOOP;
PWBasics.RepositionCell[design, newObj];
CDCells.SetInterestRect[newObj, CD.InterestRect[obj]];
PWBasics.AppendProps[newObj, obj];
END;
-- Register property and copy procedure
[] ← CDProperties.RegisterProperty[$PWCond, $PW];
CDProperties.FetchProcs[$PWCond].makeCopy ← CDProperties.CopyVal;
END.