DIRECTORY Args, CedarProcess, ColorTrixBasics, ColorTrixFile, ColorTrixMap, Commander, Dunn, Imager, ImagerColorMap, ImagerSmooth, InterminalBackdoor, Interpress, IO, MessageWindow, Process, Rope, Terminal; DunnCommandsImpl: CEDAR PROGRAM IMPORTS Args, CedarProcess, ColorTrixBasics, ColorTrixFile, ColorTrixMap, Commander, Dunn, Imager, ImagerSmooth, InterminalBackdoor, Interpress, MessageWindow, Process, Rope, Terminal ~ BEGIN ROPE: TYPE ~ Rope.ROPE; Context: TYPE ~ Imager.Context; Handle: TYPE ~ Dunn.Handle; screenPixelsPerMeter: REAL _ 72/0.0254; colorAtom: ARRAY ImagerColorMap.Gun OF ATOM ~ [$Red, $Green, $Blue]; SnapIpFile: PROC [h: 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.Master ~ 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, p, cd, ]}; ImagerSmooth.SetComponent[cd, colorAtom[gun]]; 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: 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: Handle, name: ROPE, cd: Context _ NIL] RETURNS [BOOL] ~ { RETURN[ColorTrixFile.ViewGrayFile[name, cd, FALSE, FALSE] = NIL AND Dunn.Expose[h]]; }; 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 -display -gamma -page -npages "; DunnSnap: Commander.CommandProc ~ { ok: BOOL _ TRUE; page, npages: INT _ -1; handle: Handle _ NIL; type: ColorTrixFile.FileType; err, name1, name2, name3: ROPE _ NIL; nameArg, pageArg, npagesArg, cmapArg, gammaArg, displayArg: Args.Arg; [ok, nameArg, pageArg, npagesArg, cmapArg, gammaArg, displayArg] _ Args.ArgsGet[cmd, "%s-page%i-npages%i-cmap%s-gamma%r-display%s"]; 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]}; handle _ Dunn.Open[NIL, IF displayArg.ok THEN displayArg.rope ELSE NIL]; 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"]; CedarProcess.SetPriority[background]; 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/DunnSnap", DunnSnap, Rope.Cat["\n", snapUsage]]; END. ΎDunnCommandsImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Plass and Bloomenthal, January 30, 1987 11:50:10 pm PST Snapping Procedures: Commander Procedures: Κ˜šœ™Jšœ Οmœ1™