DIRECTORY GriffinDisplay, RefreshDefs USING [EraseAndSaveBox], GriffinText USING [GetBoundingBox], GriffinViewer USING [PaintProc, DoPaint], ImagerInterpress USING [Create, Ref, DoPage, Close], CubicSplines, StyleDefs, Imager USING [Context, metersPerPoint], Rope USING [ROPE], GriffinDefs, PointDefs, MenuDefs, GriffinEncoding, ObjectDefs; ShowObjects: CEDAR PROGRAM IMPORTS GriffinDisplay, ObjectDefs, PointDefs, MenuDefs, GriffinViewer, GriffinEncoding, RefreshDefs, GriffinText, ImagerInterpress EXPORTS ObjectDefs = BEGIN OPEN ObjectDefs,PointDefs; Context: TYPE=Imager.Context; debug: BOOLEAN _ FALSE; ReplotAllObjects: PUBLIC PROCEDURE[dc: Context] = { proc: ObjectProc = {PlotObject[obj, dc]}; ForAllObjects[proc]; }; ObjectsToInterpress: PUBLIC PROCEDURE[s: Rope.ROPE] = { action: PROC [dc: Imager.Context] = { proc: ObjectProc = {PlotObject[obj, dc]}; ForAllPictureObjects[proc]; }; ip: ImagerInterpress.Ref _ ImagerInterpress.Create[s]; GriffinDisplay.ResetClipEdges[]; ImagerInterpress.DoPage[ip, action, Imager.metersPerPoint]; ImagerInterpress.Close[ip]; }; ReplotFromObject: PUBLIC PROCEDURE[startObj: ObjectHandle, dc: Context] = BEGIN obj: REF Object _ startObj; UNTIL obj=NIL DO PlotObject[obj, dc]; obj _ obj.link; ENDLOOP; END; PlotObject: PUBLIC PROCEDURE [object: ObjectHandle, dc: Context] = BEGIN IF object=NIL THEN RETURN; IF ~Visible[object] THEN RETURN; IF NOT object.validEncoding THEN ERROR; IF GriffinDisplay.IsCull[object.tl,object.br, dc] THEN RETURN; WITH object SELECT FROM obj: REF Object[shape] => BEGIN IF NOT obj.closed THEN { --Strokes IF object.cluster=OpenCluster AND obj.style.outlined=FALSE THEN GriffinDisplay.DrawFastStroke[obj.edgeEncoding, dc] ELSE GriffinDisplay.DrawStroke[obj.edgeEncoding, obj.style, dc]; } ELSE { --Areas GriffinDisplay.DrawArea[obj.edgeEncoding, obj.style, dc]; }; END; obj: REF Object[caption] => GriffinDisplay.DrawCaption[ObjToScrReal[obj.p0], obj.text, obj.style, dc]; obj: REF Object[menu] => MenuDefs.PlotMenu[obj, dc]; obj: REF Object[selectToken] => DrawSelectToken[obj, dc]; obj: REF Object[token] => SELECT obj.tokenType FROM CP => GriffinDisplay.DrawToken[ObjToScr[obj.p0],cp,dc]; open => GriffinDisplay.DrawToken[ObjToScr[obj.p0],open,dc]; vgrid => GriffinDisplay.DrawVGrid[ObjToScr[obj.p0], dc]; hgrid => GriffinDisplay.DrawHGrid[ObjToScr[obj.p0], dc]; ENDCASE; ENDCASE; END; DrawSelectToken: PROCEDURE [token: REF selectToken Object, dc: Context] = BEGIN selectedObject: ObjectHandle _ token.selectedObj; coverObj: ObjectHandle _ NIL; covered: BOOLEAN _ FALSE; clustered: BOOLEAN _ FALSE; pt: ScrPt; IF NOT token.located THEN ERROR; coverObj _ GetObjectHandleBetweenObjects[pt, GetTopPictureObj[], selectedObject] ; IF coverObj=token THEN coverObj _ GetObjectHandleBetweenObjects[pt,GetTopPictureObj[],selectedObject]; covered _ (coverObj#token AND coverObj#NIL); clustered _ selectedObject.cluster # 0; pt _ ObjToScr[token.p0]; GriffinDisplay.DrawSelection[pt,covered, clustered, dc]; END; ReplotBoxFromObject: PUBLIC PROCEDURE[tl,br: ScrPt, object: ObjectHandle, dc: Context]= BEGIN GriffinDisplay.SetClipEdges[tl,br]; ReplotFromObject[object, dc]; GriffinDisplay.ResetClipEdges[]; END; ReplotBox: PUBLIC PROCEDURE[tl,br: ScrPt, dc: Context]= BEGIN GriffinDisplay.SetClipEdges[tl,br]; ReplotAllObjects[dc]; GriffinDisplay.ResetClipEdges[]; END; PlotOneObject: PUBLIC PROCEDURE [object: ObjectHandle] = { painter: GriffinViewer.PaintProc = { PlotObject[object,dc]; }; GriffinViewer.DoPaint[painter]; }; EraseObject: PUBLIC PROCEDURE [object: ObjectHandle] = BEGIN select: REF Object[selectToken] _ NIL; painter: GriffinViewer.PaintProc = { do: ObjectProc = BEGIN IF obj#object AND obj#select THEN PlotObject[obj, dc]; END; GriffinDisplay.SetClipEdges[object.tl, object.br]; GriffinDisplay.ClearScreen[dc]; ForAllObjects[do]; GriffinDisplay.ResetClipEdges[]; }; IF object=NIL THEN RETURN; IF NOT object.validEncoding THEN ERROR; GriffinViewer.DoPaint[painter]; END; PlotLink: PUBLIC PROCEDURE[link: GriffinEncoding.Link, style: StyleDefs.StyleHandle]= BEGIN paint: GriffinViewer.PaintProc = { IF style = NIL THEN GriffinDisplay.DrawFastStroke[encoding, dc] ELSE GriffinDisplay.DrawStroke[encoding, style, dc]; }; encoding: GriffinEncoding.EdgeEncoding _ GriffinEncoding.EncodeEdge[LIST[link]]; GriffinViewer.DoPaint[paint]; END; EraseLink: PUBLIC PROCEDURE[link: GriffinEncoding.Link] = BEGIN RefreshDefs.EraseAndSaveBox[ScrRealToScr[link.tl], ScrRealToScr[link.br]]; END; EncodeObject: PUBLIC PROC [shape: REF shape Object] ~ TRUSTED { WITH traj: shape.trajectory SELECT FROM cyclic => { link: GriffinEncoding.Link _ GriffinEncoding.EncodeCubicLink[traj.knots, traj.splineType]; shape.edgeEncoding _ GriffinEncoding.EncodeEdge[LIST[link]]; }; linked => { list, rList: LIST OF GriffinEncoding.Link; FOR l: REF ObjectDefs.Link _ traj.links, l.link UNTIL l=NIL DO new: GriffinEncoding.Link _ IF l.degree=D1 THEN GriffinEncoding.EncodeLinearLink[l.knots] ELSE GriffinEncoding.EncodeCubicLink[l.knots, traj.splineType]; list _ CONS[new, list]; ENDLOOP; FOR l: LIST OF GriffinEncoding.Link _ list, l.rest UNTIL l=NIL DO rList _ CONS[l.first, rList]; ENDLOOP; shape.edgeEncoding _ GriffinEncoding.EncodeEdge[rList]; }; ENDCASE; IF shape.closed THEN shape.areaEncoding _ GriffinEncoding.EncodeArea[shape.edgeEncoding]; shape.tl _ ScrRealToScr[shape.edgeEncoding.tl]; shape.br _ ScrRealToScr[shape.edgeEncoding.br]; shape.validEncoding _ TRUE; }; AdjustBoxForStyle: PUBLIC PROC [object: ObjectHandle] ~ TRUSTED { WITH obj: object SELECT FROM shape => { w: INTEGER _ ObjValToScrVal[obj.style.width/2]+tokenSize; IF (obj.closed AND obj.style.outlined) OR NOT obj.closed THEN { obj.tl _ ScrRealToScr[[obj.edgeEncoding.tl[X]-w, obj.edgeEncoding.tl[Y]+w]]; obj.br _ScrRealToScr[[obj.edgeEncoding.br[X]+w, obj.edgeEncoding.br[Y]-w]]; }; }; caption => [obj.tl, obj.br] _ GriffinText.GetBoundingBox[obj.text, obj.style, obj.p0]; ENDCASE; }; GetObjectHandle: PUBLIC PROCEDURE [pt: PointDefs.ScrPt] RETURNS [ObjectHandle] = BEGIN found: ObjectHandle _ NIL; do: ObjectProc = { IF HitTest[pt, obj] THEN {found _ obj; RETURN[TRUE]}; }; ForAllObjectsReversed[do]; IF found#NIL THEN WITH found SELECT FROM type: REF selectToken Object => RETURN[type.selectedObj]; ENDCASE; RETURN[found]; END; GetObjectHandleBetweenObjects: PUBLIC PROCEDURE [pt: PointDefs.ScrPt, topObject,bottomObject: ObjectHandle] RETURNS [ObjectHandle] = BEGIN FOR obj: ObjectHandle _ topObject, obj.backLink UNTIL obj = bottomObject DO IF HitTest[pt, obj] THEN RETURN[obj]; ENDLOOP; RETURN[NIL]; END; HitTest: PROC [pt: PointDefs.ScrPt, obj: ObjectHandle] RETURNS [BOOLEAN] ~ TRUSTED { tol: REAL; IF ~Visible[obj] THEN RETURN[FALSE]; IF pt[X]obj.br[X] OR pt[Y]>obj.tl[Y] OR pt[Y] BEGIN tol _ MAX[1,ObjValToScrVal[object.style.width/2.0]]; IF GriffinEncoding.PointOnEdge[pt,object.edgeEncoding,tol] THEN RETURN[TRUE] ELSE IF object.closed AND obj.style.filled AND GriffinEncoding.PointInArea[pt,object.areaEncoding,tol] THEN RETURN[TRUE]; END; caption,token,menu, selectToken => RETURN[TRUE]; ENDCASE; RETURN[FALSE]; }; END. Compiler ShowObjects/n;bind griffin;griffin mstone April 24, 1981 3:10 PM geoff November 26, 1979 10:45 AM Last Edited by: Stone, February 18, 1983 1:03 pm Last Edited by: Pier, February 14, 1984 10:52:01 am PST Get an interpress context from the rope, "display" only the visible objects replots all objects linked to allObjects calls the correct type of plotting routine, be it splines, encoding, whatever is token covered? if not, is object covered at position of token? reset them reset them Hit Test.. obj may be touched Κ ˜J˜Jšœ+™+Jšœ™Jšœ!™!Jšœ0™0Jšœ7™7J˜šΟk ˜ J˜Jšœ œ˜$Jšœ œ˜#Jšœœ˜)Icodešœœ˜4Jšœ ˜ Jšœ ˜ Jšœœ˜'Jšœœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ ˜ —J˜šœ  ˜Jšœ|˜ƒJšœ˜—Jšœœ˜ J˜Jšœ œ˜Jšœœœ˜J˜J˜šΟnœœ œ˜3J˜)J˜J˜—šžœœ œ œ˜7šœœ˜%J˜)J˜J˜—J™KJ˜6J˜ Jšœ;˜;J˜J˜—J˜Jšœ(™(šžœœ œ'˜IJš˜Jšœœ˜šœœ˜J˜J˜Jšœ˜—Jšœ˜—J˜JšœM™Mšž œœ&˜BJšœ˜Jšœœœœ˜Jšœœœ˜ Jšœœœœ˜'Jšœ0œœ˜>šœœ˜šœœ˜šœœ œΟc ˜#šœœ˜:Jšœ4˜8—Jšœ<˜@Jšœ˜—šœŸ˜Jšœ9˜9Jšœ˜—Jšœ˜——˜šœœ˜JšœJ˜J——˜Jšœœ,˜4—˜Jšœœ1˜9J˜šœœœ˜3Jšœ5˜7Jšœ;˜;Jšœ9˜9Jšœ9˜9Jšœ˜—Jšœ˜—Jšœ˜—J˜J˜Jšžœ œ œ#˜Iš˜Jšœ1˜1Jšœœ˜Jšœ œœ˜Jšœ œœ˜J˜ Jšœœœœ˜ Jšœ™JšœR˜RJšœ/™/šœ˜JšœO˜O—Jšœœ œ˜,Jšœ'˜'J˜J˜8Jšœ˜—J˜J˜Jšžœœ œ2˜Wš˜J˜#J˜J˜ Jšœ˜—J˜Jšž œœ œ˜7š˜J˜#J˜Jšœ ™ J˜ Jšœ˜—J˜šž œœ˜:˜$J˜J˜—J˜J˜—J˜šž œœ œ˜6Jš˜Jšœœœ˜&˜$šœ˜Jšœ œ œ˜6Jšœ˜—J˜2Jšœ˜J˜Jšœ ™ J˜ J˜—Jšœœœœ˜Jšœœœ˜'J˜Jšœ˜—J˜šžœœ œ;˜UJš˜˜"Jšœ œœ,˜?Jšœ0˜4Jšœ˜—JšœDœ˜PJ˜Jšœ˜—J˜šž œœ œ˜9Jš˜J˜JJšœ˜J˜—š ž œœœ œœ˜@šœœ˜'˜ ˜K˜=—Kšœ0œ˜šœ˜Kšœ œ*˜=Kšœ;˜?—Kšœœ ˜Kšœ˜—š œœœ%œœ˜AKšœœ˜Kšœ˜—Kšœ7˜7K˜—Kšœ˜—KšœœE˜YJ˜/J˜/Jšœœ˜K˜—J˜šžœœœœ˜Bšœ œ˜˜ Kšœœ/˜9š œ œœœ œ˜?KšœL˜LKšœK˜KK˜—K˜—K˜VKšœ˜—K˜—J˜Jšœ ™ šžœœ œœ˜PJšœ˜Jšœœ˜˜Jšœœœœ˜5J˜—J˜š œœœœœ˜(Jšœ œ˜9Jšœ˜—Jšœ˜Jšœ˜—J˜šžœœ œ˜EJšœ&œ˜>š˜šœ,œ˜KJšœ œ˜%Jšœ˜—Jšœœ˜ Jšœ˜——J˜š žœœ*œœœ˜UJšœœ˜ Jšœœ œ˜$šœœ˜%Jš œœœœœ˜9—Jšœ™šœ œ˜šœ ˜Jšœœ+˜4Jšœ9œœœ˜Lšœœœ˜*Jšœ9œœœ˜N—Jšœ˜—Jšœ#œœ˜0Jšœ˜—Jšœœ˜K˜—K˜J˜Jšœ˜J˜—…—'<