DIRECTORY Atom USING [DottedPairNode], Convert USING [RopeFromReal], Imager USING [ClipRectangle, ConcatT, Context, Rectangle], ImagerArtwork USING [], ImagerInterpress USING [CreateFromStream, DoPage, Finish, Ref], ImagerTransformation USING [Scale, Transformation, TransformRectangle], IO USING [RopeFromROS, ROS, STREAM], Rope USING [ActionType, Cat, Map, ROPE], TEditDocument USING [Selection], TEditInputOps USING [Break, CallWithLocks], TextNode USING [Ref], TiogaAccess USING [Create, Looks, Put, TiogaChar, Writer, WriteSelection]; ImagerArtworkImpl: CEDAR PROGRAM IMPORTS Convert, Imager, ImagerInterpress, IO, Rope, TiogaAccess, ImagerTransformation, TEditInputOps EXPORTS ImagerArtwork ~ BEGIN ROPE: TYPE ~ Rope.ROPE; Transformation: TYPE ~ ImagerTransformation.Transformation; metersPerPoint: REAL _ 254.0/720000.0; mmPerPoint: REAL _ 254.0/720.0; topSpace: REAL _ 8.0*mmPerPoint; bottomSpace: REAL _ 4.0*mmPerPoint; Points: PUBLIC PROC RETURNS [Transformation] ~ { RETURN [ImagerTransformation.Scale[metersPerPoint]]; }; CreateInterpressRope: PUBLIC PROC [action: PROC [Imager.Context], bounds: Imager.Rectangle, m: Transformation, clip: BOOL _ TRUE] RETURNS [ROPE] ~ { ros: IO.STREAM ~ IO.ROS[]; outputMaster: ImagerInterpress.Ref ~ ImagerInterpress.CreateFromStream[ros, "Interpress/Xerox/3.0 "]; pageAction: PROC [context: Imager.Context] ~ { IF m # NIL THEN Imager.ConcatT[context, m]; IF clip THEN Imager.ClipRectangle[context, bounds]; action[context]; }; ImagerInterpress.DoPage[outputMaster, pageAction, 1.0]; ImagerInterpress.Finish[outputMaster]; RETURN [IO.RopeFromROS[ros]]; }; WriteArtwork: PUBLIC PROC [writer: TiogaAccess.Writer, action: PROC [Imager.Context], bounds: Imager.Rectangle, m: Transformation, clip: BOOL, fit: BOOL] ~ { interpress: ROPE ~ CreateInterpressRope[action, bounds, m, clip]; tc: TiogaAccess.TiogaChar _ [ charSet: 0, char: '\n, looks: ALL[FALSE], format: NIL, comment: TRUE, endOfNode: FALSE, deltaLevel: 0, propList: NIL ]; PutRope: PROC [rope: ROPE] ~ { action: Rope.ActionType ~ {tc.char _ c; TiogaAccess.Put[writer, tc]}; [] _ Rope.Map[base: rope, action: action]; }; PutLooksRope: PROC [rope: ROPE, look1, look2: CHAR _ '\000] ~ { save: TiogaAccess.Looks ~ tc.looks; IF look1 # '\000 THEN tc.looks[look1] _ TRUE; IF look2 # '\000 THEN tc.looks[look2] _ TRUE; PutRope[rope]; tc.looks _ save; }; PutRopeProp: PROC [key: ATOM, val: ROPE] ~ { tc.propList _ CONS[NEW[Atom.DottedPairNode _ [key: key, val: val]], tc.propList]; }; sepNeeded: BOOL _ FALSE; Sp: PROC ~ {PutRope[" "]; sepNeeded _ FALSE}; Comma: PROC ~ {IF sepNeeded THEN PutRope[", "]; sepNeeded _ FALSE}; Putmm: PROC [meters: REAL] ~ { PutLooksRope[Convert.RopeFromReal[meters*1000], 'f]; PutLooksRope["mm", 's, 'o]; sepNeeded _ TRUE; }; PutKey: PROC [rope: ROPE] ~ { Comma[]; PutLooksRope[rope, 'o]; PutLooksRope[": ", 'o]; sepNeeded _ TRUE; }; PutKeyMeters: PROC [name: ROPE, meters, defaultMeters: REAL] ~ { IF meters#defaultMeters THEN {PutKey[name]; Putmm[meters]}; }; bb: Imager.Rectangle _ ImagerTransformation.TransformRectangle[m, bounds]; scale: REAL ~ 1000.0; tc.endOfNode _ TRUE; PutRope["\n"]; tc.endOfNode _ FALSE; PutLooksRope[" [Artwork node; type 'Artwork on' to command tool] ", 'n]; IF fit AND bb.h > 0 AND bb.w > 0 THEN { aspectRope: ROPE ~ Convert.RopeFromReal[bb.h/bb.w]; topSpaceRope: ROPE ~ Convert.RopeFromReal[topSpace]; topCalcRope: ROPE ~ Rope.Cat[aspectRope, " the lineLength .mul ", topSpaceRope, " .add "]; PutRopeProp[$Postfix, Rope.Cat[ topCalcRope, "topLeading ", topCalcRope, "topIndent " ].Cat[ Convert.RopeFromReal[bottomSpace], " mm bottomLeading ", "0.5 0.3 0.95 backgroundColor the topLeading 6 pt .sub backgroundAscent 3 pt backgroundDescent 4 pt outlineBoxThickness 1 pt outlineBoxBearoff" ]]; PutRopeProp[$Fit, "TRUE"]; } ELSE { PutRopeProp[$Postfix, Rope.Cat[ Convert.RopeFromReal[(bb.h+bb.y)*scale+topSpace], " mm topLeading ", Convert.RopeFromReal[(bb.h+bb.y)*scale+topSpace], " mm topIndent " ].Cat[ Convert.RopeFromReal[(-bb.y)*scale+bottomSpace], " mm bottomLeading ", "0.5 0.3 0.95 backgroundColor the topLeading 6 pt .sub backgroundAscent 3 pt backgroundDescent 4 pt outlineBoxThickness 1 pt outlineBoxBearoff" ]]; }; PutRopeProp[$Bounds, Rope.Cat[ Convert.RopeFromReal[bb.x*scale], " mm xmin ", Convert.RopeFromReal[bb.y*scale], " mm ymin " ].Cat[ Convert.RopeFromReal[(bb.x+bb.w)*scale], " mm xmax ", Convert.RopeFromReal[(bb.y+bb.h)*scale], " mm ymax " ]]; PutRopeProp[$Artwork, "Interpress"]; PutRopeProp[$Interpress, interpress]; tc.endOfNode _ TRUE; tc.deltaLevel _ 1; tc.char _ '\n; tc.format _ $artworkFigure; TiogaAccess.Put[writer, tc]; tc.format _ NIL; tc _ vanillaTC; PutLooksRope["", 't]; PutRope[" Insert caption here "]; PutLooksRope["", 't]; tc.endOfNode _ TRUE; tc.char _ '\n; tc.format _ $artworkCaption; TiogaAccess.Put[writer, tc]; tc.format _ NIL; }; PasteArtwork: PUBLIC PROC [action: PROC [Imager.Context], bounds: Imager.Rectangle, m: Transformation, clip: BOOL, fit: BOOL] ~ { writer: TiogaAccess.Writer _ TiogaAccess.Create[]; locked: PROC [root: TextNode.Ref, tSel:TEditDocument.Selection] ~ { TEditInputOps.Break[]; TiogaAccess.WriteSelection[writer]; }; WriteArtwork[writer: writer, action: action, bounds: bounds, m: m, clip: clip, fit: fit]; TEditInputOps.CallWithLocks[locked]; }; vanillaTC: TiogaAccess.TiogaChar ~ [ charSet: 0, char: '\n, looks: ALL[FALSE], format: NIL, comment: FALSE, endOfNode: FALSE, deltaLevel: 0, propList: NIL ]; END. CreateButton p _ ImagerArtwork.PasteArtwork[LOOPHOLE[ImagerExamplesImpl.Text], [0,0,0.08,0.05], ImagerTransformation.Scale[0.5], TRUE] βImagerArtworkImpl.mesa Copyright Σ 1985, 1986, 1987 by Xerox Corporation. All rights reserved. Michael Plass, April 29, 1987 7:26:32 pm PDT Doug Wyatt, June 6, 1986 2:44:47 pm PDT Bland, August 28, 1986 4:33:18 pm PDT Κί˜codešœ™KšœH™HK™,K™'K™%—K˜šΟk ˜ Jšœœ˜Jšœœ˜Jšœœ.˜:Jšœœ˜Jšœœ)˜?Jšœœ-˜GJšœœœœ˜$Jšœœœ˜(Jšœœ ˜ Jšœœ˜+Jšœ œ˜Jšœ œ9˜J—K˜KšΠlnœœ˜ Kšœ$œ8˜eKšœ˜šœ˜K˜Kšœœœ˜Kšœœ'˜;K˜šœœ˜&K˜—šœ œ˜K˜—Kšœ œ˜ šœ œ˜#K˜—šΟnœœœœ˜0Kšœ.˜4Kšœ˜K˜—šŸœœœ œFœœœœ˜”Kš œœœœœ˜Kšœe˜ešœ œ˜.Kšœœœ˜+Kšœœ'˜3Kšœ˜Kšœ˜—Kšœ7˜7Kšœ&˜&Kšœœ˜Kšœ˜K˜—š Ÿ œœœ&œFΟjœœ˜Kšœ œ1˜Ašœ˜Kšœ ˜ Kšœ ˜ Kšœœœ˜Kšœœ˜ Kšœ œ˜Kšœ œ˜K˜Kšœ ˜ Kšœ˜—šŸœœœ˜JšœE˜EK•StartOfExpansionT[base: ROPE, start: INT _ 0, len: INT _ 2147483647, action: Rope.ActionType]šœ*˜*Kšœ˜—šŸ œœœœ ˜?Jšœ#˜#Jšœœœ˜-Jšœœœ˜-Jšœ˜Jšœ˜Kšœ˜—šŸ œœœœ˜,Kšœœœ;˜QKšœ˜—Kšœ œœ˜KšŸœœœ˜-Kš Ÿœœœ œœ˜CšŸœœ œ˜Kšœ4˜4Kšœ˜Kšœ œ˜Kšœ˜—šŸœœœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ œ˜Kšœ˜—šŸ œœœœ˜@Kšœœ˜;Kšœ˜—KšœJ˜JKšœœ ˜Kšœœ œ˜9KšœH˜Hšœœ œ œ˜'Kšœ œ#˜3Kšœœ"˜4Kšœ œI˜Zšœ˜Kšœ˜Kšœ ˜ Kšœ8˜8Kšœ˜K˜—Kšœ˜Kšœ˜—šœ˜šœ˜KšœD˜DKšœI˜IKšœF˜FKšœ˜K˜—Kšœ˜—šœ˜Kšœ.˜.Kšœ4˜4Kšœ5˜5Kšœ4˜4K˜—Kšœ$˜$Kšœ%˜%Kšœœ˜K˜Kšœ˜K˜Kšœ˜Kšœ œ˜K˜Kšœ˜Kšœ!˜!Kšœ˜Kšœœ˜Kšœ˜K˜Kšœ˜Kšœ œ˜Kšœ˜K˜—š Ÿ œœœ œFœœ˜Kšœ2˜2šœœ7˜CJšœ˜Kšœ#˜#Kšœ˜—KšœY˜YKšœ$˜$Kšœ˜K˜—šœ$˜$Kšœ ˜ Kšœ ˜ Kšœœœ˜Kšœœ˜ Kšœ œ˜Kšœ œ˜K˜Kšœ ˜ Kšœ˜K˜——Kšœ˜J˜Jšœ,œMœ˜†—…—Ϊ›