DIRECTORY CD, CDBasics, CDOrient, CDApplications, CDProperties; CDApplicationsImpl: CEDAR PROGRAM IMPORTS CD, CDApplications, CDOrient, CDBasics, CDProperties EXPORTS CDApplications = BEGIN PointToI: PUBLIC PROC [pos: CD.DesignPosition, aptr: CD.ApplicationPtr] RETURNS [BOOLEAN] = BEGIN RETURN [aptr.ob.p.hitInside[aptr, CDBasics.RectAt[pos, [0, 0]]]] END; ARectI: PUBLIC PROC [aptr: CD.ApplicationPtr] RETURNS [CD.DesignRect] = BEGIN RETURN [ CDOrient.MapRect[ itemInCell: CD.InterestRect[aptr.ob], cellSize: aptr.ob.size, cellInstOrient: aptr.orientation, cellInstPos: aptr.location ] ] END; NewApplicationI: PUBLIC PROC [ob: CD.ObPtr_NIL, location: CD.DesignPosition_[0,0], orientation: CD.Orientation_0, selected: BOOLEAN _ FALSE, properties: CD.Properties_NIL] RETURNS [CD.ApplicationPtr] = BEGIN off: CD.DesignPosition = CDBasics.BaseOfRect[ CDOrient.MapRect[ itemInCell: CD.InterestRect[ob], cellSize: ob.size, cellInstOrient: orientation, cellInstPos: [0, 0] ]]; a: CD.ApplicationPtr = NEW[CD.Application _ CD.Application[ ob: ob, location: CDBasics.SubPoints[location, off], orientation: orientation, selected: selected, properties: properties ]]; RETURN [a] END; BoundingRectO: PUBLIC PROC[list: CD.ApplicationList, selectedOnly: BOOLEAN_FALSE] RETURNS [CD.DesignRect] = BEGIN bound: CD.DesignRect _ CDBasics.empty; FOR tem: LIST OF CD.ApplicationPtr _ list, tem.rest WHILE tem#NIL DO IF selectedOnly AND NOT tem.first.selected THEN LOOP; bound _ CDBasics.Surround[bound, CDApplications.ARectO[tem.first]] ENDLOOP; RETURN [bound] END; BoundingRectI: PUBLIC PROC[list: CD.ApplicationList, selectedOnly: BOOLEAN_FALSE] RETURNS [CD.DesignRect] = BEGIN bound: CD.DesignRect _ CDBasics.empty; FOR tem: LIST OF CD.ApplicationPtr _ list, tem.rest WHILE tem#NIL DO IF selectedOnly AND NOT tem.first.selected THEN LOOP; bound _ CDBasics.Surround[bound, ARectI[tem.first]] ENDLOOP; RETURN [bound] END; AplicationAt: PUBLIC PROC [al: CD.ApplicationList, pos: CD.DesignPosition, selectedOnly: BOOL_FALSE] RETURNS [CD.ApplicationPtr] = BEGIN FOR w: CD.ApplicationList _ al, w.rest WHILE w#NIL DO IF (~selectedOnly OR w.first.selected) AND CDApplications.PointToO[pos, w.first] AND PointToI[pos, w.first] THEN RETURN [w.first] ENDLOOP; RETURN [NIL] END; TransformList: PUBLIC PROC[al: CD.ApplicationList, cellRect: CD.DesignRect, transformation: CD.Orientation] = BEGIN FOR t: CD.ApplicationList _ al, t.rest WHILE t#NIL DO Transform[t.first, cellRect, transformation]; ENDLOOP END; TranslateList: PUBLIC PROC[al: CD.ApplicationList, offset: CD.DesignPosition] = BEGIN FOR t: CD.ApplicationList _ al, t.rest WHILE t#NIL DO CDApplications.Translate[t.first, offset]; ENDLOOP; END; DeSelectList: PUBLIC PROC [list: CD.ApplicationList] = BEGIN FOR w: CD.ApplicationList _ list, w.rest WHILE w#NIL DO w.first.selected _ FALSE ENDLOOP; END; AppendToList: PUBLIC PROC [app, to: CD.ApplicationList] RETURNS [CD.ApplicationList] = BEGIN FOR w: CD.ApplicationList _ app, w.rest WHILE w#NIL DO to _ CONS[w.first, to]; ENDLOOP; RETURN [to] END; SplitPointed: PUBLIC PROC [from: CD.ApplicationList, pos: CD.DesignPosition] RETURNS [pointed, others: CD.ApplicationList] = BEGIN pApp: CD.ApplicationPtr = AplicationAt[from, pos]; pointed _ NIL; others _ NIL; FOR w: CD.ApplicationList _ from, w.rest WHILE w#NIL DO IF w.first=pApp THEN pointed _ LIST[w.first] ELSE others _ CONS[w.first, others] ENDLOOP END; SplitSelected: PUBLIC PROC [from: CD.ApplicationList] RETURNS [selected, others: CD.ApplicationList] = BEGIN selected_NIL; others_NIL; FOR w: CD.ApplicationList _ from, w.rest WHILE w#NIL DO IF w.first.selected THEN selected _ CONS[w.first, selected] ELSE others _ CONS[w.first, others] ENDLOOP END; OnlySelected: PUBLIC PROC[al: CD.ApplicationList] RETURNS [selected: CD.ApplicationList_NIL] = BEGIN FOR l: CD.ApplicationList _ al, l.rest WHILE l#NIL DO IF l.first.selected THEN selected _ CONS[l.first, selected]; ENDLOOP; END; Transform: PUBLIC PROC [aptr: CD.ApplicationPtr, cellRect: CD.DesignRect, transformation: CD.Orientation] = BEGIN r: CD.DesignRect _ CDOrient.MapRect[ itemInCell: CDOrient.RectAt[ CDBasics.SubPoints[aptr.location, CDBasics.BaseOfRect[cellRect]], aptr.ob.size, aptr.orientation], cellSize: CDBasics.SizeOfRect[cellRect], cellInstOrient: transformation, cellInstPos: CDBasics.BaseOfRect[cellRect]]; aptr.location _ CDBasics.BaseOfRect[r]; aptr.orientation _ CDOrient.ComposeOrient[ itemOrientInCell: aptr.orientation, cellOrientInWorld: transformation]; END; CopyList: PUBLIC PROC[al: CD.ApplicationList] RETURNS [CD.ApplicationList] = BEGIN newList: CD.ApplicationList _ NIL; FOR t: CD.ApplicationList _ al, t.rest WHILE t#NIL DO a: CD.ApplicationPtr = NEW[CD.Application _ t.first^]; a.properties _ CDProperties.CopyProps[a.properties]; newList _ CONS[a, newList] ENDLOOP; RETURN [newList] END; ComposedCopy: PUBLIC PROC[al: CD.ApplicationList, cellPos, cellSize: CD.DesignPosition, cellOrient: CD.Orientation] RETURNS [CD.ApplicationList] = BEGIN r: CD.DesignRect; newList: CD.ApplicationList _ NIL; FOR t: CD.ApplicationList _ al, t.rest WHILE t#NIL DO a: CD.ApplicationPtr _ NEW[CD.Application _ t.first^]; r _ CDOrient.MapRect[ itemInCell: CDOrient.RectAt[a.location, a.ob.size, a.orientation], cellSize: cellSize, cellInstOrient: cellOrient, cellInstPos: cellPos]; a.location _ CDBasics.BaseOfRect[r]; a.orientation _ CDOrient.ComposeOrient[ itemOrientInCell: a.orientation, cellOrientInWorld: cellOrient]; a.properties _ CDProperties.CopyProps[t.first.properties]; newList _ CONS[a, newList] ENDLOOP; RETURN [newList] END; DeComposedCopy: PUBLIC PROC[al: CD.ApplicationList, cellPos, cellSize: CD.DesignPosition, cellOrient: CD.Orientation] RETURNS [CD.ApplicationList] = BEGIN r: CD.DesignRect; newList: CD.ApplicationList _ NIL; FOR t: CD.ApplicationList _ al, t.rest WHILE t#NIL DO a: CD.ApplicationPtr _ NEW[CD.Application_ t.first^]; r _ CDOrient.DeMapRect[ itemInWorld: CDOrient.RectAt[a.location, a.ob.size, a.orientation], cellSize: cellSize, cellInstOrient: cellOrient, cellInstPos: cellPos]; a.location _ CDBasics.BaseOfRect[r]; a.orientation _ CDOrient.DecomposeOrient[ itemOrientInWorld: a.orientation, cellOrientInWorld: cellOrient]; a.properties _ CDProperties.CopyProps[t.first.properties]; newList _ CONS[a, newList] ENDLOOP; RETURN [newList] END; END. ÖCDApplicationsImpl.mesa (part of ChipNDale) Copyright c 1983, 1985 by Xerox Corporation. All rights reserved. by Christian Jacobi, May 12, 1983 12:22 pm last edited by Christian Jacobi, April 15, 1985 4:44:30 pm PST --Procedures with vanilla stuff around applications --be carefull, ApplicationList's are lists of pointers, distinguish between: --procedures which modify the application list, from procedures which don't --procedures which modify the applications pointed to, from procedures which don't --procedures which modify an application list, from procedures which modify the applications --procedures inspecting an application list --returns "pos points to the application aptr", using its virtual coordinates --returns a reference to an application at location pos (or NIL if there is none) --procedures which modify the applications referenced by a list --composes the lists "app" and "to" --the original list "to" is destroied and must be replaced by the retuned list --the original list "app" is not touched --procedures which handle the application list but don't modify the applications --copyes the pointed application references from "from" to "pointed" --copyes the non-pointed application references from "from" to "others" --does not make copies of the real applications --finds maximal 1 pointed application --copyes the selected application references from "from" to "selected" --copyes the non-selected application references from "from" to "others" --does not make copies of the real applications -- returns new list but same applications --procedures which create a new application list, with new applications --performs "transformation" to "aptr"; the transformation occurs to the rect "cellRect". --"cellRect" and "aptr" in the same coordinate system --WARNING transformation group NOT abelsch --creates a new list with new applications --makes a copy of "al" with world coordinates assumed that "al" has cell coordinates --cellSize in cell coordinates, cellPos in world cordinates --the new list points to new applications --makes a copy of "al" with cell coordinates assumed al has world coordinates --cellSize in cell coordinates --cellPos, cellOrient in world coordinates --the new list points to new applications Ê ù˜šœ1™1Jšœ Ïmœ7™BJšœ,™,Jšœ?™?—J˜Jšœ3™3J˜šÏk ˜ Jšžœ˜J˜ J˜ J˜J˜ J˜—šÏnœžœžœ˜"Jšžœ5˜