DIRECTORY CD, CDBasics, CDColors, CDCommandOps, CDOps, CDProperties, CDSequencer, Imager, ImagerInterpress, IO, Real, RefTab, Rope, TerminalIO; CDInterpressPlotImpl: CEDAR PROGRAM IMPORTS CD, CDBasics, CDColors, CDCommandOps, CDOps, CDProperties, CDSequencer, Imager, ImagerInterpress, IO, Real, RefTab, Rope, TerminalIO = BEGIN standardPageX: REAL = 8.5*Imager.metersPerInch; -- 8.5 inches is USA standard page width standardPageY: REAL = 11.0*Imager.metersPerInch; -- 11 inches is USA standard page height versatecDeviceX: REAL = 0.97; --of the very special versatec plotter sitting close to my office... It really doe not store in this constant the with of any other versatec plotter available... c400PageX: REAL = 0.292; c400PageY: REAL = 0.419; defaultPageX: REAL _ standardPageX; defaultPageY: REAL _ standardPageY; defaultStripeX: REAL _ versatecDeviceX; defaultBorder: REAL _ Imager.metersPerInch; fileNameDefault: Rope.ROPE _ "///temp/temp.IP"; ColorMode: TYPE = {allBlack, color, special}; colorMode: ColorMode _ allBlack; pageX: REAL; pageY: REAL; contextColors: REF CD.ContextColors = NEW[CD.ContextColors_ALL[Imager.black]]; RectToRectangle: PROC [r: CD.Rect] RETURNS [Imager.Rectangle] = { RETURN [[x: r.x1, y: r.y1, w: r.x2-r.x1, h: r.y2-r.y1]] }; SetUpBW: PROC [] = { FOR layer: CD.Layer IN CD.Layer DO contextColors[layer] _ Imager.black; ENDLOOP; contextColors[CD.backgroundLayer] _ NIL; }; SetUpColor: PROC [] = { FOR layer: CD.Layer IN CD.Layer DO WITH CDProperties.GetLayerProp[layer, $CDxInterpressPlotColor] SELECT FROM c: Imager.Color => {contextColors[layer] _ c; LOOP}; a: ATOM => IF a=$FALSE THEN {contextColors[layer] _ NIL; LOOP}; ENDCASE => NULL; contextColors[layer] _ CDColors.globalColors[bit8][normal].cols[layer]; ENDLOOP; contextColors[CD.backgroundLayer] _ NIL; }; SetUpSpecial: PROC [] = { FOR layer: CD.Layer IN CD.Layer DO contextColors[layer] _ IF CDProperties.GetLayerProp[layer, $CDxInterpressPlot]=$do THEN Imager.black ELSE NIL; ENDLOOP; contextColors[CD.backgroundLayer] _ NIL; }; HardCopyCommand: PROC [comm: CDSequencer.Command] = { TerminalIO.PutRope["HardCopy\n"]; [] _ CDCommandOps.DoWithResource[proc: ProtectedHardCopy, comm: comm, resource: $CDSimplePlotImpl]; }; PropagatedGetProp: PROC [design: CD.Design, key: REF] RETURNS [x: REF] = { x _ CDProperties.GetDesignProp[design, key]; IF x=NIL THEN x _ CDProperties.GetTechnologyProp[design.technology, key]; }; PropagatedGetIntProp: PROC [design: CD.Design, key: REF, default: INT_1] RETURNS [INT_0] = { WITH PropagatedGetProp[design, key] SELECT FROM ri: REF INT => RETURN [ri^]; ri: REF INTEGER => RETURN [ri^]; rc: REF CARDINAL => RETURN [rc^]; rn: REF NAT => RETURN [rn^]; ENDCASE => NULL; RETURN [default] }; ProtectedHardCopy: PROC [comm: CDSequencer.Command] = { abortFlag: REF BOOL = NEW[BOOL_FALSE]; fileName: Rope.ROPE _ fileNameDefault; pageNumX: INT _ 1; --number of vertical stripes pageNumY: INT _ 1; --number of horizontal stripes nX, nY: INT; --number of current page borderX, borderY: REAL; --border of page absolutelyNoAdjustments: BOOL _ FALSE; ref: ImagerInterpress.Ref; dr: CD.DrawRef; clip: CD.Rect; start: CD.Position; sizePerPage: CD.Position; scale: REAL; substituteFonts: BOOL _ FALSE; deviceTranslation: Imager.VEC _ [0, 0]; help: Rope.ROPE _ NIL; PlotPage: PROC [context: Imager.Context] = { r: CD.Rect _ CDBasics.RectAt[start, sizePerPage]; r _ CDBasics.Intersection[r, clip]; IF ~CDBasics.NonEmpty[r] THEN RETURN; Imager.TranslateT[context, deviceTranslation]; Imager.ScaleT[context, scale]; Imager.TranslateT[context, [-r.x1, -r.y1]]; Imager.ClipRectangle[context, RectToRectangle[r]]; dr _ CD.CreateDrawRef[[ design: comm.design, stopFlag: abortFlag, contextColors: contextColors, borders: TRUE, specialFonts: substituteFonts, interestClip: r, deviceContext: context ]]; IF CDSequencer.Aborted[comm.design] THEN RETURN; CDOps.DrawDesign[comm.design, dr]; }; PreAmble: PROC [ref: ImagerInterpress.Ref, contextColors: REF CD.ContextColors] = { declared: RefTab.Ref _ RefTab.Create[]; FOR layer: CD.Layer IN CD.Layer DO IF contextColors[layer]#NIL THEN IF RefTab.Insert[declared, contextColors[layer], contextColors[layer]] THEN ImagerInterpress.DeclareColor[ref, contextColors[layer]] ENDLOOP; declared _ NIL; }; SetUp: PROC [] = { RequestBorder: PROC [anyWay: BOOL _ FALSE] = { borderY _ borderX _ 0; IF (anyWay AND ~special) THEN borderY _ borderX _ defaultBorder ELSE { SELECT TerminalIO.RequestSelection[header: "border", choice: LIST["yes", "fill space", "never"]] FROM 1 => borderY _ borderX _ defaultBorder; 3 => absolutelyNoAdjustments _ TRUE; ENDCASE => NULL; } }; SetUpVaryingScaling: PROC [clip: CD.Rect] = { insidePageX, insidePageY: REAL; --what fits in a page without border IF special AND TerminalIO.Confirm["multiple pages ?"] THEN { pageNumX _ TerminalIO.RequestInt["Number of pages in x direction? >"]; IF pageNumX<1 OR pageNumX>20 THEN { TerminalIO.PutRope[" to bad\n"]; ERROR ABORTED }; } ELSE { pageNumX _ 0; }; RequestBorder[anyWay: pageNumX=0]; insidePageX _ pageX-2*borderX; insidePageY _ pageY-2*borderY; IF pageNumX=0 THEN { pageNumY _ 1; pageNumX _ 1; sizePerPage _ CDBasics.SizeOfRect[clip]; scale _ MIN[insidePageX/sizePerPage.x, insidePageY/sizePerPage.y]; } ELSE { sizePerPage.x _ (clip.x2-clip.x1)/pageNumX+1; sizePerPage.y _ Real.Fix[insidePageY*((sizePerPage.x-1.0)/insidePageX)]; scale _ insidePageX/sizePerPage.x; pageNumY _ ( (clip.y2-clip.y1)+(sizePerPage.y-1) )/sizePerPage.y; }; help _ IF pageY=c400PageY THEN " Example usage:\n InterpressToPD tem.pd _ ///temp/temp.IP bw400\n" ELSE " Example usage:\n InterpressToPD tem.pd _ ///temp/temp.IP raven384\n"; };--SetUpVaryingScaling SetUpStriped: PROC [clip: CD.Rect] = { borderY _ defaultBorder; borderX _ 0; pageNumY _ 1; IF special AND TerminalIO.Confirm["multiple stripes ?"] THEN { pageNumX _ TerminalIO.RequestInt["How many stripes? >"]; IF pageNumX<1 OR pageNumX>20 THEN { TerminalIO.PutRope[" to bad\n"]; ERROR ABORTED } } ELSE { pageNumX _ 1; }; help _ " Example usage:\n InterpressToPD tem.pd _ ///temp/temp.IP versatec\n"; sizePerPage.x _ (clip.x2-clip.x1)/pageNumX; sizePerPage.y _ clip.y2-clip.y1; scale _ pageX/sizePerPage.x; pageY _ scale*sizePerPage.y+2*borderY; }; SetUpFixedScaling: PROC [clip: CD.Rect] = { borderAnyway: BOOL; defaultScale: REAL _ Imager.metersPerPoint/comm.design.technology.lambda; scale _ defaultScale; scale _ scale*PropagatedGetIntProp[design: comm.design, key: $CDxDefaultPrintScaleNum, default: 1]; scale _ scale/PropagatedGetIntProp[design: comm.design, key: $CDxDefaultPrintScaleDenom, default: 1]; borderAnyway _ ( (clip.x2-clip.x1)*scale < (pageX - 0.05) ) AND ( (clip.y2-clip.y1)*scale < (pageY - 0.05) ); RequestBorder[borderAnyway]; sizePerPage.x _ Real.Round[(pageX-2*borderX)/scale]; sizePerPage.y _ Real.Round[(pageY-2*borderY)/scale]; pageNumX _ (clip.x2-clip.x1+sizePerPage.x-1)/sizePerPage.x; pageNumY _ (clip.y2-clip.y1+sizePerPage.y-1)/sizePerPage.y; help _ IF pageY=c400PageY THEN " Example usage:\n InterpressToPD tem.pd _ ///temp/temp.IP bw400\n" ELSE " Example usage:\n InterpressToPD tem.pd _ ///temp/temp.IP raven384\n"; }; AdjustPosition: PROC [] = { IF absolutelyNoAdjustments THEN RETURN; IF pageNumX=1 THEN { borderX _ MIN[(pageX - (clip.x2-clip.x1)*scale)/2, defaultBorder]; }; IF pageNumY=1 THEN { pictureHeight: REAL _ (clip.y2-clip.y1)*scale; borderY _ MAX[pageY-defaultBorder-pictureHeight, (pageY-pictureHeight)/2]; }; }; SubstituteFonts: PROC = { SELECT TerminalIO.RequestSelection["substitute tioga fonts", LIST["yes", "no"]] FROM 1 => { substituteFonts _ TRUE; TerminalIO.PutRope["substitute tioga fonts\n"]; }; ENDCASE => { TerminalIO.PutRope["don't substitute fonts\n"]; substituteFonts _ FALSE; }; }; GetClipRect: PROC [comm: CDSequencer.Command] = { n: INT _ TerminalIO.RequestSelection[header: "plot area", choice: LIST["complete design", "area of selected objects", "rectangle of command"] ]; SELECT n FROM 3 => { TerminalIO.PutRope["plot area drawn with command\n"]; clip _ CDBasics.ToRect[comm.pos, comm.sPos]; }; 2 => { TerminalIO.PutRope["plot area of selected objects\n"]; clip _ CDOps.BoundingBox[design: comm.design, onlySelected: TRUE]; }; ENDCASE => { TerminalIO.PutRope["plot complete design\n"]; clip _ CDOps.BoundingBox[design: comm.design, onlySelected: FALSE]; }; IF ~CDBasics.NonEmpty[clip] THEN { TerminalIO.PutRope["clip rectangle is empty\n"]; ERROR ABORTED }; }; GetMedium: PROC [] = { special _ FALSE; fixedScale _ FALSE; striped _ FALSE; SELECT TerminalIO.RequestSelection["Plot", LIST["standard page and scale", "fill standard page", "fill versatec stripe", "fill c400 page", "other"]] FROM 1 => { fixedScale _ TRUE; TerminalIO.PutRope["standard page and scale\n"]; }; 3 => { striped _ TRUE; pageX _ defaultStripeX; TerminalIO.PutRope["fill versatec stripe\n"]; }; 4 => { pageX _ c400PageX; pageY _ c400PageY; TerminalIO.PutRope["fill c400 page\n"]; }; 5 => { TerminalIO.PutRope["special:\n"]; special _ TRUE; SELECT TerminalIO.RequestSelection["Plot", LIST["fill standard pages", "fill versatec stripes", "standard scale standard pages", "fill c400 pages", "standard scale c400 pages"]] FROM 1 => { TerminalIO.PutRope["fill standard pages\n"]; }; 2 => { striped _ TRUE; pageX _ defaultStripeX; TerminalIO.PutRope["fill versatec stripes\n"]; }; 3 => { fixedScale _ TRUE; TerminalIO.PutRope["standard scale standard pages\n"]; }; 4 => { pageX _ c400PageX; pageY _ c400PageY; TerminalIO.PutRope["fill c400 pages\n"]; }; 5 => { pageX _ c400PageX; pageY _ c400PageY; fixedScale _ TRUE; TerminalIO.PutRope["standard scale c400 pages\n"]; }; ENDCASE => ERROR ABORTED; }; --2,-- ENDCASE => { TerminalIO.PutRope["fill standard page\n"]; }; }; --GetMedium --Setup special: BOOL _ FALSE; clipRect: BOOL _ FALSE; fixedScale: BOOL _ FALSE; striped: BOOL _ FALSE; IF comm.key=$InterpressPlotC THEN { TerminalIO.PutRope["** COLORS\n"]; SetUpColor[] } ELSE SELECT colorMode FROM special => { TerminalIO.PutRope["** SPECIAL COLORS\n"]; SetUpSpecial[] }; color => { TerminalIO.PutRope["** COLORS\n"]; SetUpColor[] }; allBlack => { TerminalIO.PutRope["** BW\n"]; SetUpBW[] }; ENDCASE => ERROR; pageX _ defaultPageX; pageY _ defaultPageY; SubstituteFonts[]; GetClipRect[comm]; GetMedium[]; sizePerPage _ CDBasics.SizeOfRect[clip]; IF striped THEN SetUpStriped[clip] ELSE IF fixedScale THEN SetUpFixedScaling[clip] ELSE SetUpVaryingScaling[clip]; AdjustPosition[]; TerminalIO.PutF[" printing %01g rows and %01g columns\n", IO.int[pageNumX], IO.int[pageNumY]]; }; --Setup SetUp[]; CDSequencer.UseAbortFlag[comm.design, abortFlag]; ref _ ImagerInterpress.Create[fileName]; PreAmble[ref, contextColors]; deviceTranslation _ [borderX, borderY]; FOR nX IN [0..pageNumX) DO FOR nY IN [0..pageNumY) DO IF CDSequencer.Aborted[comm.design] THEN EXIT; start.x _ clip.x1+nX*sizePerPage.x; start.y _ clip.y1+nY*sizePerPage.y; ImagerInterpress.DoPage[ref, PlotPage]; ENDLOOP; ENDLOOP; ImagerInterpress.Close[ref]; TerminalIO.PutF1[" ""%01g"" created\n", IO.rope[fileName]]; IF ~Rope.IsEmpty[help] THEN TerminalIO.PutRope[help]; IF CDSequencer.Aborted[comm.design] THEN TerminalIO.PutRope["some pages skipped\n"] ELSE TerminalIO.PutRope[" done\n"]; }; CDCommandOps.RegisterWithMenu[menu: $HardCopyMenu, entry: "b&w interpress", doc: "all layers are painted black", key: $InterpressPlot, proc: HardCopyCommand]; CDCommandOps.RegisterWithMenu[menu: $HardCopyMenu, entry: "color interpress", doc: "does not deal with overlapping layers", key: $InterpressPlotC, proc: HardCopyCommand]; TerminalIO.PutRope["Interpress plot loaded\n"]; END. ΨCDInterpressPlotImpl.mesa Copyright c 1984, 1986 by Xerox Corporation. All rights reserved. Created by: Christian Jacobi, Last edited by: Christian Jacobi, December 5, 1986 10:46:17 am PST McCreight January 15, 1987 6:36:10 pm PST --constant sizes and scales --default sizes and scales --others --set ups for this very plot which will be created right now --not re-entrant: using a globals --the real work --single page --multiple pages --1l -> 1 point Κ˜codešœ™Kšœ Οmœ7™BK™K™BK™)—K˜šΟk ˜ Kšžœ˜Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜Kšžœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ —K˜šΟnœžœž˜#Kšžœžœ`žœ"˜Ž—Kšž˜K˜K™Kšœ™K˜KšœžœΟc(˜XKšœžœ )˜YKšœžœ  ‘˜ΏK˜Kšœ žœ ˜Kšœ žœ ˜K˜K™Kšœ™K˜Kšœžœ˜#Kšœžœ˜#Kšœžœ ˜,Kšœžœ˜+K˜K™Kšœ ™ K˜Kšœžœ˜/Kšœ žœ˜-Kšœ ˜ K™K™Kšœ<™Kšœ8˜8šžœ žœ žœ˜#Kšœ ˜ Kšžœž˜ K˜—K˜—šžœ˜Kšœ ˜ K˜—KšœQ˜QKšœ+˜+Kšœ ˜ Kšœ˜Kšœ&˜&Kšœ˜—K˜š‘œžœžœ ˜+Kšœžœ˜šœžœ9˜KKšœΟgœ ™—Kšœ˜Kšœc˜cKšœe˜ešœ˜Kšœ-žœ˜1Kšœ-˜-—Kšœ˜Kšœ4˜4Kšœ4˜4Kšœ;˜;Kšœ;˜;KšœžœžœHžœK˜΅Kšœ˜—K˜š‘œžœ˜Kšžœžœžœ˜'šžœ žœ˜Kšœ žœ5˜BKšœ˜—šžœ žœ˜Kšœžœ˜.Kšœ žœ=˜JKšœ˜—Kšœ˜—K˜šŸœžœ˜šžœ7žœž˜Tšœ˜Kšœžœ˜Kšœ/˜/Kšœ˜—šžœ˜ Kšœ/˜/Kšœžœ˜Kšœ˜——Kšœ˜—K˜šŸ œžœ ˜1šœžœ4˜:KšœžœG˜SKšœ˜—šžœž˜ šœ˜Kšœ5˜5Kšœ,˜,Kšœ˜—šœ˜Kšœ6˜6Kšœ<žœ˜BKšœ˜—šžœ˜ Kšœ-˜-Kšœ<žœ˜CKšœ˜——šžœžœ˜"Kšœ0˜0Kšžœž˜ Kšœ˜—Kšœ˜—K˜šŸ œžœ˜Kšœ žœ˜Kšœ žœ˜Kšœ žœ˜šžœ%žœfž˜™˜Kšœ žœ˜Kšœ0˜0K˜—šœ˜Kšœ žœ˜Kšœ˜Kšœ-˜-K˜—šœ˜Kšœ˜Kšœ˜Kšœ'˜'K˜—šœ˜Kšœ!˜!Kšœ žœ˜šžœ%žœƒž˜Ά˜Kšœ,˜,K˜—˜Kšœ žœ˜Kšœ˜Kšœ.˜.K˜—˜Kšœ žœ˜Kšœ6˜6K˜—˜Kšœ˜Kšœ˜Kšœ(˜(K˜—˜Kšœ˜Kšœ˜Kšœ žœ˜Kšœ2˜2K˜—Kšžœžœžœ˜—K˜—š œžœ˜Kšœ+˜+Kšœ˜——Kšœ  ˜—K˜Kš ˜Kšœ žœžœ˜Kšœ žœžœ˜Kšœ žœžœ˜Kšœ žœžœ˜šžœžœ˜#Kšœ$˜$Kšœ ˜ K˜—šž œ ž˜šœ ˜ Kšœ,˜,Kšœ˜Kšœ˜—šœ ˜ Kšœ$˜$Kšœ ˜ Kšœ˜—šœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜—Kšžœžœ˜—Kšœ˜Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ(˜(Kšžœ žœ˜"Kšžœ žœ˜0Kšžœ˜Kšœ˜Kšœ;žœžœ˜_Kšœ ˜ —K˜Kšœ˜Kšœ1˜1Kšœ(˜(Kšœ˜Kšœ'˜'šžœžœž˜šžœžœž˜Kšžœ"žœžœ˜.Kšœ#˜#Kšœ#˜#Kšœ'˜'Kšžœ˜—Kšž˜—Kšœ˜Kšœ)žœ˜