DIRECTORY Args, ColorTrixBasics, ColorTrixFile, ColorTrixMap, Commander, Dunn, Imager, ImagerColorMap, ImagerSmooth, InterminalBackdoor, Interpress, IO, MessageWindow, Process, PupDefs, Rope, Terminal; DunnCommandsImpl: CEDAR PROGRAM IMPORTS Args, ColorTrixBasics, ColorTrixFile, ColorTrixMap, Commander, Dunn, Imager, ImagerSmooth, InterminalBackdoor, Interpress, MessageWindow, Process, PupDefs, Rope, Terminal ~ { ROPE: TYPE ~ Rope.ROPE; Context: TYPE ~ Imager.Context; screenPixelsPerMeter: REAL _ 72/0.0254; colorAtom: ARRAY ImagerColorMap.Gun OF ATOM ~ [$Red, $Green, $Blue]; GetHandle: PROC RETURNS [err: ROPE _ NIL, handle: Dunn.Handle] ~ { IF PupDefs.GetMyName[].Equal["Reprisal"] THEN [handle, err] _ Dunn.Reserve[] ELSE { MessageWindow.Append["Pretending to snap; use Reprisal to actually snap.", TRUE]; MessageWindow.Blink[]; handle _ Dunn.Pretend[]; }; }; SnapIpFile: PROC [h: Dunn.Handle, name: ROPE, page, npages: INT _ -1] RETURNS [BOOL] ~ { p0, p1: INT; cm: ColorTrixMap.Cmap _ NIL; vt: Terminal.Virtual _ InterminalBackdoor.terminal; cmSave: ColorTrixMap.Cmap _ ColorTrixMap.Read[]; cd: Imager.Context ~ ColorTrixBasics.InitCd[smooth, FALSE, FALSE, FALSE]; master: Interpress.OpenMaster ~ ColorTrixFile.OpenInterpress[name]; IF master = NIL THEN RETURN[FALSE]; p0 _ MAX[1, MIN[page, master.pages]]; p1 _ IF npages >= 0 AND npages <= master.pages THEN p0+npages-1 ELSE master.pages; FOR p: INT IN [p0..p1] DO FOR gun: ImagerColorMap.Gun IN ImagerColorMap.Gun DO ENABLE UNWIND => {[] _ Dunn.Composite[h]; [] _ Dunn.Expose[h]}; Action: PROC ~ {Interpress.DoPage[master: master, page: p, context: cd]}; ImagerSmooth.SetComponent[cd, colorAtom[gun]]; ColorTrixBasics.ClearVt[vt, 255]; Process.CheckForAbort[]; ColorTrixMap.PrimaryOnly[gun, cm _ ColorTrixMap.Copy[cmSave, cm]]; ColorTrixMap.Write[cm]; IF gun = red THEN Terminal.TurnOnColorDisplay[vt]; Imager.DoSaveAll[cd, Action]; IF NOT Dunn.Expose[h] THEN RETURN[FALSE]; ENDLOOP; ENDLOOP; ColorTrixMap.Write[cmSave]; RETURN[TRUE]; }; SnapColorFiles: PROC [h: Dunn.Handle, red, grn, blu: ROPE] RETURNS [BOOL] ~ { cm: ColorTrixMap.Cmap _ NIL; cmSave: ColorTrixMap.Cmap _ ColorTrixMap.Read[]; vt: Terminal.Virtual _ InterminalBackdoor.terminal; cd: Imager.Context _ ColorTrixBasics.InitCd[gray, TRUE, TRUE, FALSE]; FOR gun: ImagerColorMap.Gun IN ImagerColorMap.Gun DO ENABLE UNWIND => {[] _ Dunn.Composite[h]; [] _ Dunn.Expose[h]}; name: ROPE _ SELECT gun FROM red => red, green => grn, blue => blu, ENDCASE => NIL; ColorTrixMap.PrimaryOnly[gun, cm _ ColorTrixMap.Copy[cmSave, cm]]; ColorTrixMap.Write[cm]; IF gun = red THEN Terminal.TurnOnColorDisplay[vt]; IF NOT SnapGrayFile[h, name, cd] THEN RETURN[FALSE]; ENDLOOP; ColorTrixMap.Write[cmSave]; RETURN[TRUE]; }; SnapGrayFile: PROC [h: Dunn.Handle, name: ROPE, cd: Context _ NIL] RETURNS [BOOL] ~ { RETURN[ColorTrixFile.ViewGrayFile[name, cd, FALSE] AND Dunn.Expose[h]]; }; viewUsage: ROPE _ "DunnView [-dither] Display image on the color display. Images are un-scaled, those larger than 1024 by 768 are clipped. -dither forces the image to be displayed with a dither map Gray ramp used if BW-ais or one component of ais triplet. Dither colormap used if interpress or ais triplet."; snapUsage: ROPE _ "DunnSnap [-option] Display image on the color display; expose with Dunn camera. Images are un-scaled, those larger than 1024 by 768 are clipped. options: -cmap -gamma -page -npages "; DunnView: Commander.CommandProc ~ { ok, dither: BOOL; name1, name2, name3: ROPE; type: ColorTrixFile.FileType; nameArg, ditherArg: Args.Arg; [ok, nameArg, ditherArg] _ Args.ArgsGet[cmd, "%s-dither%b"]; IF NOT ok THEN RETURN[$Failure, viewUsage]; dither _ ditherArg.ok AND ditherArg.bool; [type, name1, name2, name3] _ ColorTrixFile.Parse[nameArg.rope]; SELECT type FROM ip => ok _ ColorTrixFile.ViewIpFile[name1]; bw => ok _ IF dither THEN ColorTrixFile.ViewDitherFile[name1] ELSE ColorTrixFile.ViewGrayFile[name1]; color => ok _ ColorTrixFile.ViewColorFiles[name1, name2, name3]; ENDCASE => RETURN [$Failure, Rope.Cat["Bad name: ", nameArg.rope]]; IF NOT ok THEN RETURN[$Failure, "Error in viewing file."]; }; DunnSnap: Commander.CommandProc ~ { ok: BOOL _ TRUE; page, npages: INT _ -1; handle: Dunn.Handle _ NIL; type: ColorTrixFile.FileType; err, name1, name2, name3: ROPE _ NIL; nameArg, pageArg, npagesArg, cmapArg, gammaArg: Args.Arg; [ok, nameArg, pageArg, npagesArg, cmapArg, gammaArg] _ Args.ArgsGet[cmd, "%s-page%i-npages%i-cmap%s-gamma%r"]; IF NOT ok THEN RETURN[$Failure, snapUsage]; [type, name1, name2, name3] _ ColorTrixFile.Parse[nameArg.rope]; IF type = bad THEN RETURN[$Failure, Rope.Concat["Bad name: ", nameArg.rope]]; { -- this scoping to service user abort ENABLE UNWIND => {Dunn.Close[handle]}; [err, handle] _ GetHandle[]; IF err # NIL THEN RETURN[$Failure, Rope.Concat[err, "Dunn not reserved."]]; IF cmapArg.ok AND NOT ColorTrixMap.Load[cmapArg.rope] THEN RETURN[$Failure, Rope.Concat["Bad colormap: ", cmapArg.rope]]; IF gammaArg.ok THEN ColorTrixMap.Gamma[gammaArg.real]; IF NOT cmapArg.ok AND NOT gammaArg.ok THEN ColorTrixMap.Gamma[2.2]; IF pageArg.ok THEN page _ pageArg.int; IF npagesArg.ok THEN npages _ npagesArg.int; IF type = ip OR type = color THEN {ok _ Dunn.Separate[handle] AND Dunn.Color[handle]} ELSE {ok _ Dunn.Composite[handle] AND Dunn.BW[handle]}; IF NOT ok THEN RETURN[$Failure, "Dunn fails to initialize properly"]; SELECT type FROM ip => ok _ SnapIpFile[handle, name1, page, npages]; bw => ok _ SnapGrayFile[handle, name1]; color => ok _ SnapColorFiles[handle, name1, name2, name3]; ENDCASE; Dunn.Close[handle]; }; MessageWindow.Clear[]; IF NOT ok THEN RETURN[$Failure, "Error in snapping file."]; }; Commander.Register["///Commands/DunnView", DunnView, Rope.Cat["\n", viewUsage]]; Commander.Register["///Commands/DunnSnap", DunnSnap, Rope.Cat["\n", snapUsage]]; }. .. ΒDunnCommandsImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Plass and Bloomenthal, May 13, 1986 6:19:39 pm PDT Snapping Procedures: Commander Procedures: Cf: /Ark-Royal/Cedar/Users/Lamming.pa/DunnCommsTest.mesa. SnapIpFile: PROC [h: Dunn.Handle, name: ROPE, s: IO.STREAM] RETURNS [BOOL _ TRUE] ~ { master: Interpress.OpenMaster ~ OpenInterpress[name, s]; IF master = NIL THEN RETURN[FALSE]; FOR page: INT IN [1..master.pages] DO -- won't quite work cause need to get handle action: PROC [context: Imager.Context] ~ { Interpress.DoPage[master: master, page: page, context: context]; }; Dunn.Snapper[action: action, pixelUnits: FALSE, color: TRUE, smooth: TRUE]; ENDLOOP; }; Κ8˜šœ™Jšœ Οmœ1™